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 5c912f81157495358ad2f090d8264c4df87857f3..595ba8e6a769acf6de5fe5ed5991f291039620ca 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 @@ -15,6 +15,7 @@ "col_break1", "account_head", "description", + "is_tax_withholding_account", "section_break_10", "rate", "accounting_dimensions_section", @@ -224,15 +225,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 2ef83b53483b4dd7e1d73d9f4ce5bbb740fd2d5d..c0ea9e0206ad244dcbdf92aefc8fd5f9166a4f20 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 @@ -7,4 +7,43 @@ from frappe.model.document import Document class PurchaseTaxesandCharges(Document): + # begin: auto-generated types + # This code is auto-generated. Do not modify anything in this block. + + from typing import TYPE_CHECKING + + if TYPE_CHECKING: + from frappe.types import DF + + account_currency: DF.Link | None + account_head: DF.Link + add_deduct_tax: DF.Literal["Add", "Deduct"] + base_tax_amount: DF.Currency + base_tax_amount_after_discount_amount: DF.Currency + base_total: DF.Currency + category: DF.Literal["Valuation and Total", "Valuation", "Total"] + charge_type: DF.Literal[ + "", + "Actual", + "On Net Total", + "On Previous Row Amount", + "On Previous Row Total", + "On Item Quantity", + ] + cost_center: DF.Link | None + 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 + parenttype: DF.Data + rate: DF.Float + row_id: DF.Data | None + tax_amount: DF.Currency + tax_amount_after_discount_amount: DF.Currency + total: DF.Currency + # end: auto-generated types + pass 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 0b7cdd533c6dc92a845e78dd8cfa5ed601ef3fc9..313ea3fe0ef766b9a95fec21edce5512abbbb7e1 100644 --- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py +++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py @@ -127,7 +127,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 1878bc903c433bb9e9c015d6130eba142fe79ddd..57a7c86c799754fa3346b5c170112f46b028ab4d 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -466,9 +466,16 @@ class calculate_taxes_and_totals(object): 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 38bc1d11a068d14b527d85ccc4407bc69ea903bd..de1d24c8b6e71360fa672a620b40539f0444b032 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", "taxes_and_charges", "shipping_col", @@ -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-22 16:15:10.937188", + "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 73dfa64fad4b9f2bc41b7b3182b048bf4975c475..8733a4f7aa92a295546753029e8efc407bdad5ea 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 5ec0722e6e3cea8f72e567d5c50a690fcf1e76ad..a97a016c868095abdc3e0dbdbbd6008135271452 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", @@ -1108,12 +1109,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.277292", "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 dfdfebfad4447818528d3ab8dc64259969b6e2e4..4666ed29d207e563c5ce02a5ec49e0c43c2bd83d 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py @@ -17,6 +17,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