[Koha-patches] [PATCH] bug_6504: Reintroduced freight costs when receiving orders
Srdjan Jankovic
srdjan at catalyst.net.nz
Fri Sep 9 05:51:47 CEST 2011
---
C4/Acquisition.pm | 1 +
acqui/addorder.pl | 3 +++
acqui/neworderempty.pl | 1 +
acqui/parcel.pl | 16 +++++-----------
.../prog/en/modules/acqui/neworderempty.tt | 6 ++++++
.../prog/en/modules/acqui/orderreceive.tt | 2 +-
.../intranet-tmpl/prog/en/modules/acqui/parcels.tt | 3 +--
7 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm
index f682256..4227830 100644
--- a/C4/Acquisition.pm
+++ b/C4/Acquisition.pm
@@ -1264,6 +1264,7 @@ sub GetParcel {
aqorders.listprice,
aqorders.rrp,
aqorders.ecost,
+ aqorders.freight,
biblio.title
FROM aqorders
LEFT JOIN aqbasket ON aqbasket.basketno=aqorders.basketno
diff --git a/acqui/addorder.pl b/acqui/addorder.pl
index e321d2c..a20c79c 100755
--- a/acqui/addorder.pl
+++ b/acqui/addorder.pl
@@ -103,6 +103,8 @@ budget_id used to pay this order.
=item C<cost>
+=item C<freight>
+
=item C<sub>
=item C<invoice>
@@ -174,6 +176,7 @@ $orderinfo->{'uncertainprice'} ||= 0;
#my $gst = $input->param('GST');
#my $budget = $input->param('budget');
#my $cost = $input->param('cost');
+#my $freight = $input->param('freight');
#my $sub = $input->param('sub');
#my $purchaseorder = $input->param('purchaseordernumber');
#my $invoice = $input->param('invoice');
diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl
index e99eeb0..2c528b7 100755
--- a/acqui/neworderempty.pl
+++ b/acqui/neworderempty.pl
@@ -380,6 +380,7 @@ $template->param(
quantityrec => $data->{'quantity'},
rrp => $data->{'rrp'},
listprice => sprintf("%.2f", $data->{'listprice'}||$data->{'price'}||$listprice),
+ freight => sprintf("%.2f", $data->{'freight'}||0),
total => sprintf("%.2f", ($data->{'ecost'}||0)*($data->{'quantity'}||0) ),
ecost => $data->{'ecost'},
notes => $data->{'notes'},
diff --git a/acqui/parcel.pl b/acqui/parcel.pl
index ec5071b..ae937fd 100755
--- a/acqui/parcel.pl
+++ b/acqui/parcel.pl
@@ -216,19 +216,14 @@ for (my $i = 0 ; $i < $countlines ; $i++) {
$totalprice += $parcelitems[$i]->{'unitprice'};
$line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'});
- #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..
- if ($i > 0 && $totalfreight != $parcelitems[$i]->{'freight'}) {
- warn "FREIGHT CHARGE MISMATCH!!";
- }
- $totalfreight = $parcelitems[$i]->{'freight'};
+ $totalfreight += $parcelitems[$i]->{'freight'};
$totalquantity += $parcelitems[$i]->{'quantityreceived'};
$tototal += $total;
}
my $pendingorders = GetPendingOrders($supplierid);
my $countpendings = scalar @$pendingorders;
+my $freight_per_order = $freight && $countpendings ? $freight/$countpendings : 0;
# pending orders totals
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd);
@@ -247,6 +242,7 @@ for (my $i = 0 ; $i < $countpendings ; $i++) {
$line{ecost} = sprintf("%.2f",$line{ecost});
$line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity});
$line{unitprice} = sprintf("%.2f",$line{unitprice});
+ $line{freight} = sprintf("%.2f",$freight_per_order);
$line{invoice} = $invoice;
$line{gst} = $gst;
$line{total} = $total;
@@ -254,7 +250,6 @@ for (my $i = 0 ; $i < $countpendings ; $i++) {
$ordergrandtotal += $line{ecost} * $line{quantity};
push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage);
}
-$freight = $totalfreight unless $freight;
my $count = $countpendings;
@@ -289,8 +284,7 @@ if ($count>$resultsperpage){
);
}
-#$totalfreight=$freight;
-$tototal = $tototal + $freight;
+$tototal = $tototal + $totalfreight;
$template->param(
invoice => $invoice,
@@ -307,7 +301,7 @@ $template->param(
countpending => $countpendings,
loop_orders => \@loop_orders,
totalprice => sprintf($cfstr, $totalprice),
- totalfreight => $totalfreight,
+ totalfreight => sprintf($cfstr, $totalfreight),
totalquantity => $totalquantity,
tototal => sprintf($cfstr, $tototal),
ordergrandtotal => sprintf($cfstr, $ordergrandtotal),
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 39e9ca2..73fbb58 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt
@@ -422,6 +422,12 @@ $(document).ready(function()
<input type="text" id="cost" size="20" name="cost" value="[% ecost %]" />
[% END %]
</li>
+ [% IF ( quantityrec ) %]
+ <li>
+ <label for="freight">Freight: </label>
+ <input type="text" id="freight" size="20" name="freight" value="[% freight %]" [% IF close %] readonly="readonly" [% END %]/>
+ </li>
+ [% END %]
<li>
<label for="notes">Notes: </label>
<textarea id="notes" cols="30" rows="3" name="notes" >[% notes %]</textarea>
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 746155f..0e20e39 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt
@@ -82,7 +82,6 @@
<input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
<input type="hidden" name="supplierid" value="[% supplierid %]" />
<input type="hidden" name="datereceived" value="[% datereceived_iso %]" />
- <input type="hidden" name="freight" value="[% freight %]" />
<input type="hidden" name="gst" value="[% gst %]" />
</div>
<div class="yui-u">
@@ -127,6 +126,7 @@
[% ELSE %]
<input type="text" size="20" name="cost" id="cost" value="[% ecost %]" />
[% END %]</li></ol>
+ <li><label for="freight">Freight: </label><input type="text" size="20" name="freight" id="freight" value="[% freight %]" /></li>
<label for="note">Notes: </label><textarea name="note" width="40" rows="8" >[% notes %]</textarea>
<input type="hidden" name="invoice" value="[% invoice %]" />
</fieldset>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt
index a7d704d..53d44d7 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcels.tt
@@ -96,11 +96,10 @@
<input type="text" size="20" id="gst" name="gst" />
</li>
[% END %]
- <!-- // Removing freight input until shipping can be proplerly handled .
<li>
<label for="freight">Shipping:</label>
<input type="text" size="20" id="freight" name="freight" />
- </li> -->
+ </li>
<li><label for="datereceived">Shipment date: </label>
<input type="text" id="datereceived" name="datereceived" maxlength="10" size="10" value="[% datereceived_today %]" />
<img src="[% themelang %]/lib/calendar/cal.gif" id="datereceived_button" alt="Show Calendar" />
--
1.6.5
More information about the Koha-patches
mailing list