Lines 1590-1596
sub CancelReceipt {
Link Here
|
1590 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1590 |
my $parent_ordernumber = $order->{'parent_ordernumber'}; |
1591 |
|
1591 |
|
1592 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
1592 |
my @itemnumbers = GetItemnumbersFromOrder( $ordernumber ); |
1593 |
my $basket = Koha::Acquisition::Orders->find({ordernumber => $ordernumber})->basket; |
1593 |
my $order_obj = Koha::Acquisition::Orders->find( $ordernumber ); # FIXME rewrite all this subroutine using this object |
1594 |
|
1594 |
|
1595 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1595 |
if($parent_ordernumber == $ordernumber || not $parent_ordernumber) { |
1596 |
# The order line has no parent, just mark it as not received |
1596 |
# The order line has no parent, just mark it as not received |
Lines 1604-1610
sub CancelReceipt {
Link Here
|
1604 |
}; |
1604 |
}; |
1605 |
$sth = $dbh->prepare($query); |
1605 |
$sth = $dbh->prepare($query); |
1606 |
$sth->execute(0, undef, undef, $ordernumber); |
1606 |
$sth->execute(0, undef, undef, $ordernumber); |
1607 |
_cancel_items_receipt( $basket->effective_create_items, $ordernumber ); |
1607 |
_cancel_items_receipt( $order_obj ); |
1608 |
} else { |
1608 |
} else { |
1609 |
# The order line has a parent, increase parent quantity and delete |
1609 |
# The order line has a parent, increase parent quantity and delete |
1610 |
# the order line. |
1610 |
# the order line. |
Lines 1651-1657
sub CancelReceipt {
Link Here
|
1651 |
WHERE ordernumber = ? |
1651 |
WHERE ordernumber = ? |
1652 |
|, undef, $parent_ordernumber); |
1652 |
|, undef, $parent_ordernumber); |
1653 |
|
1653 |
|
1654 |
_cancel_items_receipt( $basket->effective_create_items, $ordernumber, $parent_ordernumber ); |
1654 |
_cancel_items_receipt( $order_obj, $parent_ordernumber ); |
1655 |
# Delete order line |
1655 |
# Delete order line |
1656 |
$query = qq{ |
1656 |
$query = qq{ |
1657 |
DELETE FROM aqorders |
1657 |
DELETE FROM aqorders |
Lines 1662-1668
sub CancelReceipt {
Link Here
|
1662 |
|
1662 |
|
1663 |
} |
1663 |
} |
1664 |
|
1664 |
|
1665 |
if( $basket->effective_create_items eq 'ordering' ) { |
1665 |
if( $order_obj->basket->effective_create_items eq 'ordering' ) { |
1666 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1666 |
my @affects = split q{\|}, C4::Context->preference("AcqItemSetSubfieldsWhenReceiptIsCancelled"); |
1667 |
if ( @affects ) { |
1667 |
if ( @affects ) { |
1668 |
for my $in ( @itemnumbers ) { |
1668 |
for my $in ( @itemnumbers ) { |
Lines 1685-1695
sub CancelReceipt {
Link Here
|
1685 |
} |
1685 |
} |
1686 |
|
1686 |
|
1687 |
sub _cancel_items_receipt { |
1687 |
sub _cancel_items_receipt { |
1688 |
my ( $effective_create_items, $ordernumber, $parent_ordernumber ) = @_; |
1688 |
my ( $order, $parent_ordernumber ) = @_; |
1689 |
$parent_ordernumber ||= $ordernumber; |
1689 |
$parent_ordernumber ||= $order->ordernumber; |
1690 |
|
1690 |
|
1691 |
my @itemnumbers = GetItemnumbersFromOrder($ordernumber); |
1691 |
my @itemnumbers = GetItemnumbersFromOrder($order->ordernumber); # FIXME Must be $order->items |
1692 |
if ( $effective_create_items eq 'receiving' ) { |
1692 |
if ( $order->basket->effective_create_items eq 'receiving' ) { |
1693 |
# Remove items that were created at receipt |
1693 |
# Remove items that were created at receipt |
1694 |
my $query = qq{ |
1694 |
my $query = qq{ |
1695 |
DELETE FROM items, aqorders_items |
1695 |
DELETE FROM items, aqorders_items |
1696 |
- |
|
|