@pinelab/vendure-plugin-e-boekhouden 1.4.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 2.1.0 (2026-02-05)
2
+
3
+ - Upgraded to Vendure 3.5.3
4
+
5
+ # 2.0.0 (2025-11-25)
6
+
7
+ - Add support for custom VAT code strategy to define the VAT code to send to e-boekhouden
8
+
1
9
  # 1.4.2 (2025-11-13)
2
10
 
3
11
  - Documentation update
package/README.md CHANGED
@@ -15,7 +15,20 @@ mutation line for each taxrate of the order's tax summary.
15
15
  import { EboekhoudenPlugin } from '@pinelab/vendure-plugin-e-boekhouden'
16
16
 
17
17
  plugins: [
18
- EboekhoudenPlugin,
18
+ EboekhoudenPlugin.init({
19
+ getTaxCode: (ctx, order, taxRate) => {
20
+ if (order.customFields.VatID && taxRate == 0) {
21
+ return 'VERL_VERK'; // Reverse charge for EU sales
22
+ } else if (taxRate == 21) {
23
+ return 'HOOG_VERK_21';
24
+ } else if (taxRate == 9) {
25
+ return 'LAAG_VERK_9';
26
+ } else {
27
+ Logger.error(`Unknown tax rate ${taxRate} for order ${order.code}`);
28
+ return 'GEEN';
29
+ }
30
+ },
31
+ }),
19
32
  ...
20
33
  ]
