@equisoft/tax-ca
Advanced tools
Comparing version 2021.2.1 to 2021.3.0
@@ -18,4 +18,6 @@ import { FederalCode, ProvinceCode } from '../misc/code-types'; | ||
export declare const TAX_BRACKETS: TaxBrackets; | ||
export declare function getFederalTaxAmount(grossIncome: number, inflationRate?: number, yearsToInflate?: number): number; | ||
export declare function getFederalTaxAmount(provincialCode: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number; | ||
export declare function getFederalBaseTaxAmount(grossIncome: number, inflationRate?: number, yearsToInflate?: number): number; | ||
export declare function getProvincialTaxAmount(province: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number; | ||
export declare function getProvincialBaseTaxAmount(province: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number; | ||
export declare function getProvincialSurtaxAmount(province: ProvinceCode, baseTaxAmount: number, inflationRate?: number, yearsToInflate?: number): number; | ||
@@ -32,2 +34,2 @@ export declare function getFederalBaseCredit(inflationRate: number, yearsToInflate: number): number; | ||
export declare function getTotalTaxAmount(provincialCode: ProvinceCode, grossIncome: number, inflationRate?: number, yearsToInflate?: number): number; | ||
export declare function calculateEffectiveTaxRate(income: number, province: ProvinceCode): number; | ||
export declare function getEffectiveRate(province: ProvinceCode, income: number, inflationRate?: number, yearsToInflate?: number): number; |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.calculateEffectiveTaxRate = exports.getTotalTaxAmount = exports.getTotalMaxMarginalRate = exports.getMaxFederalMarginalRate = exports.getMaxProvincialMarginalRate = exports.getTotalMarginalRate = exports.getProvincialBaseCredit = exports.getProvincialMarginalRate = exports.getFederalMarginalRate = exports.getProvincialAbatement = exports.getFederalBaseCredit = exports.getProvincialSurtaxAmount = exports.getProvincialTaxAmount = exports.getFederalTaxAmount = exports.TAX_BRACKETS = void 0; | ||
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; | ||
const code_types_1 = require("../misc/code-types"); | ||
@@ -453,2 +453,9 @@ const utils_1 = require("../utils"); | ||
} | ||
function getRate(brackets, grossIncome, inflationRate, yearsToInflate) { | ||
const reducer = (previous, current) => { | ||
const bracketFrom = inflate(current.FROM, inflationRate, yearsToInflate); | ||
return bracketFrom < grossIncome ? current.RATE : previous; | ||
}; | ||
return brackets.reduce(reducer, 0); | ||
} | ||
function getTaxRates(code) { | ||
@@ -463,17 +470,26 @@ return exports.TAX_BRACKETS[code].RATES; | ||
} | ||
function getRate(brackets, grossIncome, inflationRate, yearsToInflate) { | ||
const reducer = (previous, current) => { | ||
const bracketFrom = inflate(current.FROM, inflationRate, yearsToInflate); | ||
return bracketFrom < grossIncome ? current.RATE : previous; | ||
}; | ||
return brackets.reduce(reducer, 0); | ||
function getFederalTaxAmount(provincialCode, grossIncome, inflationRate = 0, yearsToInflate = 0) { | ||
const federalBaseTaxAmount = getFederalBaseTaxAmount(grossIncome, inflationRate, yearsToInflate); | ||
const baseCredit = getFederalBaseCredit(inflationRate, yearsToInflate); | ||
const federalTax = Math.max(federalBaseTaxAmount - baseCredit, 0); | ||
const abatement = getProvincialAbatement(provincialCode, federalTax); | ||
return Math.max(federalTax - abatement, 0); | ||
} | ||
function getFederalTaxAmount(grossIncome, inflationRate = 0, yearsToInflate = 0) { | ||
exports.getFederalTaxAmount = getFederalTaxAmount; | ||
function getFederalBaseTaxAmount(grossIncome, inflationRate = 0, yearsToInflate = 0) { | ||
return extractRate(getTaxRates(code_types_1.FEDERAL_CODE), grossIncome, inflationRate, yearsToInflate); | ||
} | ||
exports.getFederalTaxAmount = getFederalTaxAmount; | ||
exports.getFederalBaseTaxAmount = getFederalBaseTaxAmount; | ||
function getProvincialTaxAmount(province, grossIncome, inflationRate = 0, yearsToInflate = 0) { | ||
const baseTaxAmount = getProvincialBaseTaxAmount(province, grossIncome, inflationRate, yearsToInflate); | ||
const baseCredit = getProvincialBaseCredit(province, inflationRate, yearsToInflate); | ||
const tax = Math.max(baseTaxAmount - baseCredit, 0); | ||
const surTax = getProvincialSurtaxAmount(province, tax, inflationRate, yearsToInflate); | ||
return tax + surTax; | ||
} | ||
exports.getProvincialTaxAmount = getProvincialTaxAmount; | ||
function getProvincialBaseTaxAmount(province, grossIncome, inflationRate = 0, yearsToInflate = 0) { | ||
return extractRate(getTaxRates(province), grossIncome, inflationRate, yearsToInflate); | ||
} | ||
exports.getProvincialTaxAmount = getProvincialTaxAmount; | ||
exports.getProvincialBaseTaxAmount = getProvincialBaseTaxAmount; | ||
function getProvincialSurtaxAmount(province, baseTaxAmount, inflationRate = 0, yearsToInflate = 0) { | ||
@@ -542,20 +558,12 @@ return extractRate(getSurtaxRates(province), baseTaxAmount, inflationRate, yearsToInflate); | ||
const provTax = getProvincialTaxAmount(provincialCode, grossIncome, inflationRate, yearsToInflate); | ||
const provSurtax = getProvincialSurtaxAmount(provincialCode, provTax, inflationRate, yearsToInflate); | ||
const fedTax = getFederalTaxAmount(grossIncome, inflationRate, yearsToInflate); | ||
return provTax + provSurtax + fedTax; | ||
const fedTax = getFederalTaxAmount(provincialCode, grossIncome, inflationRate, yearsToInflate); | ||
return Math.max(provTax, 0) + Math.max(fedTax, 0); | ||
} | ||
exports.getTotalTaxAmount = getTotalTaxAmount; | ||
function calculateEffectiveTaxRate(income, province) { | ||
function getEffectiveRate(province, income, inflationRate = 0, yearsToInflate = 0) { | ||
if (income <= 0) { | ||
return 0; | ||
} | ||
const provTax = getProvincialTaxAmount(province, income, 0, 0); | ||
const provBaseCredit = getProvincialBaseCredit(province, 0, 0); | ||
const fedTax = getFederalTaxAmount(income, 0, 0); | ||
const fedBaseCredit = getFederalBaseCredit(0, 0); | ||
const fedProvAbatement = getProvincialAbatement(province, fedTax - fedBaseCredit); | ||
const taxesToPay = Math.max(fedTax - fedBaseCredit - fedProvAbatement, 0) | ||
+ Math.max(provTax - provBaseCredit, 0); | ||
return taxesToPay / income; | ||
return (getTotalTaxAmount(province, income, inflationRate, yearsToInflate)) / income; | ||
} | ||
exports.calculateEffectiveTaxRate = calculateEffectiveTaxRate; | ||
exports.getEffectiveRate = getEffectiveRate; |
{ | ||
"name": "@equisoft/tax-ca", | ||
"version": "2021.2.1", | ||
"version": "2021.3.0", | ||
"description": "Canadian tax data and calculation functions.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
66197
1991