feat: Social Security Contribution (Employer) expense account

The employer's equal share of the Social Security Fund contribution is
not an employee deduction: it is booked against Social Security
Payable from its own expense account. Every Thai company gets
"Social Security Contribution (Employer)" under Indirect Expenses,
whether or not it runs payroll here (Company.on_update, after_install
and a patch for existing sites).
This commit is contained in:
kurogeek committed 2026-11-05 10:03:02 +00:00
1 parent b4c7274dce
commit cf687e24cc
4 files changed
+41 -12

No files matched your search

+1
View File
@@ -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
@@ -0,0 +1,5 @@
from default_thai_company.payroll import setup_companies
def execute():
setup_companies()
+34 -12
View File
@@ -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:
+1
View File
@@ -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,ภาษีถูกหัก ณ ที่จ่าย
1 Net Payable After Withholding Tax ยอดชำระสุทธิหลังหักภาษี ณ ที่จ่าย
78 Salary Deductions รายการหักจากเงินเดือน
79 Social Security ประกันสังคม
80 Social Security Payable ประกันสังคมค้างจ่าย
81 Social Security Contribution (Employer) เงินสมทบประกันสังคม (ส่วนนายจ้าง)
82 Social Security Fund contribution (Sec. 33 employee) เงินสมทบกองทุนประกันสังคม (ผู้ประกันตนมาตรา 33)
83 Bank Fee ค่าธรรมเนียมธนาคาร
84 Withholding Tax Receivable ภาษีถูกหัก ณ ที่จ่าย