[Koha-patches] [PATCH] (bug #4840) round cost in new order

Nahuel ANGELINETTI nahuel.angelinetti at biblibre.com
Mon May 31 13:45:43 CEST 2010


---
 .../prog/en/modules/acqui/neworderempty.tmpl       |   76 ++++++++++---------
 1 files changed, 40 insertions(+), 36 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl
index 37a5a5d..320b725 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tmpl
@@ -3,45 +3,49 @@
 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
 <script type="text/javascript">
 //<![CDATA[
-function update(f){
-//collect values
-quantity=f.quantity.value;
-if (quantity ==0) {
-    alert("Quantity must be >0");
-}
- discount=f.discount.value;
- currency=f.currency.value;
-listprice=f.list_price.value;
-  listinc=parseInt(f.listinc.value);
- applygst=parseInt(f.applygst.value);
-//  rrp=f.rrp.value
-//  ecost=f.ecost.value  //budgetted cost
-//  GST=f.GST.value
-//  total=f.total.value
-//make useful constants out of the above
-exchangerate=f.elements[currency].value;      //get exchange rate.  same as "discount" above?
-gst_on=(!listinc && applygst);
-//do real stuff
-rrp=listprice*exchangerate;
-ecost=rrp*(100-discount)/100;
-GST=0;
-if (gst_on){
-<!-- TMPL_IF NAME="gstrate"-->
-    rrp=rrp*(1+<!-- TMPL_VAR NAME="gstrate" -->);
-    GST=ecost*(<!-- TMPL_VAR NAME="gstrate" -->);
-<!-- TMPL_ELSE --> ; // TMPL_VAR NAME=gstrate not set.  leave rrp and GST alone.
-<!-- /TMPL_IF -->
+function round(value){
+    return Math.round(value * 100) / 100;
+        
 }
+           
+function update(f){
+    //collect values
+    quantity=f.quantity.value;
+    if (quantity ==0) {
+        alert("Quantity must be >0");
+    }
+    discount=f.discount.value;
+    currency=f.currency.value;
+    listprice=f.list_price.value;
+    listinc=parseInt(f.listinc.value);
+    applygst=parseInt(f.applygst.value);
 
-total=(ecost+GST)*quantity;
+    exchangerate=f.elements[currency].value;      //get exchange rate.  same as "discount" above?
+    
+    gst_on=(!listinc && applygst);
 
-  f.rrp.value=rrp;
-f.ecost.value=ecost;
-f.total.value=total;
-<!-- TMPL_IF NAME="GST" -->  // FIXME: TMPL_VAR NAME="GST" never populated
-  f.GST.value=GST;
-<!-- /TMPL_IF -->
-return true;
+    //do real stuff
+    rrp   = listprice*exchangerate;
+    ecost = rrp * ( 100 - discount ) / 100;
+    
+    GST=0;
+    if (gst_on){
+    <!-- TMPL_IF NAME="gstrate"-->
+        rrp=rrp*(1+<!-- TMPL_VAR NAME="gstrate" -->);
+        GST=ecost*(<!-- TMPL_VAR NAME="gstrate" -->);
+    <!-- TMPL_ELSE --> ; // TMPL_VAR NAME=gstrate not set.  leave rrp and GST alone.
+    <!-- /TMPL_IF -->
+    }
+
+    total = ( ecost + GST ) * quantity;
+
+    f.rrp.value   = round(rrp);
+    f.ecost.value = round(ecost);
+    f.total.value = round(total);
+    <!-- TMPL_IF NAME="GST" -->  // FIXME: TMPL_VAR NAME="GST" never populated
+        f.GST.value = round(GST);
+    <!-- /TMPL_IF -->
+    return true;
 }
 
 function messenger(X,Y,etc){	// FIXME: unused?
-- 
1.7.0.4



More information about the Koha-patches mailing list