diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py index 59f0322acd8..78bae96ebdb 100644 --- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py +++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py @@ -129,9 +129,9 @@ def get_pricing_rule_for_item(args): # if ignore pricing rule then set the rate or amount field to zero if item_details.doctype in ["Quotation Item", "Sales Order Item"]: item_details.update({ - "type":"Percentage", + "type":"", "rate_or_amount": 0.00 - }) + }) return item_details if not (args.item_group and args.brand): diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 57a41d18707..57baf15b52c 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -61,7 +61,8 @@ class calculate_taxes_and_totals(object): if item.doctype in ['Quotation Item', 'Sales Order Item']: item.total_margin = self.calculate_margin(item) - item.rate = item.total_margin if item.total_margin > 0 else item.rate + item.rate = flt(item.total_margin * (1.0 - (item.discount_percentage / 100.0)), item.precision("rate"))\ + if item.total_margin > 0 else item.rate item.net_rate = item.rate item.amount = flt(item.rate * item.qty, item.precision("amount")) 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 3a44befd9c8..84c46526414 100644 --- a/erpnext/selling/doctype/sales_order_item/sales_order_item.json +++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json @@ -565,6 +565,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "depends_on": "eval: doc.type != \"\"", "fieldname": "rate_or_amount", "fieldtype": "Float", "hidden": 0, @@ -585,6 +586,31 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "depends_on": "eval: doc.type != \"\"", + "fieldname": "total_margin", + "fieldtype": "Float", + "hidden": 0, + "ignore_user_permissions": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Total Margin", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0,