@equisoft/tax-ca 2022.7.0 → 2022.7.1-snapshot.20220601164236

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/.eslintrc.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "extends": [
3
+ "@equisoft/eslint-config-typescript",
4
+ "plugin:import/typescript"
5
+ ],
6
+ "settings": {
7
+ "import/resolver": {
8
+ "typescript": {
9
+ "project": [
10
+ "tsconfig.json",
11
+ "tests/tsconfig.json"
12
+ ]
13
+ }
14
+ }
15
+ },
16
+ "rules": {
17
+ "import/no-extraneous-dependencies": [
18
+ "error",
19
+ {
20
+ "devDependencies": [
21
+ "/*.js",
22
+ "test/**/*",
23
+ "**/*.test.{js,jsx,ts,tsx}",
24
+ "**/*.spec.{js,jsx,ts,tsx}"
25
+ ]
26
+ }
27
+ ]
28
+ },
29
+ "overrides": [
30
+ {
31
+ "files": ["test/**/*"],
32
+ "rules": {
33
+ "import/no-unresolved": [
34
+ "error",
35
+ {
36
+ "ignore": ["^~/"]
37
+ }
38
+ ]
39
+ }
40
+ }
41
+ ]
42
+ }
package/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ nodejs 16.15.0
package/RELEASE.md ADDED
@@ -0,0 +1,29 @@
1
+ # Upgrade Steps
2
+
3
+ - [ACTION REQUIRED]
4
+ - You must now use `import { } from @equisoft/tax-ca` instead of `import * from @equisopft/tax-ca`
5
+
6
+ # Breaking Changes
7
+
8
+ - Function `IncomeTax.calculateTaxes` has been renamed to `IncomeTax.getTaxes`, method signature has changed
9
+ -
10
+
11
+ # New Features
12
+
13
+ -
14
+ -
15
+
16
+ # Bug Fixes
17
+
18
+ - Fix the error in file A #1 (@toby-daigle)
19
+ -
20
+
21
+ # Improvements
22
+
23
+ -
24
+ -
25
+
26
+ # Other Changes
27
+
28
+ -
29
+ -
@@ -3,5 +3,5 @@ export interface RegisteredRetirementIncomeFund {
3
3
  [K: number]: number;
4
4
  };
5
5
  }
6
- export declare function getMinimumWithdrawalPercentage(age: number): number;
7
6
  export declare const RRIF: RegisteredRetirementIncomeFund;
7
+ export declare function getMinimumWithdrawalPercentage(age: number): number;
@@ -1,19 +1,13 @@
1
1
  "use strict";
