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 <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Aleisha Amohia 2022-10-25 03:08:03 +00:00 committed by Tomas Cohen Arazi
parent 3ca1ab63ac
commit 3a720e5181
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 5 additions and 2 deletions

View File

@ -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;