diff --git a/default_thai_company/patches.txt b/default_thai_company/patches.txt index 34d1898..ae5944a 100644 --- a/default_thai_company/patches.txt +++ b/default_thai_company/patches.txt @@ -10,3 +10,4 @@ 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 +default_thai_company.patches.create_employer_social_security_accounts diff --git a/default_thai_company/patches/create_employer_social_security_accounts.py b/default_thai_company/patches/create_employer_social_security_accounts.py new file mode 100644 index 0000000..873a011 --- /dev/null +++ b/default_thai_company/patches/create_employer_social_security_accounts.py @@ -0,0 +1,5 @@ +from default_thai_company.payroll import setup_companies + + +def execute(): + setup_companies() diff --git a/default_thai_company/payroll.py b/default_thai_company/payroll.py index 9d53956..7ecf341 100644 --- a/default_thai_company/payroll.py +++ b/default_thai_company/payroll.py @@ -1,7 +1,7 @@ import frappe from frappe.utils import getdate -from default_thai_company.tax_withholding import get_or_create_account, thai_companies +from default_thai_company.tax_withholding import company_ready, get_or_create_account, thai_companies # Thai personal income tax (P.N.D.1/91) is assessed per calendar year whatever # the company's fiscal year, so the Payroll Period is January to December. @@ -32,9 +32,11 @@ DEDUCTION_ACCOUNT_GROUPS = ("Current Liabilities",) # assesses it. The contribution is deductible from taxable income in full, so # the component is exempted_from_income_tax; the "Social Security Fund" # exemption sub-category is for contributions not run through payroll here. -# The employer's equal share is not an employee deduction and is left to the -# accounts. Thai books carry the withheld amount as ประกันสังคมค้างจ่าย until -# it is remitted by the 15th, so it gets its own liability. +# Thai books carry the withheld amount as ประกันสังคมค้างจ่าย until it is +# remitted by the 15th, so it gets its own liability. The employer's equal share +# is not an employee deduction: it is booked against the same liability from +# its own expense account, which every Thai company gets whether or not it runs +# payroll here. SOCIAL_SECURITY_COMPONENT = { "doctype": "Salary Component", "salary_component": "Social Security", @@ -48,6 +50,8 @@ SOCIAL_SECURITY_COMPONENT = { "formula": "int((1650 if B < 1650 else 17500 if B > 17500 else B) * 5 / 100 + 0.5)", } SOCIAL_SECURITY_ACCOUNT = "Social Security Payable" +EMPLOYER_SOCIAL_SECURITY_ACCOUNT = "Social Security Contribution (Employer)" +EMPLOYER_SOCIAL_SECURITY_ACCOUNT_GROUPS = ("Indirect Expenses", "Expenses") def hrms_installed(): @@ -122,24 +126,42 @@ def ensure_payroll_period(company, year): ).insert(ignore_permissions=True) +def ensure_employer_social_security_account(company): + return get_or_create_account( + company, + EMPLOYER_SOCIAL_SECURITY_ACCOUNT, + "Expense", + "", + EMPLOYER_SOCIAL_SECURITY_ACCOUNT_GROUPS, + ) + + def setup_company(doc, method=None): - """Company.on_update: this year's Payroll Period, the Social Security - component and the Salary Component accounts for a Thai company.""" - if doc.country == "Thailand" and hrms_installed(): + """Company.on_update: the employer's Social Security expense account, this + year's Payroll Period, the Social Security component and the Salary + Component accounts for a Thai company.""" + if doc.country != "Thailand": + return + if company_ready(doc): + ensure_employer_social_security_account(doc.name) + if hrms_installed(): ensure_payroll_period(doc.name, getdate().year) ensure_social_security_component() ensure_component_accounts(doc.name) def setup_companies(): - """after_install, the daily scheduler, and the setup_salary_components - patch: this year's Payroll Period, the Social Security component and the - Salary Component accounts for every Thai company. The scheduler rolls the - Payroll Period over on 1 January.""" + """after_install, the daily scheduler, and the setup_salary_components and + create_employer_social_security_accounts patches: the employer's Social + Security expense account, this year's Payroll Period, the Social Security + component and the Salary Component accounts for every Thai company. The + scheduler rolls the Payroll Period over on 1 January.""" + companies = thai_companies() + for company in companies: + ensure_employer_social_security_account(company) if not hrms_installed(): return year = getdate().year - companies = thai_companies() if companies: ensure_social_security_component() for company in companies: diff --git a/default_thai_company/translations/th.csv b/default_thai_company/translations/th.csv index 8c40c01..24d8e53 100644 --- a/default_thai_company/translations/th.csv +++ b/default_thai_company/translations/th.csv @@ -78,6 +78,7 @@ Withholding Tax Payable (P.N.D.1),ภาษีหัก ณ ที่จ่า Salary Deductions,รายการหักจากเงินเดือน Social Security,ประกันสังคม Social Security Payable,ประกันสังคมค้างจ่าย +Social Security Contribution (Employer),เงินสมทบประกันสังคม (ส่วนนายจ้าง) Social Security Fund contribution (Sec. 33 employee),เงินสมทบกองทุนประกันสังคม (ผู้ประกันตนมาตรา 33) Bank Fee,ค่าธรรมเนียมธนาคาร Withholding Tax Receivable,ภาษีถูกหัก ณ ที่จ่าย