From c5edb57cf1efa63a958de1dae1119c590e7a3163 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 28 Mar 2012 13:33:36 -0400 Subject: [PATCH] Bug 8037 - Add holds and funds to items already received in parcel.pl Adds a column to indicate holds on recieved items, as well as adding a new column for fund and showing the subtotals per fund above the total subtotal. --- C4/Budgets.pm | 25 ++++ acqui/parcel.pl | 5 +- .../intranet-tmpl/prog/en/modules/acqui/parcel.tt | 122 ++++++++++++-------- 3 files changed, 104 insertions(+), 48 deletions(-) diff --git a/C4/Budgets.pm b/C4/Budgets.pm index e9732ac..d9dc8ae 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -34,6 +34,7 @@ BEGIN { @EXPORT = qw( &GetBudget + &GetBudgetByOrderNumber &GetBudgets &GetBudgetHierarchy &AddBudget @@ -616,6 +617,30 @@ sub GetBudget { return $result; } +=head2 GetBudgetByOrderNumber + + &GetBudgetByOrderNumber($ordernumber); + +get a specific budget by order number + +=cut + +# ------------------------------------------------------------------- +sub GetBudgetByOrderNumber { + my ( $ordernumber ) = @_; + my $dbh = C4::Context->dbh; + my $query = " + SELECT aqbudgets.* + FROM aqbudgets, aqorders + WHERE ordernumber=? + AND aqorders.budget_id = aqbudgets.budget_id + "; + my $sth = $dbh->prepare($query); + $sth->execute( $ordernumber ); + my $result = $sth->fetchrow_hashref; + return $result; +} + =head2 GetChildBudgetsSpent &GetChildBudgetsSpent($budget-id); diff --git a/acqui/parcel.pl b/acqui/parcel.pl index bf14ff0..f73c35e 100755 --- a/acqui/parcel.pl +++ b/acqui/parcel.pl @@ -68,6 +68,7 @@ use CGI; use C4::Output; use C4::Dates qw/format_date format_date_in_iso/; use C4::Suggestions; +use C4::Reserves qw/GetReservesFromBiblionumber/; use JSON; my $input=new CGI; @@ -176,6 +177,9 @@ for (my $i = 0 ; $i < $countlines ; $i++) { $line{gst} = $gst; $line{total} = sprintf($cfstr, $total); $line{booksellerid} = $booksellerid; + my ($count) = &GetReservesFromBiblionumber($line{biblionumber}); + $line{holds} = $count; + $line{budget} = GetBudgetByOrderNumber( $line{ordernumber} ); push @loop_received, \%line; $totalprice += $parcelitems[$i]->{'unitprice'}; $line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'}); @@ -184,7 +188,6 @@ for (my $i = 0 ; $i < $countlines ; $i++) { $line{suggestionid} = $suggestion->{suggestionid}; $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby}; $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; - #double FIXME - totalfreight is redefined later. # FIXME - each order in a parcel holds the freight for the whole parcel. This means if you receive a parcel with items from multiple budgets, you'll see the freight charge in each budget.. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt index 7b0f7ca..062c894 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -1,3 +1,4 @@ +[% USE currency = format('%.2f') -%] [% INCLUDE 'doc-head-open.inc' %] Koha › Acquisitions › [% IF ( date ) %] Receipt summary for [% name %] [% IF ( invoice ) %]invoice [% invoice %][% END %] on [% formatteddatereceived %][% ELSE %]Receive orders from [% name %][% END %] @@ -338,73 +339,100 @@ Basket - Order line + Order Line + Holds Summary - View record + View record Quantity + Fund Est cost Actual cost - TOTAL + Total - - + + + [% SET funds = {} %] + [% SET estimated_total = 0 %] + [% FOREACH loop_receive IN loop_received %] + [% SET estimated_total = estimated_total + ( loop_receive.ecost * loop_receive.quantityreceived ) %] + [% SET funds.${ loop_receive.budget.budget_name }.estimated = funds.${ loop_receive.budget.budget_name }.estimated + loop_receive.ecost %] + [% SET funds.${ loop_receive.budget.budget_name }.actual = funds.${ loop_receive.budget.budget_name }.actual + loop_receive.total %] + + [% UNLESS ( loop.odd ) %] + + [% ELSE %] + + [% END %] + + [% loop_receive.basketno %] + [% loop_receive.ordernumber %] + [% IF loop_receive.holds %] [% END %] + [% loop_receive.title |html %] + [% IF ( loop_receive.author ) %] / [% loop_receive.author %][% END %] + [% IF ( loop_receive.isbn ) %] - [% loop_receive.isbn %][% END %] + [% IF ( loop_receive.publishercode ) %]
Publisher :[% loop_receive.publishercode %][% END %] + [% IF ( loop_receive.suggestionid ) %] +
+ Suggested by: [% loop_receive.surnamesuggestedby %][% IF ( loop_receive.firstnamesuggestedby ) %], [% loop_receive.firstnamesuggestedby %] [% END %] + (suggestion #[% loop_receive.suggestionid %]) + [% END %] + + MARC | Card + [% loop_receive.quantityreceived %] + [% loop_receive.budget.budget_name %] + [% loop_receive.ecost %] + [% loop_receive.unitprice %] + [% loop_receive.total %] + + + [% END %] + + + + [% FOREACH key IN funds.keys.sort %] + +   + Subtotal for [% key %] + [% currency( funds.$key.estimated ) %] + [% currency( funds.$key.actual ) %] +   + + [% END %] + - SUBTOTAL + SUBTOTAL   - [% totalprice %] + [% currency( estimated_total ) %] [% tototal %] +   [% IF ( totalfreight ) %] -   - - Shipping - [% totalfreight %] - - [% END %] +   + Shipping + [% totalfreight %] + + [% END %] [% IF ( gst ) %] - -

- HELP
- The total at the bottom of the page should be within a few cents of the total for the invoice. -

- - Tax rate - [% gst %] - + +

+ HELP
+ The total at the bottom of the page should be within a few cents of the total for the invoice. +

+ + Tax rate + [% gst %] + [% END %] - TOTAL + TOTAL [% totalquantity %] -   +   [% grandtot %] - - [% FOREACH loop_receive IN loop_received %] - - [% loop_receive.basketno %] - [% loop_receive.ordernumber %] - [% loop_receive.title |html %] - [% IF ( loop_receive.author ) %] / [% loop_receive.author %][% END %] - [% IF ( loop_receive.isbn ) %] - [% loop_receive.isbn %][% END %] - [% IF ( loop_receive.publishercode ) %]
Publisher :[% loop_receive.publishercode %][% END %] - [% IF ( loop_receive.suggestionid ) %] -
- Suggested by: [% loop_receive.surnamesuggestedby %][% IF ( loop_receive.firstnamesuggestedby ) %], [% loop_receive.firstnamesuggestedby %] [% END %] - (suggestion #[% loop_receive.suggestionid %]) - [% END %] - - MARC | Card - [% loop_receive.quantityreceived %] - [% loop_receive.ecost %] - [% loop_receive.unitprice %] - [% loop_receive.total %] - - [% END %] - [% ELSE %]There are no received orders.[% END %] -- 1.7.2.5