From 97feff3a8a7fa1709d755360c9c98f91d45bae3d Mon Sep 17 00:00:00 2001 From: Marco Calcagni Date: Thu, 19 Jul 2018 19:20:02 +0200 Subject: [PATCH] [FIX] wrong sql calculation on credit and debit value https://github.com/OCA/account-financial-reporting/issues/443 --- .../report/customer_outstanding_statement.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/customer_outstanding_statement/report/customer_outstanding_statement.py b/customer_outstanding_statement/report/customer_outstanding_statement.py index cc6452ef..1caae334 100644 --- a/customer_outstanding_statement/report/customer_outstanding_statement.py +++ b/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, 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))