-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first version of Models_2023 (failing)
- Loading branch information
Showing
11 changed files
with
528 additions
and
10 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 |
---|---|---|
@@ -1 +1,30 @@ | ||
# motorrijtuigenbelasting | ||
# motorrijtuigenbelasting [![npm](https://img.shields.io/npm/v/motorrijtuigenbelasting)](https://www.npmjs.com/package/motorrijtuigenbelasting) | ||
|
||
**Motorrijtuigenbelasting (MRB) berekenen in JavaScript/TypeScript** | ||
|
||
```bash | ||
yarn|npm add motorrijtuigenbelasting | ||
``` | ||
|
||
```js | ||
import { | ||
berekenMrb, | ||
Brandstof, | ||
Provincie, | ||
Voertuigtype, | ||
} from "motorrijtuigenbelasting"; | ||
|
||
// bedrag is motorrijtuigenbelasting per tijdvak van 3 maanden in euro's | ||
const bedrag = berekenMrb({ | ||
voertuigtype: Voertuigtype.Personenauto, | ||
brandstof: Brandstof.Benzine, | ||
elektrisch_of_waterstof: false, | ||
gewicht: 1051, | ||
provincie: Provincie.Utrecht, | ||
}); | ||
``` | ||
|
||
## Credits | ||
|
||
©️ Copyright 2023 [Joram van den Boezem](https://joram.dev) | ||
♻️ Licensed under the [MIT license](LICENSE) |
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,251 @@ | ||
import { Model_2023 } from "./models/index.js"; | ||
|
||
export type ModelParams = { | ||
/** | ||
* "In welke provincie woont u?" | ||
* | ||
* Indien "Woont u in Nederland?" op "Nee" staat, dan is dit veld "null" | ||
*/ | ||
provincie: Provincie | null; | ||
|
||
/** | ||
* "Voor welk soort motorrijtuig wilt u een berekening maken?" | ||
*/ | ||
voertuigtype: Voertuigtype; | ||
|
||
/** | ||
* "Rijdt uw personenauto volledig en uitsluitend op elektriciteit of | ||
* waterstof?" | ||
*/ | ||
elektrisch_of_waterstof: boolean; | ||
|
||
/** | ||
* "Op welke brandstof rijdt uw personenauto?" | ||
* | ||
* Indien "elektrisch_of_waterstof" op "true", dan is dit veld "null" | ||
*/ | ||
brandstof: Brandstof | null; | ||
|
||
/** | ||
* "Wat is de gewichtsklasse van uw personenauto?" | ||
* | ||
* Hebt u een papieren kentekenbewijs? Dan staat het gewicht van uw | ||
* motorrijtuig in de rubriek 'Massa ledig voertuig'. | ||
* | ||
* Hebt u een kentekencard, en is de rubriek 'Massa rijklaar' ingevuld? Dan | ||
* bepaalt u het gewicht van uw motorrijtuig door van de massa rijklaar 100 kg | ||
* af te trekken. | ||
*/ | ||
gewicht: Gewichtsklasse | number; | ||
}; | ||
|
||
export enum Provincie { | ||
"Drenthe", | ||
"Flevoland", | ||
"Friesland", | ||
"Gelderland", | ||
"Groningen", | ||
"Limburg", | ||
"Noord-Brabant", | ||
"Noord-Holland", | ||
"Overijssel", | ||
"Utrecht", | ||
"Zeeland", | ||
"Zuid-Holland", | ||
} | ||
|
||
export enum Voertuigtype { | ||
"Personenauto", | ||
"Personenauto met een CO2-uitstoot van 0 gr/km", | ||
"Personenauto met een CO2-uitstoot van 1 t/m 50 gr/km", | ||
"Bestelauto ondernemer", | ||
"Bestelauto particulier", | ||
"Bestelauto gehandicapte", | ||
"Motor", | ||
"Aanhangwagen/oplegger", | ||
"Kampeerauto", | ||
"Caravan, vouwwagen of woonwagen", | ||
"Autobus", | ||
"Rijdende winkel", | ||
"Handelaarskenteken", | ||
"Vrachtauto", | ||
} | ||
|
||
export enum Brandstof { | ||
"Benzine", | ||
"Diesel", | ||
"LPG3 en Aardgas", | ||
"LPG en overige (behalve elektriciteit en waterstof)", | ||
} | ||
|
||
export enum Gewichtsklasse { | ||
"1 t/m 550" = 550, | ||
"551 t/m 650" = 650, | ||
"651 t/m 750" = 750, | ||
"751 t/m 850" = 850, | ||
"851 t/m 950" = 950, | ||
"951 t/m 1050" = 1050, | ||
"1051 t/m 1150" = 1150, | ||
"1151 t/m 1250" = 1250, | ||
"1251 t/m 1350" = 1350, | ||
"1351 t/m 1450" = 1450, | ||
"1451 t/m 1550" = 1550, | ||
"1551 t/m 1650" = 1650, | ||
"1651 t/m 1750" = 1750, | ||
"1751 t/m 1850" = 1850, | ||
"1851 t/m 1950" = 1950, | ||
"1951 t/m 2050" = 2050, | ||
"2051 t/m 2150" = 2150, | ||
"2151 t/m 2250" = 2250, | ||
"2251 t/m 2350" = 2350, | ||
"2351 t/m 2450" = 2450, | ||
"2451 t/m 2550" = 2550, | ||
"2551 t/m 2650" = 2650, | ||
"2651 t/m 2750" = 2750, | ||
"2751 t/m 2850" = 2850, | ||
"2851 t/m 2950" = 2950, | ||
"2951 t/m 3050" = 3050, | ||
"3051 t/m 3150" = 3150, | ||
"3151 t/m 3250" = 3250, | ||
"3251 t/m 3350" = 3350, | ||
"3351 t/m 3450" = 3450, | ||
"3451 t/m 3550" = 3550, | ||
"3551 t/m 3650" = 3650, | ||
"3651 t/m 3750" = 3750, | ||
"3751 t/m 3850" = 3850, | ||
"3851 t/m 3950" = 3950, | ||
"3951 t/m 4050" = 4050, | ||
"4051 t/m 4150" = 4150, | ||
"4151 t/m 4250" = 4250, | ||
"4251 t/m 4350" = 4350, | ||
"4351 t/m 4450" = 4450, | ||
"4451 t/m 4550" = 4550, | ||
"4551 t/m 4650" = 4650, | ||
"4651 t/m 4750" = 4750, | ||
"4751 t/m 4850" = 4850, | ||
"4851 t/m 4950" = 4950, | ||
"4951 t/m 5050" = 5050, | ||
"5051 t/m 5150" = 5150, | ||
"5151 t/m 5250" = 5250, | ||
"5251 t/m 5350" = 5350, | ||
"5351 t/m 5450" = 5450, | ||
"5451 t/m 5550" = 5550, | ||
"5551 t/m 5650" = 5650, | ||
"5651 t/m 5750" = 5750, | ||
"5751 t/m 5850" = 5850, | ||
"5851 t/m 5950" = 5950, | ||
"5951 t/m 6050" = 6050, | ||
"6051 t/m 6150" = 6150, | ||
"6151 t/m 6250" = 6250, | ||
"6251 t/m 6350" = 6350, | ||
"6351 t/m 6450" = 6450, | ||
"6451 t/m 6550" = 6550, | ||
"6551 t/m 6650" = 6650, | ||
"6651 t/m 6750" = 6750, | ||
"6751 t/m 6850" = 6850, | ||
"6851 t/m 6950" = 6950, | ||
"6951 t/m 7050" = 7050, | ||
"7051 t/m 7150" = 7150, | ||
"7151 t/m 7250" = 7250, | ||
"7251 t/m 7350" = 7350, | ||
"7351 t/m 7450" = 7450, | ||
"7451 t/m 7550" = 7550, | ||
"7551 t/m 7650" = 7650, | ||
"7651 t/m 7750" = 7750, | ||
"7751 t/m 7850" = 7850, | ||
"7851 t/m 7950" = 7950, | ||
"7951 t/m 8050" = 8050, | ||
"8051 t/m 8150" = 8150, | ||
"8151 t/m 8250" = 8250, | ||
"8251 t/m 8350" = 8350, | ||
"8351 t/m 8450" = 8450, | ||
"8451 t/m 8550" = 8550, | ||
"8551 t/m 8650" = 8650, | ||
"8651 t/m 8750" = 8750, | ||
"8751 t/m 8850" = 8850, | ||
"8851 t/m 8950" = 8950, | ||
"8951 t/m 9050" = 9050, | ||
"9051 t/m 9150" = 9150, | ||
"9151 t/m 9250" = 9250, | ||
"9251 t/m 9350" = 9350, | ||
"9351 t/m 9450" = 9450, | ||
"9451 t/m 9550" = 9550, | ||
"9551 t/m 9650" = 9650, | ||
"9651 t/m 9750" = 9750, | ||
"9751 t/m 9850" = 9850, | ||
"9851 t/m 9950" = 9950, | ||
"9951 t/m 10050" = 10050, | ||
"10051 t/m 10150" = 10150, | ||
"10151 t/m 10250" = 10250, | ||
"10251 t/m 10350" = 10350, | ||
"10351 t/m 10450" = 10450, | ||
"10451 t/m 10550" = 10550, | ||
"10551 t/m 10650" = 10650, | ||
"10651 t/m 10750" = 10750, | ||
"10751 t/m 10850" = 10850, | ||
"10851 t/m 10950" = 10950, | ||
"10951 t/m 11050" = 11050, | ||
"11051 t/m 11150" = 11150, | ||
"11151 t/m 11250" = 11250, | ||
"11251 t/m 11350" = 11350, | ||
"11351 t/m 11450" = 11450, | ||
"11451 t/m 11550" = 11550, | ||
"11551 t/m 11650" = 11650, | ||
"11651 t/m 11750" = 11750, | ||
"11751 t/m 11850" = 11850, | ||
"11851 t/m 11950" = 11950, | ||
"11951 t/m 12050" = 12050, | ||
"12051 t/m 12150" = 12150, | ||
"12151 t/m 12250" = 12250, | ||
"12251 t/m 12350" = 12350, | ||
"12351 t/m 12450" = 12450, | ||
"12451 t/m 12550" = 12550, | ||
"12551 t/m 12650" = 12650, | ||
"12651 t/m 12750" = 12750, | ||
"12751 t/m 12850" = 12850, | ||
"12851 t/m 12950" = 12950, | ||
"12951 t/m 13050" = 13050, | ||
"13051 t/m 13150" = 13150, | ||
"13151 t/m 13250" = 13250, | ||
"13251 t/m 13350" = 13350, | ||
"13351 t/m 13450" = 13450, | ||
"13451 t/m 13550" = 13550, | ||
"13551 t/m 13650" = 13650, | ||
"13651 t/m 13750" = 13750, | ||
"13751 t/m 13850" = 13850, | ||
"13851 t/m 13950" = 13950, | ||
"13951 t/m 14050" = 14050, | ||
"14051 t/m 14150" = 14150, | ||
"14151 t/m 14250" = 14250, | ||
"14251 t/m 14350" = 14350, | ||
"14351 t/m 14450" = 14450, | ||
"14451 t/m 14550" = 14550, | ||
"14551 t/m 14650" = 14650, | ||
"14651 t/m 14750" = 14750, | ||
"14751 t/m 14850" = 14850, | ||
"14851 t/m 14950" = 14950, | ||
"14951 t/m 15050" = 15050, | ||
"15051 en zwaarder" = Infinity, | ||
} | ||
|
||
export type MrbArgs = ModelParams & { | ||
// Selecteer een model | ||
model?: Models; | ||
}; | ||
|
||
export enum Models { | ||
Model_2023, | ||
} | ||
|
||
const models = { | ||
[Models.Model_2023]: Model_2023, | ||
}; | ||
|
||
export function berekenMrb({ | ||
model = Models.Model_2023, | ||
...modelParams | ||
}: MrbArgs) { | ||
const modelFn = models[model]; | ||
|
||
return modelFn(modelParams); | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
export * from "./sum.js"; | ||
export * from "./berekenMrb.js"; |
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,50 @@ | ||
import { ModelParams, Voertuigtype } from "../../index.js"; | ||
import { Model_2023_Personenauto } from "./personenauto.js"; | ||
|
||
export class NotImplementedError extends Error { | ||
constructor() { | ||
super("This combination of parameters is not supported yet"); | ||
this.name = "NotImplementedError"; | ||
} | ||
} | ||
|
||
export function Model_2023(params: ModelParams) { | ||
const { | ||
// provincie, | ||
// brandstof, | ||
// elektrisch_of_waterstof, | ||
// gewicht, | ||
voertuigtype, | ||
} = params; | ||
|
||
/** | ||
* Overzicht vrijstellingen motorrijtuigenbelasting | ||
* https://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/prive/auto_en_vervoer/belastingen_op_auto_en_motor/motorrijtuigenbelasting/vrijstelling_onder_andere_voor_oldtimers/ | ||
* | ||
* Not implemented | ||
*/ | ||
|
||
/** | ||
* Bijzonder tarief motorrijtuigenbelasting | ||
* https://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/prive/auto_en_vervoer/belastingen_op_auto_en_motor/motorrijtuigenbelasting/bijzonder_tarief/ | ||
* | ||
* Not implemented | ||
*/ | ||
|
||
/** | ||
* Motorrijtuigenbelasting per soort motorrijtuig | ||
* https://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/prive/auto_en_vervoer/belastingen_op_auto_en_motor/motorrijtuigenbelasting/soort_motorrijtuig/ | ||
*/ | ||
switch (voertuigtype) { | ||
case Voertuigtype.Personenauto: | ||
case Voertuigtype["Personenauto met een CO2-uitstoot van 0 gr/km"]: | ||
case Voertuigtype["Personenauto met een CO2-uitstoot van 1 t/m 50 gr/km"]: | ||
/** | ||
* Personenauto | ||
* https://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/prive/auto_en_vervoer/belastingen_op_auto_en_motor/motorrijtuigenbelasting/soort_motorrijtuig/personenauto | ||
*/ | ||
return Model_2023_Personenauto(params); | ||
} | ||
|
||
throw new NotImplementedError(); | ||
} |
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,33 @@ | ||
import { Provincie } from "../../berekenMrb.js"; | ||
|
||
// https://opendata.cbs.nl/statline/#/CBS/nl/dataset/80889NED/table | ||
export function Model_2023_Opcenten(provincie: Provincie | null): number { | ||
switch (provincie) { | ||
case null: | ||
return 0; | ||
case Provincie.Drenthe: | ||
return 0.92; | ||
case Provincie.Flevoland: | ||
return 0.822; | ||
case Provincie.Friesland: | ||
return 0.87; | ||
case Provincie.Gelderland: | ||
return 0.93; | ||
case Provincie.Groningen: | ||
return 0.957; | ||
case Provincie.Limburg: | ||
return 0.806; | ||
case Provincie["Noord-Brabant"]: | ||
return 0.808; | ||
case Provincie["Noord-Holland"]: | ||
return 0.679; | ||
case Provincie.Overijssel: | ||
return 0.799; | ||
case Provincie.Utrecht: | ||
return 0.794; | ||
case Provincie.Zeeland: | ||
return 0.823; | ||
case Provincie["Zuid-Holland"]: | ||
return 0.957; | ||
} | ||
} |
Oops, something went wrong.