← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 672479] Re: Account_payment_extension, incorrect debt calculation

 

After studying the Eric comments and the code, I think that Eric is
right, his proposition of bugfix has more sense than the original code.

But before applying it, better we ask to Albert Cervera. This part of
code was introduced by him several months ago to take into account
reconciled entries, making its value more accurate. Before this patch,
the field only considered payments done using payment orders so invoices
partially reconciled with other refunds still were considered for their
total amount.

See:

http://bazaar.launchpad.net/~openerp-commiter/openobject-
addons/stable_5.0-extra-addons/revision/4313.1.77

BTW: I have just finished to port account_payment_extension module to v
6.0. If we apply this fix, I will apply it also to v 6.0.

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/672479

Title:
  Account_payment_extension, incorrect debt calculation

Status in OpenObject Addons Modules:
  Won't Fix

Bug description:
  Using 5.15, I try to pay one supplier throught the "payable payment" menu. I create a new paiement order and then click on "Select invoices to pay/receive payment".
Some invoices do not appear in the list which are clearly unpaid. I went to analyze the code and cannot understand current calculation which seems to me wrong as it is (in account_payment_extension/account_line_move.py/def amount_to_pay).
eg: invoice supplier total= 1500. Paid= 800, amount to be paid still =700.
If I take the following code and print the variables
(...)
            else:
                if not unreconciled:
                    unreconciled = debt
                if debt > 0:
                    debt = min(debt - paid, max(0.0, unreconciled - paid))
                else:
                    debt = max(debt - paid, min(0.0, unreconciled - paid))
(...)
I have debt = 1500, which is correct
I have paid = 800, which is correct
I have unreconciled = 700 which is still correct.
But then if I make the calculation according to those variable, I get the following:
debt = min (1500 - 800, max (0, 700-800)) = min(700,0) = 0 and the invoice never appears in the list!
I do not understand fully understand the meaning/need of above "if test" but it seems to me its purpose is to take the min quantity between the payment system and the reconcilied invoice system as the 2 systems work independantly. I would then propose better this code, which fits my way of working:

                if debt > 0:
#                    debt = min(debt - paid, max(0.0, unreconciled - paid))
                    debt = min(debt - paid, max(0.0, unreconciled))
                else:
#                    debt = max(debt - paid, min(0.0, unreconciled - paid))
                    debt = max(debt - paid, min(0.0, unreconciled))
In this case if both payment system and reconciled system are synchronised or not, the information is always correct.

Still not completely sure of all the impacts so advises are welcome!





References