FreeAgent API Expenses doesn't return "Balance Owned"


#1

Hello everyone,

We have some questions about the expenses part.
Actually we have the “gross-value” when we call FreeAgent API, but the information about the “balance owned“ is not returned.

However, it appears well on the view, so we would like to know how do you compute this value ?

As you can see below :
Response API and Fig FreeAgent Expenses View
{ “expenses”:[
{

“dated_on”:“2011-08-24”,
“currency”:“USD”,
“gross_value”:"-20.0",

]}}

            Fig : FreeAgent View of Expenses

Thank you for your reply.


#2

Hi there,

The balance owed to an individual is the difference between their expenses in FreeAgent and the sum of the repayments already made to them through the company bank account. This is something we compute in FreeAgent on-the-fly, but it could be calculated in your application, too.

You can retrieve a list of all the expenses via our API, checking the user attribute to know which user an expense relates to. You can then list all of the bank_transaction_explanation records in your account, filtering on the explanations that have the is_money_paid_to_user attribute set to true, which will then allow you to find the total number of repayments made to each user. Subtracting the sum of the repayments from the sum of the expenses will give you the Balance Owed figure that you’re seeking.

Cheers,
Dave J


#3

Hi David,

thank you for your reply. I wondered if the compute could be easier ? For exemple, if an expenses is payed to an user, will the “gross-value” become positive ? In this case, I suppose that we can only compute the sum of the “gross-value” (negative and positive) ? Maybe I didn’t understand how it works.

Thanks,
Hao


#4

Hi Hao,

if an expenses is payed to an user, will the “gross-value” become positive ?

No, the value of an expense will always remain the same, regardless of whether the cost has been repaid to the user.

I wondered if the compute could be easier ?

After giving this problem a little more thought, I’ve realised that each user has their own “Expense Account” in FreeAgent which appears in a company’s Trial Balance report and holds the balance owed to each user. The good news is that your Trial Balance report can be downloaded with a single GET request to our API. Here’s a link to the documentation: https://dev.freeagent.com/docs/trial_balance

I hope this helps!
Dave J


#5

Hi David,

thanks very much. I think that’s what I looked for. It does help me a lot.
Have a good day,

Hao