forked from guillaume-sainthillier/eurl-sasu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimpot-revenu.ts
63 lines (51 loc) · 1.52 KB
/
impot-revenu.ts
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
class Tranche {
constructor(private min: number, private max: number, private taux: number) { }
getMin(): number { return this.min; };
getMax(): number { return this.max; };
getTaux(): number { return this.taux };
getImpot(revenu) {
return this.compute(revenu);
}
compute(revenu) {
if (revenu < this.min) {
return 0;
}
if (revenu > this.max) {
let r = (this.max - this.min) * this.taux;
return r;
}
let r = (revenu - this.min) * this.taux;
return r;
}
}
export default class ImpotRevenu {
tranches: Tranche[];
revenu: number;
nbParts: number;
constructor() {
this.tranches = [
new Tranche(0, 9700, 0),
new Tranche(9701, 26818, 0.14),
new Tranche(26819, 71898, 0.3),
new Tranche(71899, 152260, 0.41),
new Tranche(152261, 99999999, 0.45),
];
}
getImpot(): number {
let baseIR = this.revenu / this.nbParts;
let total = 0;
this.tranches.forEach((tranche) => {
total += tranche.getImpot(baseIR);
});
return total * this.nbParts;
}
getTranches() {
let baseIR = this.revenu;
let total = 0;
let tranches = [];
this.tranches.forEach((tranche) => {
tranches.push({ value: tranche.getImpot(this.revenu), min: tranche.getMin(), max: tranche.getMax(), taux: tranche.getTaux() });
});
return tranches;
}
}