Browse Source

[FIX] wrong sql calculation on credit and debit value

https://github.com/OCA/account-financial-reporting/issues/443
pull/477/head
Marco Calcagni 6 years ago
committed by Graeme Gellatly
parent
commit
077f8b2b9e
  1. 8
      customer_outstanding_statement/report/customer_outstanding_statement.py

8
customer_outstanding_statement/report/customer_outstanding_statement.py

@ -48,12 +48,12 @@ class CustomerOutstandingStatement(models.AbstractModel):
SELECT m.name as move_id, l.partner_id, l.date, l.name,
l.ref, l.blocked, l.currency_id, l.company_id,
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,
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,
CASE WHEN l.balance > 0.0
THEN l.balance - sum(coalesce(pd.amount, 0.0))

Loading…
Cancel
Save