Created
November 7, 2014 08:33
-
-
Save nathando/004cb8d8e97e426119a1 to your computer and use it in GitHub Desktop.
Change the way Amount is calculated in ERPNext Selling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Replace with new calculation of item value | |
cur_frm.cscript.calculate_item_values = function() { | |
var me = this; | |
if (!this.discount_amount_applied) { | |
$.each(this.frm.item_doclist, function(i, item) { | |
frappe.model.round_floats_in(item); | |
item.rate = flt(item.amount / item.qty, precision("rate", item)); | |
me._set_in_company_currency(item, "price_list_rate", "base_price_list_rate"); | |
me._set_in_company_currency(item, "rate", "base_rate"); | |
me._set_in_company_currency(item, "amount", "base_amount"); | |
}); | |
} | |
} | |
// Calculate back the price then update | |
cur_frm.cscript.custom_amount = function(doc, dt, dn) { | |
var sales_order_item = locals[dt][dn]; | |
sales_order_item.rate = sales_order_item.amount/sales_order_item.qty; | |
cur_frm.fixed_amt = true; | |
cur_frm.cscript.calculate_taxes_and_totals(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment