From db60299cf32d337c0f3a64ea08d82cfb6077dde6 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 28 Sep 2022 14:54:53 +0530 Subject: [PATCH 1/4] fix: Item details fetching on making transaction from item dashboard (cherry picked from commit 0439e41a44db1c5e4319feae11a38728e6fba8f8) --- erpnext/stock/doctype/item/item.js | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 7e1476d240a..e61f0f514e3 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -10,6 +10,31 @@ frappe.ui.form.on("Item", { frm.add_fetch('attribute', 'to_range', 'to_range'); frm.add_fetch('attribute', 'increment', 'increment'); frm.add_fetch('tax_type', 'tax_rate', 'tax_rate'); + + frm.make_methods = { + 'Sales Order': () => { + open_form(frm, "Sales Order", "Sales Order Item", "items"); + }, + 'Delivery Note': () => { + open_form(frm, "Delivery Note", "Delivery Note Item", "items"); + }, + 'Sales Invoice': () => { + open_form(frm, "Sales Invoice", "Sales Invoice Item", "items"); + }, + 'Purchase Order': () => { + open_form(frm, "Purchase Order", "Purchase Order Item", "items"); + }, + 'Purchase Receipt': () => { + open_form(frm, "Purchase Receipt", "Purchase Receipt Item", "items"); + }, + 'Purchase Invoice': () => { + open_form(frm, "Purchase Invoice", "Purchase Invoice Item", "items"); + }, + 'Material Request': () => { + open_form(frm, "Material Request", "Material Request Item", "items"); + }, + }; + }, onload: function(frm) { erpnext.item.setup_queries(frm); @@ -858,3 +883,17 @@ frappe.tour['Item'] = [ ]; + +function open_form(frm, doctype, child_doctype, parentfield) { + frappe.model.with_doctype(doctype, () => { + let new_doc = frappe.model.get_new_doc(doctype); + + let new_child_doc = frappe.model.add_child(new_doc, child_doctype, parentfield); + new_child_doc.item_code = frm.doc.name; + new_child_doc.item_name = frm.doc.item_name; + new_child_doc.uom = frm.doc.stock_uom; + new_child_doc.description = frm.doc.description; + + frappe.ui.form.make_quick_entry(doctype, null, null, new_doc); + }); +} From 4d51d73797fa9dd7ae6b5780fee17a5d6f9fb4d7 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 28 Sep 2022 20:11:00 +0530 Subject: [PATCH 2/4] fix: Incorrect TCS amount deducted in Sales Invoice (cherry picked from commit 08443c64210227f5bd1caf07461dd1cba2b392b2) --- .../tax_withholding_category/tax_withholding_category.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py index 0b5df9e0cc0..3c7a3c934bf 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -335,6 +335,9 @@ def get_advance_vouchers( "party": ["in", parties], } + if party_type == "Customer": + filters.update({"against_voucher": ["is", "not set"]}) + if company: filters["company"] = company if from_date and to_date: @@ -493,10 +496,13 @@ def get_tcs_amount(parties, inv, tax_details, vouchers, adv_vouchers): cumulative_threshold = tax_details.get("cumulative_threshold", 0) current_invoice_total = get_invoice_total_without_tcs(inv, tax_details) + print(invoiced_amt, advance_amt, credit_note_amt, current_invoice_total) total_invoiced_amt = current_invoice_total + invoiced_amt + advance_amt - credit_note_amt + print(total_invoiced_amt, "######", "total_invoiced_amt") if cumulative_threshold and total_invoiced_amt >= cumulative_threshold: chargeable_amt = total_invoiced_amt - cumulative_threshold + print(chargeable_amt, "#########") tcs_amount = chargeable_amt * tax_details.rate / 100 if chargeable_amt > 0 else 0 return tcs_amount From f7ec00ef492ce4fbc64a9a20bfb9be0088892552 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Wed, 28 Sep 2022 20:13:24 +0530 Subject: [PATCH 3/4] chore: Remove print statements (cherry picked from commit bff3cd9068c971d9a8d4420ddb9a3100167e29c0) --- .../tax_withholding_category/tax_withholding_category.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py index 3c7a3c934bf..84c2c9a3c3e 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -496,13 +496,10 @@ def get_tcs_amount(parties, inv, tax_details, vouchers, adv_vouchers): cumulative_threshold = tax_details.get("cumulative_threshold", 0) current_invoice_total = get_invoice_total_without_tcs(inv, tax_details) - print(invoiced_amt, advance_amt, credit_note_amt, current_invoice_total) total_invoiced_amt = current_invoice_total + invoiced_amt + advance_amt - credit_note_amt - print(total_invoiced_amt, "######", "total_invoiced_amt") if cumulative_threshold and total_invoiced_amt >= cumulative_threshold: chargeable_amt = total_invoiced_amt - cumulative_threshold - print(chargeable_amt, "#########") tcs_amount = chargeable_amt * tax_details.rate / 100 if chargeable_amt > 0 else 0 return tcs_amount From 793fa182258d8ddec55b6beb9b60208f0eaea0d5 Mon Sep 17 00:00:00 2001 From: Sagar Sharma Date: Fri, 30 Sep 2022 16:18:15 +0530 Subject: [PATCH 4/4] fix: add validation for non-stock item in SCR (cherry picked from commit fa2290657af19142f71804f54e20801cc6268558) --- erpnext/controllers/subcontracting_controller.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/subcontracting_controller.py b/erpnext/controllers/subcontracting_controller.py index 6bc88d1964f..aa4468c04e4 100644 --- a/erpnext/controllers/subcontracting_controller.py +++ b/erpnext/controllers/subcontracting_controller.py @@ -69,9 +69,18 @@ class SubcontractingController(StockController): def validate_items(self): for item in self.items: - if not frappe.get_value("Item", item.item_code, "is_sub_contracted_item"): + is_stock_item, is_sub_contracted_item = frappe.get_value( + "Item", item.item_code, ["is_stock_item", "is_sub_contracted_item"] + ) + + if not is_stock_item: + msg = f"Item {item.item_name} must be a stock item." + frappe.throw(_(msg)) + + if not is_sub_contracted_item: msg = f"Item {item.item_name} must be a subcontracted item." frappe.throw(_(msg)) + if item.bom: bom = frappe.get_doc("BOM", item.bom) if not bom.is_active: