From 40267be0851309d926932e458317a9f10f5c38a2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 1 Oct 2018 19:41:17 -0300 Subject: [PATCH] Bug 21467: Allow several receipts for a given subscription MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When a new order is created from a subscription the quantity is set to 1 and cannot be modified. The idea was to order 1 subscription. This behavior leads to a limitation: it is not possible to mark a receipt as partially received. However it is how it works in real life, the vendors send invoices throughout the year. The number of items can also be changed. The idea is be to rethink the "quantity" value for an order created from a subscription and use it to track the number of invoices already paid. FIXME: This approach will not cohabit with standing orders. This patch is a first draft to get feedback on the idea. FIXME: What about cancelled orders? Test plan: - Create a new order from a subscription - Enter the number of items you think you will receive for this subscription (for instance 1 per month: 12) - Close the basket - Receive 3 items (a trimester) and create a specific invoice for this receipt. Note that the price are per unit. If you want to receive items with different prices you should make split the receipt - Receive more items. This time you will notice that the previous order will be displayed on the "order receive" under a new block "Receipt history for this subscription" - Note that the "Quantity to receive" has been decrease by the number of items you previously received - Also you can notice that this "Quantity to receive" can be modified. Indeed it can happen that the number of items to receive changed during the year - Go to the detail of the subscription and notice that the orders have been grouped by "parent ordernumber" - Continue to receive items until all have been received Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Séverine QUEUNE Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens --- acqui/finishreceive.pl | 7 +- acqui/orderreceive.pl | 12 +++ .../prog/en/modules/acqui/neworderempty.tt | 10 ++- .../prog/en/modules/acqui/orderreceive.tt | 78 +++++++++++++++---- 4 files changed, 88 insertions(+), 19 deletions(-) diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index ca50496451..79b6326bff 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -61,7 +61,8 @@ my $new_ordernumber = $ordernumber; $unitprice = Koha::Number::Price->new( $unitprice )->unformat(); $replacementprice = Koha::Number::Price->new( $replacementprice )->unformat(); -my $basket = Koha::Acquisition::Orders->find( $ordernumber )->basket; +my $order_obj = Koha::Acquisition::Orders->find( $ordernumber ); +my $basket = $order_obj->basket; #need old receivedate if we update the order, parcel.pl only shows the right parcel this way FIXME if ($quantityrec > $origquantityrec ) { @@ -100,6 +101,10 @@ if ($quantityrec > $origquantityrec ) { # save the quantity received. if ( $quantityrec > 0 ) { + if ( $order_obj->subscriptionid ) { + # Quantity can only be modified if linked to a subscription + $order->{quantity} = $quantity; # quantityrec will be deduced from this value in ModReceiveOrder + } ( $datereceived, $new_ordernumber ) = ModReceiveOrder( { biblionumber => $biblionumber, diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index 1db00d3e58..ebf29f703e 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -197,6 +197,18 @@ my @gst_values = map { option => $_ + 0.0 }, split( '\|', C4::Context->preference("gist") ); +if ( $order->{subscriptionid} ) { + # Order from a subscription, we will display an history of what has been received + my $orders = Koha::Acquisition::Orders->search( + { + subscriptionid => $order->{subscriptionid}, + parent_ordernumber => $order->{ordernumber}, + ordernumber => { '!=' => $order->{ordernumber} } + } + ); + $template->param( orders => $orders ); +} + $template->param( AcqCreateItem => $AcqCreateItem, count => 1, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt index 1ae2f3b666..ab07b1a89a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -303,14 +303,16 @@ [% quantity | html %] [% ELSE %] - [% IF (AcqCreateItemOrdering) %] - [% IF subscriptionid || basket.is_standing %] + [% IF subscriptionid %] + + [% ELSIF AcqCreateItemOrdering %] + [% IF basket.is_standing %] [% ELSE %] [% END %] [% ELSE %] - [% IF subscriptionid || basket.is_standing %] + [% IF basket.is_standing %] [% ELSE %] @@ -622,7 +624,7 @@ }); //We apply the fonction only for modify option - [% IF ( quantityrec ) %] + [% IF ( quantityrec and not subscriptionid ) %] [% IF ( acqcreate ) %] $('#quantity').blur(function(){ // if user decreases the quantity diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 9c7e702bc7..abe2d16a5f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -54,7 +54,62 @@ [% END %] - [% IF (AcqCreateItemReceiving) %] + [% IF subscriptionid and orders.count %] +
+ Receipt history for this subscription + + + + + + + + + + + + + + + [% FOR order IN orders %] + + + + + + + + + + + [% END %] + +
InvoiceOrder numberCreation dateReceive dateQuantity receivedStatusSpentInternal note
+ [% IF order.invoice %] + [% IF CAN_user_acquisition %] + + [% order.invoice.invoicenumber | html %] + [% ELSE %] + [% order.invoice.invoicenumber | html %] + [% END %] + [% END %] + [% order.ordernumber | html %][% order.basket.creationdate | $KohaDates%][% IF order.datereceived %][% order.datereceived | $KohaDates %][% END %][% order.quantityreceived | html %] + [% SWITCH order.orderstatus %] + [%# FIXME We should only see/display Complete here, right? %] + [% CASE 'new' %]New + [% CASE 'ordered' %]Ordered + [% CASE 'partial' %]Partial + [% CASE 'complete' %]Complete + [% CASE 'cancelled' %]Cancelled + [% END %] + + [% IF order.datereceived %][%# FIXME Should only be true, right? %] + [%# FIXME What if unitprice has not been filled? %] + [% order.unitprice_tax_excluded | $Price | html %] / [% order.unitprice_tax_included | $Price | html %] + [% END %] + [% order.order_internalnote | html %]
+
+ [% ELSIF (AcqCreateItemReceiving) %]