@novha/calc-engines 6.3.0 → 8.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/dist/capital-gains/brazil/BrazilCapitalGainsService.js +3 -0
- package/dist/capital-gains/brazil/BrazilCapitalGainsServiceImpl.js +56 -0
- package/dist/capital-gains/brazil/domain/types.js +3 -0
- package/dist/capital-gains/canada/CanadaCapitalGainsServiceImpl.js +29 -17
- package/dist/capital-gains/index.js +14 -2
- package/dist/capital-gains/india/IndiaCapitalGainsService.js +3 -0
- package/dist/capital-gains/india/IndiaCapitalGainsServiceImpl.js +58 -0
- package/dist/capital-gains/india/domain/types.js +3 -0
- package/dist/capital-gains/japan/JapanCapitalGainsService.js +3 -0
- package/dist/capital-gains/japan/JapanCapitalGainsServiceImpl.js +41 -0
- package/dist/capital-gains/japan/domain/types.js +3 -0
- package/dist/capital-gains/spain/SpainCapitalGainsService.js +3 -0
- package/dist/capital-gains/spain/SpainCapitalGainsServiceImpl.js +56 -0
- package/dist/capital-gains/spain/domain/types.js +3 -0
- package/dist/corporate/brazil/BrazilCorporateTaxService.js +3 -0
- package/dist/corporate/brazil/BrazilCorporateTaxServiceImpl.js +33 -0
- package/dist/corporate/brazil/domain/types.js +3 -0
- package/dist/corporate/index.js +10 -2
- package/dist/corporate/india/IndiaCorporateTaxService.js +3 -0
- package/dist/corporate/india/IndiaCorporateTaxServiceImpl.js +29 -0
- package/dist/corporate/india/domain/types.js +3 -0
- package/dist/corporate/japan/JapanCorporateTaxService.js +3 -0
- package/dist/corporate/japan/JapanCorporateTaxServiceImpl.js +29 -0
- package/dist/corporate/japan/domain/types.js +3 -0
- package/dist/corporate/spain/SpainCorporateTaxService.js +3 -0
- package/dist/corporate/spain/SpainCorporateTaxServiceImpl.js +29 -0
- package/dist/corporate/spain/domain/types.js +3 -0
- package/dist/income-tax/brazil/BrazilIncomeTaxService.js +3 -0
- package/dist/income-tax/brazil/BrazilIncomeTaxServiceImpl.js +78 -0
- package/dist/income-tax/brazil/domain/types.js +3 -0
- package/dist/income-tax/index.js +14 -2
- package/dist/income-tax/india/IndiaIncomeTaxService.js +3 -0
- package/dist/income-tax/india/IndiaIncomeTaxServiceImpl.js +75 -0
- package/dist/income-tax/india/domain/types.js +3 -0
- package/dist/income-tax/japan/JapanIncomeTaxService.js +3 -0
- package/dist/income-tax/japan/JapanIncomeTaxServiceImpl.js +75 -0
- package/dist/income-tax/japan/domain/types.js +3 -0
- package/dist/income-tax/spain/SpainIncomeTaxService.js +3 -0
- package/dist/income-tax/spain/SpainIncomeTaxServiceImpl.js +62 -0
- package/dist/income-tax/spain/domain/types.js +3 -0
- package/dist/index.js +3 -2
- package/dist/inheritance-tax/australia/AustraliaInheritanceTaxService.js +3 -0
- package/dist/inheritance-tax/australia/AustraliaInheritanceTaxServiceImpl.js +19 -0
- package/dist/inheritance-tax/australia/domain/types.js +3 -0
- package/dist/inheritance-tax/canada/CanadaInheritanceTaxService.js +3 -0
- package/dist/inheritance-tax/canada/CanadaInheritanceTaxServiceImpl.js +51 -0
- package/dist/inheritance-tax/canada/domain/types.js +3 -0
- package/dist/inheritance-tax/domain/types.js +3 -0
- package/dist/inheritance-tax/france/FranceInheritanceTaxService.js +3 -0
- package/dist/inheritance-tax/france/FranceInheritanceTaxServiceImpl.js +52 -0
- package/dist/inheritance-tax/france/domain/types.js +3 -0
- package/dist/inheritance-tax/germany/GermanyInheritanceTaxService.js +3 -0
- package/dist/inheritance-tax/germany/GermanyInheritanceTaxServiceImpl.js +52 -0
- package/dist/inheritance-tax/germany/domain/types.js +3 -0
- package/dist/inheritance-tax/index.js +31 -0
- package/dist/inheritance-tax/japan/JapanInheritanceTaxService.js +3 -0
- package/dist/inheritance-tax/japan/JapanInheritanceTaxServiceImpl.js +53 -0
- package/dist/inheritance-tax/japan/domain/types.js +3 -0
- package/dist/inheritance-tax/south-africa/SouthAfricaInheritanceTaxService.js +3 -0
- package/dist/inheritance-tax/south-africa/SouthAfricaInheritanceTaxServiceImpl.js +52 -0
- package/dist/inheritance-tax/south-africa/domain/types.js +3 -0
- package/dist/inheritance-tax/spain/SpainInheritanceTaxService.js +3 -0
- package/dist/inheritance-tax/spain/SpainInheritanceTaxServiceImpl.js +51 -0
- package/dist/inheritance-tax/spain/domain/types.js +3 -0
- package/dist/inheritance-tax/uk/UKInheritanceTaxService.js +3 -0
- package/dist/inheritance-tax/uk/UKInheritanceTaxServiceImpl.js +39 -0
- package/dist/inheritance-tax/uk/domain/types.js +3 -0
- package/dist/inheritance-tax/usa/USAInheritanceTaxService.js +3 -0
- package/dist/inheritance-tax/usa/USAInheritanceTaxServiceImpl.js +51 -0
- package/dist/inheritance-tax/usa/domain/types.js +3 -0
- package/dist/mortgage/brazil/BrazilMortgageService.js +3 -0
- package/dist/mortgage/brazil/BrazilMortgageServiceImpl.js +76 -0
- package/dist/mortgage/brazil/domain/types.js +3 -0
- package/dist/mortgage/index.js +14 -2
- package/dist/mortgage/india/IndiaMortgageService.js +3 -0
- package/dist/mortgage/india/IndiaMortgageServiceImpl.js +76 -0
- package/dist/mortgage/india/domain/types.js +3 -0
- package/dist/mortgage/japan/JapanMortgageService.js +3 -0
- package/dist/mortgage/japan/JapanMortgageServiceImpl.js +76 -0
- package/dist/mortgage/japan/domain/types.js +3 -0
- package/dist/mortgage/spain/SpainMortgageService.js +3 -0
- package/dist/mortgage/spain/SpainMortgageServiceImpl.js +96 -0
- package/dist/mortgage/spain/domain/types.js +3 -0
- package/dist/shared/domain/types.js +2 -1
- package/dist/types/capital-gains/brazil/BrazilCapitalGainsService.d.ts +4 -0
- package/dist/types/capital-gains/brazil/BrazilCapitalGainsServiceImpl.d.ts +10 -0
- package/dist/types/capital-gains/brazil/domain/types.d.ts +11 -0
- package/dist/types/capital-gains/canada/CanadaCapitalGainsServiceImpl.d.ts +1 -1
- package/dist/types/capital-gains/index.d.ts +9 -1
- package/dist/types/capital-gains/india/IndiaCapitalGainsService.d.ts +4 -0
- package/dist/types/capital-gains/india/IndiaCapitalGainsServiceImpl.d.ts +9 -0
- package/dist/types/capital-gains/india/domain/types.d.ts +9 -0
- package/dist/types/capital-gains/japan/JapanCapitalGainsService.d.ts +4 -0
- package/dist/types/capital-gains/japan/JapanCapitalGainsServiceImpl.d.ts +9 -0
- package/dist/types/capital-gains/japan/domain/types.d.ts +6 -0
- package/dist/types/capital-gains/spain/SpainCapitalGainsService.d.ts +4 -0
- package/dist/types/capital-gains/spain/SpainCapitalGainsServiceImpl.d.ts +10 -0
- package/dist/types/capital-gains/spain/domain/types.d.ts +11 -0
- package/dist/types/corporate/brazil/BrazilCorporateTaxService.d.ts +4 -0
- package/dist/types/corporate/brazil/BrazilCorporateTaxServiceImpl.d.ts +8 -0
- package/dist/types/corporate/brazil/domain/types.d.ts +19 -0
- package/dist/types/corporate/index.d.ts +9 -1
- package/dist/types/corporate/india/IndiaCorporateTaxService.d.ts +4 -0
- package/dist/types/corporate/india/IndiaCorporateTaxServiceImpl.d.ts +8 -0
- package/dist/types/corporate/india/domain/types.d.ts +15 -0
- package/dist/types/corporate/japan/JapanCorporateTaxService.d.ts +4 -0
- package/dist/types/corporate/japan/JapanCorporateTaxServiceImpl.d.ts +8 -0
- package/dist/types/corporate/japan/domain/types.d.ts +15 -0
- package/dist/types/corporate/spain/SpainCorporateTaxService.d.ts +4 -0
- package/dist/types/corporate/spain/SpainCorporateTaxServiceImpl.d.ts +8 -0
- package/dist/types/corporate/spain/domain/types.d.ts +15 -0
- package/dist/types/income-tax/brazil/BrazilIncomeTaxService.d.ts +4 -0
- package/dist/types/income-tax/brazil/BrazilIncomeTaxServiceImpl.d.ts +11 -0
- package/dist/types/income-tax/brazil/domain/types.d.ts +18 -0
- package/dist/types/income-tax/index.d.ts +9 -1
- package/dist/types/income-tax/india/IndiaIncomeTaxService.d.ts +4 -0
- package/dist/types/income-tax/india/IndiaIncomeTaxServiceImpl.d.ts +10 -0
- package/dist/types/income-tax/india/domain/types.d.ts +16 -0
- package/dist/types/income-tax/japan/JapanIncomeTaxService.d.ts +4 -0
- package/dist/types/income-tax/japan/JapanIncomeTaxServiceImpl.d.ts +10 -0
- package/dist/types/income-tax/japan/domain/types.d.ts +16 -0
- package/dist/types/income-tax/spain/SpainIncomeTaxService.d.ts +4 -0
- package/dist/types/income-tax/spain/SpainIncomeTaxServiceImpl.d.ts +10 -0
- package/dist/types/income-tax/spain/domain/types.d.ts +16 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/inheritance-tax/australia/AustraliaInheritanceTaxService.d.ts +4 -0
- package/dist/types/inheritance-tax/australia/AustraliaInheritanceTaxServiceImpl.d.ts +8 -0
- package/dist/types/inheritance-tax/australia/domain/types.d.ts +13 -0
- package/dist/types/inheritance-tax/canada/CanadaInheritanceTaxService.d.ts +4 -0
- package/dist/types/inheritance-tax/canada/CanadaInheritanceTaxServiceImpl.d.ts +9 -0
- package/dist/types/inheritance-tax/canada/domain/types.d.ts +20 -0
- package/dist/types/inheritance-tax/domain/types.d.ts +17 -0
- package/dist/types/inheritance-tax/france/FranceInheritanceTaxService.d.ts +4 -0
- package/dist/types/inheritance-tax/france/FranceInheritanceTaxServiceImpl.d.ts +9 -0
- package/dist/types/inheritance-tax/france/domain/types.d.ts +29 -0
- package/dist/types/inheritance-tax/germany/GermanyInheritanceTaxService.d.ts +4 -0
- package/dist/types/inheritance-tax/germany/GermanyInheritanceTaxServiceImpl.d.ts +9 -0
- package/dist/types/inheritance-tax/germany/domain/types.d.ts +28 -0
- package/dist/types/inheritance-tax/index.d.ts +19 -0
- package/dist/types/inheritance-tax/japan/JapanInheritanceTaxService.d.ts +4 -0
- package/dist/types/inheritance-tax/japan/JapanInheritanceTaxServiceImpl.d.ts +9 -0
- package/dist/types/inheritance-tax/japan/domain/types.d.ts +21 -0
- package/dist/types/inheritance-tax/south-africa/SouthAfricaInheritanceTaxService.d.ts +4 -0
- package/dist/types/inheritance-tax/south-africa/SouthAfricaInheritanceTaxServiceImpl.d.ts +9 -0
- package/dist/types/inheritance-tax/south-africa/domain/types.d.ts +20 -0
- package/dist/types/inheritance-tax/spain/SpainInheritanceTaxService.d.ts +4 -0
- package/dist/types/inheritance-tax/spain/SpainInheritanceTaxServiceImpl.d.ts +9 -0
- package/dist/types/inheritance-tax/spain/domain/types.d.ts +19 -0
- package/dist/types/inheritance-tax/uk/UKInheritanceTaxService.d.ts +4 -0
- package/dist/types/inheritance-tax/uk/UKInheritanceTaxServiceImpl.d.ts +8 -0
- package/dist/types/inheritance-tax/uk/domain/types.d.ts +17 -0
- package/dist/types/inheritance-tax/usa/USAInheritanceTaxService.d.ts +4 -0
- package/dist/types/inheritance-tax/usa/USAInheritanceTaxServiceImpl.d.ts +9 -0
- package/dist/types/inheritance-tax/usa/domain/types.d.ts +19 -0
- package/dist/types/mortgage/brazil/BrazilMortgageService.d.ts +4 -0
- package/dist/types/mortgage/brazil/BrazilMortgageServiceImpl.d.ts +7 -0
- package/dist/types/mortgage/brazil/domain/types.d.ts +39 -0
- package/dist/types/mortgage/index.d.ts +9 -1
- package/dist/types/mortgage/india/IndiaMortgageService.d.ts +4 -0
- package/dist/types/mortgage/india/IndiaMortgageServiceImpl.d.ts +7 -0
- package/dist/types/mortgage/india/domain/types.d.ts +39 -0
- package/dist/types/mortgage/japan/JapanMortgageService.d.ts +4 -0
- package/dist/types/mortgage/japan/JapanMortgageServiceImpl.d.ts +7 -0
- package/dist/types/mortgage/japan/domain/types.d.ts +39 -0
- package/dist/types/mortgage/spain/SpainMortgageService.d.ts +4 -0
- package/dist/types/mortgage/spain/SpainMortgageServiceImpl.d.ts +8 -0
- package/dist/types/mortgage/spain/domain/types.d.ts +44 -0
- package/dist/types/shared/domain/types.d.ts +2 -1
- package/package.json +1 -1
- package/src/capital-gains/brazil/BrazilCapitalGainsService.ts +5 -0
- package/src/capital-gains/brazil/BrazilCapitalGainsServiceImpl.ts +69 -0
- package/src/capital-gains/brazil/domain/types.ts +15 -0
- package/src/capital-gains/canada/CanadaCapitalGainsServiceImpl.ts +34 -21
- package/src/capital-gains/index.ts +40 -0
- package/src/capital-gains/india/IndiaCapitalGainsService.ts +5 -0
- package/src/capital-gains/india/IndiaCapitalGainsServiceImpl.ts +64 -0
- package/src/capital-gains/india/domain/types.ts +12 -0
- package/src/capital-gains/japan/JapanCapitalGainsService.ts +5 -0
- package/src/capital-gains/japan/JapanCapitalGainsServiceImpl.ts +47 -0
- package/src/capital-gains/japan/domain/types.ts +9 -0
- package/src/capital-gains/spain/SpainCapitalGainsService.ts +5 -0
- package/src/capital-gains/spain/SpainCapitalGainsServiceImpl.ts +69 -0
- package/src/capital-gains/spain/domain/types.ts +15 -0
- package/src/corporate/brazil/BrazilCorporateTaxService.ts +5 -0
- package/src/corporate/brazil/BrazilCorporateTaxServiceImpl.ts +40 -0
- package/src/corporate/brazil/domain/types.ts +16 -0
- package/src/corporate/index.ts +45 -1
- package/src/corporate/india/IndiaCorporateTaxService.ts +5 -0
- package/src/corporate/india/IndiaCorporateTaxServiceImpl.ts +35 -0
- package/src/corporate/india/domain/types.ts +15 -0
- package/src/corporate/japan/JapanCorporateTaxService.ts +5 -0
- package/src/corporate/japan/JapanCorporateTaxServiceImpl.ts +35 -0
- package/src/corporate/japan/domain/types.ts +15 -0
- package/src/corporate/spain/SpainCorporateTaxService.ts +5 -0
- package/src/corporate/spain/SpainCorporateTaxServiceImpl.ts +35 -0
- package/src/corporate/spain/domain/types.ts +15 -0
- package/src/income-tax/brazil/BrazilIncomeTaxService.ts +5 -0
- package/src/income-tax/brazil/BrazilIncomeTaxServiceImpl.ts +91 -0
- package/src/income-tax/brazil/domain/types.ts +21 -0
- package/src/income-tax/index.ts +40 -0
- package/src/income-tax/india/IndiaIncomeTaxService.ts +5 -0
- package/src/income-tax/india/IndiaIncomeTaxServiceImpl.ts +87 -0
- package/src/income-tax/india/domain/types.ts +16 -0
- package/src/income-tax/japan/JapanIncomeTaxService.ts +5 -0
- package/src/income-tax/japan/JapanIncomeTaxServiceImpl.ts +87 -0
- package/src/income-tax/japan/domain/types.ts +16 -0
- package/src/income-tax/spain/SpainIncomeTaxService.ts +5 -0
- package/src/income-tax/spain/SpainIncomeTaxServiceImpl.ts +75 -0
- package/src/income-tax/spain/domain/types.ts +16 -0
- package/src/index.ts +1 -0
- package/src/inheritance-tax/australia/AustraliaInheritanceTaxService.ts +5 -0
- package/src/inheritance-tax/australia/AustraliaInheritanceTaxServiceImpl.ts +21 -0
- package/src/inheritance-tax/australia/domain/types.ts +16 -0
- package/src/inheritance-tax/canada/CanadaInheritanceTaxService.ts +5 -0
- package/src/inheritance-tax/canada/CanadaInheritanceTaxServiceImpl.ts +65 -0
- package/src/inheritance-tax/canada/domain/types.ts +24 -0
- package/src/inheritance-tax/domain/types.ts +19 -0
- package/src/inheritance-tax/france/FranceInheritanceTaxService.ts +5 -0
- package/src/inheritance-tax/france/FranceInheritanceTaxServiceImpl.ts +66 -0
- package/src/inheritance-tax/france/domain/types.ts +35 -0
- package/src/inheritance-tax/germany/GermanyInheritanceTaxService.ts +5 -0
- package/src/inheritance-tax/germany/GermanyInheritanceTaxServiceImpl.ts +66 -0
- package/src/inheritance-tax/germany/domain/types.ts +34 -0
- package/src/inheritance-tax/index.ts +110 -0
- package/src/inheritance-tax/japan/JapanInheritanceTaxService.ts +5 -0
- package/src/inheritance-tax/japan/JapanInheritanceTaxServiceImpl.ts +67 -0
- package/src/inheritance-tax/japan/domain/types.ts +25 -0
- package/src/inheritance-tax/south-africa/SouthAfricaInheritanceTaxService.ts +5 -0
- package/src/inheritance-tax/south-africa/SouthAfricaInheritanceTaxServiceImpl.ts +66 -0
- package/src/inheritance-tax/south-africa/domain/types.ts +24 -0
- package/src/inheritance-tax/spain/SpainInheritanceTaxService.ts +5 -0
- package/src/inheritance-tax/spain/SpainInheritanceTaxServiceImpl.ts +65 -0
- package/src/inheritance-tax/spain/domain/types.ts +23 -0
- package/src/inheritance-tax/uk/UKInheritanceTaxService.ts +5 -0
- package/src/inheritance-tax/uk/UKInheritanceTaxServiceImpl.ts +46 -0
- package/src/inheritance-tax/uk/domain/types.ts +20 -0
- package/src/inheritance-tax/usa/USAInheritanceTaxService.ts +5 -0
- package/src/inheritance-tax/usa/USAInheritanceTaxServiceImpl.ts +65 -0
- package/src/inheritance-tax/usa/domain/types.ts +23 -0
- package/src/mortgage/brazil/BrazilMortgageService.ts +5 -0
- package/src/mortgage/brazil/BrazilMortgageServiceImpl.ts +101 -0
- package/src/mortgage/brazil/domain/types.ts +46 -0
- package/src/mortgage/index.ts +49 -1
- package/src/mortgage/india/IndiaMortgageService.ts +5 -0
- package/src/mortgage/india/IndiaMortgageServiceImpl.ts +101 -0
- package/src/mortgage/india/domain/types.ts +46 -0
- package/src/mortgage/japan/JapanMortgageService.ts +5 -0
- package/src/mortgage/japan/JapanMortgageServiceImpl.ts +101 -0
- package/src/mortgage/japan/domain/types.ts +46 -0
- package/src/mortgage/spain/SpainMortgageService.ts +5 -0
- package/src/mortgage/spain/SpainMortgageServiceImpl.ts +130 -0
- package/src/mortgage/spain/domain/types.ts +52 -0
- package/src/shared/domain/types.ts +1 -0
- package/test/australia-inheritance-tax.test.ts +35 -0
- package/test/brazil-capital-gains.test.ts +65 -0
- package/test/brazil-corporate-tax.test.ts +63 -0
- package/test/brazil-income-tax.test.ts +85 -0
- package/test/brazil-mortgage.test.ts +70 -0
- package/test/canada-inheritance-tax.test.ts +62 -0
- package/test/france-inheritance-tax.test.ts +101 -0
- package/test/germany-inheritance-tax.test.ts +100 -0
- package/test/india-capital-gains.test.ts +71 -0
- package/test/india-corporate-tax.test.ts +54 -0
- package/test/india-income-tax.test.ts +78 -0
- package/test/india-mortgage.test.ts +70 -0
- package/test/japan-capital-gains.test.ts +55 -0
- package/test/japan-corporate-tax.test.ts +54 -0
- package/test/japan-income-tax.test.ts +76 -0
- package/test/japan-inheritance-tax.test.ts +74 -0
- package/test/japan-mortgage.test.ts +69 -0
- package/test/south-africa-inheritance-tax.test.ts +81 -0
- package/test/spain-capital-gains.test.ts +66 -0
- package/test/spain-corporate-tax.test.ts +54 -0
- package/test/spain-income-tax.test.ts +84 -0
- package/test/spain-inheritance-tax.test.ts +78 -0
- package/test/spain-mortgage.test.ts +70 -0
- package/test/uk-inheritance-tax.test.ts +72 -0
- package/test/usa-inheritance-tax.test.ts +90 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { SouthAfricaInheritanceTaxServiceImpl } from '../src/inheritance-tax/south-africa/SouthAfricaInheritanceTaxServiceImpl';
|
|
2
|
+
import { Input, Rules } from '../src/inheritance-tax/south-africa/domain/types';
|
|
3
|
+
|
|
4
|
+
const southAfricaRules: Rules = {
|
|
5
|
+
primaryAbatement: 3500000,
|
|
6
|
+
taxBrackets: [
|
|
7
|
+
{ from: 0, to: 30000000, rate: 0.20 },
|
|
8
|
+
{ from: 30000000, to: null, rate: 0.25 },
|
|
9
|
+
],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
describe('SouthAfricaInheritanceTaxServiceImpl', () => {
|
|
13
|
+
it('returns zero tax for estate below primary abatement', () => {
|
|
14
|
+
const input: Input = { estateValue: 3000000, deductions: 0 };
|
|
15
|
+
const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
|
|
16
|
+
const result = service.calculate();
|
|
17
|
+
|
|
18
|
+
expect(result.inheritanceTax).toBe(0);
|
|
19
|
+
expect(result.taxableEstate).toBe(0);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('returns zero tax for estate at primary abatement', () => {
|
|
23
|
+
const input: Input = { estateValue: 3500000, deductions: 0 };
|
|
24
|
+
const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
|
|
25
|
+
const result = service.calculate();
|
|
26
|
+
|
|
27
|
+
expect(result.inheritanceTax).toBe(0);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('applies 20% rate for estate above abatement within first bracket', () => {
|
|
31
|
+
const input: Input = { estateValue: 13500000, deductions: 0 };
|
|
32
|
+
const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
|
|
33
|
+
const result = service.calculate();
|
|
34
|
+
|
|
35
|
+
// Taxable = 13500000 - 3500000 = 10000000
|
|
36
|
+
// 10000000 * 0.20 = 2000000
|
|
37
|
+
expect(result.taxableEstate).toBe(10000000);
|
|
38
|
+
expect(result.inheritanceTax).toBe(2000000);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('applies 25% rate for amounts above R30M bracket', () => {
|
|
42
|
+
const input: Input = { estateValue: 43500000, deductions: 0 };
|
|
43
|
+
const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
|
|
44
|
+
const result = service.calculate();
|
|
45
|
+
|
|
46
|
+
// Taxable = 43500000 - 3500000 = 40000000
|
|
47
|
+
// 30000000 * 0.20 = 6000000
|
|
48
|
+
// 10000000 * 0.25 = 2500000
|
|
49
|
+
// Total = 8500000
|
|
50
|
+
expect(result.taxableEstate).toBe(40000000);
|
|
51
|
+
expect(result.inheritanceTax).toBe(8500000);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('deductions reduce taxable estate', () => {
|
|
55
|
+
const input: Input = { estateValue: 13500000, deductions: 5000000 };
|
|
56
|
+
const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
|
|
57
|
+
const result = service.calculate();
|
|
58
|
+
|
|
59
|
+
// Net estate = 13500000 - 5000000 = 8500000
|
|
60
|
+
// Taxable = 8500000 - 3500000 = 5000000
|
|
61
|
+
// 5000000 * 0.20 = 1000000
|
|
62
|
+
expect(result.taxableEstate).toBe(5000000);
|
|
63
|
+
expect(result.inheritanceTax).toBe(1000000);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('returns zero for zero estate', () => {
|
|
67
|
+
const input: Input = { estateValue: 0, deductions: 0 };
|
|
68
|
+
const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
|
|
69
|
+
const result = service.calculate();
|
|
70
|
+
|
|
71
|
+
expect(result.inheritanceTax).toBe(0);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('calculates effective rate correctly', () => {
|
|
75
|
+
const input: Input = { estateValue: 13500000, deductions: 0 };
|
|
76
|
+
const service = new SouthAfricaInheritanceTaxServiceImpl(input, southAfricaRules);
|
|
77
|
+
const result = service.calculate();
|
|
78
|
+
|
|
79
|
+
expect(result.effectiveRate).toBe((result.inheritanceTax / 13500000) * 100);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { SpainCapitalGainsServiceImpl } from '../src/capital-gains/spain/SpainCapitalGainsServiceImpl';
|
|
2
|
+
import { Input, Rules } from '../src/capital-gains/spain/domain/types';
|
|
3
|
+
|
|
4
|
+
const spainRules: Rules = {
|
|
5
|
+
brackets: [
|
|
6
|
+
{ from: 0, to: 6000, rate: 0.19 },
|
|
7
|
+
{ from: 6000, to: 50000, rate: 0.21 },
|
|
8
|
+
{ from: 50000, to: 200000, rate: 0.23 },
|
|
9
|
+
{ from: 200000, to: 300000, rate: 0.27 },
|
|
10
|
+
{ from: 300000, to: null, rate: 0.30 },
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
describe('SpainCapitalGainsServiceImpl', () => {
|
|
15
|
+
it('returns zero tax for zero gain', () => {
|
|
16
|
+
const input: Input = { capitalGain: 0 };
|
|
17
|
+
const service = new SpainCapitalGainsServiceImpl(input, spainRules);
|
|
18
|
+
const result = service.calculate();
|
|
19
|
+
|
|
20
|
+
expect(result.taxableGain).toBe(0);
|
|
21
|
+
expect(result.capitalGainTax).toBe(0);
|
|
22
|
+
expect(result.totalTax).toBe(0);
|
|
23
|
+
expect(result.effectiveRate).toBe(0);
|
|
24
|
+
expect(result.breakdowns).toHaveLength(0);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('correctly calculates tax for gain in first bracket', () => {
|
|
28
|
+
const input: Input = { capitalGain: 3000 };
|
|
29
|
+
const service = new SpainCapitalGainsServiceImpl(input, spainRules);
|
|
30
|
+
const result = service.calculate();
|
|
31
|
+
|
|
32
|
+
// 0-3000: 3000 * 0.19 = 570
|
|
33
|
+
expect(result.capitalGainTax).toBe(570);
|
|
34
|
+
expect(result.totalTax).toBe(570);
|
|
35
|
+
expect(result.effectiveRate).toBeCloseTo(19, 2);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('correctly calculates tax spanning multiple brackets', () => {
|
|
39
|
+
const input: Input = { capitalGain: 100000 };
|
|
40
|
+
const service = new SpainCapitalGainsServiceImpl(input, spainRules);
|
|
41
|
+
const result = service.calculate();
|
|
42
|
+
|
|
43
|
+
// 0-6000: 6000 * 0.19 = 1140
|
|
44
|
+
// 6000-50000: 44000 * 0.21 = 9240
|
|
45
|
+
// 50000-100000: 50000 * 0.23 = 11500
|
|
46
|
+
// Total = 21880
|
|
47
|
+
expect(result.capitalGainTax).toBeCloseTo(21880, 2);
|
|
48
|
+
expect(result.totalTax).toBeCloseTo(21880, 2);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('taxable gain equals input capital gain', () => {
|
|
52
|
+
const input: Input = { capitalGain: 50000 };
|
|
53
|
+
const service = new SpainCapitalGainsServiceImpl(input, spainRules);
|
|
54
|
+
const result = service.calculate();
|
|
55
|
+
|
|
56
|
+
expect(result.taxableGain).toBe(50000);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('effective rate equals total tax divided by gain times 100', () => {
|
|
60
|
+
const input: Input = { capitalGain: 100000 };
|
|
61
|
+
const service = new SpainCapitalGainsServiceImpl(input, spainRules);
|
|
62
|
+
const result = service.calculate();
|
|
63
|
+
|
|
64
|
+
expect(result.effectiveRate).toBeCloseTo((result.capitalGainTax / 100000) * 100, 2);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { SpainCorporateTaxServiceImpl } from '../src/corporate/spain/SpainCorporateTaxServiceImpl';
|
|
2
|
+
import { Input, Rules } from '../src/corporate/spain/domain/types';
|
|
3
|
+
|
|
4
|
+
const spainRules: Rules = {
|
|
5
|
+
regime: { type: 'flat', rate: 0.25 },
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
describe('SpainCorporateTaxServiceImpl', () => {
|
|
9
|
+
it('returns zero tax for zero income', () => {
|
|
10
|
+
const input: Input = { taxableIncome: 0 };
|
|
11
|
+
const service = new SpainCorporateTaxServiceImpl(input, spainRules);
|
|
12
|
+
const result = service.calculate();
|
|
13
|
+
|
|
14
|
+
expect(result.corporateTax).toBe(0);
|
|
15
|
+
expect(result.effectiveTaxRate).toBe(0);
|
|
16
|
+
expect(result.breakdowns).toHaveLength(0);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('correctly applies the flat 25% rate', () => {
|
|
20
|
+
const input: Input = { taxableIncome: 100000 };
|
|
21
|
+
const service = new SpainCorporateTaxServiceImpl(input, spainRules);
|
|
22
|
+
const result = service.calculate();
|
|
23
|
+
|
|
24
|
+
// 100000 * 0.25 = 25000
|
|
25
|
+
expect(result.corporateTax).toBe(25000);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('calculates effective tax rate as percentage', () => {
|
|
29
|
+
const input: Input = { taxableIncome: 100000 };
|
|
30
|
+
const service = new SpainCorporateTaxServiceImpl(input, spainRules);
|
|
31
|
+
const result = service.calculate();
|
|
32
|
+
|
|
33
|
+
expect(result.effectiveTaxRate).toBe(25);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('returns one breakdown entry for flat rate calculation', () => {
|
|
37
|
+
const input: Input = { taxableIncome: 100000 };
|
|
38
|
+
const service = new SpainCorporateTaxServiceImpl(input, spainRules);
|
|
39
|
+
const result = service.calculate();
|
|
40
|
+
|
|
41
|
+
expect(result.breakdowns).toHaveLength(1);
|
|
42
|
+
expect(result.breakdowns[0].rate).toBe(0.25);
|
|
43
|
+
expect(result.breakdowns[0].amount).toBe(25000);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('scales linearly with taxable income', () => {
|
|
47
|
+
const input: Input = { taxableIncome: 500000 };
|
|
48
|
+
const service = new SpainCorporateTaxServiceImpl(input, spainRules);
|
|
49
|
+
const result = service.calculate();
|
|
50
|
+
|
|
51
|
+
expect(result.corporateTax).toBe(125000);
|
|
52
|
+
expect(result.effectiveTaxRate).toBe(25);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { SpainIncomeTaxServiceImpl } from '../src/income-tax/spain/SpainIncomeTaxServiceImpl';
|
|
2
|
+
import { IncomeTaxRules } from '../src/income-tax/spain/domain/types';
|
|
3
|
+
|
|
4
|
+
const spainRules: IncomeTaxRules = {
|
|
5
|
+
taxBrackets: [
|
|
6
|
+
{ from: 0, to: 12450, rate: 0.19 },
|
|
7
|
+
{ from: 12450, to: 20200, rate: 0.24 },
|
|
8
|
+
{ from: 20200, to: 35200, rate: 0.30 },
|
|
9
|
+
{ from: 35200, to: 60000, rate: 0.37 },
|
|
10
|
+
{ from: 60000, to: 300000, rate: 0.45 },
|
|
11
|
+
{ from: 300000, to: null, rate: 0.47 },
|
|
12
|
+
],
|
|
13
|
+
socialContributions: { rate: 0.0635 },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe('SpainIncomeTaxServiceImpl', () => {
|
|
17
|
+
it('returns zero tax for zero income', () => {
|
|
18
|
+
const service = new SpainIncomeTaxServiceImpl(0, spainRules);
|
|
19
|
+
const result = service.calculateNetIncome();
|
|
20
|
+
|
|
21
|
+
expect(result.incomeTax).toBe(0);
|
|
22
|
+
expect(result.socialContributions).toBe(0);
|
|
23
|
+
expect(result.totalDeductions).toBe(0);
|
|
24
|
+
expect(result.effectiveTaxRate).toBe(0);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('correctly calculates income tax for income in first bracket', () => {
|
|
28
|
+
const service = new SpainIncomeTaxServiceImpl(10000, spainRules);
|
|
29
|
+
const result = service.calculateNetIncome();
|
|
30
|
+
|
|
31
|
+
// 0-10000: 10000 * 0.19 = 1900
|
|
32
|
+
expect(result.incomeTax).toBeCloseTo(1900, 2);
|
|
33
|
+
expect(result.grossIncome).toBe(10000);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('correctly calculates social contributions', () => {
|
|
37
|
+
const service = new SpainIncomeTaxServiceImpl(10000, spainRules);
|
|
38
|
+
const result = service.calculateNetIncome();
|
|
39
|
+
|
|
40
|
+
// 10000 * 0.0635 = 635
|
|
41
|
+
expect(result.socialContributions).toBeCloseTo(635, 2);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('correctly calculates income tax spanning multiple brackets', () => {
|
|
45
|
+
const service = new SpainIncomeTaxServiceImpl(25000, spainRules);
|
|
46
|
+
const result = service.calculateNetIncome();
|
|
47
|
+
|
|
48
|
+
// 0-12450: 12450 * 0.19 = 2365.5
|
|
49
|
+
// 12450-20200: 7750 * 0.24 = 1860
|
|
50
|
+
// 20200-25000: 4800 * 0.30 = 1440
|
|
51
|
+
// Total = 5665.5
|
|
52
|
+
expect(result.incomeTax).toBeCloseTo(5665.5, 1);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('calculates effective tax rate as income tax divided by gross income', () => {
|
|
56
|
+
const service = new SpainIncomeTaxServiceImpl(25000, spainRules);
|
|
57
|
+
const result = service.calculateNetIncome();
|
|
58
|
+
|
|
59
|
+
expect(result.effectiveTaxRate).toBeCloseTo(result.incomeTax / result.grossIncome, 4);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('net income equals gross income minus total deductions', () => {
|
|
63
|
+
const service = new SpainIncomeTaxServiceImpl(25000, spainRules);
|
|
64
|
+
const result = service.calculateNetIncome();
|
|
65
|
+
|
|
66
|
+
expect(result.netIncome).toBeCloseTo(result.grossIncome - result.totalDeductions, 2);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('total deductions equals income tax plus social contributions', () => {
|
|
70
|
+
const service = new SpainIncomeTaxServiceImpl(25000, spainRules);
|
|
71
|
+
const result = service.calculateNetIncome();
|
|
72
|
+
|
|
73
|
+
expect(result.totalDeductions).toBeCloseTo(result.incomeTax + result.socialContributions, 2);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('applies highest bracket rate to income above 300000', () => {
|
|
77
|
+
const service = new SpainIncomeTaxServiceImpl(350000, spainRules);
|
|
78
|
+
const result = service.calculateNetIncome();
|
|
79
|
+
|
|
80
|
+
expect(result.incomeTax).toBeGreaterThan(0);
|
|
81
|
+
const lastBreakdown = result.taxBracketBreakdown[result.taxBracketBreakdown.length - 1];
|
|
82
|
+
expect(lastBreakdown.rate).toBe(0.47);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { SpainInheritanceTaxServiceImpl } from '../src/inheritance-tax/spain/SpainInheritanceTaxServiceImpl';
|
|
2
|
+
import { Input, Rules } from '../src/inheritance-tax/spain/domain/types';
|
|
3
|
+
|
|
4
|
+
const spainRules: Rules = {
|
|
5
|
+
exemption: 0,
|
|
6
|
+
taxBrackets: [
|
|
7
|
+
{ from: 0, to: 7993.46, rate: 0.0765 },
|
|
8
|
+
{ from: 7993.46, to: 31956.34, rate: 0.102 },
|
|
9
|
+
{ from: 31956.34, to: 79881.68, rate: 0.153 },
|
|
10
|
+
{ from: 79881.68, to: 239389.13, rate: 0.2125 },
|
|
11
|
+
{ from: 239389.13, to: 398777.54, rate: 0.255 },
|
|
12
|
+
{ from: 398777.54, to: 797555.08, rate: 0.2975 },
|
|
13
|
+
{ from: 797555.08, to: null, rate: 0.34 },
|
|
14
|
+
],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe('SpainInheritanceTaxServiceImpl', () => {
|
|
18
|
+
it('returns zero tax for zero estate', () => {
|
|
19
|
+
const input: Input = { estateValue: 0 };
|
|
20
|
+
const service = new SpainInheritanceTaxServiceImpl(input, spainRules);
|
|
21
|
+
const result = service.calculate();
|
|
22
|
+
|
|
23
|
+
expect(result.inheritanceTax).toBe(0);
|
|
24
|
+
expect(result.taxableEstate).toBe(0);
|
|
25
|
+
expect(result.effectiveRate).toBe(0);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('returns zero tax when estate is at or below the exemption', () => {
|
|
29
|
+
const rulesWithExemption: Rules = { ...spainRules, exemption: 100000 };
|
|
30
|
+
const input: Input = { estateValue: 80000 };
|
|
31
|
+
const service = new SpainInheritanceTaxServiceImpl(input, rulesWithExemption);
|
|
32
|
+
const result = service.calculate();
|
|
33
|
+
|
|
34
|
+
expect(result.inheritanceTax).toBe(0);
|
|
35
|
+
expect(result.taxableEstate).toBe(0);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('correctly calculates tax for estate in first bracket', () => {
|
|
39
|
+
const input: Input = { estateValue: 5000 };
|
|
40
|
+
const service = new SpainInheritanceTaxServiceImpl(input, spainRules);
|
|
41
|
+
const result = service.calculate();
|
|
42
|
+
|
|
43
|
+
// 0-5000: 5000 * 0.0765 = 382.5
|
|
44
|
+
expect(result.taxableEstate).toBe(5000);
|
|
45
|
+
expect(result.inheritanceTax).toBeCloseTo(382.5, 2);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('correctly calculates tax for estate spanning multiple brackets', () => {
|
|
49
|
+
const input: Input = { estateValue: 100000 };
|
|
50
|
+
const service = new SpainInheritanceTaxServiceImpl(input, spainRules);
|
|
51
|
+
const result = service.calculate();
|
|
52
|
+
|
|
53
|
+
// 0-7993.46: 7993.46 * 0.0765 ≈ 611.50
|
|
54
|
+
// 7993.46-31956.34: 23962.88 * 0.102 ≈ 2444.21
|
|
55
|
+
// 31956.34-79881.68: 47925.34 * 0.153 ≈ 7332.58
|
|
56
|
+
// 79881.68-100000: 20118.32 * 0.2125 ≈ 4275.14
|
|
57
|
+
// Total ≈ 14663.43
|
|
58
|
+
expect(result.taxableEstate).toBe(100000);
|
|
59
|
+
expect(result.inheritanceTax).toBeCloseTo(14663.43, 0);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('effective rate equals inheritance tax divided by estate times 100', () => {
|
|
63
|
+
const input: Input = { estateValue: 100000 };
|
|
64
|
+
const service = new SpainInheritanceTaxServiceImpl(input, spainRules);
|
|
65
|
+
const result = service.calculate();
|
|
66
|
+
|
|
67
|
+
expect(result.effectiveRate).toBeCloseTo((result.inheritanceTax / 100000) * 100, 2);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('taxable estate is reduced by the exemption amount', () => {
|
|
71
|
+
const rulesWithExemption: Rules = { ...spainRules, exemption: 20000 };
|
|
72
|
+
const input: Input = { estateValue: 50000 };
|
|
73
|
+
const service = new SpainInheritanceTaxServiceImpl(input, rulesWithExemption);
|
|
74
|
+
const result = service.calculate();
|
|
75
|
+
|
|
76
|
+
expect(result.taxableEstate).toBe(30000);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { SpainMortgageServiceImpl } from '../src/mortgage/spain/SpainMortgageServiceImpl';
|
|
2
|
+
import { MortgageInput, MortgageRules } from '../src/mortgage/spain/domain/types';
|
|
3
|
+
|
|
4
|
+
const spainRules: MortgageRules = {
|
|
5
|
+
loanConstraints: { maxLtvPercent: 0.80, maxAmortizationYears: 30 },
|
|
6
|
+
interest: { compounding: 'MONTHLY' },
|
|
7
|
+
transferTax: { brackets: [{ above: 0, rate: 0.07 }] },
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const input: MortgageInput = {
|
|
11
|
+
propertyPrice: 300000,
|
|
12
|
+
downPayment: 60000,
|
|
13
|
+
annualInterestRate: 3.5,
|
|
14
|
+
amortizationYears: 25,
|
|
15
|
+
isFirstTimeBuyer: false,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe('SpainMortgageServiceImpl', () => {
|
|
19
|
+
it('correctly calculates the loan amount', () => {
|
|
20
|
+
const service = new SpainMortgageServiceImpl();
|
|
21
|
+
const result = service.calculate(input, spainRules);
|
|
22
|
+
|
|
23
|
+
// loanAmount = 300000 - 60000 = 240000
|
|
24
|
+
expect(result.loanAmount).toBe(240000);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('correctly calculates transfer tax', () => {
|
|
28
|
+
const service = new SpainMortgageServiceImpl();
|
|
29
|
+
const result = service.calculate(input, spainRules);
|
|
30
|
+
|
|
31
|
+
// transferTax = (300000 - 0) * 0.07 = 21000
|
|
32
|
+
expect(result.transferTax).toBeCloseTo(21000, 2);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('calculates a positive monthly payment', () => {
|
|
36
|
+
const service = new SpainMortgageServiceImpl();
|
|
37
|
+
const result = service.calculate(input, spainRules);
|
|
38
|
+
|
|
39
|
+
expect(result.monthlyPayment).toBeGreaterThan(0);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('total paid is greater than the loan amount', () => {
|
|
43
|
+
const service = new SpainMortgageServiceImpl();
|
|
44
|
+
const result = service.calculate(input, spainRules);
|
|
45
|
+
|
|
46
|
+
expect(result.totalPaid).toBeGreaterThan(result.loanAmount);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('total paid equals monthly payment multiplied by total payments', () => {
|
|
50
|
+
const service = new SpainMortgageServiceImpl();
|
|
51
|
+
const result = service.calculate(input, spainRules);
|
|
52
|
+
|
|
53
|
+
const expectedTotal = result.monthlyPayment * (input.amortizationYears * 12);
|
|
54
|
+
expect(result.totalPaid).toBeCloseTo(expectedTotal, 2);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('amortization schedule has the correct number of years', () => {
|
|
58
|
+
const service = new SpainMortgageServiceImpl();
|
|
59
|
+
const result = service.calculate(input, spainRules);
|
|
60
|
+
|
|
61
|
+
expect(result.amortizationSchedule).toHaveLength(25);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('throws an error when down payment equals or exceeds property price', () => {
|
|
65
|
+
const service = new SpainMortgageServiceImpl();
|
|
66
|
+
const badInput: MortgageInput = { ...input, downPayment: 300000 };
|
|
67
|
+
|
|
68
|
+
expect(() => service.calculate(badInput, spainRules)).toThrow();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { UKInheritanceTaxServiceImpl } from '../src/inheritance-tax/uk/UKInheritanceTaxServiceImpl';
|
|
2
|
+
import { Input, Rules } from '../src/inheritance-tax/uk/domain/types';
|
|
3
|
+
|
|
4
|
+
const ukRules: Rules = {
|
|
5
|
+
nilRateBand: 325000,
|
|
6
|
+
standardRate: 0.40,
|
|
7
|
+
charityRate: 0.36,
|
|
8
|
+
charityThreshold: 10,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
describe('UKInheritanceTaxServiceImpl', () => {
|
|
12
|
+
it('returns zero tax for estate below nil-rate band', () => {
|
|
13
|
+
const input: Input = { estateValue: 200000, charitableGivingPercent: 0 };
|
|
14
|
+
const service = new UKInheritanceTaxServiceImpl(input, ukRules);
|
|
15
|
+
const result = service.calculate();
|
|
16
|
+
|
|
17
|
+
expect(result.inheritanceTax).toBe(0);
|
|
18
|
+
expect(result.taxableEstate).toBe(0);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('returns zero tax for estate at nil-rate band', () => {
|
|
22
|
+
const input: Input = { estateValue: 325000, charitableGivingPercent: 0 };
|
|
23
|
+
const service = new UKInheritanceTaxServiceImpl(input, ukRules);
|
|
24
|
+
const result = service.calculate();
|
|
25
|
+
|
|
26
|
+
expect(result.inheritanceTax).toBe(0);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('applies 40% rate for estate above nil-rate band', () => {
|
|
30
|
+
const input: Input = { estateValue: 500000, charitableGivingPercent: 0 };
|
|
31
|
+
const service = new UKInheritanceTaxServiceImpl(input, ukRules);
|
|
32
|
+
const result = service.calculate();
|
|
33
|
+
|
|
34
|
+
// (500000 - 325000) * 0.40 = 70000
|
|
35
|
+
expect(result.taxableEstate).toBe(175000);
|
|
36
|
+
expect(result.inheritanceTax).toBe(70000);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('applies 36% charity rate when charitable giving >= 10%', () => {
|
|
40
|
+
const input: Input = { estateValue: 500000, charitableGivingPercent: 10 };
|
|
41
|
+
const service = new UKInheritanceTaxServiceImpl(input, ukRules);
|
|
42
|
+
const result = service.calculate();
|
|
43
|
+
|
|
44
|
+
// (500000 - 325000) * 0.36 = 63000
|
|
45
|
+
expect(result.taxableEstate).toBe(175000);
|
|
46
|
+
expect(result.inheritanceTax).toBe(63000);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('applies standard rate when charitable giving < 10%', () => {
|
|
50
|
+
const input: Input = { estateValue: 500000, charitableGivingPercent: 9 };
|
|
51
|
+
const service = new UKInheritanceTaxServiceImpl(input, ukRules);
|
|
52
|
+
const result = service.calculate();
|
|
53
|
+
|
|
54
|
+
expect(result.inheritanceTax).toBe(70000);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('returns zero for zero estate', () => {
|
|
58
|
+
const input: Input = { estateValue: 0, charitableGivingPercent: 0 };
|
|
59
|
+
const service = new UKInheritanceTaxServiceImpl(input, ukRules);
|
|
60
|
+
const result = service.calculate();
|
|
61
|
+
|
|
62
|
+
expect(result.inheritanceTax).toBe(0);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('calculates effective rate correctly', () => {
|
|
66
|
+
const input: Input = { estateValue: 1000000, charitableGivingPercent: 0 };
|
|
67
|
+
const service = new UKInheritanceTaxServiceImpl(input, ukRules);
|
|
68
|
+
const result = service.calculate();
|
|
69
|
+
|
|
70
|
+
expect(result.effectiveRate).toBe((result.inheritanceTax / 1000000) * 100);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { USAInheritanceTaxServiceImpl } from '../src/inheritance-tax/usa/USAInheritanceTaxServiceImpl';
|
|
2
|
+
import { Input, Rules } from '../src/inheritance-tax/usa/domain/types';
|
|
3
|
+
|
|
4
|
+
const usaRules: Rules = {
|
|
5
|
+
exemption: 13610000,
|
|
6
|
+
taxBrackets: [
|
|
7
|
+
{ from: 0, to: 10000, rate: 0.18 },
|
|
8
|
+
{ from: 10000, to: 20000, rate: 0.20 },
|
|
9
|
+
{ from: 20000, to: 40000, rate: 0.22 },
|
|
10
|
+
{ from: 40000, to: 60000, rate: 0.24 },
|
|
11
|
+
{ from: 60000, to: 80000, rate: 0.26 },
|
|
12
|
+
{ from: 80000, to: 100000, rate: 0.28 },
|
|
13
|
+
{ from: 100000, to: 150000, rate: 0.30 },
|
|
14
|
+
{ from: 150000, to: 250000, rate: 0.32 },
|
|
15
|
+
{ from: 250000, to: 500000, rate: 0.34 },
|
|
16
|
+
{ from: 500000, to: 750000, rate: 0.36 },
|
|
17
|
+
{ from: 750000, to: 1000000, rate: 0.38 },
|
|
18
|
+
{ from: 1000000, to: null, rate: 0.40 },
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe('USAInheritanceTaxServiceImpl', () => {
|
|
23
|
+
it('returns zero tax for estate below exemption', () => {
|
|
24
|
+
const input: Input = { estateValue: 10000000 };
|
|
25
|
+
const service = new USAInheritanceTaxServiceImpl(input, usaRules);
|
|
26
|
+
const result = service.calculate();
|
|
27
|
+
|
|
28
|
+
expect(result.inheritanceTax).toBe(0);
|
|
29
|
+
expect(result.taxableEstate).toBe(0);
|
|
30
|
+
expect(result.breakdowns).toHaveLength(0);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('returns zero tax for estate at exactly the exemption', () => {
|
|
34
|
+
const input: Input = { estateValue: 13610000 };
|
|
35
|
+
const service = new USAInheritanceTaxServiceImpl(input, usaRules);
|
|
36
|
+
const result = service.calculate();
|
|
37
|
+
|
|
38
|
+
expect(result.inheritanceTax).toBe(0);
|
|
39
|
+
expect(result.taxableEstate).toBe(0);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('correctly calculates tax for estate just above exemption', () => {
|
|
43
|
+
const input: Input = { estateValue: 13620000 }; // 10000 above exemption
|
|
44
|
+
const service = new USAInheritanceTaxServiceImpl(input, usaRules);
|
|
45
|
+
const result = service.calculate();
|
|
46
|
+
|
|
47
|
+
// 10000 * 0.18 = 1800
|
|
48
|
+
expect(result.taxableEstate).toBe(10000);
|
|
49
|
+
expect(result.inheritanceTax).toBe(1800);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('correctly calculates tax with multiple brackets', () => {
|
|
53
|
+
const input: Input = { estateValue: 13660000 }; // 50000 above exemption
|
|
54
|
+
const service = new USAInheritanceTaxServiceImpl(input, usaRules);
|
|
55
|
+
const result = service.calculate();
|
|
56
|
+
|
|
57
|
+
// 10000 * 0.18 = 1800
|
|
58
|
+
// 10000 * 0.20 = 2000
|
|
59
|
+
// 20000 * 0.22 = 4400
|
|
60
|
+
// 10000 * 0.24 = 2400
|
|
61
|
+
// Total = 10600
|
|
62
|
+
expect(result.taxableEstate).toBe(50000);
|
|
63
|
+
expect(result.inheritanceTax).toBe(10600);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('returns zero for zero estate', () => {
|
|
67
|
+
const input: Input = { estateValue: 0 };
|
|
68
|
+
const service = new USAInheritanceTaxServiceImpl(input, usaRules);
|
|
69
|
+
const result = service.calculate();
|
|
70
|
+
|
|
71
|
+
expect(result.inheritanceTax).toBe(0);
|
|
72
|
+
expect(result.effectiveRate).toBe(0);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('returns zero for negative estate', () => {
|
|
76
|
+
const input: Input = { estateValue: -100000 };
|
|
77
|
+
const service = new USAInheritanceTaxServiceImpl(input, usaRules);
|
|
78
|
+
const result = service.calculate();
|
|
79
|
+
|
|
80
|
+
expect(result.inheritanceTax).toBe(0);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('calculates effective rate correctly', () => {
|
|
84
|
+
const input: Input = { estateValue: 14610000 }; // 1,000,000 above exemption
|
|
85
|
+
const service = new USAInheritanceTaxServiceImpl(input, usaRules);
|
|
86
|
+
const result = service.calculate();
|
|
87
|
+
|
|
88
|
+
expect(result.effectiveRate).toBe((result.inheritanceTax / 14610000) * 100);
|
|
89
|
+
});
|
|
90
|
+
});
|