@novha/calc-engines 6.2.0 → 7.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/canada/CanadaCapitalGainsServiceImpl.js +29 -17
- 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 +25 -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/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/shared/domain/types.js +2 -1
- package/dist/types/capital-gains/canada/CanadaCapitalGainsServiceImpl.d.ts +1 -1
- 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 +15 -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/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/shared/domain/types.d.ts +2 -1
- package/package.json +1 -1
- package/src/capital-gains/canada/CanadaCapitalGainsServiceImpl.ts +34 -21
- 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 +86 -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/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/shared/domain/types.ts +1 -0
- package/test/australia-inheritance-tax.test.ts +35 -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/south-africa-inheritance-tax.test.ts +81 -0
- package/test/uk-inheritance-tax.test.ts +72 -0
- package/test/usa-inheritance-tax.test.ts +90 -0
|
@@ -8,5 +8,6 @@ var CalculatorType;
|
|
|
8
8
|
CalculatorType["LOAN"] = "LOAN";
|
|
9
9
|
CalculatorType["CORPORATE_TAX"] = "CORPORATE_TAX";
|
|
10
10
|
CalculatorType["CAPITAL_GAINS"] = "CAPITAL_GAINS";
|
|
11
|
+
CalculatorType["INHERITANCE_TAX"] = "INHERITANCE_TAX";
|
|
11
12
|
})(CalculatorType || (exports.CalculatorType = CalculatorType = {}));
|
|
12
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
13
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvc2hhcmVkL2RvbWFpbi90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxJQUFZLGNBT1g7QUFQRCxXQUFZLGNBQWM7SUFDdEIsMkNBQXlCLENBQUE7SUFDekIsdUNBQXFCLENBQUE7SUFDckIsK0JBQWEsQ0FBQTtJQUNiLGlEQUErQixDQUFBO0lBQy9CLGlEQUErQixDQUFBO0lBQy9CLHFEQUFtQyxDQUFBO0FBQ3ZDLENBQUMsRUFQVyxjQUFjLDhCQUFkLGNBQWMsUUFPekIiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZW51bSBDYWxjdWxhdG9yVHlwZSB7XG4gICAgSU5DT01FX1RBWCA9ICdJTkNPTUVfVEFYJyxcbiAgICBNT1JUR0FHRSA9ICdNT1JUR0FHRScsXG4gICAgTE9BTiA9ICdMT0FOJyxcbiAgICBDT1JQT1JBVEVfVEFYID0gJ0NPUlBPUkFURV9UQVgnLFxuICAgIENBUElUQUxfR0FJTlMgPSAnQ0FQSVRBTF9HQUlOUycsXG4gICAgSU5IRVJJVEFOQ0VfVEFYID0gJ0lOSEVSSVRBTkNFX1RBWCcsXG59XG5cbmV4cG9ydCBpbnRlcmZhY2UgUnVsZU1ldGEge1xuICAgIGlkOiBzdHJpbmc7XG4gICAgY291bnRyeTogc3RyaW5nO1xuICAgIHJlZ2lvbjogc3RyaW5nO1xuICAgIGNhbGN1bGF0b3I6IENhbGN1bGF0b3JUeXBlO1xuICAgIHZlcnNpb246IHN0cmluZztcbiAgICBlZmZlY3RpdmVmcm9tOiBzdHJpbmc7XG4gICAgZWZmZWN0aXZldG86IHN0cmluZyB8IG51bGw7XG4gICAgc291cmNlPzogUnVsZVNvdXJjZVtdO1xufVxuXG5leHBvcnQgaW50ZXJmYWNlIFJ1bGVTb3VyY2Uge1xuICAgIG5hbWU6IHN0cmluZztcbiAgICB1cmw6IHN0cmluZztcbn0iXX0=
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AustraliaInheritanceTaxService } from "./AustraliaInheritanceTaxService";
|
|
2
|
+
import { Input, Result, Rules } from "./domain/types";
|
|
3
|
+
export declare class AustraliaInheritanceTaxServiceImpl implements AustraliaInheritanceTaxService {
|
|
4
|
+
private _input;
|
|
5
|
+
private _rules;
|
|
6
|
+
constructor(input: Input, rules: Rules);
|
|
7
|
+
calculate(): Result;
|
|
8
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Breakdown } from "../../domain/types";
|
|
2
|
+
export interface Rules {
|
|
3
|
+
applicable: false;
|
|
4
|
+
}
|
|
5
|
+
export interface Input {
|
|
6
|
+
estateValue: number;
|
|
7
|
+
}
|
|
8
|
+
export interface Result {
|
|
9
|
+
taxableEstate: number;
|
|
10
|
+
inheritanceTax: number;
|
|
11
|
+
effectiveRate: number;
|
|
12
|
+
breakdowns: Breakdown[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CanadaInheritanceTaxService } from "./CanadaInheritanceTaxService";
|
|
2
|
+
import { Input, Result, Rules } from "./domain/types";
|
|
3
|
+
export declare class CanadaInheritanceTaxServiceImpl implements CanadaInheritanceTaxService {
|
|
4
|
+
private _input;
|
|
5
|
+
private _rules;
|
|
6
|
+
constructor(input: Input, rules: Rules);
|
|
7
|
+
calculate(): Result;
|
|
8
|
+
private applyBrackets;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Breakdown } from "../../domain/types";
|
|
2
|
+
export interface TaxBracket {
|
|
3
|
+
from: number;
|
|
4
|
+
to: number | null;
|
|
5
|
+
rate: number;
|
|
6
|
+
}
|
|
7
|
+
export interface Rules {
|
|
8
|
+
inclusionRate: number;
|
|
9
|
+
taxBrackets: TaxBracket[];
|
|
10
|
+
}
|
|
11
|
+
export interface Input {
|
|
12
|
+
estateValue: number;
|
|
13
|
+
adjustedCostBase: number;
|
|
14
|
+
}
|
|
15
|
+
export interface Result {
|
|
16
|
+
taxableEstate: number;
|
|
17
|
+
inheritanceTax: number;
|
|
18
|
+
effectiveRate: number;
|
|
19
|
+
breakdowns: Breakdown[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface TaxBracket {
|
|
2
|
+
from: number;
|
|
3
|
+
to: number | null;
|
|
4
|
+
rate: number;
|
|
5
|
+
}
|
|
6
|
+
export interface Breakdown {
|
|
7
|
+
from: string;
|
|
8
|
+
to: string;
|
|
9
|
+
rate: number;
|
|
10
|
+
amount: number;
|
|
11
|
+
}
|
|
12
|
+
export interface Result {
|
|
13
|
+
taxableEstate: number;
|
|
14
|
+
inheritanceTax: number;
|
|
15
|
+
effectiveRate: number;
|
|
16
|
+
breakdowns: Breakdown[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FranceInheritanceTaxService } from "./FranceInheritanceTaxService";
|
|
2
|
+
import { Input, Result, Rules } from "./domain/types";
|
|
3
|
+
export declare class FranceInheritanceTaxServiceImpl implements FranceInheritanceTaxService {
|
|
4
|
+
private _input;
|
|
5
|
+
private _rules;
|
|
6
|
+
constructor(input: Input, rules: Rules);
|
|
7
|
+
calculate(): Result;
|
|
8
|
+
private applyBrackets;
|
|
9
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Breakdown } from "../../domain/types";
|
|
2
|
+
export interface TaxBracket {
|
|
3
|
+
from: number;
|
|
4
|
+
to: number | null;
|
|
5
|
+
rate: number;
|
|
6
|
+
}
|
|
7
|
+
export interface RelationshipClass {
|
|
8
|
+
exemption: number;
|
|
9
|
+
brackets: TaxBracket[];
|
|
10
|
+
}
|
|
11
|
+
export interface Rules {
|
|
12
|
+
relationships: {
|
|
13
|
+
spouse: RelationshipClass;
|
|
14
|
+
child: RelationshipClass;
|
|
15
|
+
sibling: RelationshipClass;
|
|
16
|
+
other: RelationshipClass;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export type RelationshipType = 'spouse' | 'child' | 'sibling' | 'other';
|
|
20
|
+
export interface Input {
|
|
21
|
+
estateValue: number;
|
|
22
|
+
relationship: RelationshipType;
|
|
23
|
+
}
|
|
24
|
+
export interface Result {
|
|
25
|
+
taxableEstate: number;
|
|
26
|
+
inheritanceTax: number;
|
|
27
|
+
effectiveRate: number;
|
|
28
|
+
breakdowns: Breakdown[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GermanyInheritanceTaxService } from "./GermanyInheritanceTaxService";
|
|
2
|
+
import { Input, Result, Rules } from "./domain/types";
|
|
3
|
+
export declare class GermanyInheritanceTaxServiceImpl implements GermanyInheritanceTaxService {
|
|
4
|
+
private _input;
|
|
5
|
+
private _rules;
|
|
6
|
+
constructor(input: Input, rules: Rules);
|
|
7
|
+
calculate(): Result;
|
|
8
|
+
private applyBrackets;
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Breakdown } from "../../domain/types";
|
|
2
|
+
export interface TaxBracket {
|
|
3
|
+
from: number;
|
|
4
|
+
to: number | null;
|
|
5
|
+
rate: number;
|
|
6
|
+
}
|
|
7
|
+
export interface TaxClass {
|
|
8
|
+
exemption: number;
|
|
9
|
+
brackets: TaxBracket[];
|
|
10
|
+
}
|
|
11
|
+
export interface Rules {
|
|
12
|
+
taxClasses: {
|
|
13
|
+
I: TaxClass;
|
|
14
|
+
II: TaxClass;
|
|
15
|
+
III: TaxClass;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export type TaxClassName = 'I' | 'II' | 'III';
|
|
19
|
+
export interface Input {
|
|
20
|
+
estateValue: number;
|
|
21
|
+
taxClass: TaxClassName;
|
|
22
|
+
}
|
|
23
|
+
export interface Result {
|
|
24
|
+
taxableEstate: number;
|
|
25
|
+
inheritanceTax: number;
|
|
26
|
+
effectiveRate: number;
|
|
27
|
+
breakdowns: Breakdown[];
|
|
28
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CanadaInheritanceTaxServiceImpl as CanadaInheritanceTaxService } from './canada/CanadaInheritanceTaxServiceImpl';
|
|
2
|
+
import { Input as CanadaInheritanceTaxInput, Rules as CanadaInheritanceTaxRules, Result as CanadaInheritanceTaxResult } from './canada/domain/types';
|
|
3
|
+
import { FranceInheritanceTaxServiceImpl as FranceInheritanceTaxService } from './france/FranceInheritanceTaxServiceImpl';
|
|
4
|
+
import { Input as FranceInheritanceTaxInput, Rules as FranceInheritanceTaxRules, Result as FranceInheritanceTaxResult } from './france/domain/types';
|
|
5
|
+
import { SouthAfricaInheritanceTaxServiceImpl as SouthAfricaInheritanceTaxService } from './south-africa/SouthAfricaInheritanceTaxServiceImpl';
|
|
6
|
+
import { Input as SouthAfricaInheritanceTaxInput, Rules as SouthAfricaInheritanceTaxRules, Result as SouthAfricaInheritanceTaxResult } from './south-africa/domain/types';
|
|
7
|
+
import { AustraliaInheritanceTaxServiceImpl as AustraliaInheritanceTaxService } from './australia/AustraliaInheritanceTaxServiceImpl';
|
|
8
|
+
import { Input as AustraliaInheritanceTaxInput, Rules as AustraliaInheritanceTaxRules, Result as AustraliaInheritanceTaxResult } from './australia/domain/types';
|
|
9
|
+
import { UKInheritanceTaxServiceImpl as UKInheritanceTaxService } from './uk/UKInheritanceTaxServiceImpl';
|
|
10
|
+
import { Input as UKInheritanceTaxInput, Rules as UKInheritanceTaxRules, Result as UKInheritanceTaxResult } from './uk/domain/types';
|
|
11
|
+
import { USAInheritanceTaxServiceImpl as USAInheritanceTaxService } from './usa/USAInheritanceTaxServiceImpl';
|
|
12
|
+
import { Input as USAInheritanceTaxInput, Rules as USAInheritanceTaxRules, Result as USAInheritanceTaxResult } from './usa/domain/types';
|
|
13
|
+
import { GermanyInheritanceTaxServiceImpl as GermanyInheritanceTaxService } from './germany/GermanyInheritanceTaxServiceImpl';
|
|
14
|
+
import { Input as GermanyInheritanceTaxInput, Rules as GermanyInheritanceTaxRules, Result as GermanyInheritanceTaxResult } from './germany/domain/types';
|
|
15
|
+
export { CanadaInheritanceTaxService, CanadaInheritanceTaxInput, CanadaInheritanceTaxRules, CanadaInheritanceTaxResult, FranceInheritanceTaxService, FranceInheritanceTaxInput, FranceInheritanceTaxRules, FranceInheritanceTaxResult, SouthAfricaInheritanceTaxService, SouthAfricaInheritanceTaxInput, SouthAfricaInheritanceTaxRules, SouthAfricaInheritanceTaxResult, AustraliaInheritanceTaxService, AustraliaInheritanceTaxInput, AustraliaInheritanceTaxRules, AustraliaInheritanceTaxResult, UKInheritanceTaxService, UKInheritanceTaxInput, UKInheritanceTaxRules, UKInheritanceTaxResult, USAInheritanceTaxService, USAInheritanceTaxInput, USAInheritanceTaxRules, USAInheritanceTaxResult, GermanyInheritanceTaxService, GermanyInheritanceTaxInput, GermanyInheritanceTaxRules, GermanyInheritanceTaxResult, };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SouthAfricaInheritanceTaxService } from "./SouthAfricaInheritanceTaxService";
|
|
2
|
+
import { Input, Result, Rules } from "./domain/types";
|
|
3
|
+
export declare class SouthAfricaInheritanceTaxServiceImpl implements SouthAfricaInheritanceTaxService {
|
|
4
|
+
private _input;
|
|
5
|
+
private _rules;
|
|
6
|
+
constructor(input: Input, rules: Rules);
|
|
7
|
+
calculate(): Result;
|
|
8
|
+
private applyBrackets;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Breakdown } from "../../domain/types";
|
|
2
|
+
export interface TaxBracket {
|
|
3
|
+
from: number;
|
|
4
|
+
to: number | null;
|
|
5
|
+
rate: number;
|
|
6
|
+
}
|
|
7
|
+
export interface Rules {
|
|
8
|
+
primaryAbatement: number;
|
|
9
|
+
taxBrackets: TaxBracket[];
|
|
10
|
+
}
|
|
11
|
+
export interface Input {
|
|
12
|
+
estateValue: number;
|
|
13
|
+
deductions: number;
|
|
14
|
+
}
|
|
15
|
+
export interface Result {
|
|
16
|
+
taxableEstate: number;
|
|
17
|
+
inheritanceTax: number;
|
|
18
|
+
effectiveRate: number;
|
|
19
|
+
breakdowns: Breakdown[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UKInheritanceTaxService } from "./UKInheritanceTaxService";
|
|
2
|
+
import { Input, Result, Rules } from "./domain/types";
|
|
3
|
+
export declare class UKInheritanceTaxServiceImpl implements UKInheritanceTaxService {
|
|
4
|
+
private _input;
|
|
5
|
+
private _rules;
|
|
6
|
+
constructor(input: Input, rules: Rules);
|
|
7
|
+
calculate(): Result;
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Breakdown } from "../../domain/types";
|
|
2
|
+
export interface Rules {
|
|
3
|
+
nilRateBand: number;
|
|
4
|
+
standardRate: number;
|
|
5
|
+
charityRate: number;
|
|
6
|
+
charityThreshold: number;
|
|
7
|
+
}
|
|
8
|
+
export interface Input {
|
|
9
|
+
estateValue: number;
|
|
10
|
+
charitableGivingPercent: number;
|
|
11
|
+
}
|
|
12
|
+
export interface Result {
|
|
13
|
+
taxableEstate: number;
|
|
14
|
+
inheritanceTax: number;
|
|
15
|
+
effectiveRate: number;
|
|
16
|
+
breakdowns: Breakdown[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { USAInheritanceTaxService } from "./USAInheritanceTaxService";
|
|
2
|
+
import { Input, Result, Rules } from "./domain/types";
|
|
3
|
+
export declare class USAInheritanceTaxServiceImpl implements USAInheritanceTaxService {
|
|
4
|
+
private _input;
|
|
5
|
+
private _rules;
|
|
6
|
+
constructor(input: Input, rules: Rules);
|
|
7
|
+
calculate(): Result;
|
|
8
|
+
private applyBrackets;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Breakdown } from "../../domain/types";
|
|
2
|
+
export interface TaxBracket {
|
|
3
|
+
from: number;
|
|
4
|
+
to: number | null;
|
|
5
|
+
rate: number;
|
|
6
|
+
}
|
|
7
|
+
export interface Rules {
|
|
8
|
+
exemption: number;
|
|
9
|
+
taxBrackets: TaxBracket[];
|
|
10
|
+
}
|
|
11
|
+
export interface Input {
|
|
12
|
+
estateValue: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Result {
|
|
15
|
+
taxableEstate: number;
|
|
16
|
+
inheritanceTax: number;
|
|
17
|
+
effectiveRate: number;
|
|
18
|
+
breakdowns: Breakdown[];
|
|
19
|
+
}
|
|
@@ -3,7 +3,8 @@ export declare enum CalculatorType {
|
|
|
3
3
|
MORTGAGE = "MORTGAGE",
|
|
4
4
|
LOAN = "LOAN",
|
|
5
5
|
CORPORATE_TAX = "CORPORATE_TAX",
|
|
6
|
-
CAPITAL_GAINS = "CAPITAL_GAINS"
|
|
6
|
+
CAPITAL_GAINS = "CAPITAL_GAINS",
|
|
7
|
+
INHERITANCE_TAX = "INHERITANCE_TAX"
|
|
7
8
|
}
|
|
8
9
|
export interface RuleMeta {
|
|
9
10
|
id: string;
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Result } from "../domain/types";
|
|
1
|
+
import { Breakdown, Result } from "../domain/types";
|
|
2
2
|
import { CanadaCapitalGainsService } from "./CanadaCapitalGainsService";
|
|
3
3
|
import { Input, Rules, TaxBracket } from "./domain/types";
|
|
4
4
|
|
|
@@ -27,43 +27,56 @@ export class CanadaCapitalGainsServiceImpl implements CanadaCapitalGainsService
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const taxableGain = gain * this._rules.inclusionRate;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const baseIncome = this._input.totalTaxableIncome;
|
|
33
|
-
|
|
34
|
-
const incomeWithGain = baseIncome + taxableGain;
|
|
35
|
-
|
|
36
|
-
const baseTax = this.calculateProgressiveTax(baseIncome, this._rules.taxBrackets);
|
|
37
|
-
const taxWithGain = this.calculateProgressiveTax(incomeWithGain, this._rules.taxBrackets);
|
|
38
|
-
|
|
39
|
-
const capitalGainTax = taxWithGain - baseTax;
|
|
30
|
+
const otherIncome = this._input.totalTaxableIncome - gain;
|
|
31
|
+
const { tax, breakdowns } = this.applyBrackets(taxableGain, otherIncome, this._rules.taxBrackets);
|
|
40
32
|
|
|
41
33
|
return {
|
|
42
34
|
taxableGain,
|
|
43
|
-
capitalGainTax,
|
|
35
|
+
capitalGainTax: tax,
|
|
44
36
|
socialContributions: 0,
|
|
45
37
|
netInvestmentIncomeTax: 0,
|
|
46
|
-
totalTax:
|
|
47
|
-
effectiveRate: gain > 0 ? (
|
|
48
|
-
breakdowns
|
|
38
|
+
totalTax: tax,
|
|
39
|
+
effectiveRate: gain > 0 ? (tax / gain) * 100 : 0,
|
|
40
|
+
breakdowns,
|
|
49
41
|
};
|
|
50
42
|
}
|
|
51
43
|
|
|
52
|
-
private
|
|
44
|
+
private applyBrackets(
|
|
45
|
+
taxableGain: number,
|
|
46
|
+
otherIncome: number,
|
|
47
|
+
brackets: TaxBracket[],
|
|
48
|
+
): { tax: number; breakdowns: Breakdown[] } {
|
|
53
49
|
let tax = 0;
|
|
50
|
+
const breakdowns: Breakdown[] = [];
|
|
51
|
+
let remaining = taxableGain;
|
|
52
|
+
let incomeUsed = otherIncome;
|
|
54
53
|
|
|
55
54
|
for (const bracket of brackets) {
|
|
55
|
+
if (remaining <= 0) break;
|
|
56
|
+
|
|
56
57
|
const upper = bracket.to ?? Infinity;
|
|
57
58
|
|
|
58
|
-
if (
|
|
59
|
+
if (incomeUsed >= upper) continue;
|
|
59
60
|
|
|
60
|
-
const
|
|
61
|
+
const bracketStart = Math.max(bracket.from, incomeUsed);
|
|
62
|
+
const bracketSpace = upper - bracketStart;
|
|
63
|
+
const taxable = Math.min(bracketSpace, remaining);
|
|
61
64
|
|
|
62
65
|
if (taxable > 0) {
|
|
63
|
-
|
|
66
|
+
const bracketTax = taxable * bracket.rate;
|
|
67
|
+
tax += bracketTax;
|
|
68
|
+
remaining -= taxable;
|
|
69
|
+
incomeUsed += taxable;
|
|
70
|
+
|
|
71
|
+
breakdowns.push({
|
|
72
|
+
from: `${bracket.from}`,
|
|
73
|
+
to: `${bracket.to ?? 'Above'}`,
|
|
74
|
+
rate: bracket.rate,
|
|
75
|
+
amount: bracketTax,
|
|
76
|
+
});
|
|
64
77
|
}
|
|
65
78
|
}
|
|
66
79
|
|
|
67
|
-
return tax;
|
|
80
|
+
return { tax, breakdowns };
|
|
68
81
|
}
|
|
69
|
-
}
|
|
82
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AustraliaInheritanceTaxService } from "./AustraliaInheritanceTaxService";
|
|
2
|
+
import { Input, Result, Rules } from "./domain/types";
|
|
3
|
+
|
|
4
|
+
export class AustraliaInheritanceTaxServiceImpl implements AustraliaInheritanceTaxService {
|
|
5
|
+
private _input: Input;
|
|
6
|
+
private _rules: Rules;
|
|
7
|
+
|
|
8
|
+
constructor(input: Input, rules: Rules) {
|
|
9
|
+
this._input = input;
|
|
10
|
+
this._rules = rules;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
calculate(): Result {
|
|
14
|
+
return {
|
|
15
|
+
taxableEstate: 0,
|
|
16
|
+
inheritanceTax: 0,
|
|
17
|
+
effectiveRate: 0,
|
|
18
|
+
breakdowns: [],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Breakdown } from "../../domain/types";
|
|
2
|
+
|
|
3
|
+
export interface Rules {
|
|
4
|
+
applicable: false;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface Input {
|
|
8
|
+
estateValue: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Result {
|
|
12
|
+
taxableEstate: number;
|
|
13
|
+
inheritanceTax: number;
|
|
14
|
+
effectiveRate: number;
|
|
15
|
+
breakdowns: Breakdown[];
|
|
16
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Breakdown } from "../domain/types";
|
|
2
|
+
import { CanadaInheritanceTaxService } from "./CanadaInheritanceTaxService";
|
|
3
|
+
import { Input, Result, Rules, TaxBracket } from "./domain/types";
|
|
4
|
+
|
|
5
|
+
export class CanadaInheritanceTaxServiceImpl implements CanadaInheritanceTaxService {
|
|
6
|
+
private _input: Input;
|
|
7
|
+
private _rules: Rules;
|
|
8
|
+
|
|
9
|
+
constructor(input: Input, rules: Rules) {
|
|
10
|
+
this._input = input;
|
|
11
|
+
this._rules = rules;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
calculate(): Result {
|
|
15
|
+
const gain = this._input.estateValue - this._input.adjustedCostBase;
|
|
16
|
+
|
|
17
|
+
if (gain <= 0) {
|
|
18
|
+
return {
|
|
19
|
+
taxableEstate: 0,
|
|
20
|
+
inheritanceTax: 0,
|
|
21
|
+
effectiveRate: 0,
|
|
22
|
+
breakdowns: [],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const taxableGain = gain * this._rules.inclusionRate;
|
|
27
|
+
const { tax, breakdowns } = this.applyBrackets(taxableGain, this._rules.taxBrackets);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
taxableEstate: taxableGain,
|
|
31
|
+
inheritanceTax: tax,
|
|
32
|
+
effectiveRate: gain > 0 ? (tax / gain) * 100 : 0,
|
|
33
|
+
breakdowns,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private applyBrackets(
|
|
38
|
+
taxableAmount: number,
|
|
39
|
+
brackets: TaxBracket[],
|
|
40
|
+
): { tax: number; breakdowns: Breakdown[] } {
|
|
41
|
+
let tax = 0;
|
|
42
|
+
const breakdowns: Breakdown[] = [];
|
|
43
|
+
|
|
44
|
+
for (const bracket of brackets) {
|
|
45
|
+
if (taxableAmount <= bracket.from) break;
|
|
46
|
+
|
|
47
|
+
const upper = bracket.to ?? taxableAmount;
|
|
48
|
+
const taxable = Math.min(upper, taxableAmount) - bracket.from;
|
|
49
|
+
|
|
50
|
+
if (taxable > 0) {
|
|
51
|
+
const bracketTax = taxable * bracket.rate;
|
|
52
|
+
tax += bracketTax;
|
|
53
|
+
|
|
54
|
+
breakdowns.push({
|
|
55
|
+
from: `${bracket.from}`,
|
|
56
|
+
to: `${bracket.to ?? 'Above'}`,
|
|
57
|
+
rate: bracket.rate,
|
|
58
|
+
amount: bracketTax,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return { tax, breakdowns };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Breakdown } from "../../domain/types";
|
|
2
|
+
|
|
3
|
+
export interface TaxBracket {
|
|
4
|
+
from: number;
|
|
5
|
+
to: number | null;
|
|
6
|
+
rate: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Rules {
|
|
10
|
+
inclusionRate: number;
|
|
11
|
+
taxBrackets: TaxBracket[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface Input {
|
|
15
|
+
estateValue: number;
|
|
16
|
+
adjustedCostBase: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Result {
|
|
20
|
+
taxableEstate: number;
|
|
21
|
+
inheritanceTax: number;
|
|
22
|
+
effectiveRate: number;
|
|
23
|
+
breakdowns: Breakdown[];
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface TaxBracket {
|
|
2
|
+
from: number;
|
|
3
|
+
to: number | null;
|
|
4
|
+
rate: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface Breakdown {
|
|
8
|
+
from: string;
|
|
9
|
+
to: string;
|
|
10
|
+
rate: number;
|
|
11
|
+
amount: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface Result {
|
|
15
|
+
taxableEstate: number;
|
|
16
|
+
inheritanceTax: number;
|
|
17
|
+
effectiveRate: number;
|
|
18
|
+
breakdowns: Breakdown[];
|
|
19
|
+
}
|