21
34
  ```
@@ -1,5 +1,5 @@
1
1
  import { CMutatieRegel, OMut } from '../client';
2
- import { Order } from '@vendure/core';
2
+ import { Order, RequestContext } from '@vendure/core';
3
3
  import { EBoekhoudenConfigEntity } from './e-boekhouden-config.entity';
4
4
  import { OrderTaxSummary } from '@vendure/common/lib/generated-types';
5
5
  /**
@@ -18,8 +18,7 @@ export declare class EBoekhoudenAdapter {
18
18
  * Transforms an order, together with config, to a e-Boekhouden mutation format
19
19
  * using the order.taxSummary
20
20
  */
21
- static toMutation(order: Order, config: EBoekhoudenConfigEntity): OMut;
22
- static toMutationLine(tax: OrderTaxSummary, config: EBoekhoudenConfigEntity): CMutatieRegel;
23
- static getTax(value: number, reference: string): 'LAAG_VERK_9' | 'HOOG_VERK_21' | 'AFW' | 'GEEN';
21
+ static toMutation(ctx: RequestContext, order: Order, config: EBoekhoudenConfigEntity): OMut;
22
+ static toMutationLine(ctx: RequestContext, tax: OrderTaxSummary, order: Order, config: EBoekhoudenConfigEntity): CMutatieRegel;
24
23
  static toDateString(date: Date): string;
25
24
  }
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EBoekhoudenAdapter = exports.recalculateTaxFromTotalIncVAT = void 0;
4
- const core_1 = require("@vendure/core");
5
- const constants_1 = require("../constants");
4
+ const e_boekhouden_plugin_1 = require("../e-boekhouden.plugin");
6
5
  const toPrice = (price) => (Math.round(price) / 100).toFixed(2);
7
6
  /**
8
7
  * Recalculate taxes based on the taxBase+taxTotal (the totalIncVAT), because Vendure calculates taxes per orderline and
@@ -27,9 +26,9 @@ class EBoekhoudenAdapter {
27
26
  * Transforms an order, together with config, to a e-Boekhouden mutation format
28
27
  * using the order.taxSummary
29
28
  */
30
- static toMutation(order, config) {
29
+ static toMutation(ctx, order, config) {
31
30
  const description = `Order ${order.code} - ${order.customer?.firstName} ${order.customer?.lastName} (${order.customer?.emailAddress})`;
32
- const cMutatieRegel = order.taxSummary.map((summary) => this.toMutationLine(summary, config));
31
+ const cMutatieRegel = order.taxSummary.map((summary) => this.toMutationLine(ctx, summary, order, config));
33
32
  return {
34
33
  Soort: 'GeldOntvangen',
35
34
  Datum: this.toDateString(order.orderPlacedAt || order.updatedAt),
@@ -41,7 +40,7 @@ class EBoekhoudenAdapter {
41
40
  },
42
41
  };
43
42
  }
44
- static toMutationLine(tax, config) {
43
+ static toMutationLine(ctx, tax, order, config) {
45
44
  const recalculatedTax = (0, exports.recalculateTaxFromTotalIncVAT)(tax);
46
45
  return {
47
46
  BedragExclBTW: toPrice(recalculatedTax.totalExVAT),
@@ -49,25 +48,10 @@ class EBoekhoudenAdapter {
49
48
  BedragBTW: toPrice(recalculatedTax.totalTax),
50
49
  BTWPercentage: String(tax.taxRate),
51
50
  TegenrekeningCode: config.contraAccount,
52
- BTWCode: this.getTax(tax.taxRate, tax.description),
51
+ BTWCode: e_boekhouden_plugin_1.EBoekhoudenPlugin.options.getTaxCode(ctx, order, tax.taxRate),
53
52
  BedragInvoer: toPrice(recalculatedTax.totalIncVAT),
54
53
  };
55
54
  }
56
- static getTax(value, reference) {
57
- if (value === 9) {
58
- return 'LAAG_VERK_9';
59
- }
60
- else if (value === 21) {
61
- return 'HOOG_VERK_21';
62
- }
63
- else if (value === 0) {
64
- return 'GEEN';
65
- }
66
- else {
67
- core_1.Logger.error(`Unknown taxValue ${value} for ${reference}. Used 21 as default`, constants_1.loggerCtx);
68
- return 'HOOG_VERK_21';
69
- }
70
- }
71
55
  static toDateString(date) {
72
56
  const dateString = date.toISOString();
73
57
  return dateString.substr(0, 10);
@@ -95,7 +95,7 @@ let EBoekhoudenService = class EBoekhoudenService {
95
95
  let sessionId;
96
96
  try {
97
97
  sessionId = await this.openSession(config);
98
- const mutation = e_boekhouden_adapter_1.EBoekhoudenAdapter.toMutation(order, config);
98
+ const mutation = e_boekhouden_adapter_1.EBoekhoudenAdapter.toMutation(ctx, order, config);
99
99
  const result = await this.client.AddMutatieAsync({
100
100
  SessionID: sessionId,
101
101
  SecurityCode2: config.secret2,
@@ -0,0 +1,11 @@
1
+ import { RequestContext } from '@vendure/core';
2
+ import { Order } from '@vendure/core';
3
+ /**
4
+ * Codes as defined in the e-Boekhouden documentation
5
+ * https://cdn.e-boekhouden.nl/handleiding/Documentation_soap_english.pdf
6
+ */
7
+ export type EBoekhoudenBTWCode = 'HOOG_VERK' | 'HOOG_VERK_21' | 'LAAG_VERK' | 'LAAG_VERK_9' | 'LAAG_VERK_L9' | 'VERL_VERK_9' | 'VERL_VERK' | 'AFW' | 'BU_EU_VERK' | 'BI_EU_VERK' | 'BI_EU_VERK_D' | 'AFST_VERK' | 'LAAG_INK' | 'LAAG_INK_9' | 'VERL_INK_LG' | 'HOOG_INK' | 'HOOG_INK_21' | 'VERL_INK' | 'AFW_VERK' | 'BU_EU_INK' | 'BI_EU_INK' | 'GEEN';
8
+ export type GetTaxCodeFn = (ctx: RequestContext, order: Order, taxRate: number) => EBoekhoudenBTWCode;
9
+ export interface EBoekhoudenOptions {
10
+ getTaxCode: GetTaxCodeFn;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,7 @@
1
1
  import { AdminUiExtension } from '@vendure/ui-devkit/compiler';
2
+ import { EBoekhoudenOptions } from './api/types';
2
3
  export declare class EBoekhoudenPlugin {
4
+ static options: EBoekhoudenOptions;
5
+ static init(options: EBoekhoudenOptions): typeof EBoekhoudenPlugin;
3
6
  static ui: AdminUiExtension;
4
7
  }
@@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
10
10
  };
11
+ var EBoekhoudenPlugin_1;
11
12
  Object.defineProperty(exports, "__esModule", { value: true });
12
13
  exports.EBoekhoudenPlugin = void 0;
13
14
  const core_1 = require("@vendure/core");
@@ -16,7 +17,11 @@ const e_boekhouden_service_1 = require("./api/e-boekhouden.service");
16
17
  const e_boekhouden_config_entity_1 = require("./api/e-boekhouden-config.entity");
17
18
  const schema_graphql_1 = require("./api/schema.graphql");
18
19
  const e_boekhouden_resolver_1 = require("./api/e-boekhouden.resolver");
19
- let EBoekhoudenPlugin = class EBoekhoudenPlugin {
20
+ let EBoekhoudenPlugin = EBoekhoudenPlugin_1 = class EBoekhoudenPlugin {
21
+ static init(options) {
22
+ this.options = options;
23
+ return EBoekhoudenPlugin_1;
24
+ }
20
25
  };
21
26
  exports.EBoekhoudenPlugin = EBoekhoudenPlugin;
22
27
  EBoekhoudenPlugin.ui = {
@@ -35,7 +40,7 @@ EBoekhoudenPlugin.ui = {
35
40
  },
36
41
  ],
37
42
  };
38
- exports.EBoekhoudenPlugin = EBoekhoudenPlugin = __decorate([
43
+ exports.EBoekhoudenPlugin = EBoekhoudenPlugin = EBoekhoudenPlugin_1 = __decorate([
39
44
  (0, core_1.VendurePlugin)({
40
45
  imports: [core_1.PluginCommonModule],
41
46
  entities: [e_boekhouden_config_entity_1.EBoekhoudenConfigEntity],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinelab/vendure-plugin-e-boekhouden",
3
- "version": "1.4.2",
3
+ "version": "2.1.0",
4
4
  "description": "Vendure plugin for integration with the e-boekhouden accounting platform",
5
5
  "author": "Martijn van de Brug <martijn@pinelab.studio>",
6
6
  "homepage": "https://plugins.pinelab.studio/",
@@ -28,5 +28,5 @@
28
28
  "dependencies": {
29
29
  "soap": "^0.43.0"
30
30
  },
31
- "gitHead": "ba4e499e13892b029fac2aa29082c03ec8032249"
31
+ "gitHead": "349500e8984c828a399d21bd63bb8eb11aa790e8"
32
32
  }