From 3a720e5181395e9a5a978b8a2a126164e1cc711d Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Tue, 25 Oct 2022 03:08:03 +0000 Subject: [PATCH] Bug 31631: (follow-up) Use CalculateFundValuesIncludingTax when modifying existing order This patch depends on Bug 31840. To test: 1) Edit an order and increase the price so that you would expect it to trigger a warning that you will exceed the amount allowed for this Fund 2) Confirm the warning is triggered Signed-off-by: David Nind Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- acqui/addorder.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/acqui/addorder.pl b/acqui/addorder.pl index 7297cbb4a0..c5b9847b01 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -129,7 +129,7 @@ use C4::Biblio qw( TransformHtmlToXml TransformKohaToMarc ); -use C4::Budgets qw( GetBudget GetBudgetSpent GetBudgetOrdered ); +use C4::Budgets qw( GetBudget GetBudgetSpent GetBudgetOrdered FieldsForCalculatingFundValues ); use C4::Items qw( AddItemFromMarc ); use C4::Output qw( output_html_with_http_headers ); use C4::Log qw( logaction ); @@ -162,7 +162,10 @@ unless($confirm_budget_exceeding) { if ( $ordernumber ) { # modifying an existing order so remove order price from $budget_ordered my $order = Koha::Acquisition::Orders->find($ordernumber); - $budget_ordered = $budget_ordered - ( $order->ecost_tax_included * $order->quantity ); + + # get correct unitprice and ecost fields + my ( $unitprice_field, $ecost_field ) = FieldsForCalculatingFundValues(); + $budget_ordered = $budget_ordered - ( $order->$ecost_field * $order->quantity ); } my $budget_used = $budget_spent + $budget_ordered; -- 2.39.5