[FIX] account: Invoice Analysis total without sign
- Go to Accounting > Reports > Invoices
- Go to the pivot view
- Enable 'Total' and 'Untaxed Total' in the measures
The Total is wrong.
The sign of the total must be positive for the customer invoices and the
vendors refunds; and negative for the credit notes and the vendors bills.
Before this commit, the total of the credit notes and the vendors bills
weren't negative.
This occurs because the sign of the result of amount_total * invoice_type.sign
is different of the sign of amount_total_signed. Indeed amount_total is
the total amount without sign, and invoice_type.sign is used to change
the sign only for the vendors bills and the vendors refunds
(see https://github.com/odoo/odoo/blob/3cf9cfc985950c30c6b76480f77f5ffe53650b24/addons/account/report/account_invoice_report.py#L144).
Contrariwise amount_total_signed is the total amount signed : negative
for the credit notes and the vendors refunds.
Later on the calculation, the total amount is multiplied to
invoice_type.sign, to have the signs as expected
(see https://github.com/odoo/odoo/blob/3cf9cfc985950c30c6b76480f77f5ffe53650b24/addons/account/report/account_invoice_report.py#L118)
Fine tuning of this commit: 4218f3b
opw-1999175
This commit is contained in:
@@ -114,7 +114,7 @@ class AccountInvoiceReport(models.Model):
|
||||
ai.partner_bank_id,
|
||||
SUM ((invoice_type.sign_qty * ail.quantity) / u.factor * u2.factor) AS product_qty,
|
||||
SUM(ail.price_subtotal_signed * invoice_type.sign) AS price_total,
|
||||
(ai.amount_total * invoice_type.sign) / (SELECT count(*) FROM account_invoice_line l where invoice_id = ai.id) *
|
||||
ai.amount_total_signed / (SELECT count(*) FROM account_invoice_line l where invoice_id = ai.id) *
|
||||
count(*) * invoice_type.sign AS amount_total,
|
||||
SUM(ABS(ail.price_subtotal_signed)) / CASE
|
||||
WHEN SUM(ail.quantity / u.factor * u2.factor) <> 0::numeric
|
||||
|
||||
Reference in New Issue
Block a user