-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix(invoice): bad computation of rest column for invoices on list #33747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18.0
Are you sure you want to change the base?
Conversation
|
|
||
| $totalallpayments = $paiement + $totalcreditnotes + $totaldeposits; | ||
| $remaintopay = $obj->total_ttc - $totalallpayments; | ||
| $remaintopay = -$discount->getAvailableDiscounts($companystatic, '', 'fk_facture_source=' . $facturestatic->id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getAvailableDiscounts with this parameters seems to return the amount of discount generated by a credit note that have the invoice as source, not the remain to pay of the invoice.
The remain to pay is the total to pay minus all things that reduces the amount to pay, so the credit notes applied to the invoice, the deposits and the payments already done.
Old code seems correct.
Can you provide a screenshot of error and how to reproduce the bug ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eldy The problem arises when you declare an overpayment, for example.
Example:
Invoice of €500, payment received of €1000 => "Créance" field indicated in the invoice list = -€500
If the overpayment is transformed into a discount (button for this on the invoice) and then used in part to pay another invoice (breakdown of the discount on the customer file, customer tab, link to fixed discounts), say €400 is used to pay another invoice, leaving €100 of overpayment => In this case, the "Créance" on the original invoice is still -€500, which is not right, it should show -€100.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So pb is when we convert the overpayment into a discount. Once this is done, the balance of invoice is no more -500 but 0 because the overpaid amount has been moved into another area and will be consumed independently.
Balance for user should be:
invoice 0 euro + available discount = 500 euros
So we should removed, in the existing calculated "remain to pay", the amount of converted discount that is no more due because given as discount.
|
The valu shown must follow the same business rule than the business rule defined to show the invoice (compta/facture/card.php) The current rule in compta/facture/card.php to define amount paid and remain to pay is: So the difference with the list is that we have at end in the card that we don't have. |
|
@eldy The correct amount is on the comm/remx.php page. In the section "Réductions ou crédits disponibles", we have a list of overpayment invoice with discount available. The amount of discount available is correct in this section. |
The value into remx are the discount available for consumption into other invoices, not the remain to pay of an invoice. If you have an invoice of 100, then you pay 20, then you consume an old credit not of 30, and you apply a commercial discount of 10, the remain to pay is 40. I think the trouble of overpayment has a different origin. The calculation for column value must be the same than when reading the card. I pushed recently a fix on develop to align the code on list with the one on code so you should find a remain to pay of 0 when there is an overpayment now. |
@eldy did you have the commit link of that for the backport ? or at least the file name impacted by your fix ? |
|
Sorry it was a long time ago, and i can't retreive where the fix was. I think it was "several fixes" to fix the bad consistency. Nevermind, on recent version, the remain to pay is calculated with And the part of amount of excess received seems already included into the getSumCreditNotesUsed(). So don't need to use the getAvailableDiscounts(). So i surely miss something, so the most important is to be able to find a use case to reproduce the bug. I failed to find one. So if you can describe a proces to reproduct it we may progress on this. Seems duplicate of need for #33191 |
FIX|Fix bad computation of rest column for invoices on list
I've added getAvailableDiscounts method to get the good rest