From 7fd9a1ae0b71bccdbad2d3fef62cc12ff3d6ce9b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 15 Feb 2023 08:54:36 +0100 Subject: [PATCH] Bug 25655: Store invoice price and currency even if no currency change We could need these info to be stored even if the currency is the same as the active one, for statistic purpose for instance. Signed-off-by: Michaela Sieber Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- C4/Acquisition.pm | 3 +++ t/db_dependent/Acquisition.t | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index f4e837db9a..6873a67e85 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1383,6 +1383,9 @@ sub ModReceiveOrder { $datereceived = $datereceived ? dt_from_string( $datereceived ) : dt_from_string; $datereceived = $datereceived->ymd; + $order->{invoice_unitprice} ||= $order->{unitprice}; + $order->{invoice_currency} ||= Koha::Acquisition::Currencies->get_active->currency; + my $suggestionid = GetSuggestionFromBiblionumber( $biblionumber ); if ($suggestionid) { ModSuggestion( {suggestionid=>$suggestionid, diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t index 1560cf930f..67e405d07d 100755 --- a/t/db_dependent/Acquisition.t +++ b/t/db_dependent/Acquisition.t @@ -803,6 +803,7 @@ subtest 'ModReceiveOrder invoice_unitprice and invoice_currency' => sub { quantityreceived => 0, ecost_tax_excluded => 42, unitprice_tax_excluded => 42, + unitprice => 42, } } ); @@ -819,16 +820,17 @@ subtest 'ModReceiveOrder invoice_unitprice and invoice_currency' => sub { budget_id => $order->budget_id, } ); + my $active_currency = Koha::Acquisition::Currencies->get_active; my $received_order = Koha::Acquisition::Orders->find($received_ordernumber); is( $received_order->invoice_unitprice, - undef, 'no price should be stored if none passed' ); + $order->unitprice, 'no price should be stored if none passed' ); is( $received_order->invoice_currency, - undef, 'no currency should be stored if none passed' ); + $active_currency->currency, 'no currency should be stored if none passed' ); $order = $order->get_from_storage; - is( $order->invoice_unitprice, undef, + is( $order->invoice_unitprice, $order->unitprice, 'no price should be stored if none passed' ); - is( $order->invoice_currency, undef, + is( $order->invoice_currency, $active_currency->currency, 'no currency should be stored if none passed' ); }; subtest 'with invoice_unitprice' => sub { @@ -841,6 +843,7 @@ subtest 'ModReceiveOrder invoice_unitprice and invoice_currency' => sub { quantityreceived => 0, ecost_tax_excluded => 42, unitprice_tax_excluded => 42, + unitprice => 42, } } ); @@ -886,6 +889,7 @@ subtest 'ModReceiveOrder invoice_unitprice and invoice_currency' => sub { quantityreceived => 0, ecost_tax_excluded => 42, unitprice_tax_excluded => 42, + unitprice => 42, } } ); @@ -902,17 +906,19 @@ subtest 'ModReceiveOrder invoice_unitprice and invoice_currency' => sub { budget_id => $order->budget_id, } ); + my $active_currency = Koha::Acquisition::Currencies->get_active; my $received_order = Koha::Acquisition::Orders->find($received_ordernumber); is( $received_order->invoice_unitprice, - undef, 'no price should be stored if none passed' ); + $order->unitprice, 'no price should be stored if none passed' ); is( $received_order->invoice_currency, - undef, 'no currency should be stored if none passed' ); + $active_currency->currency, 'no currency should be stored if none passed' ); $order = $order->get_from_storage; - is( $order->invoice_unitprice, undef, + is( $order->invoice_unitprice, $order->unitprice, 'no price should be stored if none passed' ); - is( $order->invoice_currency, undef, + is( $order->invoice_currency, $active_currency->currency, 'no currency should be stored if none passed' ); + }; subtest 'with invoice_unitprice' => sub { @@ -925,6 +931,7 @@ subtest 'ModReceiveOrder invoice_unitprice and invoice_currency' => sub { quantityreceived => 0, ecost_tax_excluded => 42, unitprice_tax_excluded => 42, + unitprice => 42, } } ); -- 2.39.5