Rent Allowance HRA 1 python result = version.l10n_hk_rental_id and version._get_contract_wage() >= 10000 and 'SKIP_RENT_ALLOWANCE' not in inputs code target_rent = min(version._get_contract_wage() - 10000, version.l10n_hk_rental_id.amount) remaining_budget = max(target_rent - l10n_hk_payrun_totals['HRA'], 0.0) result = min(remaining_budget, payslip.paid_amount) Basic Salary 2 BASIC none code result = payslip.paid_amount - result_rules['HRA']['total'] Commission COMMISSION 5 input input Back Pay BACKPAY 6 input input Internet Allowance ALW.INT 30 python result = bool(not payslip.is_outside_contract and version.l10n_hk_internet) code target_amount = version.l10n_hk_internet * worked_days_prorata_rate remaining_budget = max(version.l10n_hk_internet - l10n_hk_payrun_totals['ALW.INT'], 0.0) result = min(target_amount, remaining_budget) Deduction GLOBAL_DEDUCTION 98 python result = 'GLOBAL_DEDUCTION' in inputs code result = -inputs['GLOBAL_DEDUCTION'].amount result_name = inputs['GLOBAL_DEDUCTION'].name Reimbursement GLOBAL_REIMBURSEMENT 99 input input 713 Gross 713_GROSS 100 none code result = categories['BASIC'] + categories['ALW'] + categories['DED'] Referral Fee REFERRAL_FEE 103 python result = inputs['REFERRAL_FEE'].amount > 0.0 if 'REFERRAL_FEE' in inputs else False input End of Year Payment END_OF_YEAR_PAYMENT 109 python result = payslip.l10n_hk_includes_eoy_pay code if inputs.get('CUST_END_OF_YEAR_PAY'): result = inputs['CUST_END_OF_YEAR_PAY'].amount else: # Calculate the number of days in current year first_day = payslip.date_from + relativedelta(month=1, day=1) last_day = payslip.date_to + relativedelta(month=12, day=31) total_days = (last_day - first_day).days + 1 # Find past 12-month payslips last_year_payslips = payslip._get_previous_year_payslips(order='date_from desc') # Calculate the work rate number_of_days = last_year_payslips._get_number_of_worked_days(only_full_pay=True) number_of_months = number_of_days / total_days * 12 # total_days remains the same for last 12 months and current year # Calculate the average monthly salary gross = last_year_payslips._get_line_values(['713_GROSS'], compute_sum=True)['713_GROSS']['sum']['total'] gross -= last_year_payslips._get_total_non_full_pay() average_monthly_salary = inputs['CUST_AVG_MONTHLY_SALARY'].amount if inputs.get('CUST_AVG_MONTHLY_SALARY') else gross / number_of_months # Calculate the pro-rata rate current_year_payslips = last_year_payslips.filtered(lambda p: p.date_from >= first_day) + payslip number_of_days = current_year_payslips._get_number_of_worked_days() prorata_rate = number_of_days / total_days result = average_monthly_salary * prorata_rate MPF Gross MPF_GROSS 110 none code result = categories['BASIC'] + categories['ALW'] + categories['DED'] Employee Mandatory Contribution EEMC 111 python cumulative_gross = l10n_hk_payrun_totals['MPF_GROSS'] + result_rules['MPF_GROSS']['total'] first_mpf_date = employee._get_first_version_date() + relativedelta(days=30) is_above_mpf_threshold = cumulative_gross >= payslip._rule_parameter('l10n_hk_mpf_threshold') is_allowed_to_contribute = not employee.birthday or employee.birthday > payslip.date_from - relativedelta(years=65) result = is_above_mpf_threshold and first_mpf_date <= payslip.date_from and is_allowed_to_contribute code cumulative_gross = l10n_hk_payrun_totals['MPF_GROSS'] + result_rules['MPF_GROSS']['total'] target_monthly_mpf = min(0.05 * cumulative_gross, payslip._rule_parameter('l10n_hk_mpf_maximum')) result = -(target_monthly_mpf - abs(l10n_hk_payrun_totals['EEMC'])) True Employer Mandatory Contribution ERMC 111 python result = not employee.birthday or employee.birthday > payslip.date_to - relativedelta(years=65) code cumulative_gross = l10n_hk_payrun_totals['MPF_GROSS'] + result_rules['MPF_GROSS']['total'] target_monthly_mpf = min(0.05 * cumulative_gross, payslip._rule_parameter('l10n_hk_mpf_maximum')) result = -(target_monthly_mpf - abs(l10n_hk_payrun_totals['ERMC'])) Employee Voluntary Contribution EEVC 112 python result = version.l10n_hk_mpf_vc_option in ['custom', 'max'] code cumulative_gross = l10n_hk_payrun_totals['MPF_GROSS'] + result_rules['MPF_GROSS']['total'] if version.l10n_hk_mpf_vc_option == 'custom': target_monthly_eevc = version.l10n_hk_mpf_vc_percentage * cumulative_gross else: target_total = 0.05 * cumulative_gross statutory_max = payslip._rule_parameter('l10n_hk_mpf_maximum') target_monthly_eevc = max(target_total - statutory_max, 0.0) result = -(target_monthly_eevc - abs(l10n_hk_payrun_totals['EEVC'])) True Employer Voluntary Contribution ERVC 112 python result = version.l10n_hk_mpf_vc_option in ['custom', 'max'] code result = result_rules['EEVC']['total'] Attachment of Salary 174 ATTACH_SALARY python result = 'ATTACH_SALARY' in inputs code result = -inputs['ATTACH_SALARY'].amount result_name = inputs['ATTACH_SALARY'].name Assignment of Salary 174 ASSIG_SALARY python result = 'ASSIG_SALARY' in inputs code result = -inputs['ASSIG_SALARY'].amount result_name = inputs['ASSIG_SALARY'].name Child Support CHILD_SUPPORT code 174 python result = 'CHILD_SUPPORT' in inputs result = -inputs['CHILD_SUPPORT'].amount result_name = inputs['CHILD_SUPPORT'].name Expenses Reimbursement EXPENSES python result = inputs['EXPENSES'].amount > 0.0 if 'EXPENSES' in inputs else False code result = inputs['EXPENSES'].amount result_name = inputs['EXPENSES'].name Deduction 198 DEDUCTION python result = 'DEDUCTION' in inputs code result = -inputs['DEDUCTION'].amount result_name = inputs['DEDUCTION'].name Reimbursement 199 REIMBURSEMENT python result = 'REIMBURSEMENT' in inputs code result = inputs['REIMBURSEMENT'].amount result_name = inputs['REIMBURSEMENT'].name Taxable Salary 200 GROSS none code result = categories['BASIC'] + categories['ALW'] Net Salary 210 NET none code result = categories['BASIC'] + categories['ALW'] + categories['DED'] + categories['EEMPF'] Monthly End Autopay MEA 220 python first_version_date = employee._get_first_version_date() is_same_month = first_version_date.month == payslip.date_from.month if first_version_date else False is_same_year = first_version_date.year == payslip.date_from.year if first_version_date else False new_join = is_same_month and is_same_year result = first_version_date.day <= 15 or not new_join code result = result_rules['NET']['total'] 2nd Batch Autopay SBA 220 python first_version_date = employee._get_first_version_date() is_same_month = first_version_date.month == payslip.date_from.month if first_version_date else False is_same_year = first_version_date.year == payslip.date_from.year if first_version_date else False new_join = is_same_month and is_same_year result = first_version_date.day > 15 and new_join code result = result_rules['NET']['total']