Skip to content

Commit

Permalink
feat: update income tax values by IN RFB 2141
Browse files Browse the repository at this point in the history
  • Loading branch information
heytorvas committed Jun 5, 2023
1 parent dd61a15 commit 338d184
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 42 deletions.
12 changes: 6 additions & 6 deletions api/data/irrf.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"0": {
"min": 0,
"max": 1903.98,
"max": 2112.00,
"deduction": 0
},
"7.5": {
"min": 1903.99,
"min": 2112.01,
"max": 2826.65,
"deduction": 142.8
"deduction": 158.40
},
"15": {
"min": 2826.66,
"max": 3751.05,
"deduction": 354.8
"deduction": 370.40
},
"22.5": {
"min": 3751.06,
"max": 4664.68,
"deduction": 636.13
"deduction": 651.73
},
"27.5": {
"min": 4664.68,
"max": 10000000,
"deduction": 869.36
"deduction": 884.96
}
}
12 changes: 6 additions & 6 deletions api/tests/e2e/test_v1_clt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def test_calculate_liquid_salary_only_raw(self):
assert response["medical_assistant"] == 0
assert response["fgts"] == 240
assert response["inss"] == 269
assert response["irrf"] == 62.02
assert response["total"] == 2668.98
assert response["irrf"] == 46.42
assert response["total"] == 2684.58

def test_calculate_liquid_salary_with_raw_and_transport_voucher(self):
body = {"raw": 3000, "transport_voucher": True}
Expand All @@ -43,9 +43,9 @@ def test_calculate_liquid_salary_with_raw_and_transport_voucher(self):
assert response["dependents"] == 0
assert response["transport_voucher"] == 180
assert response["inss"] == 269
assert response["irrf"] == 62.02
assert response["irrf"] == 46.42
assert response["fgts"] == 240
assert response["total"] == 2488.98
assert response["total"] == 2504.58

def test_calculate_liquid_salary_with_dependents(self):
body = {"raw": 3000, "dependents": 1, "transport_voucher": True}
Expand All @@ -60,6 +60,6 @@ def test_calculate_liquid_salary_with_dependents(self):
assert response["dependents"] == 1
assert response["transport_voucher"] == 180
assert response["inss"] == 269
assert response["irrf"] == 47.81
assert response["irrf"] == 32.21
assert response["fgts"] == 240
assert response["total"] == 2503.19
assert response["total"] == 2518.79
26 changes: 13 additions & 13 deletions api/tests/e2e/test_v1_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@ def test_compare_clt_pj_salary(self):

assert response["clt"]["raw"] == 7000
assert response["clt"]["inss"] == 816.18
assert response["clt"]["irrf"] == 831.19
assert response["clt"]["irrf"] == 815.59
assert response["clt"]["fgts"] == 560
assert response["clt"]["thirteenth"] == 446.05
assert response["clt"]["vacation"] == 586.29
assert response["clt"]["total"] == 6944.97
assert response["clt"]["thirteenth"] == 447.35
assert response["clt"]["vacation"] == 587.59
assert response["clt"]["total"] == 6963.17

assert response["pj"]["raw"] == 7234.34
assert response["pj"]["raw"] == 7253.3
assert response["pj"]["attachment"] == "I"
assert response["pj"]["tax"] == 289.37
assert response["pj"]["total"] == 6944.97
assert response["pj"]["tax"] == 290.13
assert response["pj"]["total"] == 6963.17

def test_compare_pj_clt_salary(self):
body = {"attachment": "V", "raw": 14000}
response = json.loads(
client.post(f"{self.URL}/pj", headers=self.HEADERS, json=body).text
)

