Bug 21467: Do not erase the internal note of the first order

For the subscription we would like to keep the original internal note
(from the first order), to display it unmodified each time we receive
issues.

Sponsored-by: BULAC - http://www.bulac.fr/

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2018-10-02 13:31:20 -03:00 committed by Nick Clemens
parent b9149799e3
commit 9a011c58e7
3 changed files with 57 additions and 6 deletions

View File

@ -1443,16 +1443,19 @@ sub ModReceiveOrder {
UPDATE aqorders
SET quantity = ?,
orderstatus = 'partial'|;
$query .= q|, order_internalnote = ?| if defined $order->{order_internalnote};
$query .= q| WHERE ordernumber = ?|;
my $sth = $dbh->prepare($query);
$sth->execute(
( $is_standing ? 1 : ($order->{quantity} - $quantrec) ),
( defined $order->{order_internalnote} ? $order->{order_internalnote} : () ),
$order->{ordernumber}
);
if ( not $order->{subscriptionid} && defined $order->{order_internalnote} ) {
$dbh->do(q|UPDATE aqorders
SET order_internalnote = ?|, {}, $order->{order_internalnote});
}
# Recalculate tax_value
$dbh->do(q|
UPDATE aqorders

View File

@ -197,6 +197,8 @@ my @gst_values = map {
option => $_ + 0.0
}, split( '\|', C4::Context->preference("gist") );
my $order_internalnote = $order->{order_internalnote};
my $order_vendornote = $order->{order_vendornote};
if ( $order->{subscriptionid} ) {
# Order from a subscription, we will display an history of what has been received
my $orders = Koha::Acquisition::Orders->search(
@ -206,7 +208,14 @@ if ( $order->{subscriptionid} ) {
ordernumber => { '!=' => $order->{ordernumber} }
}
);
$template->param( orders => $orders );
if ( $order->{parent_ordernumber} != $order->{ordernumber} ) {
my $parent_order = Koha::Acquisition::Orders->find($order->{parent_ordernumber});
$order_internalnote = $parent_order->{order_internalnote};
$order_vendornote = $parent_order->{order_vendornote};
}
$template->param(
orders => $orders,
);
}
$template->param(
@ -240,8 +249,8 @@ $template->param(
invoiceid => $invoice->{invoiceid},
invoice => $invoice->{invoicenumber},
datereceived => $datereceived,
order_internalnote => $order->{order_internalnote},
order_vendornote => $order->{order_vendornote},
order_internalnote => $order_internalnote,
order_vendornote => $order_vendornote,
suggestionid => $suggestion->{suggestionid},
surnamesuggestedby => $suggestion->{surnamesuggestedby},
firstnamesuggestedby => $suggestion->{firstnamesuggestedby},

View File

@ -19,7 +19,7 @@ use Modern::Perl;
use POSIX qw(strftime);
use Test::More tests => 72;
use Test::More tests => 73;
use t::lib::Mocks;
use Koha::Database;
@ -713,4 +713,43 @@ subtest 'ModReceiveOrder replacementprice tests' => sub {
is ($received_order->{replacementprice},'16.120000',"Replacement price set if none passed in");
};
subtest 'ModReceiveOrder and subscription' => sub {
plan tests => 2;
my $builder = t::lib::TestBuilder->new;
my $first_note = 'first note';
my $second_note = 'second note';
my $subscription = $builder->build_object( { class => 'Koha::Subscriptions' } );
my $order = $builder->build_object(
{
class => 'Koha::Acquisition::Orders',
value => {
subscriptionid => $subscription->subscriptionid,
order_internalnote => $first_note,
quantity => 5,
quantityreceived => 0,
}
}
);
my $order_info = $order->unblessed;
# We do not want the note from the original note to be modified
# Keeping it will permit to display it for future receptions
$order_info->{order_internalnote} = $second_note;
my ( undef, my $received_ordernumber ) = ModReceiveOrder(
{
biblionumber => $order->biblionumber,
order => $order_info,
invoice => $order->{invoiceid},
quantityreceived => 1,
budget_id => $order->budget_id,
}
);
my $received_order = Koha::Acquisition::Orders->find($received_ordernumber);
is( $received_order->order_internalnote,
$second_note, "No price set if none passed in" );
$order->get_from_storage;
is( $order->get_from_storage->order_internalnote, $first_note );
};
$schema->storage->txn_rollback();