From ad470af479db0b0fc1e268f1c7646e7551131661 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 --- acqui/addorder.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/acqui/addorder.pl b/acqui/addorder.pl index 25fd4b3109..6894500f5f 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 ); @@ -160,7 +160,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.20.1