Discount in purchase cycle

This commit is contained in:
Nijil Y 2011-12-08 16:09:18 +05:30
parent 4499851ceb
commit d8e5bed9e5
4 changed files with 146 additions and 63 deletions

49
erpnext/accounts/doctype/pv_detail/pv_detail.txt Normal file → Executable file
View File

@ -5,7 +5,7 @@
{
'creation': '2010-08-08 17:09:17',
'docstatus': 0,
'modified': '2011-10-20 18:41:17',
'modified': '2011-12-08 15:58:58',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
@ -14,7 +14,6 @@
{
'autoname': 'EVD.######',
'colour': 'White:FFF',
'default_print_format': 'Standard',
'doctype': 'DocType',
'istable': 1,
'module': 'Accounts',
@ -22,7 +21,7 @@
'section_style': 'Tray',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 27
'version': 28
},
# These values are common for all DocField
@ -115,7 +114,7 @@
'doctype': 'DocField',
'fieldname': 'rate',
'fieldtype': 'Currency',
'label': 'Rate (Default Curr.)',
'label': 'Rate *(Default Curr.)',
'oldfieldname': 'rate',
'oldfieldtype': 'Currency',
'permlevel': 0,
@ -129,7 +128,7 @@
'doctype': 'DocField',
'fieldname': 'import_rate',
'fieldtype': 'Currency',
'label': 'Rate',
'label': 'Rate ',
'oldfieldname': 'import_rate',
'oldfieldtype': 'Currency',
'permlevel': 0,
@ -138,6 +137,15 @@
'trigger': 'Client'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'discount_rate',
'fieldtype': 'Currency',
'label': 'Discount %',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
@ -210,19 +218,6 @@
'width': '120px'
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'project_name',
'fieldtype': 'Link',
'in_filter': 1,
'label': 'Project Name',
'options': 'Project',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
@ -308,5 +303,23 @@
'permlevel': 0,
'print_hide': 1,
'report_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'purchase_ref_rate',
'fieldtype': 'Currency',
'label': 'Ref Rate *',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'import_ref_rate',
'fieldtype': 'Currency',
'label': 'Ref Rate ',
'permlevel': 0
}
]

View File

@ -5,7 +5,7 @@
{
'creation': '2010-08-08 17:09:12',
'docstatus': 0,
'modified': '2011-12-08 14:09:24',
'modified': '2011-12-08 16:05:27',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
@ -21,7 +21,7 @@
'section_style': 'Tray',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 52
'version': 54
},
# These values are common for all DocField
@ -108,7 +108,7 @@
'doctype': 'DocField',
'fieldname': 'purchase_rate',
'fieldtype': 'Currency',
'label': 'Rate (Default Curr.)',
'label': 'Rate (Default Curr.) *',
'oldfieldname': 'purchase_rate',
'oldfieldtype': 'Currency',
'permlevel': 0,
@ -123,7 +123,7 @@
'doctype': 'DocField',
'fieldname': 'purchase_ref_rate',
'fieldtype': 'Currency',
'label': 'Ref Rate',
'label': 'Ref Rate *',
'permlevel': 0
},
@ -172,7 +172,7 @@
'fieldname': 'import_rate',
'fieldtype': 'Currency',
'hidden': 0,
'label': 'Rate *',
'label': 'Rate ',
'oldfieldname': 'import_rate',
'oldfieldtype': 'Currency',
'permlevel': 0,
@ -185,7 +185,7 @@
'doctype': 'DocField',
'fieldname': 'import_ref_rate',
'fieldtype': 'Currency',
'label': 'Ref Rate *',
'label': 'Ref Rate ',
'permlevel': 0
},

View File

