Bug 20726: Add acquisition history on the subscription detail page

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 <severine.queune@bulac.fr>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2018-05-07 20:00:25 -03:00 committed by Nick Clemens
parent 1756b874a3
commit 284cf15a25
2 changed files with 59 additions and 86 deletions

View File

@ -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' %]
<title>Koha &rsaquo; Serials &rsaquo; Details for subscription #[% subscriptionid | html %]</title>
@ -328,42 +330,71 @@
</div>
</div>
[% IF ( show_acquisition_details ) %]
[% IF orders %]
<div id="acquisition_details">
<h2>Acquisition details</h2>
<table>
<table id="orders">
<thead>
<tr><th></th><th>Price exc. taxes</th><th>Price inc. taxes</th><th>Fund</th><th></th></tr>
<tr>
<th>Invoice</th>
<th>Basket</th>
<th>Order number</th>
<th class="title-string">Creation date</th>
<th class="title-string">Receive date</th>
<th>Status</th>
<th>Fund</th>
<th>Ordered</th>
<th>Spent</th>
</tr>
</thead>
<tbody>
[% FOR order IN orders %]
<tr>
<td>Ordered amount</td>
<td>[% value_tax_excluded_ordered | html %]</td>
<td>[% value_tax_included_ordered | html %]</td>
<td>[% budget_name_ordered | html %]</td>
<td>
[% IF ( ordered_exists ) %]
<a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno | html %]">See basket information</a>
[% END %]
</td>
</tr>
<tr>
<td>Spent amount</td>
<td>[% value_tax_excluded_spent | html %]</td>
<td>[% value_tax_included_spent | html %]</td>
<td>[% budget_name_spent | html %]</td>
<td>
[% IF ( spent_exists ) %]
<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid | html %]">See invoice information</a>
[% IF order.invoice %]
[% IF CAN_user_acquisition %]
<a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% order.invoiceid %]" title="Invoice detail page">
[% order.invoice.invoicenumber | html %]</a>
[% ELSE %]
[% order.invoice.invoicenumber | html %]
[% END %]
[% END %]
</td>
<td>[% IF CAN_user_acquisition_order_manage %]
<a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% order.basketno | uri %]">[% order.basket.basketname | html %] ([% order.basketno | html %])</a>
[% ELSE %]
[% order.basket.basketname | html %] ([% order.basketno | html %])
[% END %]</td>
<td>[% order.ordernumber | html %]</td>
<td><span title="[% order.basket.creationdate | uri %]">[% order.basket.creationdate | $KohaDates %]</span></td>
<td><span title="[% order.datereceived | uri %]">[% order.datereceived | $KohaDates %]</span></td>
<td>
[% SWITCH order.orderstatus %]
[% CASE 'new' %]New
[% CASE 'ordered' %]Ordered
[% CASE 'partial' %]Partial
[% CASE 'complete' %]Complete
[% CASE 'cancelled' %]Cancelled
[% END %]
</td>
<td>[% order.fund.budget_name | html %]</td>
<td>
[% UNLESS order.datereceived %]
[% order.ecost_tax_excluded | $Price %] / [% order.ecost_tax_included | $Price %]
[% END %]
</td>
<td>
[% IF order.datereceived %]
[%# FIXME What if unitprice has not been filled? %]
[% order.unitprice_tax_excluded | $Price %] / [% order.unitprice_tax_included | $Price %]
[% END %]
</td>
</tr>
[% END %]
</tbody>
</table>
</div>
[% END %]
</div>
[% END %]
</div>
</div>

View File

@ -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;
}
}