2
- // tslint:disable:max-line-length
3
2
  /*
4
- Sources
5
- http://www.getsmarteraboutmoney.ca/en/managing-your-money/investing/rrifs-and-annuities/Pages/Making-withdrawals-from-your-RRIF.aspx
3
+ Sources
4
+ http://www.getsmarteraboutmoney.ca/en/managing-your-money/investing/rrifs-and-annuities/Pages/Making-withdrawals-from-your-RRIF.aspx
6
5
 
7
- Revised
8
- 2021-12-21
9
- */
10
- // tslint:enable:max-line-length
6
+ Revised
7
+ 2021-12-21
8
+ */
11
9
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.RRIF = exports.getMinimumWithdrawalPercentage = void 0;
13
- function getMinimumWithdrawalPercentage(age) {
14
- return age >= 71 ? exports.RRIF.MIN_WITHDRAWAL_PCT[age] : 1 / (90 - age);
15
- }
16
- exports.getMinimumWithdrawalPercentage = getMinimumWithdrawalPercentage;
10
+ exports.getMinimumWithdrawalPercentage = exports.RRIF = void 0;
17
11
  exports.RRIF = {
18
12
  MIN_WITHDRAWAL_PCT: {
19
13
  50: 0.0250,
@@ -64,3 +58,7 @@ exports.RRIF = {
64
58
  95: 0.20,
65
59
  },
66
60
  };
61
+ function getMinimumWithdrawalPercentage(age) {
62
+ return age >= 71 ? exports.RRIF.MIN_WITHDRAWAL_PCT[age] : 1 / (90 - age);
63
+ }
64
+ exports.getMinimumWithdrawalPercentage = getMinimumWithdrawalPercentage;
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
- // tslint:disable:max-line-length
3
2
  /*
4
- Sources
5
- https://www.canada.ca/en/revenue-agency/services/tax/registered-plans-administrators/pspa/mp-rrsp-dpsp-tfsa-limits-ympe.html
3
+ Sources
4
+ https://www.canada.ca/en/revenue-agency/services/tax/registered-plans-administrators/pspa/mp-rrsp-dpsp-tfsa-limits-ympe.html
6
5
 
7
- Revised
8
- 2021-12-21
9
- */
10
- // tslint:enable:max-line-length
6
+ Revised
7
+ 2021-12-21
8
+ */
11
9
  Object.defineProperty(exports, "__esModule", { value: true });
12
10
  exports.RRSP = void 0;
13
11
  exports.RRSP = {
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
- // tslint:disable:max-line-length
3
2
  /*
4
- Sources
5
- https://www.canada.ca/en/revenue-agency/services/tax/registered-plans-administrators/pspa/mp-rrsp-dpsp-tfsa-limits-ympe.html
3
+ Sources
4
+ https://www.canada.ca/en/revenue-agency/services/tax/registered-plans-administrators/pspa/mp-rrsp-dpsp-tfsa-limits-ympe.html
6
5
 
7
- Revised
8
- 2021-12-21
9
- */
10
- // tslint:enable:max-line-length
6
+ Revised
7
+ 2021-12-21
8
+ */
11
9
  Object.defineProperty(exports, "__esModule", { value: true });
12
10
  exports.TFSA = void 0;
13
11
  exports.TFSA = {
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  /*
3
- Sources
4
- https://www.bankofcanada.ca/rates/price-indexes/cpi/
5
- Use column v41690973
3
+ Sources
4
+ https://www.bankofcanada.ca/rates/price-indexes/cpi/
5
+ Use column v41690973
6
6
 
7
- NOT USED BY FNA-ENGINE
8
- Revised
9
- 2021-12-21
10
- */
7
+ NOT USED BY FNA-ENGINE
8
+ Revised
9
+ 2021-12-21
10
+ */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CONSUMER_PRICE_INDEX = void 0;
13
13
  exports.CONSUMER_PRICE_INDEX = {
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  /*
3
- Sources
4
- https://www.iqpf.org/docs/default-source/outils/iqpf-normes-projection2021.pdf
3
+ Sources
4
+ https://www.iqpf.org/docs/default-source/outils/iqpf-normes-projection2021.pdf
5
5
 
6
- Revised
7
- 2021-05-05
8
- */
6
+ Revised
7
+ 2021-05-05
8
+ */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.IQPF = void 0;
11
11
  exports.IQPF = {
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  /*
3
- Sources
4
- http://app.iqpf.org/?locale=en#/guidelines/life-expectancy
3
+ Sources
4
+ http://app.iqpf.org/?locale=en#/guidelines/life-expectancy
5
5
 
6
- Revised
7
- 2020-12-21
8
- */
6
+ Revised
7
+ 2020-12-21
8
+ */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.LIFE_EXPECTANCY = void 0;
11
11
  exports.LIFE_EXPECTANCY = {
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
  /*
3
- Sources
4
- https://www.finance-investissement.com/zone-experts_/martin-dupras/la-valeur-reelle-de-reporter-la-rente-du-rrq/
5
- Description
6
- Cumulative difference in %, according to the table calculated by Martin Dupras,
7
- from the reference age of 65, divided by 12 months.
8
- The formula consuming these values is only utilized by kronos-fna.
9
- Revised
10
- 2022-04-28
11
- */
3
+ Sources
4
+ https://www.finance-investissement.com/zone-experts_/martin-dupras/la-valeur-reelle-de-reporter-la-rente-du-rrq/
5
+
6
+ Description
7
+ Cumulative difference in %, according to the table calculated by Martin Dupras,
8
+ from the reference age of 65, divided by 12 months.
9
+ The formula consuming these values is only utilized by kronos-fna.
10
+
11
+ Revised
12
+ 2022-04-28
13
+ */
12
14
  Object.defineProperty(exports, "__esModule", { value: true });
13
15
  exports.PPP_INCREASE_FACTOR = void 0;
14
16
  exports.PPP_INCREASE_FACTOR = {
@@ -80,7 +80,7 @@ exports.CPP = {
80
80
  }
81
81
  let monthsDelta = (0, math_1.clamp)(monthsToRequestDate, monthsToMinRequestDate, monthsToMaxRequestDate);
82
82
  monthsDelta -= Math.max(monthsToLastBirthDay, monthsToReferenceDate);
83
- return 1 + monthsDelta * (monthsDelta >= 0 ? BONUS : PENALTY);
83
+ return 1 + (monthsDelta * (monthsDelta >= 0 ? BONUS : PENALTY));
84
84
  },
85
85
  getAverageIndexationRate() {
86
86
  const sum = this.INDEXATION_RATE_REFERENCES.reduce((previous, current) => previous + current[1], 0);
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  /*
3
- Sources
4
- https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/benefit-amount.html
5
- https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/recovery-tax.html
6
- https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/eligibility.html (delay bonus)
7
- https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/payments.html
3
+ Sources
4
+ https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/benefit-amount.html
5
+ https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/recovery-tax.html
6
+ https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/eligibility.html (delay bonus)
7
+ https://www.canada.ca/en/services/benefits/publicpensions/cpp/old-age-security/payments.html
8
8
 
9
- Revised
10
- 2022-04-07
11
- */
9
+ Revised
10
+ 2022-04-07
11
+ */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.OAS = void 0;
14
14
  const date_1 = require("../utils/date");
@@ -1,4 +1,4 @@
1
- import { Rate } from '..';
1
+ import { Rate } from '../taxes/income-tax';
2
2
  export interface Factor {
3
3
  FROM: number;
4
4
  TO: number;
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
- // tslint:disable:max-line-length
3
2
  /*
4
- Sources
5
- http://www.rrq.gouv.qc.ca/en/programmes/regime_rentes/regime_chiffres/Pages/regime_chiffres.aspx
6
- https://www.rrq.gouv.qc.ca/en/services/publications/regime_rentes/retraite/Pages/tableaux-revenus-travail-admissibles.aspx
3
+ Sources
4
+ http://www.rrq.gouv.qc.ca/en/programmes/regime_rentes/regime_chiffres/Pages/regime_chiffres.aspx
5
+ https://www.rrq.gouv.qc.ca/en/services/publications/regime_rentes/retraite/Pages/tableaux-revenus-travail-admissibles.aspx
7
6
 
8
- Revised
9
- 2022-01-20
10
- */
11
- // tslint:enable:max-line-length
7
+ Revised
8
+ 2022-01-20
9
+ */
12
10
  Object.defineProperty(exports, "__esModule", { value: true });
13
11
  exports.QPP = void 0;
14
12
  const date_1 = require("../utils/date");
@@ -76,7 +74,7 @@ exports.QPP = {
76
74
  }
77
75
  let monthsDelta = (0, math_1.clamp)(monthsToRequestDate, monthsToMinRequestDate, monthsToMaxRequestDate);
78
76
  monthsDelta -= Math.max(monthsToLastBirthDay, monthsToReferenceDate);
79
- return 1 + monthsDelta * (monthsDelta >= 0 ? BONUS : PENALTY);
77
+ return 1 + (monthsDelta * (monthsDelta >= 0 ? BONUS : PENALTY));
80
78
  },
81
79
  getAverageIndexationRate() {
82
80
  const sum = this.INDEXATION_RATE_REFERENCES.reduce((previous, current) => previous + current[1], 0);
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  /*
3
- Sources
4
- Non-eligible Dividends: https://www.taxtips.ca/dtc/non-eligible-dividend-tax-credit.htm
5
- Eligible Dividends: https://www.taxtips.ca/dtc/eligible-dividends/eligible-dividend-tax-credit-rates.htm
3
+ Sources
4
+ Non-eligible Dividends: https://www.taxtips.ca/dtc/non-eligible-dividend-tax-credit.htm
5
+ Eligible Dividends: https://www.taxtips.ca/dtc/eligible-dividends/eligible-dividend-tax-credit-rates.htm
6
6
 
7
- Revised
8
- 2022-01-04
9
- */
7
+ Revised
8
+ 2022-01-04
9
+ */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.ELIGIBLE_DIVIDEND = exports.NON_ELIGIBLE_DIVIDEND = void 0;
12
12
  exports.NON_ELIGIBLE_DIVIDEND = {
@@ -1,13 +1,11 @@
1
1
  "use strict";
2
- // tslint:disable:max-line-length
3
2
  /*
4
- Sources
5
- https://www.canada.ca/en/employment-social-development/programs/ei/ei-list/ei-employers/2022-maximum-insurable-earnings.html
3
+ Sources
4
+ https://www.canada.ca/en/employment-social-development/programs/ei/ei-list/ei-employers/2022-maximum-insurable-earnings.html
6
5
 
7
- Revised
8
- 2021-12-22
9
- */
10
- // tslint:enable:max-line-length
6
+ Revised
7
+ 2021-12-22
8
+ */
11
9
  Object.defineProperty(exports, "__esModule", { value: true });
12
10
  exports.EI = void 0;
13
11
  exports.EI = {
@@ -15,16 +15,16 @@ export declare type TaxBrackets = {
15
15
  [key in ProvinceCode | FederalCode]: TaxBracket;
16
16
  };
17
17
  export declare const TAX_BRACKETS: TaxBrackets;
18
- export declare function getFederalTaxAmount(provincialCode: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number;
19
18
  export declare function getFederalBaseTaxAmount(grossIncome: number, inflationRate?: number, yearsToInflate?: number): number;
20
- export declare function getProvincialTaxAmount(province: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number;
21
- export declare function getProvincialBaseTaxAmount(province: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number;
22
- export declare function getProvincialSurtaxAmount(province: ProvinceCode, baseTaxAmount: number, inflationRate?: number, yearsToInflate?: number): number;
23
19
  export declare function getFederalBaseCredit(inflationRate: number, yearsToInflate: number): number;
24
20
  export declare function getProvincialAbatement(province: ProvinceCode, federalTaxAmount: number): number;
21
+ export declare function getFederalTaxAmount(provincialCode: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number;
22
+ export declare function getProvincialSurtaxAmount(province: ProvinceCode, baseTaxAmount: number, inflationRate?: number, yearsToInflate?: number): number;
23
+ export declare function getProvincialBaseTaxAmount(province: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number;
24
+ export declare function getProvincialBaseCredit(province: ProvinceCode, inflationRate: number, yearsToInflate: number): number;
25
+ export declare function getProvincialTaxAmount(province: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number;
25
26
  export declare function getFederalMarginalRate(provincialCode: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number;
26
27
  export declare function getProvincialMarginalRate(provincialCode: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number;
27
- export declare function getProvincialBaseCredit(province: ProvinceCode, inflationRate: number, yearsToInflate: number): number;
28
28
  export declare function getTotalMarginalRate(provincialCode: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number;
29
29
  export declare function getMaxProvincialMarginalRate(provincialCode: ProvinceCode): number;
30
30
  export declare function getMaxFederalMarginalRate(provincialCode: ProvinceCode): number;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- // tslint:disable:max-line-length
3
2
  /*
4
3
  Sources
5
4
  http://www.taxtips.ca/marginaltaxrates.htm
@@ -8,9 +7,8 @@ Sources
8
7
  Revised
9
8
  2022-01-11
10
9
  */
11
- // tslint:enable:max-line-length
12
10
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.getEffectiveRate = exports.getTotalTaxAmount = exports.getTotalMaxMarginalRate = exports.getMaxFederalMarginalRate = exports.getMaxProvincialMarginalRate = exports.getTotalMarginalRate = exports.getProvincialBaseCredit = exports.getProvincialMarginalRate = exports.getFederalMarginalRate = exports.getProvincialAbatement = exports.getFederalBaseCredit = exports.getProvincialSurtaxAmount = exports.getProvincialBaseTaxAmount = exports.getProvincialTaxAmount = exports.getFederalBaseTaxAmount = exports.getFederalTaxAmount = exports.TAX_BRACKETS = void 0;
11
+ exports.getEffectiveRate = exports.getTotalTaxAmount = exports.getTotalMaxMarginalRate = exports.getMaxFederalMarginalRate = exports.getMaxProvincialMarginalRate = exports.getTotalMarginalRate = exports.getProvincialMarginalRate = exports.getFederalMarginalRate = exports.getProvincialTaxAmount = exports.getProvincialBaseCredit = exports.getProvincialBaseTaxAmount = exports.getProvincialSurtaxAmount = exports.getFederalTaxAmount = exports.getProvincialAbatement = exports.getFederalBaseCredit = exports.getFederalBaseTaxAmount = exports.TAX_BRACKETS = void 0;
14
12
  const code_types_1 = require("../misc/code-types");
15
13
  const utils_1 = require("../utils");
16
14
  const collections_1 = require("../utils/collections");
@@ -478,6 +476,19 @@ function getAbatement(code) {
478
476
  function getSurtaxRates(code) {
479
477
  return exports.TAX_BRACKETS[code].SURTAX_RATES;
480
478
  }
479
+ function getFederalBaseTaxAmount(grossIncome, inflationRate = 0, yearsToInflate = 0) {
480
+ return extractRate(getTaxRates(code_types_1.FEDERAL_CODE), grossIncome, inflationRate, yearsToInflate);
481
+ }
482
+ exports.getFederalBaseTaxAmount = getFederalBaseTaxAmount;
483
+ function getFederalBaseCredit(inflationRate, yearsToInflate) {
484
+ const baseTaxCredit = exports.TAX_BRACKETS.CA.BASE_TAX_CREDIT * exports.TAX_BRACKETS.CA.TAX_CREDIT_RATE;
485
+ return inflate(baseTaxCredit, inflationRate, yearsToInflate);
486
+ }
487
+ exports.getFederalBaseCredit = getFederalBaseCredit;
488
+ function getProvincialAbatement(province, federalTaxAmount) {
489
+ return getAbatement(province) * federalTaxAmount;
490
+ }
491
+ exports.getProvincialAbatement = getProvincialAbatement;
481
492
  function getFederalTaxAmount(provincialCode, grossIncome, inflationRate = 0, yearsToInflate = 0) {
482
493
  const federalBaseTaxAmount = getFederalBaseTaxAmount(grossIncome, inflationRate, yearsToInflate);
483
494
  const baseCredit = getFederalBaseCredit(inflationRate, yearsToInflate);
@@ -486,10 +497,19 @@ function getFederalTaxAmount(provincialCode, grossIncome, inflationRate = 0, yea
486
497
  return Math.max(federalTax - abatement, 0);
487
498
  }
488
499
  exports.getFederalTaxAmount = getFederalTaxAmount;
489
- function getFederalBaseTaxAmount(grossIncome, inflationRate = 0, yearsToInflate = 0) {
490
- return extractRate(getTaxRates(code_types_1.FEDERAL_CODE), grossIncome, inflationRate, yearsToInflate);
500
+ function getProvincialSurtaxAmount(province, baseTaxAmount, inflationRate = 0, yearsToInflate = 0) {
501
+ return extractRate(getSurtaxRates(province), baseTaxAmount, inflationRate, yearsToInflate);
491
502
  }
492
- exports.getFederalBaseTaxAmount = getFederalBaseTaxAmount;
503
+ exports.getProvincialSurtaxAmount = getProvincialSurtaxAmount;
504
+ function getProvincialBaseTaxAmount(province, grossIncome, inflationRate = 0, yearsToInflate = 0) {
505
+ return extractRate(getTaxRates(province), grossIncome, inflationRate, yearsToInflate);
506
+ }
507
+ exports.getProvincialBaseTaxAmount = getProvincialBaseTaxAmount;
508
+ function getProvincialBaseCredit(province, inflationRate, yearsToInflate) {
509
+ const baseTaxCredit = exports.TAX_BRACKETS[province].BASE_TAX_CREDIT * exports.TAX_BRACKETS[province].RATES[0].RATE;
510
+ return inflate(baseTaxCredit, inflationRate, yearsToInflate);
511
+ }
512
+ exports.getProvincialBaseCredit = getProvincialBaseCredit;
493
513
  function getProvincialTaxAmount(province, grossIncome, inflationRate = 0, yearsToInflate = 0) {
494
514
  const baseTaxAmount = getProvincialBaseTaxAmount(province, grossIncome, inflationRate, yearsToInflate);
495
515
  const baseCredit = getProvincialBaseCredit(province, inflationRate, yearsToInflate);
@@ -498,23 +518,6 @@ function getProvincialTaxAmount(province, grossIncome, inflationRate = 0, yearsT
498
518
  return tax + surTax;
499
519
  }
500
520
  exports.getProvincialTaxAmount = getProvincialTaxAmount;
501
- function getProvincialBaseTaxAmount(province, grossIncome, inflationRate = 0, yearsToInflate = 0) {
502
- return extractRate(getTaxRates(province), grossIncome, inflationRate, yearsToInflate);
503
- }
504
- exports.getProvincialBaseTaxAmount = getProvincialBaseTaxAmount;
505
- function getProvincialSurtaxAmount(province, baseTaxAmount, inflationRate = 0, yearsToInflate = 0) {
506
- return extractRate(getSurtaxRates(province), baseTaxAmount, inflationRate, yearsToInflate);
507
- }
508
- exports.getProvincialSurtaxAmount = getProvincialSurtaxAmount;
509
- function getFederalBaseCredit(inflationRate, yearsToInflate) {
510
- const baseTaxCredit = exports.TAX_BRACKETS.CA.BASE_TAX_CREDIT * exports.TAX_BRACKETS.CA.TAX_CREDIT_RATE;
511
- return inflate(baseTaxCredit, inflationRate, yearsToInflate);
512
- }
513
- exports.getFederalBaseCredit = getFederalBaseCredit;
514
- function getProvincialAbatement(province, federalTaxAmount) {
515
- return getAbatement(province) * federalTaxAmount;
516
- }
517
- exports.getProvincialAbatement = getProvincialAbatement;
518
521
  function getFederalMarginalRate(provincialCode, grossIncome, inflationRate = 0, yearsToInflate = 0) {
519
522
  const brackets = getTaxRates(code_types_1.FEDERAL_CODE);
520
523
  const rate = getRate(brackets, grossIncome, inflationRate, yearsToInflate);
@@ -532,11 +535,6 @@ function getProvincialMarginalRate(provincialCode, grossIncome, inflationRate =
532
535
  return taxRate + (taxRate * surtaxRate);
533
536
  }
534
537
  exports.getProvincialMarginalRate = getProvincialMarginalRate;
535
- function getProvincialBaseCredit(province, inflationRate, yearsToInflate) {
536
- const baseTaxCredit = exports.TAX_BRACKETS[province].BASE_TAX_CREDIT * exports.TAX_BRACKETS[province].RATES[0].RATE;
537
- return inflate(baseTaxCredit, inflationRate, yearsToInflate);
538
- }
539
- exports.getProvincialBaseCredit = getProvincialBaseCredit;
540
538
  function getTotalMarginalRate(provincialCode, grossIncome, inflationRate = 0, yearsToInflate = 0) {
541
539
  const provRate = getProvincialMarginalRate(provincialCode, grossIncome, inflationRate, yearsToInflate);
542
540
  const fedRate = getFederalMarginalRate(provincialCode, grossIncome, inflationRate, yearsToInflate);
@@ -544,16 +542,16 @@ function getTotalMarginalRate(provincialCode, grossIncome, inflationRate = 0, ye
544
542
  }
545
543
  exports.getTotalMarginalRate = getTotalMarginalRate;
546
544
  function getMaxProvincialMarginalRate(provincialCode) {
547
- // tslint:disable-next-line:no-non-null-assertion
545
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
548
546
  const marginalRate = (0, collections_1.maxBy)(getTaxRates(provincialCode), (bracket) => bracket.TO).RATE;
549
- // tslint:disable-next-line:no-non-null-assertion
550
- const surtaxRate = (0, collections_1.maxBy)(getSurtaxRates(provincialCode), bracket => bracket.TO).RATE;
547
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
548
+ const surtaxRate = (0, collections_1.maxBy)(getSurtaxRates(provincialCode), (bracket) => bracket.TO).RATE;
551
549
  return marginalRate + (marginalRate * surtaxRate);
552
550
  }
553
551
  exports.getMaxProvincialMarginalRate = getMaxProvincialMarginalRate;
554
552
  function getMaxFederalMarginalRate(provincialCode) {
555
- // tslint:disable-next-line:no-non-null-assertion
556
- const maxRate = (0, collections_1.maxBy)(getTaxRates(code_types_1.FEDERAL_CODE), bracket => bracket.TO).RATE;
553
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
554
+ const maxRate = (0, collections_1.maxBy)(getTaxRates(code_types_1.FEDERAL_CODE), (bracket) => bracket.TO).RATE;
557
555
  return maxRate * (1 - getAbatement(provincialCode));
558
556
  }
559
557
  exports.getMaxFederalMarginalRate = getMaxFederalMarginalRate;
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.maxBy = void 0;
4
4
  function maxBy(values, mapFn) {
5
5
  const max = Math.max(...values.map(mapFn));
6
- return values.find(item => mapFn(item) === max);
6
+ return values.find((item) => mapFn(item) === max);
7
7
  }
8
8
  exports.maxBy = maxBy;
@@ -2,12 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.roundToPrecision = exports.clamp = void 0;
4
4
  function clamp(num, min, max) {
5
- return num <= min ? min : num >= max ? max : num;
5
+ if (num <= min) {
6
+ return min;
7
+ }
8
+ return num >= max ? max : num;
6
9
  }
7
10
  exports.clamp = clamp;
8
11
  function roundToPrecision(value, precision = 0) {
9
- return !isNaN(value)
10
- ? Math.round(value * Math.pow(10, precision)) / Math.pow(10, precision)
11
- : 0;
12
+ if (!Number.isNaN(Number(value))) {
13
+ return Math.round(value * (Math.pow(10, precision))) / (Math.pow(10, precision));
14
+ }
15
+ return 0;
12
16
  }
13
17
  exports.roundToPrecision = roundToPrecision;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equisoft/tax-ca",
3
- "version": "2022.7.0",
3
+ "version": "2022.7.1-snapshot.20220601164236",
4
4
  "description": "Canadian tax data and calculation functions.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,22 +26,31 @@
26
26
  ],
27
27
  "scripts": {
28
28
  "build": "tsc",
29
- "lint": "tslint -p tests/tsconfig.json \"src/**/*.ts\" \"tests/**/*.ts\"",
30
- "lint:ci": "yarn lint --format junit -o build/tests/tslint/junit.xml",
29
+ "eslint": "eslint ./src ./tests/",
30
+ "eslint:ci": "yarn eslint",
31
31
  "prepublishOnly": "rm -rf dist/ && yarn build",
32
- "test": "jest --config=tests/jest.config.js",
33
- "test:ci": "JEST_JUNIT_OUTPUT_DIR='build/tests/jest/' yarn test --maxWorkers=2 --ci --reporters=default --reporters=jest-junit",
32
+ "test": "NODE_ENV=test jest --config=tests/jest.config.js",
33
+ "test:ci": "NODE_ENV=test yarn test --runInBand --ci",
34
34
  "watch": "tsc --watch"
35
35
  },
36
36
  "devDependencies": {
37
- "@equisoft/tslint-config": "0.0.8",
38
- "@types/jest": "27.5.0",
37
+ "@equisoft/eslint-config": "3.0.1",
38
+ "@equisoft/eslint-config-typescript": "3.0.1",
39
+ "@equisoft/typescript-config": "2.0.0",
40
+ "@microsoft/eslint-formatter-sarif": "3.0.0",
41
+ "@types/jest": "27.5.1",
39
42
  "@types/node": "17.0.23",
43
+ "@typescript-eslint/eslint-plugin": "5.25.0",
44
+ "@typescript-eslint/parser": "5.25.0",
45
+ "eslint": "8.15.0",
46
+ "eslint-import-resolver-node": "0.3.6",
47
+ "eslint-import-resolver-typescript": "2.7.1",
48
+ "eslint-plugin-import": "2.26.0",
40
49
  "jest": "27.5.1",
41
50
  "jest-junit": "13.2.0",
42
51
  "ts-jest": "27.1.4",
43
- "tslint": "5.20.1",
44
- "typescript": "4.6.4"
52
+ "typescript": "4.6.4",
53
+ "yargs": "17.5.1"
45
54
  },
46
- "dependencies": {}
47
- }
55
+ "packageManager": "yarn@3.2.1"
56
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "extends": "@equisoft/typescript-config/tsconfig.standards.json",
3
+ "compilerOptions": {
4
+ "target": "es6",
5
+ "module": "commonjs",
6
+ "esModuleInterop": true,
7
+ "noEmitOnError": true,
8
+ "outDir": "dist",
9
+ "baseUrl": "./src/",
10
+ "paths": {},
11
+ "declaration": true,
12
+ "declarationDir": "dist"
13
+ },
14
+ "include": [
15
+ "src/**/*"
16
+ ],
17
+ "exclude": [
18
+ "src/**/*.spec.ts"
19
+ ]
20
+ }