From 4e3c885808a16bd08ada57b82673aea60bd182d9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 8 Apr 2024 20:26:44 +0530 Subject: [PATCH] fix: Show itemised TDS breakup based on Apply TDS checkbox on item level --- .../purchase_taxes_and_charges.json | 11 +++++++++- .../purchase_taxes_and_charges.py | 1 + .../tax_withholding_category.py | 7 +++++- erpnext/controllers/taxes_and_totals.py | 11 +++++++++- .../purchase_receipt/purchase_receipt.json | 22 ++++++++++++++++++- .../purchase_receipt/purchase_receipt.py | 2 ++ .../purchase_receipt_item.json | 11 +++++++++- .../purchase_receipt_item.py | 1 + 8 files changed, 61 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json index adab54b3756..e82649a25ab 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json @@ -16,6 +16,7 @@ "col_break1", "account_head", "description", + "is_tax_withholding_account", "section_break_10", "rate", "accounting_dimensions_section", @@ -225,15 +226,23 @@ "label": "Account Currency", "options": "Currency", "read_only": 1 + }, + { + "default": "0", + "fieldname": "is_tax_withholding_account", + "fieldtype": "Check", + "label": "Is Tax Withholding Account", + "read_only": 1 } ], "idx": 1, "istable": 1, "links": [], - "modified": "2024-01-14 10:04:36.618240", + "modified": "2024-04-08 19:51:36.678551", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Taxes and Charges", + "naming_rule": "Random", "owner": "Administrator", "permissions": [], "sort_field": "modified", diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py index d6c02922447..585d5e65ad1 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py @@ -33,6 +33,7 @@ class PurchaseTaxesandCharges(Document): description: DF.SmallText included_in_paid_amount: DF.Check included_in_print_rate: DF.Check + is_tax_withholding_account: DF.Check item_wise_tax_detail: DF.Code | None parent: DF.Data parentfield: DF.Data 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 339c54df5f1..2a2428a6c1b 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -146,7 +146,12 @@ def get_party_tax_withholding_details(inv, tax_withholding_category=None): tax_row = get_tax_row_for_tcs(inv, tax_details, tax_amount, tax_deducted) cost_center = get_cost_center(inv) - tax_row.update({"cost_center": cost_center}) + tax_row.update( + { + "cost_center": cost_center, + "is_tax_withholding_account": 1, + } + ) if inv.doctype == "Purchase Invoice": return tax_row, tax_deducted_on_advances, voucher_wise_amount diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index f5d89fb95f6..57715597315 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -466,7 +466,16 @@ class calculate_taxes_and_totals: if tax.charge_type == "Actual": # distribute the tax amount proportionally to each item row actual = flt(tax.tax_amount, tax.precision("tax_amount")) - current_tax_amount = item.net_amount * actual / self.doc.net_total if self.doc.net_total else 0.0 + + if tax.get("is_tax_withholding_account") and item.meta.get_field("apply_tds"): + if not item.get("apply_tds") or not self.doc.tax_withholding_net_total: + current_tax_amount = 0.0 + else: + current_tax_amount = item.net_amount * actual / self.doc.tax_withholding_net_total + else: + current_tax_amount = ( + item.net_amount * actual / self.doc.net_total if self.doc.net_total else 0.0 + ) elif tax.charge_type == "On Net Total": current_tax_amount = (tax_rate / 100.0) * item.net_amount diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json index b926e9826eb..ee8df084f08 100755 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json @@ -58,6 +58,8 @@ "column_break_27", "total", "net_total", + "tax_withholding_net_total", + "base_tax_withholding_net_total", "taxes_charges_section", "tax_category", "taxes_and_charges", @@ -1246,13 +1248,31 @@ "label": "Subcontracting Receipt", "options": "Subcontracting Receipt", "search_index": 1 + }, + { + "fieldname": "tax_withholding_net_total", + "fieldtype": "Currency", + "hidden": 1, + "label": "Tax Withholding Net Total", + "no_copy": 1, + "options": "currency", + "read_only": 1 + }, + { + "fieldname": "base_tax_withholding_net_total", + "fieldtype": "Currency", + "hidden": 1, + "label": "Base Tax Withholding Net Total", + "no_copy": 1, + "print_hide": 1, + "read_only": 1 } ], "icon": "fa fa-truck", "idx": 261, "is_submittable": 1, "links": [], - "modified": "2024-03-20 16:05:31.713453", + "modified": "2024-04-08 20:23:03.699201", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt", diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 7895d26952c..6dc92772d8c 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -51,6 +51,7 @@ class PurchaseReceipt(BuyingController): base_net_total: DF.Currency base_rounded_total: DF.Currency base_rounding_adjustment: DF.Currency + base_tax_withholding_net_total: DF.Currency base_taxes_and_charges_added: DF.Currency base_taxes_and_charges_deducted: DF.Currency base_total: DF.Currency @@ -120,6 +121,7 @@ class PurchaseReceipt(BuyingController): supplier_name: DF.Data | None supplier_warehouse: DF.Link | None tax_category: DF.Link | None + tax_withholding_net_total: DF.Currency taxes: DF.Table[PurchaseTaxesandCharges] taxes_and_charges: DF.Link | None taxes_and_charges_added: DF.Currency diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json index 6b01047f006..a95f99ffd43 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -58,6 +58,7 @@ "pricing_rules", "stock_uom_rate", "is_free_item", + "apply_tds", "section_break_29", "net_rate", "net_amount", @@ -1107,12 +1108,20 @@ "fieldname": "use_serial_batch_fields", "fieldtype": "Check", "label": "Use Serial No / Batch Fields" + }, + { + "default": "1", + "fieldname": "apply_tds", + "fieldtype": "Check", + "hidden": 1, + "label": "Apply TDS", + "read_only": 1 } ], "idx": 1, "istable": 1, "links": [], - "modified": "2024-02-04 11:48:06.653771", + "modified": "2024-04-08 20:00:16.278292", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt Item", diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py index 3c6dcdca488..908c0a7a0f4 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py @@ -16,6 +16,7 @@ class PurchaseReceiptItem(Document): allow_zero_valuation_rate: DF.Check amount: DF.Currency + apply_tds: DF.Check asset_category: DF.Link | None asset_location: DF.Link | None barcode: DF.Data | None