[stable 6.0.2] Account Balance Sheet parser logic error leads to incorrect totals amounts and developer confusion
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) |
Fix Released
|
Medium
|
OpenERP R&D Addons Team 3 |
Bug Description
If you look at the section where it calculates sum_dr and sum_cr it is incorrect. Well it is technically correct, but in the sense of having a balance sheet that balances it is incorrect.
Take the accounting equation property = property rights expanded to assets = liabilities + equity
In the case of a net profit we incorrectly add the result to sum_dr, our equity has increased afterall, so sum_cr should increase, (this behaviour is correct, except the function is named wrong) however in the case of a net loss we subtract the amount from sum_cr (which should be sum_dr) which is incorrect as our equity has reduced.
However here is the first bug - sum_dr and sum_cr are around the wrong way - sum_cr is increased for asset accounts, and sum_dr is increased for liabilities - it should be the other way around
Put another way, for a balance sheet, we don't really want the totals to be the sum of dr's and cr's, we want it to be the total of the stuff on the left (Assets) and the total of the stuff on the right (Property Rights).
So in the case of a Net Profit we must increase equity (credit) and in the case of a net loss we must reduce equity (credit). At no point should we be changing debits. The value of our Assets has not changed (in so far that a net loss already reduces our assets), it is our equity that has reduced.
Now to make this one step more confusing, and for some unknown reason it has been decided to leave liabilities as a negative balance, and then on the report use absolute value which is also incorrect. Many assets and liabilities should have a balance opposite of the standard, Accumulated depreciation for example in Assets, VAT Paid in Liabilities, Bank Accounts temporarily in overdraft.
In my own parser, which I have written, to resolve this we declare a dictionary called signs and at the point we compute the account.balance we multiple it by the sign.
sign = {
}
We use more types than standard but you get the idea. Assets are their balance, liability is their balance *-1.
Then all we do in the for account in accounts loop is make the balance: account.balance * sign[typ]
So in summary
sum_dr and sum_cr are round the wrong way.
Adding a net loss to Assets is incorrect - it should be subtracted from Equity.
values (already reported bug) should not be absolute, but rather their inverse for liability and equity accounts.
Related branches
- Mustufa Rangwala (Open ERP) (community): Approve
- qdp (OpenERP): Pending requested
-
Diff: 161 lines (+13/-7)13 files modifiedaccount/configurable_account_chart.xml (+1/-1)
account/demo/account_minimal.xml (+1/-1)
l10n_at/account_chart.xml (+1/-0)
l10n_ca/account_types_en.xml (+1/-0)
l10n_cr/data/account_account_type.xml (+1/-0)
l10n_fr/plan_comptable_general_demo.xml (+1/-1)
l10n_lu/l10n_lu_data.xml (+1/-1)
l10n_ma/account_type.xml (+1/-1)
l10n_mx/account_chart.xml (+1/-0)
l10n_ro/account_chart.xml (+1/-0)
l10n_syscohada/l10n_syscohada_data.xml (+1/-1)
l10n_uk/l10n_uk_types.xml (+1/-1)
l10n_ve/account_chart.xml (+1/-0)
Changed in openobject-addons: | |
status: | Opinion → Triaged |
Changed in openobject-addons: | |
status: | Confirmed → In Progress |
Changed in openobject-addons: | |
milestone: | none → 6.1 |
Changed in openobject-addons: | |
status: | Fix Committed → Fix Released |
tags: | added: maintenance |
Attachment of o4sb custom balance sheet parser - hopefully it can be of some use in resolving this. Of course you would also need to update report, at the very least getting rid of absolute value functions.
Note this is not a drop in replacement as it is designed for Aeroo reports and a custom extension of account.account but at least the logic is similar and it is based off the original balance sheet parser.