Bugzilla – Attachment 96663 Details for
Bug 17667
Standing orders - cancelling a receipt increase the original quantity
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17667: Do not modify quantity of the original standing order when a receipt is cancelled
Bug-17667-Do-not-modify-quantity-of-the-original-s.patch (text/plain), 4.31 KB, created by
Jonathan Druart
on 2019-12-27 16:26:32 UTC
(
hide
)
Description:
Bug 17667: Do not modify quantity of the original standing order when a receipt is cancelled
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-12-27 16:26:32 UTC
Size:
4.31 KB
patch
obsolete
>From 278e2b25d6e1add05fa003619ee691a1314eeb9d Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 18 Dec 2019 18:10:15 +0100 >Subject: [PATCH] Bug 17667: Do not modify quantity of the original standing > order when a receipt is cancelled > >When cancelling a receipt, the quantity of the original order is >increased. > >Test plan: >Create a basket, mark is as "standing orders" >Create an order >receive it >cancel the receipt >=> Without this patch the quantity of the original order is 2 >=> With this patch applied the quantity it always 1 >--- > C4/Acquisition.pm | 84 ++++++++++++++++++++++++++++--------------------------- > 1 file changed, 43 insertions(+), 41 deletions(-) > >diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm >index fcd590df79..ba34b31272 100644 >--- a/C4/Acquisition.pm >+++ b/C4/Acquisition.pm >@@ -1614,48 +1614,50 @@ sub CancelReceipt { > } else { > # The order line has a parent, increase parent quantity and delete > # the order line. >- $query = qq{ >- SELECT quantity, datereceived >- FROM aqorders >- WHERE ordernumber = ? >- }; >- $sth = $dbh->prepare($query); >- $sth->execute($parent_ordernumber); >- my $parent_order = $sth->fetchrow_hashref; >- unless($parent_order) { >- warn "Parent order $parent_ordernumber does not exist."; >- return; >- } >- if($parent_order->{'datereceived'}) { >- warn "CancelReceipt: parent order is received.". >- " Can't cancel receipt."; >- return; >- } >- $query = qq{ >- UPDATE aqorders >- SET quantity = ?, >- orderstatus = 'ordered' >- WHERE ordernumber = ? >- }; >- $sth = $dbh->prepare($query); >- my $rv = $sth->execute( >- $order->{'quantity'} + $parent_order->{'quantity'}, >- $parent_ordernumber >- ); >- unless($rv) { >- warn "Cannot update parent order line, so do not cancel". >- " receipt"; >- return; >- } >+ unless ( $order_obj->basket->is_standing ) { >+ $query = qq{ >+ SELECT quantity, datereceived >+ FROM aqorders >+ WHERE ordernumber = ? >+ }; >+ $sth = $dbh->prepare($query); >+ $sth->execute($parent_ordernumber); >+ my $parent_order = $sth->fetchrow_hashref; >+ unless($parent_order) { >+ warn "Parent order $parent_ordernumber does not exist."; >+ return; >+ } >+ if($parent_order->{'datereceived'}) { >+ warn "CancelReceipt: parent order is received.". >+ " Can't cancel receipt."; >+ return; >+ } >+ $query = qq{ >+ UPDATE aqorders >+ SET quantity = ?, >+ orderstatus = 'ordered' >+ WHERE ordernumber = ? >+ }; >+ $sth = $dbh->prepare($query); >+ my $rv = $sth->execute( >+ $order->{'quantity'} + $parent_order->{'quantity'}, >+ $parent_ordernumber >+ ); >+ unless($rv) { >+ warn "Cannot update parent order line, so do not cancel". >+ " receipt"; >+ return; >+ } > >- # Recalculate tax_value >- $dbh->do(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 >- WHERE ordernumber = ? >- |, undef, $parent_ordernumber); >+ # Recalculate tax_value >+ $dbh->do(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 >+ WHERE ordernumber = ? >+ |, undef, $parent_ordernumber); >+ } > > _cancel_items_receipt( $order_obj, $parent_ordernumber ); > # Delete order line >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17667
:
96427
|
96433
|
96663
|
96664
|
97317
|
97318
|
97593
|
97594