From 4b4295d051b40d49d72e230d6bf6be55d00cb6ed Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 12 Oct 2018 15:19:28 -0300 Subject: [PATCH] Bug 21467: Display a summary line per parent_ordernumber MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will help to keep track of the different orders for a given subscription. Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Séverine QUEUNE Signed-off-by: Katrin Fischer --- .../prog/en/modules/serials/subscription-detail.tt | 48 ++++++++++++++++------ serials/subscription-detail.pl | 18 +++++++- 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt index 4f4fe026e0..ad727b0b82 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt @@ -346,7 +346,7 @@ - [% IF orders.count %] + [% IF orders_grouped.size %]

Acquisition details

@@ -373,12 +373,39 @@ - [% FOR order IN orders %] - [% IF order.parent_ordernumber != order.ordernumber %] - - [% ELSE %] - - [% END %] + [% FOR ordernumber IN orders_grouped.keys %] + [% SET parent_tree_id = loop.count %] + [% SET parent_order = orders_grouped.$ordernumber %] + + [%# invoice %] + + [%# ordernumber %] + + + + [%# internalnote %] + [%# vendornote %] + [%# fund %] + + + + + [% FOR order IN parent_order.orders %] + - + [%# basket %] @@ -422,6 +445,7 @@ [% END %] + [% END %] [% END %]
+ [% IF CAN_user_acquisition_order_manage %] + [% parent_order.basket.basketname | html %] ([% parent_order.basket.basketno | html %]) + [% ELSE %] + [% parent_order.basket.basketname | html %] ([% parent_order.basket.basketno | html %]) + [% END %] + [% parent_order.basket.creationdate | $KohaDates %][% parent_order.datereceived | $KohaDates %] + [% SWITCH parent_order.orderstatus %] + [% CASE 'new' %]New + [% CASE 'ordered' %]Ordered + [% CASE 'partial' %]Partial + [% CASE 'complete' %]Complete + [% CASE 'cancelled' %]Cancelled + [% END %] + [% parent_order.quantity | html %][% parent_order.ecost_tax_excluded | $Price %] / [% parent_order.ecost_tax_included | $Price %][% parent_order.unitprice_tax_excluded | $Price %] / [% parent_order.unitprice_tax_included | $Price %]
[% IF order.invoice %] [% IF CAN_user_acquisition %] @@ -389,11 +416,7 @@ [% END %] [% END %] [% IF CAN_user_acquisition_order_manage %] - [% order.basket.basketname | html %] ([% order.basketno | html %]) - [% ELSE %] - [% order.basket.basketname | html %] ([% order.basketno | html %]) - [% END %][% order.ordernumber | html %] [% order.basket.creationdate | $KohaDates%] [% IF order.datereceived %][% order.datereceived | $KohaDates %][% END %]
diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl index 9ea681b23a..fb8721cf8e 100755 --- a/serials/subscription-detail.pl +++ b/serials/subscription-detail.pl @@ -129,7 +129,21 @@ for my $field ( @$additional_fields ) { $template->param( additional_fields_for_subscription => $additional_fields ); # FIXME Do we want to hide canceled orders? -my $orders = Koha::Acquisition::Orders->search( { subscriptionid => $subscriptionid }, { order_by => { -desc => 'parent_ordernumber' } } ); +my $orders = Koha::Acquisition::Orders->search( { subscriptionid => $subscriptionid }, { order_by => [ { -desc => 'timestamp' }, \[ "field(orderstatus, 'ordered', 'partial', 'complete')" ] ] } ); +my $orders_grouped; +while ( my $o = $orders->next ) { + if ( $o->ordernumber == $o->parent_ordernumber ) { + $orders_grouped->{$o->parent_ordernumber}->{datereceived} = $o->datereceived; + $orders_grouped->{$o->parent_ordernumber}->{orderstatus} = $o->orderstatus; + $orders_grouped->{$o->parent_ordernumber}->{basket} = $o->basket; + } + $orders_grouped->{$o->parent_ordernumber}->{quantity} += $o->quantity; + $orders_grouped->{$o->parent_ordernumber}->{ecost_tax_excluded} += sprintf('%.2f', $o->ecost_tax_excluded * $o->quantity); + $orders_grouped->{$o->parent_ordernumber}->{ecost_tax_included} += sprintf('%.2f', $o->ecost_tax_included * $o->quantity); + $orders_grouped->{$o->parent_ordernumber}->{unitprice_tax_excluded} += sprintf('%.2f', $o->unitprice_tax_excluded * $o->quantity); + $orders_grouped->{$o->parent_ordernumber}->{unitprice_tax_included} += sprintf('%.2f', $o->unitprice_tax_included * $o->quantity); + push @{$orders_grouped->{$o->parent_ordernumber}->{orders}}, $o; +} $template->param( subscriptionid => $subscriptionid, @@ -147,7 +161,7 @@ $template->param( intranetcolorstylesheet => C4::Context->preference('intranetcolorstylesheet'), irregular_issues => scalar @irregular_issues, default_bib_view => $default_bib_view, - orders => $orders, + orders_grouped => $orders_grouped, (uc(C4::Context->preference("marcflavour"))) => 1, ); -- 2.11.0