salario-pt 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # salario
2
+
3
+ Node.js package to calculate Portuguese net salary from gross salary, using official IRS tax tables.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install
9
+ ```
10
+
11
+ ## CLI
12
+
13
+ ```bash
14
+ node cli.js <salary> [situation] [numDependents] [year]
15
+ ```
16
+
17
+ Only salary is required. Defaults: `NotMarried`, `0` dependents, `2025`.
18
+
19
+ ```bash
20
+ node cli.js 1500
21
+ # Gross: 1500€ | Net: 1148.9€ | IRS: 186.1€ | SS: 165€
22
+
23
+ node cli.js 2000 MarriedOneHolder 1 2025
24
+ # Gross: 2000€ | Net: 1637.69€ | IRS: 142.31€ | SS: 220€
25
+ ```
26
+
27
+ ## Programmatic Usage
28
+
29
+ ```js
30
+ const { calculateSalary } = require('./index');
31
+ ```
32
+
33
+ ### calculateSalary(options)
34
+
35
+ Calculates the full salary breakdown for a given gross salary.
36
+
37
+ ```js
38
+ const result = calculateSalary({
39
+ situation: 'NotMarried',
40
+ numDependents: 0,
41
+ year: '2026',
42
+ salary: 1500
43
+ });
44
+
45
+ console.log(result);
46
+ /*
47
+ {
48
+ grossSalary: 1500,
49
+ netSalary: 1166.8,
50
+ ssDiscount: 168.17,
51
+ irsDiscount: 165,
52
+ companyMonthlyCost: 2165.63,
53
+ companyAnnualCost 25987.5
54
+ }
55
+ */
56
+ ```
57
+
58
+
59
+ **Parameters:**
60
+
61
+ | Field | Type | Description |
62
+ |-------|------|-------------|
63
+ | `situation` | string | `'NotMarried'`, `'MarriedOneHolder'`, or `'MarriedTwoHolders'` |
64
+ | `numDependents` | number | Number of dependents (0-5+) |
65
+ | `year` | string | Tax year: `'2026'`, `'2025'`, `'2024_03'`, `'2024_02'`, `'2024'`, or `'2023'` |
66
+ | `salary` | number | Gross monthly salary in euros |
67
+
68
+ **Returns:** `{ grossSalary, netSalary, ssDiscount, irsDiscount, companyMonthlyCost, companyAnnualCost }`
69
+
70
+ ## Test
71
+
72
+ ```bash
73
+ npm test
74
+ ```
75
+
76
+ ## How it works
77
+
78
+ 1. Loads CSV tax tables from `data/` (parsed with papaparse, cached after first load)
79
+ 2. Determines the tax type based on situation, dependents, and year
80
+ 3. Finds the matching tax bracket for the gross salary
81
+ 4. Calculates:
82
+ - **IRS discount** = (gross x tax rate) - parcela a abater - (adicional x dependents), minimum 0
83
+ - **SS discount** = gross x 11%
84
+ - **Net salary** = gross - IRS discount - SS discount
package/cli.js ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { calculateSalary } = require('./index');
4
+
5
+ const args = process.argv.slice(2);
6
+
7
+ if (args.length < 1) {
8
+ console.log('Usage: node cli.js <salary> [situation] [numDependents] [year]');
9
+ console.log('');
10
+ console.log(' salary Gross monthly salary in euros');
11
+ console.log(' situation NotMarried (default), MarriedOneHolder, MarriedTwoHolders');
12
+ console.log(' numDependents Number of dependents, 0-5+ (default: 0)');
13
+ console.log(' year 2026 (default), 2024_03, 2024_02, 2024, 2023');
14
+ console.log('');
15
+ console.log('Examples:');
16
+ console.log(' node cli.js 1500');
17
+ console.log(' node cli.js 1500 MarriedOneHolder 1 2025');
18
+ process.exit(1);
19
+ }
20
+
21
+ const salary = parseFloat(args[0]);
22
+ const situation = args[1] || 'NotMarried';
23
+ const numDependents = parseInt(args[2] || '0', 10);
24
+ const year = args[3] || '2026';
25
+
26
+ const result = calculateSalary({ salary, situation, numDependents, year });
27
+
28
+ console.log(`Gross: ${result.grossSalary}€ | Net: ${result.netSalary}€ | IRS: ${result.irsDiscount}€ | SS: ${result.ssDiscount}€`);
29
+ console.log(`Company Monthly Cost: ${result.companyMonthlyCost}€`)
30
+ console.log(`Company Annual Cost: ${result.companyAnnualCost}€`)
@@ -0,0 +1,114 @@
1
+ tipo;sinal;limite;maximo;parcela_abater;var1;var2;adicional;var3
2
+ SOLD;max;762;0,00%;0;0;0;0;0
3
+ SOLD;max;886,57;14,50%;14,50%;2,3;1114,71;34,29;2,1
4
+ SOLD;max;932,14;21,00%;21,00%;1,3;1376,37;34,29;4,3
5
+ SOLD;max;999,14;21,00%;121,28;0;0;34,29;5,4
6
+ SOLD;max;1106,93;26,50%;176,23;0;0;34,29;7,5
7
+ SOLD;max;1600,36;28,50%;198,37;0;0;34,29;14
8
+ SOLD;max;1961,36;35,00%;302,39;0;0;34,29;17,8
9
+ SOLD;max;2529,05;37,00%;341,62;0;0;34,29;22,1
10
+ SOLD;max;3694,46;38,72%;384,99;0;0;34,29;27,4
11
+ SOLD;max;5469,9;40,05%;434,32;0;0;34,29;31,5
12
+ SOLD;max;6420,55;42,72%;580,36;0;0;34,29;33,1
13
+ SOLD;max;20064,21;44,95%;723,22;0;0;34,29;41,2
14
+ SOLD;min;20064,21;47,17%;1169,65;0;0;34,29;-1
15
+ SOLCAS2;max;762;0,00%;0;0;0;0;0
16
+ SOLCAS2;max;886,57;14,50%;14,50%;2,3;1093,31;0;6,7
17
+ SOLCAS2;max;932,14;21,00%;21,00%;1,3;1350,22;0;8,8
18
+ SOLCAS2;max;999,14;21,00%;114,14;0;0;0;9,6
19
+ SOLCAS2;max;1106,93;26,50%;169,09;0;0;0;11,2
20
+ SOLCAS2;max;1600,36;28,50%;191,23;0;0;0;16,6
21
+ SOLCAS2;max;1961,36;35,00%;295,26;0;0;0;19,9
22
+ SOLCAS2;max;2529,05;37,00%;334,48;0;0;0;23,8
23
+ SOLCAS2;max;3694,46;38,72%;377,86;0;0;0;28,5
24
+ SOLCAS2;max;5469,9;40,05%;427,18;0;0;0;32,2
25
+ SOLCAS2;max;6420,55;42,72%;573,22;0;0;0;33,8
26
+ SOLCAS2;max;20064,21;44,95%;716,08;0;0;0;41,4
27
+ SOLCAS2;min;20064,21;47,17%;1162,51;0;0;0;-1
28
+ CAS2D;max;762;0,00%;0;0;0;0;0
29
+ CAS2D;max;886,57;14,50%;14,50%;2,3;1093,3;21,43;4,3
30
+ CAS2D;max;932,14;21,00%;21,00%;1,3;1350,21;21,43;6,5
31
+ CAS2D;max;999,14;21,00%;114,14;0;0;21,43;7,4
32
+ CAS2D;max;1106,93;26,50%;169,09;0;0;21,43;9,3
33
+ CAS2D;max;1600,36;28,50%;191,23;0;0;21,43;15,2
34
+ CAS2D;max;1961,36;35,00%;295,25;0;0;21,43;18,9
35
+ CAS2D;max;2529,05;37,00%;334,48;0;0;21,43;22,9
36
+ CAS2D;max;3694,46;38,72%;377,85;0;0;21,43;27,9
37
+ CAS2D;max;5469,9;40,05%;427,18;0;0;21,43;31,8
38
+ CAS2D;max;6420,55;42,72%;573,22;0;0;21,43;33,5
39
+ CAS2D;max;20064,21;44,95%;716,08;0;0;21,43;41,3
40
+ CAS2D;min;20064,21;47,17%;1162,51;0;0;21,43;-1
41
+ CAS1;max;762;0,00%;0;0;0;0;0
42
+ CAS1;max;886,57;14,50%;14,50%;2,3;1153,28;0;4,5
43
+ CAS1;max;932,14;14,50%;14,50%;1,883;1212,39;0;6,3
44
+ CAS1;max;999,14;14,50%;76,51;0;0;0;7,1
45
+ CAS1;max;1106,93;15,93%;91,2;0;0;0;8,8
46
+ CAS1;max;1600,36;21,00%;156,03;0;0;0;11,8
47
+ CAS1;max;1961,36;24,68%;218,66;0;0;0;13,5
48
+ CAS1;max;2529,05;27,58%;275,52;0;0;0;16,7
49
+ CAS1;max;3694,46;29,80%;331,54;0;0;0;20,8
50
+ CAS1;max;5469,9;33,11%;453,94;0;0;0;25,9
51
+ CAS1;max;6420,55;38,72%;808,52;0;0;0;26,1
52
+ CAS1;max;20064,21;42,51%;1052,4;0;0;0;37,3
53
+ CAS1;min;20064,21;47,17%;1986,71;0;0;0;-1
54
+ CAS1D;max;762;0,00%;0;0;0;0;0
55
+ CAS1D;max;886,57;14,50%;14,50%;2,3;1146,84;42,86;0
56
+ CAS1D;max;932,14;14,50%;14,50%;1,883;1204,55;42,86;1,9
57
+ CAS1D;max;999,14;14,50%;74,37;0;0;42,86;2,8
58
+ CAS1D;max;1106,93;15,93%;88,64;0;0;42,86;4,1
59
+ CAS1D;max;1600,36;21,00%;144,78;0;0;42,86;9,3
60
+ CAS1D;max;1961,36;24,68%;203,73;0;0;42,86;12,1
61
+ CAS1D;max;2529,05;27,58%;260,59;0;0;42,86;15,6
62
+ CAS1D;max;3694,46;29,80%;316,61;0;0;42,86;20,1
63
+ CAS1D;max;5469,9;33,11%;439,01;0;0;42,86;24,3
64
+ CAS1D;max;6420,55;38,72%;745,55;0;0;42,86;26,4
65
+ CAS1D;max;20064,21;42,51%;989,43;0;0;42,86;37,4
66
+ CAS1D;min;20064,21;47,17%;1923,74;0;0;42,86;-1
67
+ SOLCAS2+DEF;max;1519,41;0,00%;0;0;0;0;0
68
+ SOLCAS2+DEF;max;1971,21;26,50%;402,64;0;0;0;6,1
69
+ SOLCAS2+DEF;max;2093,21;28,50%;442,07;0;0;0;7,4
70
+ SOLCAS2+DEF;max;2354,21;35,00%;578,13;0;0;0;10,4
71
+ SOLCAS2+DEF;max;4015,41;37,00%;625,21;0;0;0;21,4
72
+ SOLCAS2+DEF;max;4252,25;38,72%;694,08;0;0;0;22,4
73
+ SOLCAS2+DEF;max;6527,69;40,05%;750,84;0;0;0;28,5
74
+ SOLCAS2+DEF;max;6621,19;42,72%;925,13;0;0;0;28,7
75
+ SOLCAS2+DEF;max;20264,85;44,95%;1072,45;0;0;0;39,7
76
+ SOLCAS2+DEF;min;20264,85;47,17%;1523,35;0;0;0;-1
77
+ SOLD+DEF;max;1677,09;0,00%;0;0;0;0;0
78
+ SOLD+DEF;max;2042,64;26,50%;401,57;0;0;42,86;4,7
79
+ SOLD+DEF;max;2307,5;28,50%;442,42;0;0;42,86;7,5
80
+ SOLD+DEF;max;2425,64;35,00%;592,41;0;0;42,86;8,8
81
+ SOLD+DEF;max;3743,98;37,00%;640,92;0;0;42,86;18,7
82
+ SOLD+DEF;max;4252,25;38,72%;705,13;0;0;42,86;21,1
83
+ SOLD+DEF;max;6527,69;40,05%;761,9;0;0;42,86;27,7
84
+ SOLD+DEF;max;6621,19;42,72%;936,19;0;0;42,86;27,9
85
+ SOLD+DEF;max;20264,85;44,95%;1083,51;0;0;42,86;39,4
86
+ SOLD+DEF;min;20264,85;47,17%;1534,4;0;0;42,86;-1
87
+ CAS2D+DEF;max;1574,66;0,00%;0;0;0;0;0
88
+ CAS2D+DEF;max;2185,5;26,50%;395,86;0;0;21,43;7,4
89
+ CAS2D+DEF;max;2307,5;28,50%;439,57;0;0;21,43;8,5
90
+ CAS2D+DEF;max;2354,21;35,00%;589,55;0;0;21,43;9
91
+ CAS2D+DEF;max;3301,12;37,00%;636,64;0;0;21,43;17,1
92
+ CAS2D+DEF;max;4252,25;38,72%;693,25;0;0;21,43;21,9
93
+ CAS2D+DEF;max;6527,69;40,05%;750,02;0;0;21,43;28,2
94
+ CAS2D+DEF;max;6621,19;42,72%;924,31;0;0;21,43;28,4
95
+ CAS2D+DEF;max;20264,85;44,95%;1071,63;0;0;21,43;39,6
96
+ CAS2D+DEF;min;20264,85;47,17%;1522,52;0;0;21,43;-1
97
+ CAS1+DEF;max;1779,19;0,00%;0;0;0;0;0
98
+ CAS1+DEF;max;2664,64;21,00%;373,63;0;0;0;7
99
+ CAS1+DEF;max;2818,5;24,68%;471,79;0;0;0;7,9
100
+ CAS1+DEF;max;3051,12;27,58%;553,49;0;0;0;9,4
101
+ CAS1+DEF;max;3395,1;29,80%;621,08;0;0;0;11,5
102
+ CAS1+DEF;max;6527,69;33,11%;733,56;0;0;0;21,9
103
+ CAS1+DEF;max;6621,19;38,72%;1099,39;0;0;0;22,1
104
+ CAS1+DEF;max;20264,85;42,51%;1350,89;0;0;0;35,8
105
+ CAS1+DEF;min;20264,85;47,17%;2294,54;0;0;0;-1
106
+ CAS1D+DEF;max;1881,23;0,00%;0;0;0;0;0
107
+ CAS1D+DEF;max;2664,64;21,00%;352,2;0;0;42,86;6,2
108
+ CAS1D+DEF;max;2818,5;24,68%;450,36;0;0;42,86;7,2
109
+ CAS1D+DEF;max;3051,12;27,58%;532,06;0;0;42,86;8,7
110
+ CAS1D+DEF;max;3395,1;29,80%;599,65;0;0;42,86;10,9
111
+ CAS1D+DEF;max;6527,69;33,11%;712,13;0;0;42,86;21,5
112
+ CAS1D+DEF;max;6621,19;38,72%;1077,96;0;0;42,86;21,8
113
+ CAS1D+DEF;min;20264,85;42,51%;1329,46;0;0;42,86;35,7
114
+ CAS1D+DEF;min;20264,85;47,17%;2273,11;0;0;42,86;-1
@@ -0,0 +1,70 @@
1
+ tipo;sinal;limite;maximo;parcela_abater;var1;var2;adicional;var3
2
+ SOLD;max;820,00;0,00%;0;0;0;0;0
3
+ SOLD;max;935,00;13,25%;13,25%;2,6;1135,39;34,29;2,2
4
+ SOLD;max;1001,00;18,00%;18,00%;1,4;1385,2;34,29;4,9
5
+ SOLD;max;1123,00;18,00%;96,82;0;0;34,29;6,3
6
+ SOLD;max;1765,00;26,00%;186,66;0;0;34,29;13,5
7
+ SOLD;max;2057,00;32,75%;305,80;0;0;34,29;16,2
8
+ SOLD;max;2664,00;37,00%;393,23;0;0;34,29;21
9
+ SOLD;max;3193,00;38,72%;439,05;0;0;34,29;23,9
10
+ SOLD;max;4173,00;40,05%;481,52;0;0;34,29;27,7
11
+ SOLD;max;5470,00;41,00%;521,17;0;0;34,29;30,8
12
+ SOLD;max;6540,00;42,70%;614,16;0;0;34,29;32,8
13
+ SOLD;max;20067,00;44,95%;761,31;0;0;34,29;41
14
+ SOLD;min;20067,00;47,17%;1206,80;0;0;34,29;-1
15
+ SOLCAS2;max;820,00;0,00%;0;0;0;0;0
16
+ SOLCAS2;max;935,00;13,25%;13,25%;2,6;1135,39;21,43;5,9
17
+ SOLCAS2;max;1001,00;18,00%;18,00%;1,4;1385,2;21,43;8,3
18
+ SOLCAS2;max;1123,00;18,00%;96,82;0;0;21,43;9,4
19
+ SOLCAS2;max;1765,00;26,00%;186,66;0;0;21,43;15,4
20
+ SOLCAS2;max;2057,00;32,75%;305,80;0;0;21,43;17,9
21
+ SOLCAS2;max;2664,00;37,00%;393,23;0;0;21,43;22,2
22
+ SOLCAS2;max;3193,00;38,72%;439,05;0;0;21,43;25
23
+ SOLCAS2;max;4173,00;40,05%;481,52;0;0;21,43;28,5
24
+ SOLCAS2;max;5470,00;41,00%;521,17;0;0;21,43;31,5
25
+ SOLCAS2;max;6540,00;42,70%;614,16;0;0;21,43;33,3
26
+ SOLCAS2;max;20067,00;44,95%;761,31;0;0;21,43;41,2
27
+ SOLCAS2;min;20067,00;47,17%;1206,80;0;0;21,43;-1
28
+ CAS1;max;857,00;0,00%;0;0;0;0;0
29
+ CAS1;max;935,00;13,25%;13,25%;2,6;1186,62;42,86;4
30
+ CAS1;max;1001,00;13,25%;13,25%;1,4;1402,3;42,86;5,8
31
+ CAS1;max;1393,00;13,25%;74,44;0;0;42,86;7,9
32
+ CAS1;max;1900,00;18,50%;147,57;0;0;42,86;10,7
33
+ CAS1;max;2801,00;26,00%;290,07;0;0;42,86;15,6
34
+ CAS1;max;3423,00;28,00%;346,09;0;0;42,86;17,9
35
+ CAS1;max;4099,00;29,15%;385,46;0;0;42,86;19,7
36
+ CAS1;max;5800,00;32,50%;522,78;0;0;42,86;23,5
37
+ CAS1;max;6422,00;36,00%;725,78;0;0;42,86;24,7
38
+ CAS1;max;20064,21;42,50%;1143,21;0;0;42,86;36,8
39
+ CAS1;min;20064,21;47,17%;2080,2;0;0;42,86;-1
40
+ SOLCAS2+DEF;max;1519,41;0,00%;0;0;0;0;0
41
+ SOLCAS2+DEF;max;1648,29;13,25%;201,32;0;0;0;1,0
42
+ SOLCAS2+DEF;max;1994,61;23,00%;362,03;0;0;0;4,8
43
+ SOLCAS2+DEF;max;2410,71;32,75%;556,51;0;0;0;9,7
44
+ SOLCAS2+DEF;max;4373,75;37,00%;658,97;0;0;0;21,9
45
+ SOLCAS2+DEF;max;6621,18;40,05%;792,37;0;0;0;28,1
46
+ SOLCAS2+DEF;max;6717,41;42,28%;940,03;0;0;0;28,3
47
+ SOLCAS2+DEF;max;20264,85;44,95%;1119,39;0;0;0;39,4
48
+ SOLCAS2+DEF;min;20264,85;47,17%;1569,27;0;0;0;-1
49
+ SOLD+DEF;max;1677,09;0,00%;0;0;0;0;0
50
+ SOLD+DEF;max;1994,61;23,00%;385,73;0;0;42,86;1,5
51
+ SOLD+DEF;max;2410,71;32,75%;580,21;0;0;42,86;6,9
52
+ SOLD+DEF;max;4373,75;37,00%;682,67;0;0;42,86;20,4
53
+ SOLD+DEF;max;6621,18;40,05%;816,07;0;0;42,86;27,1
54
+ SOLD+DEF;max;6717,41;42,28%;963,73;0;0;42,86;27,3
55
+ SOLD+DEF;max;20264,85;44,95%;1143,09;0;0;42,86;39,1
56
+ SOLD+DEF;min;20264,85;47,17%;1592,97;0;0;42,86;-1
57
+ CAS2D+DEF;max;1574,66;0,00%;0;0;0;0;0
58
+ CAS2D+DEF;max;1648,29;13,25%;208,64;0;0;21,43;0
59
+ CAS2D+DEF;max;1994,61;23,00%;369,35;0;0;21,43;2,4
60
+ CAS2D+DEF;max;2410,71;32,75%;563,83;0;0;21,43;8,5
61
+ CAS2D+DEF;max;4373,75;37,00%;666,29;0;0;21,43;21,3
62
+ CAS2D+DEF;max;6621,18;40,05%;799,69;0;0;21,43;27,6
63
+ CAS2D+DEF;max;6717,41;42,28%;947,35;0;0;21,43;27,9
64
+ CAS2D+DEF;max;20264,85;44,95%;1126,71;0;0;21,43;39,3
65
+ CAS2D+DEF;min;20264,85;47,17%;1576,59;0;0;21,43;-1
66
+ CAS1+DEF;max;2105,51;0,00%;0;0;0;0;0
67
+ CAS1+DEF;max;3622,95;31,60%;719,35;0;0;42,86;11,7
68
+ CAS1+DEF;max;6587,01;33,00%;770,07;0;0;42,86;21,3
69
+ CAS1+DEF;max;20264,85;42,50%;1395,84;0;0;42,86;35,6
70
+ CAS1+DEF;min;20264,85;47,17%;2342,21;0;0;42,86;-1
@@ -0,0 +1,68 @@
1
+ tipo;sinal;limite;maximo;parcela_abater;var1;var2;adicional;var3
2
+ SOLD;max;820;0,00%;0;0;0;0;0
3
+ SOLD;max;935;0,00%;0,00%;0;0;34,29;0
4
+ SOLD;max;989;0,00%;0,00%;0;0;34,29;0
5
+ SOLD;max;1125;0,00%;0;0;0;34,29;0
6
+ SOLD;max;1175;0,00%;0;0;0;34,29;0
7
+ SOLD;max;1769;3,75%;44,07;0;0;34,29;1,3
8
+ SOLD;max;2057;8,00%;119,25;0;0;34,29;2,2
9
+ SOLD;max;2408;10,65%;173,76;0;0;34,29;3,4
10
+ SOLD;max;3201;19,36%;383,44;0;0;34,29;7,4
11
+ SOLD;max;5492;40,05%;1045,8;0;0;34,29;21
12
+ SOLD;max;20021;44,95%;1314,64;0;0;34,29;38,4
13
+ SOLD;min;20021;47,17%;1760,1;0;0;34,29;-1
14
+ SOLCAS2;max;820;0,00%;0;0;0;0;0
15
+ SOLCAS2;max;935;0,00%;0,00%;0;0;21,43;0
16
+ SOLCAS2;max;989;0,00%;0,00%;0;0;21,43;0
17
+ SOLCAS2;max;1125;0,00%;0;0;0;21,43;0
18
+ SOLCAS2;max;1175;0,00%;0;0;0;21,43;0
19
+ SOLCAS2;max;1769;3,75%;44,07;0;0;21,43;1,3
20
+ SOLCAS2;max;2057;8,00%;119,25;0;0;21,43;2,2
21
+ SOLCAS2;max;2408;10,65%;173,76;0;0;21,43;3,4
22
+ SOLCAS2;max;3201;19,36%;383,44;0;0;21,43;7,4
23
+ SOLCAS2;max;5492;40,05%;1045,8;0;0;21,43;21
24
+ SOLCAS2;max;20021;44,95%;1314,64;0;0;21,43;38,4
25
+ SOLCAS2;min;20021;47,17%;1760,1;0;0;21,43;-1
26
+ CAS1;max;904;0,00%;0;0;0;0;0
27
+ CAS1;max;935;0,00%;0,00%;0;0;42,86;0
28
+ CAS1;max;989;0,00%;0,00%;0;0;42,86;0
29
+ CAS1;max;1070;0,00%;0;0;0;42,86;0
30
+ CAS1;max;1394;0,00%;0;0;0;42,86;0
31
+ CAS1;max;1912;1,65%;23,01;0;0;42,86;0,4
32
+ CAS1;max;2178;5,05%;87,95;0;0;42,86;1
33
+ CAS1;max;2671;5,91%;106,69;0;0;42,86;1,9
34
+ CAS1;max;3284;12,97%;295,33;0;0;42,86;4
35
+ CAS1;max;5906;30,72%;878,33;0;0;42,86;15,8
36
+ CAS1;max;20064;38,72%;1350,25;0;0;42,86;32
37
+ CAS1;min;20064;47,17%;3046,68;0;0;42,86;-1
38
+ SOLCAS2+DEF;max;1677;0,00%;0;0;0;0;0
39
+ SOLCAS2+DEF;max;2012;5,00%;83,83;0;0;0;0,8
40
+ SOLCAS2+DEF;max;2428;8,00%;144,2;0;0;0;2,1
41
+ SOLCAS2+DEF;max;4376;10,65%;208,55;0;0;0;5,9
42
+ SOLCAS2+DEF;max;4634;19,36%;589,61;0;0;0;6,6
43
+ SOLCAS2+DEF;max;6621;40,05%;1548,47;0;0;0;16,7
44
+ SOLCAS2+DEF;max;20265;44,95%;1872,58;0;0;0;35,7
45
+ SOLCAS2+DEF;min;20265;47,17%;2323,47;0;0;0;-1
46
+ SOLD+DEF;max;1919;0,00%;0;0;0;0;0
47
+ SOLD+DEF;max;2012;5,53%;106,1;0;0;42,86;0,3
48
+ SOLD+DEF;max;2785;8,00%;155,82;0;0;42,86;2,4
49
+ SOLD+DEF;max;4394;17,75%;427,41;0;0;42,86;8
50
+ SOLD+DEF;max;6687;34,84%;1178,52;0;0;42,86;17,2
51
+ SOLD+DEF;max;6978;40,05%;1526,7;0;0;42,86;18,2
52
+ SOLD+DEF;max;20265;44,95%;1868,29;0;0;42,86;35,7
53
+ SOLD+DEF;min;20265;47,17%;2319,18;0;0;42,86;-1
54
+ CAS2D+DEF;max;1651;0,00%;0;0;0;0;0
55
+ CAS2D+DEF;max;2023;5,50%;90,81;0;0;21,43;1
56
+ CAS2D+DEF;max;2441;6,25%;105,98;0;0;21,43;1,9
57
+ CAS2D+DEF;max;3037;9,60%;187,75;0;0;21,43;3,4
58
+ CAS2D+DEF;max;4394;17,75%;435,26;0;0;21,43;7,8
59
+ CAS2D+DEF;max;6687;34,84%;1186,37;0;0;21,43;17,1
60
+ CAS2D+DEF;max;6978;40,05%;1534,55;0;0;21,43;18,1
61
+ CAS2D+DEF;max;20265;44,95%;1876,14;0;0;21,43;35,7
62
+ CAS2D+DEF;min;20265;47,17%;2327,03;0;0;21,43;-1
63
+ CAS1+DEF;max;2302;0,00%;0;0;0;0;0
64
+ CAS1+DEF;max;3394;7,09%;163,15;0;0;42,86;2,3
65
+ CAS1+DEF;max;3652;12,97%;362,8;0;0;42,86;3
66
+ CAS1+DEF;max;6621;27,65%;898,97;0;0;42,86;14,1
67
+ CAS1+DEF;max;20265;42,44%;1878,34;0;0;42,86;33,2
68
+ CAS1+DEF;min;20265;47,17%;2836,1;0;0;42,86;-1
@@ -0,0 +1,68 @@
1
+ tipo;sinal;limite;maximo;parcela_abater;var1;var2;adicional;var3
2
+ SOLD;max;820;0,00%;0;0;0;0;0
3
+ SOLD;max;935;13,00%;13,00%;2,6;1135,39;34,29;5,8
4
+ SOLD;max;989;16,50%;16,50%;1,35;1386,11;34,29;7,6
5
+ SOLD;max;1125;16,50%;88,39;0;0;34,29;9
6
+ SOLD;max;1175;22,00%;150,26;0;0;34,29;9,2
7
+ SOLD;max;1769;25,00%;185,5;0;0;34,29;14,5
8
+ SOLD;max;2057;32,00%;309,36;0;0;34,29;17
9
+ SOLD;max;2408;35,50%;381,35;0;0;34,29;19,7
10
+ SOLD;max;3201;38,72%;458,76;0;0;34,29;24,4
11
+ SOLD;max;5492;40,05%;501,49;0;0;34,29;30,9
12
+ SOLD;max;20021;44,95%;770,33;0;0;34,29;41,1
13
+ SOLD;min;20021;47,17%;1215,8;0;0;34,29;-1
14
+ SOLCAS2;max;820;0,00%;0;0;0;0;0
15
+ SOLCAS2;max;935;13,00%;13,00%;2,6;1135,39;21,43;5,8
16
+ SOLCAS2;max;989;16,50%;16,50%;1,35;1386,11;21,43;7,6
17
+ SOLCAS2;max;1125;16,50%;88,39;0;0;21,43;8,6
18
+ SOLCAS2;max;1175;22,00%;150,26;0;0;21,43;9,2
19
+ SOLCAS2;max;1769;25,00%;185,5;0;0;21,43;14,5
20
+ SOLCAS2;max;2057;32,00%;309,36;0;0;21,43;17
21
+ SOLCAS2;max;2408;35,50%;381,35;0;0;21,43;19,7
22
+ SOLCAS2;max;3201;38,72%;458,76;0;0;21,43;24,4
23
+ SOLCAS2;max;5492;40,05%;501,49;0;0;21,43;30,9
24
+ SOLCAS2;max;20021;44,95%;770,33;0;0;21,43;41,1
25
+ SOLCAS2;min;20021;47,17%;1215,8;0;0;21,43;-1
26
+ CAS1;max;904;0,00%;0;0;0;0;0
27
+ CAS1;max;935;13,00%;13,00%;2,6;1251,62;42,86;1,6
28
+ CAS1;max;989;13,00%;13,00%;1,35;1545,09;42,86;3,1
29
+ CAS1;max;1070;13,00%;97,54;0;0;42,86;3,9
30
+ CAS1;max;1394;13,20%;99,68;0;0;42,86;6
31
+ CAS1;max;1912;16,50%;145,69;0;0;42,86;8,9
32
+ CAS1;max;2178;20,18%;216,11;0;0;42,86;10,3
33
+ CAS1;max;2671;23,62%;291,09;0;0;42,86;12,7
34
+ CAS1;max;3284;25,94%;352,9;0;0;42,86;15,2
35
+ CAS1;max;5906;30,72%;510,04;0;0;42,86;22,1
36
+ CAS1;max;20064;38,72%;981,97;0;0;42,86;33,8
37
+ CAS1;min;20064;47,17%;2678,4;0;0;42,86;-1
38
+ SOLCAS2+DEF;max;1677;0,00%;0;0;0;0;0
39
+ SOLCAS2+DEF;max;2012;22,00%;368,86;0;0;0;3,7
40
+ SOLCAS2+DEF;max;2428;32,00%;570,08;0;0;0;8,5
41
+ SOLCAS2+DEF;max;4376;35,50%;655,08;0;0;0;20,05
42
+ SOLCAS2+DEF;max;4634;38,72%;795,77;0;0;0;21,5
43
+ SOLCAS2+DEF;max;6621;40,05%;857,63;0;0;0;27,1
44
+ SOLCAS2+DEF;max;20265;44,95%;1181,74;0;0;0;39,1
45
+ SOLCAS2+DEF;min;20265;47,17%;1632,63;0;0;0;-1
46
+ SOLD+DEF;max;1919;0,00%;0;0;0;0;0
47
+ SOLD+DEF;max;2012;22,12%;424,35;0;0;42,86;1
48
+ SOLD+DEF;max;2785;32,00%;623,26;0;0;42,86;9,6
49
+ SOLD+DEF;max;4394;35,50%;720,75;0;0;42,86;19,1
50
+ SOLD+DEF;max;6687;38,72%;862,02;0;0;42,86;25,8
51
+ SOLD+DEF;max;6978;40,05%;951,3;0;0;42,86;26,4
52
+ SOLD+DEF;max;20265;44,95%;1292,88;0;0;42,86;38,6
53
+ SOLD+DEF;min;20265;47,17%;1743,78;0;0;42,86;-1
54
+ CAS2D+DEF;max;1651;0,00%;0;0;0;0;0
55
+ CAS2D+DEF;max;2023;22,00%;363,15;0;0;21,43;4
56
+ CAS2D+DEF;max;2441;25,00%;423,84;0;0;21,43;7,6
57
+ CAS2D+DEF;max;3037;32,00%;594,69;0;0;21,43;12,4
58
+ CAS2D+DEF;max;4394;35,50%;700,99;0;0;21,43;19,5
59
+ CAS2D+DEF;max;6687;38,72%;842,26;0;0;21,43;26,1
60
+ CAS2D+DEF;max;6978;40,05%;931,54;0;0;21,43;26,7
61
+ CAS2D+DEF;max;20265;44,95%;1273,12;0;0;21,43;38,7
62
+ CAS2D+DEF;min;20265;47,17%;1724,02;0;0;21,43;-1
63
+ CAS1+DEF;max;2302;0,00%;0;0;0;0;0
64
+ CAS1+DEF;max;3394;23,62%;543,85;0;0;42,86;7,6
65
+ CAS1+DEF;max;3652;25,94%;622,41;0;0;42,86;8,9
66
+ CAS1+DEF;max;6621;30,72%;797,17;0;0;42,86;18,7
67
+ CAS1+DEF;max;20265;42,44%;1573,11;0;0;42,86;34,7
68
+ CAS1+DEF;min;20265;47,17%;2530,87;0;0;42,86;-1
@@ -0,0 +1,68 @@
1
+ tipo;sinal;limite;maximo;parcela_abater;var1;var2;adicional;var3
2
+ SOLD;max;870;0,00%;0;0;0;0;0
3
+ SOLD;max;992;13,00%;13,00%;2,6;1208,32;34,29;5,6
4
+ SOLD;max;1070;16,50%;16,50%;1,35;1477,67;34,29;8
5
+ SOLD;max;1136;16,50%;90,81;0;0;34,29;8,5
6
+ SOLD;max;1187;22,00%;153,29;0;0;34,29;9,1
7
+ SOLD;max;1787;25,00%;188,90;0;0;34,29;14,4
8
+ SOLD;max;2078;32,00%;313,99;0;0;34,29;16,9
9
+ SOLD;max;2432;35,50%;386,72;0;0;34,29;19,6
10
+ SOLD;max;3233;38,72%;465,03;0;0;34,29;24,3
11
+ SOLD;max;5547;40,05%;508,03;0;0;34,29;30,9
12
+ SOLD;max;20221;44,95%;779,83;0;0;34,29;41,1
13
+ SOLD;min;20221;47,17%;1228,74;0;0;34,29;-1
14
+ SOLCAS2;max;870;0,00%;0;0;0;0;0
15
+ SOLCAS2;max;992;13,00%;13,00%;2,6;1208,32;21,43;5,6
16
+ SOLCAS2;max;1070;16,50%;16,50%;1,35;1477,67;21,43;8
17
+ SOLCAS2;max;1136;16,50%;90,81;0;0;21,43;8,5
18
+ SOLCAS2;max;1187;22,00%;153,29;0;0;21,43;9,1
19
+ SOLCAS2;max;1787;25,00%;188,90;0;0;21,43;14,4
20
+ SOLCAS2;max;2078;32,00%;313,99;0;0;21,43;16,9
21
+ SOLCAS2;max;2432;35,50%;386,72;0;0;21,43;19,6
22
+ SOLCAS2;max;3233;38,72%;465,03;0;0;21,43;24,3
23
+ SOLCAS2;max;5547;40,05%;508,03;0;0;21,43;30,9
24
+ SOLCAS2;max;20221;44,95%;779,83;0;0;21,43;41,1
25
+ SOLCAS2;min;20221;47,71%;1228,74;0;0;21,43;-1
26
+ CAS1;max;957;0,00%;0;0;0;0;0
27
+ CAS1;max;992;13,00%;13,00%;2,6;1324,55;42,86;1,7
28
+ CAS1;max;1070;13,00%;13,00%;1,35;1632,65;42,86;3,8
29
+ CAS1;max;1081;13,00%;98,75;0;0;42,86;3,9
30
+ CAS1;max;1408;13,20%;100,91;0;0;42,86;6
31
+ CAS1;max;1931;16,50%;147,37;0;0;42,86;8,9
32
+ CAS1;max;2200;20,18%;218,43;0;0;42,86;10,3
33
+ CAS1;max;2698;23,62%;294,11;0;0;42,86;12,7
34
+ CAS1;max;3317;25,94%;356,70;0;0;42,86;15,2
35
+ CAS1;max;5965;30,72%;515,25;0;0;42,86;22,1
36
+ CAS1;max;20265;38,72%;992,45;0;0;42,86;33,8
37
+ CAS1;min;20265;47,17%;2704,84;0;0;42,86;-1
38
+ SOLCAS2+DEF;max;1694;0,00%;0;0;0;0;0
39
+ SOLCAS2+DEF;max;2032;22,00%;372,68;0;0;0;3,7
40
+ SOLCAS2+DEF;max;2452;32,00%;575,88;0;0;0;8,5
41
+ SOLCAS2+DEF;max;4220;35,50%;661,7;0;0;0;20,05
42
+ SOLCAS2+DEF;max;4680;38,72%;804,02;0;0;0;21,5
43
+ SOLCAS2+DEF;max;6867;40.05%;866,26;0;0;0;27,1
44
+ SOLCAS2+DEF;max;20468;44,95%;1193,92;0;0;0;39,1
45
+ SOLCAS2+DEF;min;20468;47,17%;1648,31;0;0;0;-1
46
+ SOLD+DEF;max;1938;0,00%;0;0;0;0;0
47
+ SOLD+DEF;max;2032;22,12%;428,69;0;0;42,86;1
48
+ SOLD+DEF;max;2813;32,00%;629,45;0;0;42,86;9,6
49
+ SOLD+DEF;max;4438;35,50%;727,91;0;0;42,86;19,1
50
+ SOLD+DEF;max;6754;38,72%;870,81;0;0;42,86;25,8
51
+ SOLD+DEF;max;7048;40,05%;960,64;0;0;42,86;26,4
52
+ SOLD+DEF;max;20468;44,95%;1305,99;0;0;42,86;38,6
53
+ SOLD+DEF;min;20468;47,17%;1760,38;0;0;42,86;-1
54
+ CAS2D+DEF;max;1668;0,00%;0;0;0;0;0
55
+ CAS2D+DEF;max;2043;22,00%;366,96;0;0;21,43;4
56
+ CAS2D+DEF;max;2465;25,00%;428,25;0;0;21,43;7,6
57
+ CAS2D+DEF;max;3067;32,00%;600,8;0;0;21,43;12,4
58
+ CAS2D+DEF;max;4438;35,50%;708,15;0;0;21,43;19,5
59
+ CAS2D+DEF;max;6754;38,72%;851,05;0;0;21,43;26,1
60
+ CAS2D+DEF;max;7048;40,05%;940,88;0;0;21,43;26,7
61
+ CAS2D+DEF;max;20468;44,95%;1286,23;0;0;21,43;38,7
62
+ CAS2D+DEF;min;20468;47,17%;1740,62;0;0;21,43;-1
63
+ CAS1+DEF;max;2325;0,00%;0;0;0;0;0
64
+ CAS1+DEF;max;3428;23,62%;549,17;0;0;42,86;7,6
65
+ CAS1+DEF;max;3689;25,94%;628,7;0;0;42,86;8,9
66
+ CAS1+DEF;max;6687;30,72%;805,03;0;0;42,86;18,7
67
+ CAS1+DEF;max;20468;42,44%;1588,75;0;0;42,86;34,7
68
+ CAS1+DEF;min;20468;47,17%;2556,89;0;0;42,86;-1
@@ -0,0 +1,68 @@
1
+ tipo;sinal;limite;maximo;parcela_abater;var1;var2;adicional;var3
2
+ SOLD;max;920;0,00%;0;0;0;0;0
3
+ SOLD;max;1042;12,50%;12,50%;2,6;1273,85;34,29;5,3
4
+ SOLD;max;1108;15,70%;15,70%;1,35;1554,83;34,29;7,2
5
+ SOLD;max;1154;15,70%;94,71;0;0;34,29;7,5
6
+ SOLD;max;1212;21,20%;158,18;0;0;34,29;8,1
7
+ SOLD;max;1819;24,10%;193,33;0;0;34,29;13,5
8
+ SOLD;max;2119;31,10%;320,66;0;0;34,29;16
9
+ SOLD;max;2499;34,90%;401,19;0;0;34,29;18,8
10
+ SOLD;max;3305;38,36%;487,66;0;0;34,29;23,6
11
+ SOLD;max;5547;39,69%;531,62;0;0;34,29;30,1
12
+ SOLD;max;20221;44,95%;823,4;0;0;34,29;40,9
13
+ SOLD;min;20221;47,17%;1272,31;0;0;34,29;-1
14
+ SOLCAS2;max;920;0,00%;0;0;0;0;0
15
+ SOLCAS2;max;1042;12,50%;12,50%;2,6;1273,85;21,43;5,3
16
+ SOLCAS2;max;1108;15,70%;15,70%;1,35;1554,83;21,43;7,2
17
+ SOLCAS2;max;1154;15,70%;94,71;0;0;21,43;7,5
18
+ SOLCAS2;max;1212;21,20%;158,18;0;0;21,43;8,1
19
+ SOLCAS2;max;1819;24,10%;193,33;0;0;21,43;13,5
20
+ SOLCAS2;max;2119;31,10%;320,66;0;0;21,43;16
21
+ SOLCAS2;max;2499;34,90%;401,19;0;0;21,43;18,8
22
+ SOLCAS2;max;3305;38,36%;487,66;0;0;21,43;23,6
23
+ SOLCAS2;max;5547;39,69%;531,62;0;0;21,43;30,1
24
+ SOLCAS2;max;20221;44,95%;823,4;0;0;21,43;40,9
25
+ SOLCAS2;min;20221;47,17%;1272,31;0;0;21,43;-1
26
+ CAS1;max;991;0,00%;0;0;0;0;0
27
+ CAS1;max;1042;12,50%;12,50%;2,6;1372,15;42,86;2,2
28
+ CAS1;max;1108;12,50%;12,50%;1,35;1677,85;42,86;3,8
29
+ CAS1;max;1119;12,50%;96,17;0;0;42,86;3,9
30
+ CAS1;max;1432;12,72%;98,64;0;0;42,86;5,8
31
+ CAS1;max;1962;15,70%;141,32;0;0;42,86;8,5
32
+ CAS1;max;2240;19,38%;213,53;0;0;42,86;9,8
33
+ CAS1;max;2773;22,77%;289,47;0;0;42,86;12,3
34
+ CAS1;max;3389;25,70%;370,72;0;0;42,86;14,8
35
+ CAS1;max;5965;28,81%;476,12;0;0;42,86;20,8
36
+ CAS1;max;20265;38,43%;1049,96;0;0;42,86;33,2
37
+ CAS1;min;20265;47,17%;2821,13;0;0;42,86;-1
38
+ SOLCAS2+DEF;max;1694;0,00%;0;0;0;0;0
39
+ SOLCAS2+DEF;max;2063;21,20%;359,13;0;0;0;3,8
40
+ SOLCAS2+DEF;max;2492;31,10%;563,37;0;0;0;8,5
41
+ SOLCAS2+DEF;max;4487;34,90%;658,07;0;0;0;20,2
42
+ SOLCAS2+DEF;max;4753;38,36%;813,33;0;0;0;21,2
43
+ SOLCAS2+DEF;max;6687;39,69%;876,55;0;0;0;26,6
44
+ SOLCAS2+DEF;max;20468;44,95%;1228,29;0;0;0;38,9
45
+ SOLCAS2+DEF;min;20468;47,17%;1682,68;0;0;0;-1
46
+ SOLD+DEF;max;1938;0,00%;0;0;0;0;0
47
+ SOLD+DEF;max;2063;21,32%;413,19;0;0;42,86;1,3
48
+ SOLD+DEF;max;2854;31,10%;614,96;0;0;42,86;9,6
49
+ SOLD+DEF;max;4504;34,90%;723,42;0;0;42,86;18,8
50
+ SOLD+DEF;max;6826;38,36%;879,26;0;0;42,86;25,5
51
+ SOLD+DEF;max;7048;39,69%;970,05;0;0;42,86;25,9
52
+ SOLD+DEF;max;20468;44,95%;1340,78;0;0;42,86;38,4
53
+ SOLD+DEF;min;20468;47,17%;1795,17;0;0;42,86;-1
54
+ CAS2D+DEF;max;1668;0,00%;0;0;0;0;0
55
+ CAS2D+DEF;max;2068;20,49%;341,78;0;0;21,43;4
56
+ CAS2D+DEF;max;2497;24,10%;416,44;0;0;21,43;7,4
57
+ CAS2D+DEF;max;3107;31,10%;591,23;0;0;21,43;12,1
58
+ CAS2D+DEF;max;4504;34,90%;709,3;0;0;21,43;19,2
59
+ CAS2D+DEF;max;6826;38,36%;865,14;0;0;21,43;25,7
60
+ CAS2D+DEF;max;7048;39,69%;955,93;0;0;21,43;26,1
61
+ CAS2D+DEF;max;20468;44,95%;1326,66;0;0;21,43;38,5
62
+ CAS2D+DEF;min;20468;47,17%;1781,05;0;0;21,43;-1
63
+ CAS1+DEF;max;2325;0,00%;0;0;0;0;0
64
+ CAS1+DEF;max;3494;22,77%;529,41;0;0;42,86;7,6
65
+ CAS1+DEF;max;3761;25,70%;631,79;0;0;42,86;8,9
66
+ CAS1+DEF;max;6687;28,81%;748,76;0;0;42,86;17,6
67
+ CAS1+DEF;max;20468;42,44%;1660,2;0;0;42,86;34,3
68
+ CAS1+DEF;min;20468;47,17%;2628,34;0;0;42,86;-1
package/index.js ADDED
@@ -0,0 +1,22 @@
1
+ const { loadTables } = require('./src/tables');
2
+ const { calculate } = require('./src/calculate');
3
+
4
+ function calculateSalary({ situation = 'NotMarried', numDependents = 0, year = '2026', salary }) {
5
+
6
+ const csvJsons = loadTables();
7
+ const csvJson = csvJsons[year];
8
+
9
+ if (!csvJson) {
10
+ throw new Error(`Unknown year: ${year}. Available: ${Object.keys(csvJsons).join(', ')}`);
11
+ }
12
+
13
+ const result = calculate(salary, situation, numDependents, year, csvJson);
14
+
15
+ if (result === null) {
16
+ throw new Error(`Could not calculate salary for the given parameters`);
17
+ }
18
+
19
+ return result;
20
+ }
21
+
22
+ module.exports = { calculateSalary };
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "salario-pt",
3
+ "version": "1.0.0",
4
+ "description": "Portuguese salary calculator - calculates net salary from gross",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "salario-pt": "./cli.js"
8
+ },
9
+ "scripts": {
10
+ "test": "node --test test.js"
11
+ },
12
+ "keywords": [
13
+ "salary",
14
+ "portugal",
15
+ "irs",
16
+ "tax",
17
+ "calculator",
18
+ "net-salary"
19
+ ],
20
+ "author": "Adriano <adrianojlt@gmail.com>",
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/adrianojlt/salario.git"
25
+ },
26
+ "dependencies": {
27
+ "papaparse": "^5.4.1",
28
+ "salario-pt": "file:salario-pt-1.0.0.tgz"
29
+ }
30
+ }
@@ -0,0 +1,86 @@
1
+ const Situation = {
2
+ NotMarried: '0',
3
+ MarriedOneHolder: '1',
4
+ MarriedTwoHolders: '2'
5
+ };
6
+
7
+ const TSU = "1.2375";
8
+
9
+ const SITUATION_MAP = {
10
+ 'NotMarried': '0',
11
+ 'MarriedOneHolder': '1',
12
+ 'MarriedTwoHolders': '2'
13
+ };
14
+
15
+ function getType(situation, dependents, year) {
16
+ if (year === "2023") {
17
+ if (situation === Situation.NotMarried) {
18
+ if (dependents === 0) return "SOLCAS2";
19
+ return "SOLD";
20
+ }
21
+ if (situation === Situation.MarriedOneHolder) {
22
+ if (dependents === 0) return "CAS1";
23
+ return "CAS1D";
24
+ }
25
+ if (situation === Situation.MarriedTwoHolders) {
26
+ if (dependents === 0) return "SOLCAS2";
27
+ return "CAS2D";
28
+ }
29
+ }
30
+
31
+ if (year.startsWith("2024") || year.startsWith("2025") || year.startsWith("2026")) {
32
+ if (situation === Situation.NotMarried) {
33
+ if (dependents === 0) return "SOLCAS2";
34
+ return "SOLD";
35
+ }
36
+ if (situation === Situation.MarriedOneHolder) {
37
+ return "CAS1";
38
+ }
39
+ if (situation === Situation.MarriedTwoHolders) {
40
+ return "SOLCAS2";
41
+ }
42
+ }
43
+ }
44
+
45
+ function calculate(grossSalary, situation, numDependents, year, csvJson) {
46
+
47
+ const internalSituation = SITUATION_MAP[situation] || situation;
48
+
49
+ const type = getType(internalSituation, numDependents, year);
50
+
51
+ const inMaxRange = (x) => grossSalary < parseFloat(x.limite.replace(',', '.')) && x.sinal === 'max';
52
+ const inMinRange = (x) => grossSalary >= parseFloat(x.limite.replace(',', '.')) && x.sinal === 'min';
53
+
54
+ const values = csvJson.filter(x => x.tipo === type && (inMaxRange(x) || inMinRange(x)));
55
+
56
+ if (!values[0]) return null;
57
+
58
+ const row = values[0];
59
+
60
+ const part = parseFloat(row.parcela_abater.replace(',', '.'));
61
+ const percentage = parseFloat(row.maximo.replace(/%/g, '').replace(',', '.')) / 100;
62
+ const salaryWithTax = parseFloat((grossSalary * percentage).toFixed(2));
63
+ const dependentsPart = parseFloat(parseFloat(row.adicional.replace(',', '.')).toFixed(2));
64
+ const additionalPart = dependentsPart * numDependents;
65
+
66
+ let irsDiscount = salaryWithTax - part - additionalPart;
67
+ let ssDiscount = grossSalary * 0.11;
68
+
69
+ if (irsDiscount < 0) irsDiscount = 0;
70
+
71
+ const netSalary = grossSalary - (irsDiscount + ssDiscount);
72
+
73
+ const companyMonthlyCost = ((grossSalary * parseFloat(TSU)) * 14) / 12;
74
+ const companyAnnualCost = companyMonthlyCost * 12;
75
+
76
+ return {
77
+ grossSalary,
78
+ netSalary: parseFloat(netSalary.toFixed(2)),
79
+ ssDiscount: parseFloat(ssDiscount.toFixed(2)),
80
+ irsDiscount: parseFloat(irsDiscount.toFixed(2)),
81
+ companyMonthlyCost: parseFloat(companyMonthlyCost.toFixed(2)),
82
+ companyAnnualCost: parseFloat(companyAnnualCost.toFixed(2))
83
+ };
84
+ }
85
+
86
+ module.exports = { calculate };
package/src/tables.js ADDED
@@ -0,0 +1,35 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const Papa = require('papaparse');
4
+
5
+ let cachedTables = null;
6
+
7
+ const YEARS = ['2026', '2025', '2024_03', '2024_02', '2024', '2023'];
8
+
9
+ function getDataPath() {
10
+ const packageRoot = path.join(__dirname, '..');
11
+ const dataPath = path.join(packageRoot, 'data');
12
+ if (fs.existsSync(path.join(dataPath, 'taxas_continente_2026.csv'))) {
13
+ return dataPath;
14
+ }
15
+ return path.join(__dirname, '..', '..', '..', 'data');
16
+ }
17
+
18
+ function loadTables() {
19
+ if (cachedTables) return cachedTables;
20
+
21
+ cachedTables = {};
22
+
23
+ const dataPath = getDataPath();
24
+
25
+ for (const year of YEARS) {
26
+ const filePath = path.join(dataPath, `taxas_continente_${year}.csv`);
27
+ const csv = fs.readFileSync(filePath, 'utf-8');
28
+ const results = Papa.parse(csv, { header: true, delimiter: ';' });
29
+ cachedTables[year] = results.data;
30
+ }
31
+
32
+ return cachedTables;
33
+ }
34
+
35
+ module.exports = { loadTables };