Browse Source

[FIX] wrong sql calculation on credit and debit value

https://github.com/OCA/account-financial-reporting/issues/443
pull/448/head
Marco Calcagni 6 years ago
committed by Jordi Ballester Alomar
parent
commit
97feff3a8a
  1. 8
      customer_outstanding_statement/report/customer_outstanding_statement.py

8
customer_outstanding_statement/report/customer_outstanding_statement.py

@ -52,12 +52,12 @@ class CustomerOutstandingStatement(models.AbstractModel):
SELECT m.name as move_id, l.partner_id, l.date, l.name, SELECT m.name as move_id, l.partner_id, l.date, l.name,
l.ref, l.blocked, l.currency_id, l.company_id, l.ref, l.blocked, l.currency_id, l.company_id,
CASE WHEN (l.currency_id is not null AND l.amount_currency > 0.0) CASE WHEN (l.currency_id is not null AND l.amount_currency > 0.0)
THEN sum(l.amount_currency)
ELSE sum(l.debit)
THEN avg(l.amount_currency)
ELSE avg(l.debit)
END as debit, END as debit,
CASE WHEN (l.currency_id is not null AND l.amount_currency < 0.0) CASE WHEN (l.currency_id is not null AND l.amount_currency < 0.0)
THEN sum(l.amount_currency * (-1))
ELSE sum(l.credit)
THEN avg(l.amount_currency * (-1))
ELSE avg(l.credit)
END as credit, END as credit,
CASE WHEN l.balance > 0.0 CASE WHEN l.balance > 0.0
THEN l.balance - sum(coalesce(pd.amount, 0.0)) THEN l.balance - sum(coalesce(pd.amount, 0.0))

Loading…
Cancel
Save