From 385ea6a92d692e5168b767eceb9babdc902454c3 Mon Sep 17 00:00:00 2001 From: Shinoy M Date: Mon, 2 Jul 2012 18:18:31 +0530 Subject: [PATCH] Bug 8343 - Editable discount rate and miscellaneous charges during ordering Add new fields like -Discount percentage- and -Miscellaneous cost- in the order page.Default discount rate will be shown in the Discount percentage field and it is editable.You can enter Miscellaneous charges in the Miscellaneous cost field and it is calculated per quantity. --- acqui/neworderempty.pl | 2 +- koha-tmpl/intranet-tmpl/prog/en/js/acq.js | 9 +++++++-- .../prog/en/modules/acqui/neworderempty.tt | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 807a82b..9bb2338 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -360,7 +360,7 @@ $template->param( authorisedbyname => $borrower->{'firstname'} . " " . $borrower->{'surname'}, biblioitemnumber => $data->{'biblioitemnumber'}, discount_2dp => sprintf( "%.2f", $bookseller->{'discount'} ) , # for display - discount => $bookseller->{'discount'}, + discount => defined($data->{'discount'}) ? $data->{'discount'} : $bookseller->{'discount'}, orderdiscount_2dp => sprintf( "%.2f", $data->{'discount'} || 0 ), orderdiscount => $data->{'discount'}, listincgst => $bookseller->{'listincgst'}, diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js index 0c3ce91..dbe33c1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/acq.js @@ -646,12 +646,13 @@ function updateCosts(){ var listprice = new Number($("#listprice").val()); var currcode = new String($("#currency").val()); var exchangerate = new Number($("#currency_rate_"+currcode).val()); + var miscellaneous = new Number($("#miscellaneous").val()); var gst_on=false; var rrp = new Number(listprice*exchangerate); - var ecost = rrp; + var ecost = rrp + miscellaneous; if ( 100-discount != 100 ) { //Prevent rounding issues if no discount - ecost = new Number(Math.floor(rrp * (100 - discount )) / 100); + ecost = new Number(Math.floor(rrp * (100 - discount )) / 100) + miscellaneous; } var total = new Number( ecost * quantity); $("#rrp").val(rrp.toFixed(2)); @@ -659,6 +660,10 @@ function updateCosts(){ $("#total").val(total.toFixed(2)); $("listprice").val(listprice.toFixed(2)); + // In case the discount changed, we should update the message + var discount_2dp = discount.toFixed(2); + $('#discount_value').html(discount_2dp); + return true; } 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 398a568..9deef47 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt @@ -503,12 +503,31 @@ $(document).ready(function()
  • [% IF ( close ) %] + Discount percentage: + + [% ELSE %] + + + [% END %] +
  • +
  • + [% IF ( close ) %] + Miscellaneous cost: + + [% ELSE %] + + + [% END %] +
  • +
  • + [% IF ( close ) %] [% ELSE %] [% END %] + [% IF ( discount_2dp ) %] (adjusted for [% discount_2dp %]% discount) [% END %]
  • [% IF ( close ) %] -- 1.7.10.4