diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index eec40d085e..cb8f4e6835 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -603,7 +603,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ callback: function(r) { if (!r.exc && r.message) { me._set_values_for_item_list(r.message); - if(item) me.gross_profit(item); + if(item) me.set_gross_profit(item); if(calculate_taxes_and_totals) me.calculate_taxes_and_totals(); } } @@ -879,8 +879,10 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }, - gross_profit: function(item) { - item.gross_profit = flt((((item.rate - item.valuation_rate) * item.qty) * (this.frm.doc.conversion_rate || 1)), precision("amount", item)); + set_gross_profit: function(item) { + if (this.frm.doc.doctype == "Sales Order") { + item.gross_profit = flt((((item.rate - item.valuation_rate) * item.qty) * (this.frm.doc.conversion_rate || 1)), precision("amount", item)); + } } }); @@ -894,7 +896,7 @@ frappe.ui.form.on(cur_frm.doctype + " Item", "rate", function(frm, cdt, cdn) { item.discount_percentage = 0.0; } - cur_frm.cscript.gross_profit(item); + cur_frm.cscript.set_gross_profit(item); cur_frm.cscript.calculate_taxes_and_totals(); }) diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.json b/erpnext/selling/doctype/sales_order_item/sales_order_item.json index 6a6f4545fd..fb65ee8f1a 100644 --- a/erpnext/selling/doctype/sales_order_item/sales_order_item.json +++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json @@ -1232,6 +1232,7 @@ "label": "Valuation Rate", "length": 0, "no_copy": 1, + "options": "Company:company:default_currency", "permlevel": 0, "precision": "", "print_hide": 1, @@ -1257,6 +1258,7 @@ "label": "Gross Profit", "length": 0, "no_copy": 1, + "options": "Company:company:default_currency", "permlevel": 0, "precision": "", "print_hide": 1, @@ -1390,7 +1392,7 @@ "istable": 1, "max_attachments": 0, "menu_index": 0, - "modified": "2016-02-25 17:52:22.402065", + "modified": "2016-02-26 11:08:24.708912", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order Item", diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index a29111f42a..ef9cadc0be 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -125,7 +125,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ item.rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0), precision("rate", item)); - this.gross_profit(item); + this.set_gross_profit(item); this.calculate_taxes_and_totals(); }, diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index e036a5d04f..9b61c00e83 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -68,7 +68,7 @@ def get_item_details(args): if args.get("is_subcontracted") == "Yes": out.bom = get_default_bom(args.item_code) - get_goss_profit(out) + get_gross_profit(out) return out @@ -470,8 +470,10 @@ def get_default_bom(item_code=None): frappe.throw(_("No default BOM exists for Item {0}").format(item_code)) -def get_goss_profit(out): +def get_gross_profit(out): + if isinstance(out.valuation_rate, dict): return out + out.update({ - "gross_profit": ((out.price_list_rate - out.valuation_rate) * out.qty) * (out.conversio_rate or 1) + "gross_profit": ((out.base_rate - out.valuation_rate) * out.qty) }) return out