Skip to content

Commit

Permalink
Return zero taxes instead of throwing when income is below PA (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgb-io authored Sep 27, 2023
1 parent 49fb7c4 commit f011f5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/incomeTax.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { calculateIncomeTax } from "./incomeTax";
import { calculatePersonalAllowance } from "./personalAllowance";

const expectations = [
{ taxableAnnualIncome: 0, basic: 0, higher: 0, additional: 0 },
{ taxableAnnualIncome: 5_000, basic: 0, higher: 0, additional: 0 },
{ taxableAnnualIncome: 15_000, basic: 486, higher: 0, additional: 0 },
{ taxableAnnualIncome: 17_500, basic: 986, higher: 0, additional: 0 },
{ taxableAnnualIncome: 20_000, basic: 1486, higher: 0, additional: 0 },
Expand Down
7 changes: 6 additions & 1 deletion src/incomeTax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,10 @@ export const calculateIncomeTax = ({
};
}

throw new Error("Unexpected Input");
// Income is lower than the personal allowance - no income tax
return {
basicRateTax: 0,
higherRateTax: 0,
additionalRateTax: 0,
};
};

0 comments on commit f011f5f

Please sign in to comment.