From 284cf15a255c30fb2a1f6ce0ddbcb5a5ebb6bc80 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 7 May 2018 20:00:25 -0300 Subject: [PATCH] Bug 20726: Add acquisition history on the subscription detail page MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Since bug 20365 is going to add the ability to create several pending orders on the same subscription we should display the history of the acquisitions on the subscription detail page. Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Séverine QUEUNE Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- .../prog/en/modules/serials/subscription-detail.tt | 73 +++++++++++++++------- serials/subscription-detail.pl | 66 ++----------------- 2 files changed, 56 insertions(+), 83 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 7f8b219aad..eb933c8140 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 @@ -1,8 +1,10 @@ [% USE raw %] [% USE Asset %] [% USE Koha %] +[% USE KohaDates %] [% USE Branches %] [% USE AuthorisedValues %] +[% USE Price %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Serials › Details for subscription #[% subscriptionid | html %] @@ -328,42 +330,71 @@ - [% IF ( show_acquisition_details ) %] + [% IF orders %]

Acquisition details

- +
- + + + + + + + + + + + + [% FOR order IN orders %] - - - - - - - - - - + + + + + + + + [% END %]
Price exc. taxesPrice inc. taxesFund
InvoiceBasketOrder numberCreation dateReceive dateStatusFundOrderedSpent
Ordered amount[% value_tax_excluded_ordered | html %][% value_tax_included_ordered | html %][% budget_name_ordered | html %] - [% IF ( ordered_exists ) %] - See basket information + [% IF order.invoice %] + [% IF CAN_user_acquisition %] + + [% order.invoice.invoicenumber | html %] + [% ELSE %] + [% order.invoice.invoicenumber | html %] [% END %] + [% END %]
Spent amount[% value_tax_excluded_spent | html %][% value_tax_included_spent | html %][% budget_name_spent | html %][% 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 %][% order.datereceived | $KohaDates %] - [% IF ( spent_exists ) %] - See invoice information + [% SWITCH order.orderstatus %] + [% CASE 'new' %]New + [% CASE 'ordered' %]Ordered + [% CASE 'partial' %]Partial + [% CASE 'complete' %]Complete + [% CASE 'cancelled' %]Cancelled + [% END %] + [% order.fund.budget_name | html %] + [% UNLESS order.datereceived %] + [% order.ecost_tax_excluded | $Price %] / [% order.ecost_tax_included | $Price %] + [% END %] + + [% IF order.datereceived %] + [%# FIXME What if unitprice has not been filled? %] + [% order.unitprice_tax_excluded | $Price %] / [% order.unitprice_tax_included | $Price %] [% END %]
-
- [% END %] - - + + [% END %] diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl index b7e7c05bd0..cc7a5d2985 100755 --- a/serials/subscription-detail.pl +++ b/serials/subscription-detail.pl @@ -116,32 +116,6 @@ my $numberpattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($su my $default_bib_view = get_default_view(); -my ( $order, $bookseller, $tmpl_infos ); -if ( defined $subscriptionid ) { - my $lastOrderNotReceived = GetLastOrderNotReceivedFromSubscriptionid $subscriptionid; - my $lastOrderReceived = GetLastOrderReceivedFromSubscriptionid $subscriptionid; - if ( defined $lastOrderNotReceived ) { - my $basket = GetBasket $lastOrderNotReceived->{basketno}; - my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} ); - ( $tmpl_infos->{value_tax_included_ordered}, $tmpl_infos->{value_tax_excluded_ordered} ) = get_value_with_gst_params ( $lastOrderNotReceived->{ecost}, $lastOrderNotReceived->{tax_rate}, $bookseller ); - $tmpl_infos->{value_tax_included_ordered} = sprintf( "%.2f", $tmpl_infos->{value_tax_included_ordered} ); - $tmpl_infos->{value_tax_excluded_ordered} = sprintf( "%.2f", $tmpl_infos->{value_tax_excluded_ordered} ); - $tmpl_infos->{budget_name_ordered} = GetBudgetName $lastOrderNotReceived->{budget_id}; - $tmpl_infos->{basketno} = $lastOrderNotReceived->{basketno}; - $tmpl_infos->{ordered_exists} = 1; - } - if ( defined $lastOrderReceived ) { - my $basket = GetBasket $lastOrderReceived->{basketno}; - my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} ); - ( $tmpl_infos->{value_tax_included_spent}, $tmpl_infos->{value_tax_excluded_spent} ) = get_value_with_gst_params ( $lastOrderReceived->{unitprice}, $lastOrderReceived->{tax_rate}, $bookseller ); - $tmpl_infos->{value_tax_included_spent} = sprintf( "%.2f", $tmpl_infos->{value_tax_included_spent} ); - $tmpl_infos->{value_tax_excluded_spent} = sprintf( "%.2f", $tmpl_infos->{value_tax_excluded_spent} ); - $tmpl_infos->{budget_name_spent} = GetBudgetName $lastOrderReceived->{budget_id}; - $tmpl_infos->{invoiceid} = $lastOrderReceived->{invoiceid}; - $tmpl_infos->{spent_exists} = 1; - } -} - my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } ); for my $field ( @$additional_fields ) { if ( $field->{authorised_value_category} ) { @@ -150,6 +124,9 @@ 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 } ); + $template->param( subscriptionid => $subscriptionid, serialslist => \@serialslist, @@ -166,10 +143,8 @@ $template->param( intranetcolorstylesheet => C4::Context->preference('intranetcolorstylesheet'), irregular_issues => scalar @irregular_issues, default_bib_view => $default_bib_view, + orders => $orders, (uc(C4::Context->preference("marcflavour"))) => 1, - show_acquisition_details => defined $tmpl_infos->{ordered_exists} || defined $tmpl_infos->{spent_exists} ? 1 : 0, - basketno => $order->{basketno}, - %$tmpl_infos, ); output_html_with_http_headers $query, $cookie, $template->output; @@ -188,36 +163,3 @@ sub get_default_view { } return 'detail'; } - -sub get_value_with_gst_params { - my $value = shift; - my $tax_rate = shift; - my $bookseller = shift; - if ( $bookseller->listincgst ) { - return ( $value, $value / ( 1 + $tax_rate ) ); - } else { - return ( $value * ( 1 + $tax_rate ), $value ); - } -} - -sub get_tax_excluded { - my $value = shift; - my $tax_rate = shift; - my $bookseller = shift; - if ( $bookseller->invoiceincgst ) { - return $value / ( 1 + $tax_rate ); - } else { - return $value; - } -} - -sub get_gst { - my $value = shift; - my $tax_rate = shift; - my $bookseller = shift; - if ( $bookseller->invoiceincgst ) { - return $value / ( 1 + $tax_rate ) * $tax_rate; - } else { - return $value * ( 1 + $tax_rate ) - $value; - } -} -- 2.11.4.GIT