Bug 25655: Save values from ModOrderReceive

Sponsored-by: The Research University in the Helmholtz Association (KIT)
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-01-16 22:37:09 +01:00 committed by Tomas Cohen Arazi
parent c9f7b72426
commit fb0e6a20f8

View file

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