@ -125,6 +125,22 @@ cur_frm.cscript.import_rate = function(doc, cdt, cdn) {
cur_frm.cscript.calc_amount(doc, 1);
}
//==================== Discount Rate ================================================================
cur_frm.cscript.discount_rate = function(doc, cdt, cdn) {
// Calculate Amount
cur_frm.cscript.calc_amount(doc, 4);
}
//==================== Purchase Ref Rate ================================================================
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 ============================================================
/*cur_frm.cscript.calc_amount = function(doc, n) {
@ -242,19 +258,64 @@ 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, {'purchase_ref_rate':flt(cl[i].import_ref_rate)*flt(doc.conversion_rate)}, fname);
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(n == 2){
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, {'purchase_ref_rate':flt(cl[i].import_ref_rate)*flt(doc.conversion_rate)}, fname);
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)),}, 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, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i].purchase_rate) / flt(doc.conversion_rate))}, fname);
}
}
if(n == 3){
set_multiple(tname, cl[i].name, {'purchase_rate': flt(flt(cl[i].amount) / flt(cl[i].qty)) }, 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, {'import_amount': flt(flt(cl[i].qty) * flt(cl[i].purchase_rate) / flt(doc.conversion_rate))}, fname);
}
if( n==4){
set_multiple(tname, cl[i].name, {'import_ref_rate': flt(flt(cl[i].purchase_ref_rate) / flt(doc.conversion_rate))}, fname);
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);
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==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));

View File

@ -5,7 +5,7 @@
{
'creation': '2010-08-08 17:09:16',
'docstatus': 0,
'modified': '2011-11-16 15:43:36',
'modified': '2011-12-08 16:06:08',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
@ -14,7 +14,6 @@
{
'autoname': 'GRND/.#######',
'colour': 'White:FFF',
'default_print_format': 'Standard',
'doctype': 'DocType',
'istable': 1,
'module': 'Stock',
@ -22,7 +21,7 @@
'section_style': 'Tray',
'server_code_error': ' ',
'show_in_menu': 0,
'version': 63
'version': 64
},
# These values are common for all DocField
@ -116,23 +115,6 @@
'width': '100px'
},
# DocField
{
'colour': 'White:FFF',
'default': '0.00',
'doctype': 'DocField',
'fieldname': 'purchase_rate',
'fieldtype': 'Currency',
'label': 'Rate (Default Curr.)',
'oldfieldname': 'purchase_rate',
'oldfieldtype': 'Currency',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'trigger': 'Client',
'width': '100px'
},
# DocField
{
'default': '0.00',
@ -147,6 +129,32 @@
'width': '100px'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'purchase_ref_rate',
'fieldtype': 'Currency',
'label': 'Ref Rate *',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'default': '0.00',
'doctype': 'DocField',
'fieldname': 'purchase_rate',
'fieldtype': 'Currency',
'label': 'Rate *(Default Curr.)',
'oldfieldname': 'purchase_rate',
'oldfieldtype': 'Currency',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'trigger': 'Client',
'width': '100px'
},
# DocField
{
'default': '0.00',
@ -179,6 +187,24 @@
'width': '100px'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'discount_rate',
'fieldtype': 'Currency',
'label': 'Discount Rate %',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'import_ref_rate',
'fieldtype': 'Currency',
'label': 'Ref Rate ',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
@ -319,7 +345,6 @@
'doctype': 'DocField',
'fieldname': 'serial_no',
'fieldtype': 'Text',
'in_filter': 1,
'label': 'Serial No',
'no_copy': 1,
'oldfieldname': 'serial_no',
@ -373,19 +398,6 @@
'width': '100px'
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'project_name',
'fieldtype': 'Link',
'in_filter': 1,
'label': 'Project Name',
'options': 'Project',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'colour': 'White:FFF',
@ -451,7 +463,6 @@
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'item_tax_amount',
'fieldtype': 'Currency',
@ -502,7 +513,6 @@
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'valuation_rate',
'fieldtype': 'Currency',
@ -519,7 +529,6 @@
# DocField
{
'colour': 'White:FFF',
'description': 'Tax detail table fetched from item master as a string and stored in this field.\nUsed for Purchase Other Charges',
'doctype': 'DocField',
'fieldname': 'item_tax_rate',