/
salary2019.py
116 lines (95 loc) · 4.48 KB
/
salary2019.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import sys
sys.path.append('/home/odoo/odoo_dev/odoo/')
from odoo.tools import float_round
file = open("salary2019.txt","w")
file.write("id,amount_select,condition_range_min,condition_range_max,amount_percentage,amount_fix,amount_python_compute,name,category_id,sequence,code,parent_rule_id/id,condition_select,condition_range,amount_percentage_base,register_id/id\n")
def compute_basic_bareme(value):
if value <= 12860.0:
basic_bareme = value * 0.2675
elif value <= 19630.0:
basic_bareme = 3440.05 + 0.428 * (value - 12860.00)
elif value <= 40470.00:
basic_bareme = 6337.61 + 0.4815 * (value - 19630.00)
else:
basic_bareme = 16372.07 + 0.535 * (value - 40470.0)
return float_round(basic_bareme, precision_rounding=0.01)
def convert_to_month(value):
return float_round(value / 12.0, precision_rounding=0.01, rounding_method='DOWN')
for bareme in [1, 2, 3]:
if bareme == 1:
first_amount = 555
gross_values = [0] + list(range(first_amount, 7500 + 15, 15))
label = ''
elif bareme == 2:
first_amount = 1065
gross_values = [0] + list(range(first_amount, 7500 + 15, 15))
label = 'II'
elif bareme == 3:
first_amount = 15
gross_values = [0] + list(range(first_amount, 7500 + 15, 15))
label = 'III'
for index, gross in enumerate(gross_values):
# PART 1: Withholding tax amount computation
withholding_tax_amount = 0.0
lower_bound = gross - gross % 15
# yearly_gross_revenue = Revenu Annuel Brut
yearly_gross_revenue = lower_bound * 12.0
# yearly_net_taxable_amount = Revenu Annuel Net Imposable
if yearly_gross_revenue <= 16033.33:
yearly_net_taxable_revenue = yearly_gross_revenue * (1.0 - 0.3)
else:
yearly_net_taxable_revenue = yearly_gross_revenue - 4810.00
# BAREME III: Non resident
if bareme == 3:
basic_bareme = compute_basic_bareme(yearly_net_taxable_revenue)
withholding_tax_amount = convert_to_month(basic_bareme)
else:
# BAREME I: Isolated or spouse with income
if bareme == 1:
basic_bareme = max(compute_basic_bareme(yearly_net_taxable_revenue) - 2065.10, 0.0)
withholding_tax_amount = convert_to_month(basic_bareme)
# BAREME II: spouse without income
if bareme == 2:
yearly_net_taxable_revenue_for_spouse = min(yearly_net_taxable_revenue * 0.3, 10930.0)
basic_bareme_1 = compute_basic_bareme(yearly_net_taxable_revenue_for_spouse)
basic_bareme_2 = compute_basic_bareme(yearly_net_taxable_revenue - yearly_net_taxable_revenue_for_spouse)
withholding_tax_amount = convert_to_month(max(basic_bareme_1 + basic_bareme_2 - 4130.20, 0))
if index == 0:
lower_bound = 0
upper_bound = first_amount
else:
lower_bound = gross
upper_bound = gross + 15
if gross == 7500:
upper_bound = 2147483647
if bareme == 1:
first_id = 1
elif bareme == 2:
first_id = 600
elif bareme == 3:
first_id = 1201
file.write("%s,fix,%s,%s,,%s,,Withholding Tax,Withholding Tax Grid 2019 (Precompte Professionnel Bareme 2019),130,P.P,hr_payroll_rules_bareme%s,range,GROSS,,contrib_register_pp\n" % (first_id + index, lower_bound, upper_bound, -round(withholding_tax_amount, 2), label))
file.write(",,,,,,,,,,,,,,,\n")
if bareme == 1:
file.write(",,,,,,,,,,,,,,,\n")
for children in range(1, 21):
if children == 1:
withholding_tax_amount = 36.0
if children == 2:
withholding_tax_amount = 104.0
if children == 3:
withholding_tax_amount = 275.0
if children == 4:
withholding_tax_amount = 483.0
if children == 5:
withholding_tax_amount = 713.0
if children == 6:
withholding_tax_amount = 944.0
if children == 7:
withholding_tax_amount = 1174.0
if children >= 8:
withholding_tax_amount = 1428.0 + (children - 8) * 256.0
result = - max(withholding_tax_amount, 0.0)
rule_id = 1410 + children - 1
file.write('%s,code,%s,%s,,,"result = min(%s, - (categories.PP + categories.PPRed + categories.FamRed + categories.ChA))",Child Allowance Belgium,Child Allowance Belgium,142,Ch.A,hr_payroll_rules_child,range,employee.dependent_children,,\n' % (rule_id, children, children, withholding_tax_amount))
file.close()