From 338d184d7d5014fd7bc4de920424e4fba3e0ad61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Heytor=20V=C3=ADctor?= Date: Sun, 4 Jun 2023 22:29:20 -0300 Subject: [PATCH] feat: update income tax values by IN RFB 2141 --- api/data/irrf.json | 12 +++++------ api/tests/e2e/test_v1_clt.py | 12 +++++------ api/tests/e2e/test_v1_compare.py | 26 ++++++++++++------------ api/tests/e2e/test_v1_thirteenth.py | 4 ++-- api/tests/unit/test_clt.py | 31 +++++++++++++++-------------- 5 files changed, 43 insertions(+), 42 deletions(-) diff --git a/api/data/irrf.json b/api/data/irrf.json index 5009d03..6df282e 100644 --- a/api/data/irrf.json +++ b/api/data/irrf.json @@ -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 } } diff --git a/api/tests/e2e/test_v1_clt.py b/api/tests/e2e/test_v1_clt.py index 40e04b2..81cde1a 100644 --- a/api/tests/e2e/test_v1_clt.py +++ b/api/tests/e2e/test_v1_clt.py @@ -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} @@ -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} @@ -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 diff --git a/api/tests/e2e/test_v1_compare.py b/api/tests/e2e/test_v1_compare.py index aaaff8b..23f8870 100644 --- a/api/tests/e2e/test_v1_compare.py +++ b/api/tests/e2e/test_v1_compare.py @@ -21,16 +21,16 @@ 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} @@ -38,13 +38,13 @@ def test_compare_pj_clt_salary(self): 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 diff --git a/api/tests/e2e/test_v1_thirteenth.py b/api/tests/e2e/test_v1_thirteenth.py index 85b2fd4..95f6bfb 100644 --- a/api/tests/e2e/test_v1_thirteenth.py +++ b/api/tests/e2e/test_v1_thirteenth.py @@ -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} @@ -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 diff --git a/api/tests/unit/test_clt.py b/api/tests/unit/test_clt.py index ce1b112..35dfbd3 100644 --- a/api/tests/unit/test_clt.py +++ b/api/tests/unit/test_clt.py @@ -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) @@ -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 @@ -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 @@ -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