Hello everyone.
When i login into my client's account i see the zero amount of availible funds but when i try to get remainder through API i got -9568,58! Furthermore when i download account_actitivies csv report i see in Total spent value of 71980.88 while in reply from api i got 81527.25. the "spent" from API is considerably higher so results calculated from API totally not match results from UI and report.
How i calculate reminders with API, in short : (paid - spend)
def get_paid(client, customer_id):
query = {
'service': 'BudgetOrderService',
'selector': {
'fields': ['SpendingLimit'],
}
}
billing_accounts = run_query(client, customer_id, query=query)
paid = 0
for account in billing_accounts['entries']:
paid += account['spendingLimit']['microAmount'] / 1000000
return paid
minus
def get_spent(client, customer_id):
query = '''
SELECT CampaignId, Cost, CampaignStatus, Amount
FROM CAMPAIGN_PERFORMANCE_REPORT
'''
for row in run_awql(client, customer_id, query):
if row['Campaign ID'] == 'Total':
return round(int(row['Cost']) / 1000000, 2)
As a result i usually get pretty precise and realistic results. But in case of this customer with customer_id
5668060624 i got this bizarre minus over 9000.
I asked a question about that in technical support - their answer in short was that this strange data deviations might occured of possible refunds.
I still have no way to get the correct result whatever reason data deviated. May be my method of calculations is wrong, please give an advise, thanks!