discount rate on purchase
This commit is contained in:
parent
eb8233c779
commit
4491f01ce4
@ -135,6 +135,11 @@ cur_frm.cscript.purchase_ref_rate = function(doc, cdt, cdn) {
|
||||
// Calculate Amount
|
||||
cur_frm.cscript.calc_amount(doc, 4);
|
||||
}
|
||||
//==================== Import Ref Rate ================================================================
|
||||
cur_frm.cscript.import_ref_rate = function(doc, cdt, cdn) {
|
||||
// Calculate Amount
|
||||
cur_frm.cscript.calc_amount(doc, 5);
|
||||
}
|
||||
|
||||
|
||||
//====================== Calculate Amount ============================================================
|
||||
@ -253,19 +258,18 @@ cur_frm.cscript.calc_amount = function(doc, n) {
|
||||
for(var i=0;i<cl.length;i++)
|
||||
{
|
||||
if(n == 1){
|
||||
set_multiple(tname, cl[i].name, {'discount_rate': flt(flt( flt( flt(cl[i].import_ref_rate) - flt(cl[i].import_rate) ) * 100 )/flt(cl[i].import_ref_rate)) }, fname);
|
||||
set_multiple(tname, cl[i].name, {'purchase_rate': flt(doc.conversion_rate) * flt(cl[i].import_rate) }, fname);
|
||||
set_multiple(tname, cl[i].name, {'amount': flt(flt(cl[i].qty) * flt(doc.conversion_rate) * flt(cl[i].import_rate))}, fname);
|
||||
set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i].import_rate))}, fname);
|
||||
if(cl[i].import_ref_rate){
|
||||
set_multiple(tname, cl[i].name, {'purchase_ref_rate':flt(cl[i].import_ref_rate)*flt(doc.conversion_rate)}, fname);
|
||||
}
|
||||
//dicount value should be changed
|
||||
|
||||
}
|
||||
if(n == 2){
|
||||
set_multiple(tname, cl[i].name, {'discount_rate': flt(flt( flt( flt(cl[i].purchase_ref_rate) - flt(cl[i].purchase_rate) ) * 100 )/flt(cl[i].purchase_ref_rate)) }, fname);
|
||||
set_multiple(tname, cl[i].name, {'amount': flt(flt(cl[i].qty) * flt(cl[i].purchase_rate)), 'import_rate': flt(flt(cl[i].purchase_rate) / flt(doc.conversion_rate)) }, fname);
|
||||
set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i].purchase_rate) / flt(doc.conversion_rate))}, fname);
|
||||
set_multiple(tname, cl[i].name, {'purchase_ref_rate':flt(cl[i].import_ref_rate)*flt(doc.conversion_rate)}, fname);
|
||||
//discount value should be changed
|
||||
|
||||
}
|
||||
if(n == 3){
|
||||
set_multiple(tname, cl[i].name, {'purchase_rate': flt(flt(cl[i].amount) / flt(cl[i].qty)) }, fname);
|
||||
@ -280,6 +284,36 @@ cur_frm.cscript.calc_amount = function(doc, n) {
|
||||
set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i].purchase_rate) / flt(doc.conversion_rate))}, fname);
|
||||
|
||||
}
|
||||
|
||||
if( n==5){
|
||||
set_multiple(tname, cl[i].name, {'purchase_ref_rate': flt(flt(cl[i].import_ref_rate) * flt(doc.conversion_rate))}, fname);
|
||||
set_multiple(tname, cl[i].name, {'purchase_rate':flt( flt(cl[i].import_ref_rate) - flt(flt(cl[i].import_ref_rate)*flt(cl[i].discount_rate)/100) ) * flt(doc.conversion_rate) }, fname);
|
||||
set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i].purchase_rate) / flt(doc.conversion_rate))}, fname);
|
||||
set_multiple(tname, cl[i].name, {'amount':flt(flt(cl[i].qty) * flt(cl[i].purchase_rate))}, fname);
|
||||
set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i].purchase_rate) / flt(doc.conversion_rate))}, fname);
|
||||
|
||||
}
|
||||
if( n==6){
|
||||
|
||||
//set_multiple(tname, cl[i].name, {'import_ref_rate': flt(flt(cl[i].purchase_ref_rate) / flt(doc.conversion_rate))}, fname);
|
||||
if (cl[i].purchase_ref_rate){
|
||||
set_multiple(tname, cl[i].name, {'purchase_rate':flt( flt(cl[i].purchase_ref_rate) - flt(flt(cl[i].purchase_ref_rate)*flt(cl[i].discount_rate)/100) )}, fname);
|
||||
}
|
||||
else{
|
||||
set_multiple(tname, cl[i].name, {'purchase_rate': flt(flt(cl[i].import_rate) * flt(doc.conversion_rate))}, fname);
|
||||
}
|
||||
if (cl[i].import_ref_rate){
|
||||
set_multiple(tname, cl[i].name, {'import_rate':flt( flt(cl[i].import_ref_rate) - flt(flt(cl[i].import_ref_rate)*flt(cl[i].discount_rate)/100) )}, fname);
|
||||
}
|
||||
else{
|
||||
set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i].import_rate) * flt(doc.conversion_rate))}, fname);
|
||||
}
|
||||
|
||||
set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i].purchase_rate) / flt(doc.conversion_rate))}, fname);
|
||||
set_multiple(tname, cl[i].name, {'amount':flt(flt(cl[i].qty) * flt(cl[i].purchase_rate))}, fname);
|
||||
set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i].purchase_rate) / flt(doc.conversion_rate))}, fname);
|
||||
|
||||
}
|
||||
if (n != 3){
|
||||
net_total += flt(flt(cl[i].qty) * flt(cl[i].purchase_rate));
|
||||
net_total_import += flt(flt(cl[i].qty) * flt(cl[i].import_rate));
|
||||
|
Loading…
x
Reference in New Issue
Block a user