feat: customer-side withholding tax on Payment Entry

Thai customers withhold tax at payment; ERPNext's customer-side handling
is Indian TCS which adds tax on top of the Sales Invoice. Override
SalesInvoice.set_tax_withholding to no-op for Thai companies, expose
"Apply Tax Withholding Amount" on Customer/Receive Payment Entries, and
on validate compute rate x pre-VAT amount of each allocated reference
(prorated, single threshold honoured) as a deduction to "Withholding Tax
Receivable". Client script fetches the Customer's category when the box
is ticked.
This commit is contained in:
2026-09-11 10:00:24 +00:00
parent 8b3cf9af1e
commit 6819242521
4 changed files with 139 additions and 5 deletions
+17 -5
View File
@@ -43,7 +43,7 @@ required_apps = ["erpnext"]
# page_js = {"page" : "public/js/file.js"}
# include js in doctype views
# doctype_js = {"doctype" : "public/js/doctype.js"}
doctype_js = {"Payment Entry": "public/js/payment_entry.js"}
# doctype_list_js = {"doctype" : "public/js/doctype_list.js"}
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"}
@@ -90,7 +90,16 @@ fixtures = [
{"doctype": "Print Format", "filters": [["name", "in", ["Default Standard Sales Invoice"]]]},
{
"doctype": "Property Setter",
"filters": [["name", "in", ["Sales Invoice-main-default_print_format"]]],
"filters": [
[
"name",
"in",
[
"Sales Invoice-main-default_print_format",
"Payment Entry-apply_tax_withholding_amount-depends_on",
],
]
],
},
{"doctype": "Tax Withholding Category", "filters": [["name", "like", "WHT %"]]},
]
@@ -145,9 +154,9 @@ fixtures = [
# ---------------
# Override standard doctype classes
# override_doctype_class = {
# "ToDo": "custom_app.overrides.CustomToDo"
# }
override_doctype_class = {
"Sales Invoice": "default_thai_company.tax_withholding.ThaiSalesInvoice",
}
# Document Events
# ---------------
@@ -164,6 +173,9 @@ doc_events = {
"Company": {
"on_update": "default_thai_company.tax_withholding.setup_company",
},
"Payment Entry": {
"validate": "default_thai_company.tax_withholding.set_customer_withholding",
},
}
# Scheduled Tasks