Bugzilla – Attachment 183111 Details for
Bug 33756
Wrong calculation of total amount spent?
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33756: Use aqorders.quantityreceived to calculate total amount spent
0001-Bug-33756-Use-aqorders.quantityreceived-to-calculate.patch (text/plain), 2.52 KB, created by
Emmi Takkinen
on 2025-06-10 08:09:28 UTC
(
hide
)
Description:
Bug 33756: Use aqorders.quantityreceived to calculate total amount spent
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2025-06-10 08:09:28 UTC
Size:
2.52 KB
patch
obsolete
>From 7dde837ef5f3a8f78512a8c894582c1142e35d93 Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Tue, 10 Jun 2025 11:06:44 +0300 >Subject: [PATCH] Bug 33756: Use aqorders.quantityreceived to calculate total > amount spent > >We currently use aqorders.quantity to calculate how much funds have >been spent for orders. This leads to situation where sum doesn't >match the amount which has been already spented. This patch changes >this by using quantityreceived column instead of quantity column >to calculate spented funds. > >This test plan assumes that you already have budgets and orders in >your database. > >To test: >1. Find an existing fund where some of the ordered items have been >received and look up their budget_id. Use this report if needed: >SELECT budget_id, budget_code FROM aqbudgets >WHERE budget_id IN( >SELECT budget_id >FROM aqorders >WHERE quantity != quantityreceived >AND quantityreceived > 0) >2. Set syspref CalculateFundValuesIncludingTax as "Exclude". >3. Add following report to your report library: >SELECT SUM(quantity), SUM(quantityreceived), >SUM(unitprice_tax_excluded * quantity) AS "Budget spent by quantity", >SUM(unitprice_tax_excluded * quantityreceived) AS "Budget spent by quantity received" >FROM aqorders >WHERE budget_id= [budget_id from step 1.] >3. Search your chosen budget from Funds page (/cgi-bin/koha/admin/aqbudgets.pl). >4. Compare funds tables "Base-level ordered" and "Total spend columns" >with report results. >=> Note that both column values match value in reports >"Budget spent by quantity" columns value. >5. Apply this patch. >6. Refresh funds table. >=> Note that now column values match value in reports >"Budget spent by quantity received" columns value. > >Also prove that t/db_dependent/Budgets.t and >t/db_dependent/Budgets/CloneBudgetHierarchy.t still pass. > >Sponsored-by: Koha-Suomi Oy >--- > C4/Budgets.pm | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/C4/Budgets.pm b/C4/Budgets.pm >index 83acec0a92..a4a3d01ba8 100644 >--- a/C4/Budgets.pm >+++ b/C4/Budgets.pm >@@ -735,7 +735,7 @@ sub GetBudgetHierarchy { > SELECT aqorders.budget_id, aqbudgets.budget_parent_id, > SUM( | > . C4::Acquisition::get_rounding_sql(qq|COALESCE($unitprice_field, $ecost_field)|) >- . q| * quantity ) AS budget_spent >+ . q| * quantityreceived ) AS budget_spent > FROM aqorders JOIN aqbudgets USING (budget_id) > WHERE quantityreceived > 0 AND datecancellationprinted IS NULL > GROUP BY budget_id, budget_parent_id >-- >2.34.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33756
: 183111