Skip to content

Commit

Permalink
feat: bestelauto (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongaar authored May 10, 2023
1 parent ae158e4 commit ace34ab
Show file tree
Hide file tree
Showing 22 changed files with 775 additions and 302 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"postCreateCommand": "yarn install",
"customizations": {
"vscode": {
"extensions": ["esbenp.prettier-vscode"]
"extensions": ["esbenp.prettier-vscode", "Orta.vscode-jest"]
}
}
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ node_modules
!.yarn/versions

# tests
coverage
coverage

# secrets
.env
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"jest.nodeEnv": {
"NODE_OPTIONS": "--experimental-vm-modules"
}
}
46 changes: 39 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- [Installation](#installation)
- [Usage](#usage-1)
- [Contributing](#contributing)
- [Roadmap](#roadmap)
- [Implementation status](#implementation-status)
- [Development](#development)
- [Devcontainer](#devcontainer)
- [Credits](#credits)
Expand Down Expand Up @@ -103,12 +103,44 @@ console.log({ results });

Contributions are very welcome!

## Roadmap

- [ ] implement missing propulsiontypes
- [ ] implement missing vehicletypes
- [ ] implement betalennaargebruik package
- [ ] emit warning when there is a known discrepancy between the model and the
## Implementation status

- [x] CLI
- [ ] MRB2023
- [x] Personenauto
- [x] Propulsion types
- [x] Provinces
- [x] Low emission
- [x] No emission
- [x] Bestelauto particulier
- [x] Propulsion types
- [x] Particulate matter surtax
- [x] No emission
- [ ] Bestelauto gehandicapte
- [ ] Bestelauto ondernemer
- [x] Propulsion types
- [x] Particulate matter surtax
- [x] No emission
- [ ] Tests
- [ ] Motor
- [ ] Aanhangwagen/oplegger
- [x] Kampeerauto
- [x] Propulsion types
- [x] Rented for business purposes
- [x] Particulate matter surtax
- [x] No emission
- [ ] Caravan, vouwwagen of woonwagen
- [ ] Autobus
- [ ] Rijdende winkel
- [ ] Handelaarskenteken
- [ ] Vrachtauto
- [ ] Convert RDW data
- [ ] Vehicle type (incomplete)
- [x] Weight
- [x] Propulsion types
- [ ] Particulate matter surtax (incomplete)
- [ ] Betalennaargebruik package
- [ ] Emit warning when there is a known discrepancy between the model and the
official calculator

See [TODO.md](TODO.md) for known problems which need fixing and general todos.
Expand Down
26 changes: 14 additions & 12 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
### TODOs

| Filename | line # | TODO |
| :-------------------------------------------------------------------------------- | :----: | :-------------------------------------------------------------------- |
| [packages/mrb2023/tests/index.test.ts](packages/mrb2023/tests/index.test.ts#L46) | 46 | indien niet woonachtig in nederland, worden opcenten niet meegerekend |
| [packages/mrb2023/tests/index.test.ts](packages/mrb2023/tests/index.test.ts#L103) | 103 | we receive 1978 while the baseline gives 1977. not sure what is wrong |
| [packages/mrb2023/tests/index.test.ts](packages/mrb2023/tests/index.test.ts#L143) | 143 | we receive 52 while the baseline gives 65. not sure what is wrong |
| [packages/mrb2023/tests/index.test.ts](packages/mrb2023/tests/index.test.ts#L175) | 175 | this scenario is not covered in baseline calculator |
| [packages/mrb2023/tests/index.test.ts](packages/mrb2023/tests/index.test.ts#L182) | 182 | this scenario is not covered in baseline calculator |
| [packages/rdw/src/index.ts](packages/rdw/src/index.ts#L193) | 193 | add 115R-installatie |
| [packages/rdw/src/index.ts](packages/rdw/src/index.ts#L238) | 238 | this should be moved to mrb{revision} as it could change yoy |
| [packages/rdw/src/index.ts](packages/rdw/src/index.ts#L246) | 246 | De bestelauto moet minimaal 12 jaar oud zijn bij het begin van het |
| [packages/rdw/src/index.ts](packages/rdw/src/index.ts#L263) | 263 | bij het motorrijtuig vermeld staat dat het affabriek roetfilter |
| [packages/rdw/types/index.d.ts](packages/rdw/types/index.d.ts#L141) | 141 | this should be moved to mrb{revision} as it could change yoy |
| Filename | line # | TODO |
| :---------------------------------------------------------------------------------------------- | :----: | :-------------------------------------------------------------------- |
| [packages/mrb2023/src/index.ts](packages/mrb2023/src/index.ts#L76) | 76 | |
| [packages/mrb2023/tests/kampeerauto.test.ts](packages/mrb2023/tests/kampeerauto.test.ts#L49) | 49 | we receive 52 while the baseline gives 65. not sure what is wrong |
| [packages/mrb2023/tests/kampeerauto.test.ts](packages/mrb2023/tests/kampeerauto.test.ts#L81) | 81 | this scenario is not covered in baseline calculator |
| [packages/mrb2023/tests/kampeerauto.test.ts](packages/mrb2023/tests/kampeerauto.test.ts#L88) | 88 | this scenario is not covered in baseline calculator |
| [packages/mrb2023/tests/personenauto.test.ts](packages/mrb2023/tests/personenauto.test.ts#L45) | 45 | indien niet woonachtig in nederland, worden opcenten niet meegerekend |
| [packages/mrb2023/tests/personenauto.test.ts](packages/mrb2023/tests/personenauto.test.ts#L102) | 102 | we receive 1978 while the baseline gives 1977. not sure what is wrong |
| [packages/rdw/src/index.ts](packages/rdw/src/index.ts#L172) | 172 | is this correct? |
| [packages/rdw/src/index.ts](packages/rdw/src/index.ts#L202) | 202 | add 115R-installatie |
| [packages/rdw/src/index.ts](packages/rdw/src/index.ts#L247) | 247 | this should be moved to mrb{revision} as it could change yoy |
| [packages/rdw/src/index.ts](packages/rdw/src/index.ts#L255) | 255 | De bestelauto moet minimaal 12 jaar oud zijn bij het begin van het |
| [packages/rdw/src/index.ts](packages/rdw/src/index.ts#L272) | 272 | bij het motorrijtuig vermeld staat dat het affabriek roetfilter |
| [packages/rdw/types/index.d.ts](packages/rdw/types/index.d.ts#L148) | 148 | this should be moved to mrb{revision} as it could change yoy |
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import("ts-jest").JestConfigWithTsJest} */

export default {
preset: "ts-jest/presets/default-esm",
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
};
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"workspaces": [
"packages/*"
],
"type": "module",
"scripts": {
"build": "yarn workspaces foreach --topological --verbose run build",
"build:watch": "yarn workspaces foreach --parallel --interlaced run build:watch",
Expand All @@ -17,6 +18,8 @@
"release": "semantic-release",
"test": "yarn workspaces foreach --topological --verbose run test",
"test:watch": "yarn workspaces foreach --parallel --interlaced run test:watch",
"test:all": "NODE_OPTIONS=--experimental-vm-modules jest",
"test:all:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
"todos": "leasot --exit-nicely --reporter markdown --ignore \"**/node_modules\" \"**/*.ts\" > TODO.md"
},
"lint-staged": {
Expand All @@ -25,14 +28,18 @@
"devDependencies": {
"@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1",
"@types/jest": "29.5.1",
"doctoc": "2.2.1",
"husky": "8.0.3",
"jest": "29.5.0",
"leasot": "13.3.0",
"lint-staged": "13.2.2",
"moker": "1.1.0",
"prettier": "2.8.8",
"semantic-release": "21.0.2",
"semantic-release-yarn": "1.0.0"
"semantic-release-yarn": "1.0.0",
"ts-jest": "29.1.0",
"typescript": "5.0.4"
},
"packageManager": "yarn@3.4.1",
"moker": {
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import { app } from "./dist/index.js";

app.run().catch((error) => {
// console.error(String(error))
console.error(error);
if ("DEBUG" in process.env) {
console.error(error);
} else {
console.error(String(error));
}
});
22 changes: 15 additions & 7 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {
type Params,
} from "@motorrijtuigenbelasting/core";
import mrb2023 from "@motorrijtuigenbelasting/mrb2023";
import { fetchRdwData, rdwDataToParams } from "@motorrijtuigenbelasting/rdw";
import {
fetchRdwData,
rdwDataToParams,
type RdwData,
} from "@motorrijtuigenbelasting/rdw";
import { command, program } from "bandersnatch";
import yaml from "js-yaml";

Expand Down Expand Up @@ -95,6 +99,7 @@ const cmd = command()
"log-rdw-data": logRdwData,
}) => {
let params: Params;
let rdwData: RdwData | undefined;

if (vehicleId) {
if (!rdwAppToken) {
Expand All @@ -104,7 +109,6 @@ const cmd = command()
if (
typeof propulsionType !== "undefined" ||
typeof co2Emission !== "undefined" ||
typeof particulateMatterSurtax !== "undefined" ||
typeof vehicleType !== "undefined" ||
typeof weight !== "undefined"
) {
Expand All @@ -113,10 +117,9 @@ const cmd = command()
);
}

const rdwData = await fetchRdwData(vehicleId, rdwAppToken);
rdwData = await fetchRdwData(vehicleId, rdwAppToken);

if (logRdwData) {
console.dir(rdwData, { depth: null });
format = "js";
}

Expand All @@ -131,13 +134,13 @@ const cmd = command()
co2Emission: co2Emission || null,
},
],
particulateMatterSurtax: particulateMatterSurtax ?? null,
rentedForBusinessPurposes: rentedForBusinessPurposes ?? null,
};
}

params = {
...params,
particulateMatterSurtax: particulateMatterSurtax ?? null,
rentedForBusinessPurposes: rentedForBusinessPurposes ?? null,
province: province || null,
mileage,
};
Expand All @@ -147,7 +150,12 @@ const cmd = command()
switch (format) {
case "js":
console.dir(
{ vehicleId, params, mrb2023: mrb2023results },
{
...(logRdwData ? { rdwData } : {}),
vehicleId,
params,
mrb2023: mrb2023results,
},
{ depth: null }
);
break;
Expand Down
29 changes: 28 additions & 1 deletion packages/mrb2023/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import {
VehicleType,
type Model,
} from "@motorrijtuigenbelasting/core";
import { kampeerauto, personenauto } from "./vehicleTypes/index.js";
import {
bestelautoOndernemer,
bestelautoParticulier,
kampeerauto,
personenauto,
} from "./vehicleTypes/index.js";

const model: Model = (params) => {
const {
Expand Down Expand Up @@ -55,6 +60,28 @@ const model: Model = (params) => {
* https://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/prive/auto_en_vervoer/belastingen_op_auto_en_motor/motorrijtuigenbelasting/bijzonder_tarief/kampeerauto-camper
*/
return kampeerauto(params);

case VehicleType["Bestelauto particulier"]:
/**
* Bestelauto
* https://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/prive/auto_en_vervoer/belastingen_op_auto_en_motor/motorrijtuigenbelasting/soort_motorrijtuig/bestelauto/
*/
return bestelautoParticulier(params);

case VehicleType["Bestelauto gehandicapte"]:
/**
* Bestelauto gehandicapte
* https://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/prive/auto_en_vervoer/belastingen_op_auto_en_motor/motorrijtuigenbelasting/soort_motorrijtuig/bestelauto/bestelautotarief_voor_gehandicapte_personen
*/
// @todo
break;

case VehicleType["Bestelauto ondernemer"]:
/**
* Bestelauto ondernemer
* https://www.belastingdienst.nl/wps/wcm/connect/bldcontentnl/belastingdienst/prive/auto_en_vervoer/belastingen_op_auto_en_motor/motorrijtuigenbelasting/soort_motorrijtuig/bestelauto/bestelautotarief_voor_ondernemers
*/
return bestelautoOndernemer(params);
}

throw new NotImplementedError();
Expand Down
42 changes: 42 additions & 0 deletions packages/mrb2023/src/rates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,46 @@ export const rateMap = {
],
},
},
[VehicleType["Bestelauto ondernemer"]]: {
/**
* Wet op de motorrijtuigenbelasting 1994
* Artikel 24b
* Geldig op 1-1-2023
* https://wetten.overheid.nl/BWBR0006324/2023-01-01#HoofdstukIV
*/
rates: [
{
threshold: 0,
fixedAmount: 45.42,
},
{
threshold: 600,
fixedAmount: 55.53,
variable: {
amount: 7.12,
},
},
{
threshold: 1100,
fixedAmount: 91.24,
variable: {
amount: 7.65,
},
},
{
threshold: 2100,
fixedAmount: 168.17,
variable: {
amount: 8.23,
},
},
{
threshold: 2800,
fixedAmount: 222.62,
variable: {
amount: 1.87,
},
},
],
},
} as RateMap;
Loading

0 comments on commit ace34ab

Please sign in to comment.