From 03739147049ed78bd2bb43f5f47cfc70d6be43ba Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 24 Feb 2022 14:42:56 +0530 Subject: [PATCH 1/2] fix: Commission not applied while making Sales Order from Quotation --- .../doctype/sales_invoice_item/sales_invoice_item.json | 6 ++++-- .../doctype/sales_order_item/sales_order_item.json | 7 +++++-- .../doctype/delivery_note_item/delivery_note_item.json | 9 ++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json index ae9ac35729..2901cf0888 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json @@ -832,6 +832,7 @@ }, { "default": "0", + "fetch_from": "item_code.grant_commission", "fieldname": "grant_commission", "fieldtype": "Check", "label": "Grant Commission", @@ -841,7 +842,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2021-10-05 12:24:54.968907", + "modified": "2022-02-24 14:41:36.392560", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Item", @@ -849,5 +850,6 @@ "owner": "Administrator", "permissions": [], "sort_field": "modified", - "sort_order": "DESC" + "sort_order": "DESC", + "states": [] } \ No newline at end of file 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 080d517d13..7e55499533 100644 --- a/erpnext/selling/doctype/sales_order_item/sales_order_item.json +++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.json @@ -83,8 +83,8 @@ "planned_qty", "column_break_69", "work_order_qty", - "produced_qty", "delivered_qty", + "produced_qty", "returned_qty", "shopping_cart_section", "additional_notes", @@ -701,8 +701,10 @@ "width": "50px" }, { + "description": "For Production", "fieldname": "produced_qty", "fieldtype": "Float", + "hidden": 1, "label": "Produced Quantity", "oldfieldname": "produced_qty", "oldfieldtype": "Currency", @@ -791,6 +793,7 @@ }, { "default": "0", + "fetch_from": "item_code.grant_commission", "fieldname": "grant_commission", "fieldtype": "Check", "label": "Grant Commission", @@ -800,7 +803,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2022-02-21 13:55:08.883104", + "modified": "2022-02-24 14:41:57.325799", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order Item", diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json index 51c88bed61..f1f5d96e62 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json @@ -757,6 +757,7 @@ }, { "default": "0", + "fetch_from": "item_code.grant_commission", "fieldname": "grant_commission", "fieldtype": "Check", "label": "Grant Commission", @@ -767,12 +768,14 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2021-10-06 12:12:44.018872", + "modified": "2022-02-24 14:42:20.211085", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note Item", + "naming_rule": "Random", "owner": "Administrator", "permissions": [], "sort_field": "modified", - "sort_order": "DESC" -} + "sort_order": "DESC", + "states": [] +} \ No newline at end of file From 4e9a9f35a605f4f886cc9cc920ec4ab4262b9709 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 28 Feb 2022 12:41:59 +0530 Subject: [PATCH 2/2] test: add correct test case --- .../doctype/sales_invoice/test_sales_invoice.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index 941061f2a2..07591e7b1e 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -2429,14 +2429,22 @@ class TestSalesInvoice(unittest.TestCase): def test_sales_commission(self): - si = frappe.copy_doc(test_records[0]) + si = frappe.copy_doc(test_records[2]) + + frappe.db.set_value('Item', si.get('items')[0].item_code, 'grant_commission', 1) + frappe.db.set_value('Item', si.get('items')[1].item_code, 'grant_commission', 0) + item = copy.deepcopy(si.get('items')[0]) item.update({ "qty": 1, "rate": 500, - "grant_commission": 1 }) - si.append("items", item) + + item = copy.deepcopy(si.get('items')[1]) + item.update({ + "qty": 1, + "rate": 500, + }) # Test valid values for commission_rate, total_commission in ((0, 0), (10, 50), (100, 500)):