feat: Type of Income Paid on Tax Withholding Category

Custom Select income_type: the row of the withholding tax certificate
(50 tawi) a payment under the category is reported on, set for every
shipped category.

Frappe syncs fixtures before customizations on install and migrate, so a
fixture value for a Custom Field that does not exist yet is dropped;
before_install / before_migrate create the category fields first.
This commit is contained in:
2026-09-22 03:29:39 +00:00
parent 270e44c080
commit 42857b1377
6 changed files with 148 additions and 27 deletions
+15
View File
@@ -1,3 +1,6 @@
import json
import os
import erpnext
import frappe
from erpnext.accounts.doctype.payment_entry.payment_entry import PaymentEntry
@@ -8,6 +11,7 @@ from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category
normal_round,
)
from frappe import _
from frappe.modules.utils import sync_customizations_for_doctype
from frappe.utils import cint, flt
from default_thai_company.utils import money_in_words
@@ -122,6 +126,17 @@ def prepare_fixture_accounts(doc, method=None):
link_company(doc, company, ensure_company_accounts(company))
def sync_category_customizations():
"""before_install / before_migrate: create the Tax Withholding Category Custom
Fields (custom/tax_withholding_category.json) ahead of the fixture import.
Frappe syncs fixtures before customizations, and a fixture value for a field
that does not exist yet is dropped."""
folder = frappe.get_app_path("default_thai_company", "default_thai_company", "custom")
filename = "tax_withholding_category.json"
with open(os.path.join(folder, filename)) as f:
sync_customizations_for_doctype(json.load(f), folder, filename)
def company_ready(doc):
"""A Thai company whose chart of accounts exists."""
return doc.country == "Thailand" and frappe.db.exists("Account", {"company": doc.name})