Skip to content

Commit

Permalink
fix(fa): Removing tax from children aid (#15143)
Browse files Browse the repository at this point in the history
* adding sortable feature

* Revert "adding sortable feature"

This reverts commit d9691c5.

* adding more detail for api

* removing white space break just adding html element to the db

* adding children to api

* not taking tax from children aid

* removing other changes

* removing more that is not in this pr

* removing more

* adding minus

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
MargretFinnboga and kodiakhq[bot] authored Jun 7, 2024
1 parent f883da9 commit e0f4b99
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ const AcceptModal = ({

const checkingValue = (element?: number) => (element ? element : 0)

const amount =
(state.amount || 0) +
(state.childrenAidAmount || 0) -
checkingValue(state.income) -
sumValues
const amount = (state.amount || 0) - checkingValue(state.income) - sumValues

const taxAmountWithPersonalTax = calculateFinalTaxAmount(
amount,
Expand All @@ -119,6 +115,7 @@ const AcceptModal = ({
const finalAmount = calculateAcceptedAidFinalAmount(
amount,
taxAmountWithPersonalTax,
state.childrenAidAmount || 0,
)

const taxAmount = calculateTaxOfAmount(amount)
Expand Down Expand Up @@ -178,6 +175,9 @@ const AcceptModal = ({

{hasChildrenAid && (
<Box marginBottom={3}>
<Text variant="small" fontWeight="semiBold" marginBottom={1}>
ATH. ekki er tekinn skattur af styrk barna
</Text>
<NumberInput
label="Styrkur vegna barna"
placeholder="Sláðu inn upphæð"
Expand Down
20 changes: 20 additions & 0 deletions libs/financial-aid/shared/src/lib/taxCalculator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,24 @@ describe('Tax calculator', () => {
const acceptedAidFinalAmount = calculateAcceptedAidFinalAmount(
100000,
100,
0,
)
expect(acceptedAidFinalAmount).toEqual(99900)
})
test('should return accepted final amount with 100% personal and 100% spouse credit, adding children aid', () => {
const acceptedAidFinalAmount = calculateAcceptedAidFinalAmount(
100000,
100,
40000,
)
expect(acceptedAidFinalAmount).toEqual(139900)
})

test('should return accepted final amount with 10% personal and 30% spouse credit', () => {
const acceptedAidFinalAmount = calculateAcceptedAidFinalAmount(
300000,
64926,
0,
)
expect(acceptedAidFinalAmount).toEqual(235074)
})
Expand All @@ -147,9 +157,19 @@ describe('Tax calculator', () => {
const acceptedAidFinalAmount = calculateAcceptedAidFinalAmount(
150000,
50000,
0,
)
expect(acceptedAidFinalAmount).toEqual(100000)
})

test('should return accepted final amount with 10% personal and 30% spouse credit, adding children aid', () => {
const acceptedAidFinalAmount = calculateAcceptedAidFinalAmount(
150000,
50000,
50000,
)
expect(acceptedAidFinalAmount).toEqual(150000)
})
})

describe('calculateFinalTaxAmount', () => {
Expand Down
3 changes: 2 additions & 1 deletion libs/financial-aid/shared/src/lib/taxCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ export const calculatePersonalTaxAllowanceFromAmount = (
export const calculateAcceptedAidFinalAmount = (
amount: number,
finalTaxAmount: number,
childrenAid: number,
): number => {
return amount - finalTaxAmount
return amount - finalTaxAmount + childrenAid
}

export const calculateFinalTaxAmount = (
Expand Down

0 comments on commit e0f4b99

Please sign in to comment.