From fb0e6a20f8590c68d2aea0572d7dad785ad0f9a7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 16 Jan 2023 22:37:09 +0100 Subject: [PATCH] Bug 25655: Save values from ModOrderReceive Sponsored-by: The Research University in the Helmholtz Association (KIT) Signed-off-by: Michaela Sieber Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- C4/Acquisition.pm | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 12178420bf..844dc63171 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1415,23 +1415,29 @@ sub ModReceiveOrder { $order->{ordernumber} ); - if ( not $order->{subscriptionid} && defined $order->{order_internalnote} ) { - $dbh->do( - q|UPDATE aqorders - SET order_internalnote = ? - WHERE ordernumber = ?|, {}, - $order->{order_internalnote}, $order->{ordernumber} - ); - } - # Recalculate tax_value - $dbh->do(q| + $query = q| UPDATE aqorders SET tax_value_on_ordering = quantity * | . get_rounding_sql(q|ecost_tax_excluded|) . q| * tax_rate_on_ordering, tax_value_on_receiving = quantity * | . get_rounding_sql(q|unitprice_tax_excluded|) . q| * tax_rate_on_receiving + |; + + my @params; + if ( not $order->{subscriptionid} && defined $order->{order_internalnote} ) + { + $query .= q|, order_internalnote = ?|; + push @params, $order->{order_internalnote}; + } + if ( defined $order->{invoice_unitprice} ) { + $query .= q|, invoice_unitprice = ?, invoice_currency = ?|; + push @params, $order->{invoice_unitprice}, $order->{invoice_currency}; + } + $query .= q| WHERE ordernumber = ? - |, undef, $order->{ordernumber}); + |; + + $dbh->do($query, undef, @params, $order->{ordernumber}); delete $order->{ordernumber}; $order->{budget_id} = ( $budget_id || $order->{budget_id} ); @@ -1483,6 +1489,10 @@ sub ModReceiveOrder { , order_internalnote = ? | if defined $order->{order_internalnote}; + $query .= q| + , invoice_unitprice = ?, invoice_currency = ? + | if defined $order->{invoice_unitprice}; + $query .= q| where biblionumber=? and ordernumber=?|; my $sth = $dbh->prepare( $query ); @@ -1508,6 +1518,10 @@ sub ModReceiveOrder { push @params, $order->{order_internalnote}; } + if ( defined $order->{invoice_unitprice} ) { + push @params, $order->{invoice_unitprice}, $order->{invoice_currency}; + } + push @params, ( $biblionumber, $order->{ordernumber} ); $sth->execute( @params ); -- 2.39.5