From a6f986eff5bd080e4a0b9e5b9ecdfd3ff6dda1c1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 12 Aug 2020 15:22:50 +0200 Subject: [PATCH] Bug 20150: Try to fix Acquisitions wizard It is always using listprice when we need to do the same math as the acq home page. This patch is reusing the queries from GetBudgetHierarchy --- reports/acquisitions_stats.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/reports/acquisitions_stats.pl b/reports/acquisitions_stats.pl index eb56a05b31..ecd93bf2c9 100755 --- a/reports/acquisitions_stats.pl +++ b/reports/acquisitions_stats.pl @@ -445,8 +445,12 @@ sub calculate { $strcalc .= "COUNT(*) "; } elsif ( $process == 2 ) { $strcalc .= "COUNT(DISTINCT(aqorders.biblionumber)) "; - } elsif ( $process == 3 || $process == 4 || $process == 5 ) { - $strcalc .= "SUM(aqorders.listprice) "; + } elsif ( $process == 3 ) { # Amount + $strcalc .= q|SUM(| . C4::Acquisition::get_rounding_sql(q|ecost_tax_included|) . q| * quantity ) + SUM(| . C4::Acquisition::get_rounding_sql(q|COALESCE(unitprice_tax_included, ecost_tax_included)|) . q| * quantity ) AS budget_total |; + } elsif ( $process == 4 ) { # Ordered + $strcalc .= q|SUM(| . C4::Acquisition::get_rounding_sql(q|ecost_tax_included|) . q| * quantity ) AS budget_ordered | + } elsif ( $process == 5 ) { # Spent + $strcalc .= q|SUM(| . C4::Acquisition::get_rounding_sql(q|COALESCE(unitprice_tax_included, ecost_tax_included)|) . q| * quantity ) AS budget_spent | } else { $strcalc .= "NULL "; } -- 2.20.1