-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ABF-7927] dev(capital gains inclusion): ajout d'une fonction pour ca…
…lculer le montant d'inclusion pour les gains en capital (#447) * added function to calculate amount that will be taxed for capital gains added babel dependencies to support debugging jest tests from intellij * fix var declaration * exporting file * floor version for babel * cleanup function
- Loading branch information
1 parent
d396bdb
commit 22cdf99
Showing
7 changed files
with
1,454 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {presets: ['@babel/preset-env', '@babel/preset-typescript']} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Rate } from '../taxes'; | ||
|
||
export const CAPITAL_GAINS_BRACKETS: Rate[] = [ | ||
{ | ||
FROM: 0, | ||
TO: 250000, | ||
RATE: 0.5, | ||
}, | ||
{ | ||
FROM: 250000, | ||
TO: Infinity, | ||
RATE: 0.667, | ||
}, | ||
]; | ||
|
||
export function getCapitalGainsTaxableAmount(totalCapitalGains: number): number { | ||
return CAPITAL_GAINS_BRACKETS.reduce((taxableAmount, currentBracket) => { | ||
const currentBracketRate = currentBracket.RATE; | ||
|
||
const bracketTaxableAmount = Math.min(totalCapitalGains, currentBracket.TO); | ||
|
||
if (bracketTaxableAmount <= currentBracket.FROM) return taxableAmount; | ||
|
||
return taxableAmount + ((bracketTaxableAmount - currentBracket.FROM) * currentBracketRate); | ||
}, 0); | ||
} |
22 changes: 22 additions & 0 deletions
22
src/investments/tests/non-registered-retirement-savings-plan.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { getCapitalGainsTaxableAmount } from '../non-registered-savings-plan'; | ||
|
||
describe('getCapitalGainsTaxableAmount', () => { | ||
it('should calculate taxable amount on capital gains income', () => { | ||
const capitalGainsList = [ | ||
{ capitalGains: 150000, taxableAmount: 75000 }, | ||
{ capitalGains: 0, taxableAmount: 0 }, | ||
{ capitalGains: -50, taxableAmount: 0 }, | ||
{ capitalGains: 250000, taxableAmount: 125000 }, | ||
{ capitalGains: 350000, taxableAmount: 125000 + 66700 }, | ||
{ capitalGains: 350001, taxableAmount: 125000 + 66700.667 }, | ||
{ capitalGains: 250100, taxableAmount: 125000 + 66.7 }, | ||
{ capitalGains: 249000, taxableAmount: 124500 }, | ||
{ capitalGains: 250001, taxableAmount: 125000 + 0.667 }, | ||
]; | ||
|
||
capitalGainsList.forEach((item) => { | ||
const taxableAmount = getCapitalGainsTaxableAmount(item.capitalGains); | ||
expect(taxableAmount).toBe(item.taxableAmount); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.