From b4c7274dce7ad6eaa486391b0a8d3e29f6da848f Mon Sep 17 00:00:00 2001 From: kurogeek Date: Thu, 5 Nov 2026 04:29:04 +0000 Subject: [PATCH] feat: Bank Fee expense account for every Thai company Thai banks charge transfer and collection fees that customers net off their payments and that the bank nets off ours; Payment Entry books them as deductions, which need an expense account. The Standard chart has none, so every Thai company gets "Bank Fee" under Indirect Expenses (Company.on_update, after_install and a patch for existing sites). --- default_thai_company/banking.py | 25 +++++++++++++++++++ default_thai_company/hooks.py | 2 ++ default_thai_company/patches.txt | 1 + .../patches/create_bank_fee_accounts.py | 5 ++++ default_thai_company/translations/th.csv | 1 + 5 files changed, 34 insertions(+) create mode 100644 default_thai_company/banking.py create mode 100644 default_thai_company/patches/create_bank_fee_accounts.py diff --git a/default_thai_company/banking.py b/default_thai_company/banking.py new file mode 100644 index 0000000..1717315 --- /dev/null +++ b/default_thai_company/banking.py @@ -0,0 +1,25 @@ +from default_thai_company.tax_withholding import company_ready, get_or_create_account, thai_companies + +# Thai banks charge transfer and collection fees that customers net off their +# payments and that the bank nets off ours; Payment Entry books them as +# deductions, which need an expense account. The Standard chart has none, so +# every Thai company gets one under Indirect Expenses. +BANK_FEE_ACCOUNT = "Bank Fee" +BANK_FEE_ACCOUNT_GROUPS = ("Indirect Expenses", "Expenses") + + +def ensure_bank_fee_account(company): + return get_or_create_account(company, BANK_FEE_ACCOUNT, "Expense", "", BANK_FEE_ACCOUNT_GROUPS) + + +def setup_company(doc, method=None): + """Company.on_update: Bank Fee account for a Thai company.""" + if company_ready(doc): + ensure_bank_fee_account(doc.name) + + +def setup_companies(): + """after_install and the create_bank_fee_accounts patch: companies that + exist before this code did never pass through `setup_company`.""" + for company in thai_companies(): + ensure_bank_fee_account(company) diff --git a/default_thai_company/hooks.py b/default_thai_company/hooks.py index 7f56839..6420e93 100644 --- a/default_thai_company/hooks.py +++ b/default_thai_company/hooks.py @@ -157,6 +157,7 @@ after_install = [ "default_thai_company.vat.setup_companies", "default_thai_company.shipping.setup_companies", "default_thai_company.payroll.setup_companies", + "default_thai_company.banking.setup_companies", ] # Fixture import re-inserts the Location tree; restore lft/rgt for user-added nodes. after_migrate = "default_thai_company.assets.rebuild_locations" @@ -234,6 +235,7 @@ doc_events = { "default_thai_company.assets.setup_company", "default_thai_company.shipping.setup_company", "default_thai_company.payroll.setup_company", + "default_thai_company.banking.setup_company", ], }, # HRMS doctype; the hook only fires on sites that have it. diff --git a/default_thai_company/patches.txt b/default_thai_company/patches.txt index e24af99..34d1898 100644 --- a/default_thai_company/patches.txt +++ b/default_thai_company/patches.txt @@ -9,3 +9,4 @@ default_thai_company.patches.create_vat_templates default_thai_company.patches.create_shipping_rules default_thai_company.patches.create_payroll_periods default_thai_company.patches.setup_salary_components +default_thai_company.patches.create_bank_fee_accounts diff --git a/default_thai_company/patches/create_bank_fee_accounts.py b/default_thai_company/patches/create_bank_fee_accounts.py new file mode 100644 index 0000000..a996565 --- /dev/null +++ b/default_thai_company/patches/create_bank_fee_accounts.py @@ -0,0 +1,5 @@ +from default_thai_company.banking import setup_companies + + +def execute(): + setup_companies() diff --git a/default_thai_company/translations/th.csv b/default_thai_company/translations/th.csv index 8c341a2..8c40c01 100644 --- a/default_thai_company/translations/th.csv +++ b/default_thai_company/translations/th.csv @@ -79,6 +79,7 @@ Salary Deductions,รายการหักจากเงินเดือ Social Security,ประกันสังคม Social Security Payable,ประกันสังคมค้างจ่าย Social Security Fund contribution (Sec. 33 employee),เงินสมทบกองทุนประกันสังคม (ผู้ประกันตนมาตรา 33) +Bank Fee,ค่าธรรมเนียมธนาคาร Withholding Tax Receivable,ภาษีถูกหัก ณ ที่จ่าย Output VAT,ภาษีขาย Input VAT,ภาษีซื้อ