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 <michaela.sieber@kit.edu>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Jonathan Druart 2023-02-15 08:54:36 +01:00 committed by Tomas Cohen Arazi
parent f4b74f6c1f
commit 7fd9a1ae0b
2 changed files with 18 additions and 8 deletions

View File

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

View File

@ -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,
}
}
);