I'm studiyng a downloads and sales logging and reporting code and come to a possible bug.
It seems like downloads and earnings reports are based on a data from the sales log. But sales are logging only in time of completing the purchase.
So if one payment is done, and then is turned on (payment status becomes "complete"), a sales log entry is created this moment. And then if this payment is turned off (status == "pending" again), log entry stays in place, as if payment is still actual.
This can be much worse if a payment was turned on and off several times - there will be a several similar log entries.
It seems to me that logs can't be good data source to create an actual picture of funds situation. I'm thinking of creating a custom BD table that ties payments, downloads and their statuses. It's data will be updated on each payments status change, so it will always be actual.
Am i thinking in right direction?)