Minor rework of template js.
Lines explicitly ended with semicolons. Allow some better behavior if TMPL_VAR's are undefined or zero. Note FIXME added. I believe this is part of the fragmentary integration of Katipo code for GST. Would be obliged if someone with access there can confirm. Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This commit is contained in:
parent
eaa62ab2cd
commit
01230ccd5e
1 changed files with 15 additions and 12 deletions
|
@ -5,38 +5,41 @@
|
||||||
//<![CDATA[
|
//<![CDATA[
|
||||||
function update(f){
|
function update(f){
|
||||||
//collect values
|
//collect values
|
||||||
quantity=f.quantity.value
|
quantity=f.quantity.value;
|
||||||
if (quantity ==0) {
|
if (quantity ==0) {
|
||||||
alert("Quantity must be >0");
|
alert("Quantity must be >0");
|
||||||
}
|
}
|
||||||
discount=f.discount.value
|
discount=f.discount.value;
|
||||||
listinc=parseInt(f.listinc.value)
|
currency=f.currency.value;
|
||||||
currency=f.currency.value
|
listprice=f.list_price.value;
|
||||||
applygst=parseInt(f.applygst.value)
|
listinc=parseInt(f.listinc.value);
|
||||||
listprice=f.list_price.value
|
applygst=parseInt(f.applygst.value);
|
||||||
// rrp=f.rrp.value
|
// rrp=f.rrp.value
|
||||||
// ecost=f.ecost.value //budgetted cost
|
// ecost=f.ecost.value //budgetted cost
|
||||||
// GST=f.GST.value
|
// GST=f.GST.value
|
||||||
// total=f.total.value
|
// total=f.total.value
|
||||||
//make useful constants out of the above
|
//make useful constants out of the above
|
||||||
exchangerate=f.elements[currency].value //get exchange rate
|
exchangerate=f.elements[currency].value; //get exchange rate. same as "discount" above?
|
||||||
gst_on=(!listinc && applygst);
|
gst_on=(!listinc && applygst);
|
||||||
//do real stuff
|
//do real stuff
|
||||||
rrp=listprice*exchangerate;
|
rrp=listprice*exchangerate;
|
||||||
ecost=rrp*(100-discount)/100
|
ecost=rrp*(100-discount)/100;
|
||||||
GST=0;
|
GST=0;
|
||||||
if (gst_on){
|
if (gst_on){
|
||||||
|
<!-- TMPL_IF NAME="gstrate"-->
|
||||||
rrp=rrp*(1+<!-- TMPL_VAR NAME="gstrate" -->);
|
rrp=rrp*(1+<!-- TMPL_VAR NAME="gstrate" -->);
|
||||||
GST=ecost*(<!-- 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
|
total=(ecost+GST)*quantity;
|
||||||
|
|
||||||
f.rrp.value=rrp;
|
f.rrp.value=rrp;
|
||||||
f.ecost.value=ecost;
|
f.ecost.value=ecost;
|
||||||
f.total.value=total;
|
f.total.value=total;
|
||||||
<!-- TMPL_IF NAME="GST"-->
|
<!-- TMPL_IF NAME="GST" --> // FIXME: TMPL_VAR NAME="GST" never populated
|
||||||
f.GST.value=GST;
|
f.GST.value=GST;
|
||||||
<!-- /TMPL_IF -->
|
<!-- /TMPL_IF -->
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue