Account Balance Report

I am attempting to build a report that will find all customers with a given account balance. [Needed to identify who paid their bill by EFT but omitted to identify the transaction, so $1234.56 arrived in the bank account and you are looking for anyone with a balance of $1234.56.]

I can write the sql to calculate the account balance (by adding up all the transactions), however, since the account balance is a) provided on the left panel on the Customers screen; b) accessible by the party:getAccountBalance(customer) function, I figure that there must be an easier way to get it than adding all transactions.

Is there a faster way than adding up everything?

[I managed to do it with a subquery to find the last openingBalance transaction, and then sum that and the later transactions. But it got ugly when I allowed for the case of a new customer with no opening balance transactions.]

Regards, Tim G

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Account Balance Report

Hi Tim,

Suggest have a look at the Customer Aged balance report sql for clues on how to best calculate balances.

http://www.openvpms.org/customisation/customer-aged-balance-report

You can easily change to sql to just look at total rather than aged balances.

Cheers Tony

Re: Account Balance Report

Tony - I apologise for the delay in responding. Thanks for the pointer. I now have things all running.

Regards, Tim G

Syndicate content