Skip to content

Commit

Permalink
fix: remove max opcenten
Browse files Browse the repository at this point in the history
  • Loading branch information
hongaar committed Feb 2, 2023
1 parent 9fdd4ec commit b642cdb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
28 changes: 8 additions & 20 deletions src/models/2023/personenauto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ import { Model_Personenauto } from "../personenauto.js";
import { Model_2023_Opcenten } from "./opcenten.js";
import { Model_2023_Tarieven } from "./tarieven.js";

/**
* Het aantal opcenten bedraagt voor de belastingtijdvakken die na 31 december
* 2011 aanvangen ten hoogste 125,80.
*
* https://wetten.overheid.nl/jci1.3:c:BWBR0005645&titeldeel=IV&hoofdstuk=XV&paragraaf=2&artikel=222&z=2023-01-01&g=2023-01-01
*/
const MAX_OPCENTEN = 125.8;

/**
* Een personenauto moet voor de motorrijtuigenbelasting voldoen aan de volgende
* eisen:
Expand Down Expand Up @@ -103,17 +95,7 @@ export function Model_2023_Personenauto(params: ModelParams) {
subtotaal: opcentenGrondslag * opcentenPercentage,
});

if (opcentenGrondslag * opcentenPercentage > MAX_OPCENTEN) {
onderdelen.push({
omschrijving: "Provinciale opcenten maximum (correctie)",
waarde: MAX_OPCENTEN,
subtotaal: MAX_OPCENTEN - opcentenGrondslag * opcentenPercentage,
});

subtotaal += MAX_OPCENTEN;
} else {
subtotaal += opcentenGrondslag * opcentenPercentage;
}
subtotaal += opcentenGrondslag * opcentenPercentage;

/**
* Hebt u een personenauto met een CO2-uitstoot van 1 tot en met 50 gram per
Expand All @@ -129,7 +111,13 @@ export function Model_2023_Personenauto(params: ModelParams) {
"Hebt u een personenauto met een CO2-uitstoot van 1 tot en met 50 gram per kilometer? Dan geldt een halftarief. Dit betekent dat u de helft betaalt van het tarief voor een gewone personenauto. (correctie)",
subtotaal: (subtotaal / 2) * -1,
});

return berekenOutput(onderdelen);
}

if (voertuigtype === Voertuigtype["Personenauto"]) {
return berekenOutput(onderdelen);
}

return berekenOutput(onderdelen);
throw new InvalidParameters(`voertuigtype: ${voertuigtype}`);
}
29 changes: 28 additions & 1 deletion tests/models/2023/personenauto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,25 @@ test("lage_uitstoot", () => {
).toBe(53);
});

test("invalid_provincie", () => {
test("invalid parameters", () => {
expect(() =>
Model_2023_Personenauto({
brandstof: "invalid" as Brandstof,
elektrisch_of_waterstof: false,
voertuigtype: Voertuigtype.Personenauto,
provincie: Provincie.Utrecht,
gewicht: 0,
})
).toThrow();
expect(() =>
Model_2023_Personenauto({
brandstof: Brandstof.Benzine,
elektrisch_of_waterstof: false,
voertuigtype: "invalid" as Voertuigtype,
provincie: Provincie.Utrecht,
gewicht: 0,
})
).toThrow();
expect(() =>
Model_2023_Personenauto({
brandstof: Brandstof.Benzine,
Expand All @@ -157,4 +175,13 @@ test("invalid_provincie", () => {
gewicht: 0,
})
).toThrow();
expect(() =>
Model_2023_Personenauto({
brandstof: Brandstof.Benzine,
elektrisch_of_waterstof: false,
voertuigtype: Voertuigtype.Personenauto,
provincie: "invalid" as Provincie,
gewicht: "invalid" as unknown as number,
})
).toThrow();
});

0 comments on commit b642cdb

Please sign in to comment.