assert response["clt"]["raw"] == 12174.1
assert response["clt"]["raw"] == 12154.90
assert response["clt"]["inss"] == 828.39
assert response["clt"]["irrf"] == 2250.71
assert response["clt"]["fgts"] == 973.93
assert response["clt"]["total"] == 11829.94
assert response["clt"]["vacation"] == 1003.09
assert response["clt"]["thirteenth"] == 757.92
assert response["clt"]["irrf"] == 2229.83
assert response["clt"]["fgts"] == 972.39
assert response["clt"]["total"] == 11829.97
assert response["clt"]["vacation"] == 1002.84
assert response["clt"]["thirteenth"] == 758.06

assert response["pj"]["attachment"] == "V"
assert response["pj"]["raw"] == 14000
Expand Down
4 changes: 2 additions & 2 deletions api/tests/e2e/test_v1_thirteenth.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_calculate_thirteenth_full(self):

assert response["raw"] == 5000
assert response["months"] == 12
assert response["total"] == 4095.59
assert response["total"] == 4111.19

def test_calculate_thirteenth_partitioned(self):
body = {"raw": 5000, "months": 10}
Expand All @@ -31,4 +31,4 @@ def test_calculate_thirteenth_partitioned(self):

assert response["raw"] == 5000
assert response["months"] == 10
assert response["total"] == 3539.89
assert response["total"] == 3555.49
31 changes: 16 additions & 15 deletions api/tests/unit/test_clt.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ def test_get_percentage_and_deduction_from_inss(self):
assert float(percentage) == 9
assert deduction == 18.18

def test_get_percentage_and_deduction_from_irrf(self):
percentage, deduction = _find_percentage_and_deduction(IRRF_DATA, 2000)
@pytest.mark.parametrize("raw,percent,ded", [(2000, 0, 0), (2500, 7.5, 158.4)])
def test_get_percentage_and_deduction_from_irrf(self, raw, percent, ded):
percentage, deduction = _find_percentage_and_deduction(IRRF_DATA, raw)

assert float(percentage) == 7.5
assert deduction == 142.8
assert float(percentage) == percent
assert deduction == ded

def test_calculate_liquid_salary(self):
input = CLTBase(raw=3000)
Expand All @@ -53,8 +54,8 @@ def test_calculate_liquid_salary(self):
assert salary.medical_assistant == 0
assert salary.fgts == 240
assert salary.inss == 269
assert salary.irrf == 62.02
assert salary.total == 2668.98
assert salary.irrf == 46.42
assert salary.total == 2684.58

def test_calculate_transport_voucher(self):
salary = 2000
Expand All @@ -71,12 +72,12 @@ def test_calculate_transport_voucher(self):

@pytest.mark.parametrize(
"salary,inss,value",
[(3000, 269, 62.02), (4000, 396.18, 185.77), (5000, 536.18, 368.23)],
[(3000, 269, 46.42), (4000, 396.18, 170.17), (5000, 536.18, 352.63)],
)
def test_calculate_irrf_without_dependents(self, salary, inss, value):
assert _calculate_irrf_value(salary, inss, dependents=0) == value

@pytest.mark.parametrize("dependent,value", [(1, 47.81), (2, 33.59), (3, 19.37)])
@pytest.mark.parametrize("dependent,value", [(1, 32.21), (2, 17.99), (3, 3.77)])
def test_calculate_irrf_with_dependents(self, dependent, value):
assert (
_calculate_irrf_value(salary=3000, inss=269, dependents=dependent) == value
Expand All @@ -96,10 +97,10 @@ def test_calculate_clt_salary_by_pj(self):
input = CLTBase(raw=7000)
clt = calculate_clt_salary_by_pj(input)

assert clt.total == 6999.98
assert clt.raw == 7065.8
assert clt.inss == 825.39
assert clt.irrf == 846.75
assert clt.fgts == 565.26
assert clt.vacation == 591.59
assert clt.thirteenth == 449.47
assert clt.total == 6999.95
assert clt.raw == 7044.0
assert clt.inss == 822.34
assert clt.irrf == 826.00
assert clt.fgts == 563.52
assert clt.vacation == 591.13
assert clt.thirteenth == 449.64

0 comments on commit 338d184

Please sign in to comment.