@unchainedshop/core-orders 5.0.0-alpha.5 → 5.0.0-alpha.8

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/README.md CHANGED
@@ -13,126 +13,18 @@ npm install @unchainedshop/core-orders
13
13
 
14
14
  ## Usage
15
15
 
16
- ```typescript
17
- import { configureOrdersModule, OrderStatus } from '@unchainedshop/core-orders';
18
-
19
- const ordersModule = await configureOrdersModule({ db });
20
-
21
- // Create an order
22
- const orderId = await ordersModule.create({
23
- userId: 'user-123',
24
- currency: 'CHF',
25
- countryCode: 'CH',
26
- });
16
+ The platform initializes this module as `platform.unchainedAPI.modules.orders`.
27
17
 
28
- // Add position to order
29
- await ordersModule.positions.create({
30
- orderId,
31
- productId: 'product-456',
32
- quantity: 2,
33
- });
18
+ ```typescript
19
+ const { orders } = platform.unchainedAPI.modules;
34
20
 
35
- // Checkout order
36
- await ordersModule.checkout(orderId, { paymentContext: {} });
21
+ const order = await orders.findOrder({ orderId: 'order-123' });
22
+ const userOrders = await orders.findOrders({ userId: 'user-123', limit: 20 });
37
23
  ```
38
24
 
39
- ## API Overview
40
-
41
- ### Module Configuration
42
-
43
- | Export | Description |
44
- |--------|-------------|
45
- | `configureOrdersModule` | Configure and return the orders module |
46
-
47
- ### Queries
48
-
49
- | Method | Description |
50
- |--------|-------------|
51
- | `findOrder` | Find order by ID or number |
52
- | `findOrders` | Find orders with filtering and pagination |
53
- | `count` | Count orders matching query |
54
- | `orderExists` | Check if order exists |
55
-
56
- ### Mutations
57
-
58
- | Method | Description |
59
- |--------|-------------|
60
- | `create` | Create a new order |
61
- | `update` | Update order data |
62
- | `delete` | Delete an order |
63
- | `checkout` | Process order checkout |
64
- | `confirm` | Confirm an order |
65
- | `reject` | Reject an order |
66
- | `setPaymentProvider` | Set payment provider |
67
- | `setDeliveryProvider` | Set delivery provider |
68
-
69
- ### Submodules
70
-
71
- #### Positions (`orders.positions`)
72
- | Method | Description |
73
- |--------|-------------|
74
- | `findPositions` | Find order positions |
75
- | `create` | Add position to order |
76
- | `update` | Update position |
77
- | `delete` | Remove position |
78
-
79
- #### Payments (`orders.payments`)
80
- | Method | Description |
81
- |--------|-------------|
82
- | `findPayment` | Find order payment |
83
- | `create` | Create payment for order |
84
- | `markPaid` | Mark payment as paid |
85
- | `charge` | Charge the payment |
86
-
87
- #### Deliveries (`orders.deliveries`)
88
- | Method | Description |
89
- |--------|-------------|
90
- | `findDelivery` | Find order delivery |
91
- | `create` | Create delivery for order |
92
- | `markDelivered` | Mark as delivered |
93
- | `send` | Trigger delivery |
94
-
95
- #### Discounts (`orders.discounts`)
96
- | Method | Description |
97
- |--------|-------------|
98
- | `findDiscounts` | Find order discounts |
99
- | `create` | Add discount to order |
100
- | `delete` | Remove discount |
101
-
102
- ### Constants
103
-
104
- | Export | Description |
105
- |--------|-------------|
106
- | `OrderStatus` | Order status values (OPEN, PENDING, CONFIRMED, FULFILLED, REJECTED) |
107
-
108
- ### Settings
109
-
110
- | Export | Description |
111
- |--------|-------------|
112
- | `ordersSettings` | Access order module settings |
113
-
114
- ### Types
115
-
116
- | Export | Description |
117
- |--------|-------------|
118
- | `Order` | Order document type |
119
- | `OrderPosition` | Position document type |
120
- | `OrderPayment` | Payment document type |
121
- | `OrderDelivery` | Delivery document type |
122
- | `OrderDiscount` | Discount document type |
123
- | `OrdersModule` | Module interface type |
124
-
125
- ## Events
25
+ Order positions, payments, deliveries, discounts, and statistics are exposed through the corresponding submodules. Use `unchainedAPI.services.orders` or the GraphQL API for cart operations and checkout so pricing, validation, payment, and delivery are coordinated.
126
26
 
127
- | Event | Description |
128
- |-------|-------------|
129
- | `ORDER_CREATE` | Order created |
130
- | `ORDER_UPDATE` | Order updated |
131
- | `ORDER_REMOVE` | Order deleted |
132
- | `ORDER_CHECKOUT` | Order checked out |
133
- | `ORDER_CONFIRMED` | Order confirmed |
134
- | `ORDER_REJECTED` | Order rejected |
135
- | `ORDER_FULFILLED` | Order fulfilled |
27
+ See the [module guide](https://docs.unchained.shop/platform-configuration/modules/orders), [checkout guide](https://docs.unchained.shop/guides/checkout-implementation), [public exports](src/orders-index.ts), and [module implementation](src/module/configureOrdersModule.ts).
136
28
 
137
29
  ## License
138
30
 
@@ -0,0 +1,4 @@
1
+ import type { MigrationRepository } from '@unchainedshop/mongodb';
2
+ import type { PricingCalculation } from '@unchainedshop/utils';
3
+ export declare const convertOrderCalculationToNet: (calculation: PricingCalculation[]) => PricingCalculation[];
4
+ export default function migrateOrderCalculationToNet(repository: MigrationRepository): void;
@@ -0,0 +1,125 @@
1
+ import { OrdersCollection } from "../db/OrdersCollection.js";
2
+ const legacyCalculationSelector = {
3
+ 'calculation.0': { $exists: true },
4
+ calculation: {
5
+ $not: { $elemMatch: { category: { $ne: 'TAXES' }, isNetPrice: true } },
6
+ },
7
+ };
8
+ export const convertOrderCalculationToNet = (calculation) => {
9
+ let previousBaseRow;
10
+ const attributed = calculation.map((row) => {
11
+ if (!row || !Number.isFinite(row.amount)) {
12
+ throw new Error('Calculation contains an invalid amount');
13
+ }
14
+ if (row.category !== 'TAXES') {
15
+ previousBaseRow = row;
16
+ return row;
17
+ }
18
+ const baseCategory = row.baseCategory || previousBaseRow?.category;
19
+ if (!baseCategory || baseCategory === 'TAXES') {
20
+ throw new Error('Cannot determine the base category of a tax row');
21
+ }
22
+ const discountId = row.discountId ??
23
+ (previousBaseRow?.category === baseCategory ? previousBaseRow.discountId : undefined);
24
+ return { ...row, baseCategory, discountId, isNetPrice: false };
25
+ });
26
+ const converted = attributed.flatMap((row) => {
27
+ if (row.category !== 'TAXES')
28
+ return [row];
29
+ return [
30
+ {
31
+ category: row.baseCategory,
32
+ amount: -row.amount,
33
+ discountId: row.discountId,
34
+ isNetPrice: true,
35
+ meta: row.meta,
36
+ },
37
+ row,
38
+ ];
39
+ });
40
+ const sum = (rows, category, discountId) => rows.reduce((total, row) => (category === undefined || row.category === category) &&
41
+ (discountId === undefined || row.discountId === discountId)
42
+ ? total + row.amount
43
+ : total, 0);
44
+ const taxes = attributed.filter((row) => row.category === 'TAXES');
45
+ const taxSum = (category, discountId) => sum(category === undefined ? taxes : taxes.filter((row) => row.baseCategory === category), undefined, discountId);
46
+ const categories = [
47
+ ...new Set(attributed.map((row) => (row.category === 'TAXES' ? row.baseCategory : row.category))),
48
+ ];
49
+ const discountIds = [...new Set(attributed.map((row) => row.discountId))].filter((discountId) => discountId !== undefined);
50
+ let roundingCategory = 'ROUNDING';
51
+ while (categories.includes(roundingCategory))
52
+ roundingCategory = `_${roundingCategory}`;
53
+ const scopes = [
54
+ ...categories.flatMap((category) => [
55
+ ...discountIds.map((discountId) => ({ category, discountId })),
56
+ { category, discountId: undefined },
57
+ ]),
58
+ ...discountIds.map((discountId) => ({ category: undefined, discountId })),
59
+ { category: undefined, discountId: undefined },
60
+ ];
61
+ const balances = scopes.map(({ category, discountId }) => ({
62
+ category,
63
+ discountId,
64
+ amount: sum(attributed, category, discountId) - taxSum(category, discountId),
65
+ }));
66
+ for (const { category, discountId, amount } of balances) {
67
+ const difference = amount - sum(converted, category, discountId);
68
+ if (!Number.isFinite(amount) || !Number.isFinite(difference)) {
69
+ throw new Error('Calculation contains an invalid balance');
70
+ }
71
+ if (difference) {
72
+ converted.push({
73
+ category: category ?? roundingCategory,
74
+ discountId,
75
+ amount: difference,
76
+ isNetPrice: true,
77
+ meta: { migration: 20260907120000, reason: 'Preserve historical floating-point balance' },
78
+ });
79
+ }
80
+ }
81
+ for (const { category, discountId, amount } of balances) {
82
+ if (sum(converted, category, discountId) !== amount) {
83
+ throw new Error(`Cannot preserve historical balance for ${category ?? 'order'} ${discountId ?? ''}`);
84
+ }
85
+ }
86
+ for (const discountId of discountIds) {
87
+ const before = sum(attributed, 'DISCOUNTS', discountId);
88
+ const after = sum(converted, 'DISCOUNTS', discountId) + taxSum('DISCOUNTS', discountId);
89
+ if (Math.round(before) !== Math.round(after) || Boolean(before) !== Boolean(after)) {
90
+ throw new Error(`Cannot preserve historical discount ${discountId}`);
91
+ }
92
+ }
93
+ return converted;
94
+ };
95
+ export default function migrateOrderCalculationToNet(repository) {
96
+ repository?.register({
97
+ id: 20260907120000,
98
+ name: 'Convert persisted order calculations from gross to net category balances',
99
+ up: async ({ logger }) => {
100
+ const Orders = await OrdersCollection(repository.db);
101
+ const projection = { _id: 1, calculation: 1 };
102
+ let migrated = 0;
103
+ for await (const order of Orders.find(legacyCalculationSelector, { projection })) {
104
+ let calculation;
105
+ try {
106
+ calculation = convertOrderCalculationToNet(order.calculation);
107
+ }
108
+ catch (error) {
109
+ throw new Error(`Cannot migrate order ${order._id}: ${error.message}`, { cause: error });
110
+ }
111
+ if (!calculation.some((row) => row.isNetPrice === true)) {
112
+ calculation = calculation.map((row) => ({ ...row, isNetPrice: true }));
113
+ }
114
+ const result = await Orders.updateOne({ _id: order._id, calculation: order.calculation }, { $set: { calculation } });
115
+ if (result.matchedCount) {
116
+ migrated += 1;
117
+ }
118
+ else if (await Orders.findOne({ _id: order._id, ...legacyCalculationSelector }, { projection })) {
119
+ throw new Error(`Order ${order._id} changed during migration; retry after stopping old writers`);
120
+ }
121
+ }
122
+ logger?.info(`Converted ${migrated} order calculation(s) to net category balances`);
123
+ },
124
+ });
125
+ }
@@ -8,6 +8,9 @@ export declare const configureOrderDeliveriesModule: ({ OrderDeliveries, }: {
8
8
  findDelivery: ({ orderDeliveryId }: {
9
9
  orderDeliveryId: string;
10
10
  }, options?: mongodb.FindOptions) => Promise<OrderDelivery | null>;
11
+ findDeliveries: ({ orderDeliveryIds }: {
12
+ orderDeliveryIds: string[];
13
+ }, options?: mongodb.FindOptions) => Promise<OrderDelivery[]>;
11
14
  findDeliveryByProvidersId: ({ deliveryProviderIds }: {
12
15
  deliveryProviderIds: string[];
13
16
  }, options?: mongodb.FindOptions) => Promise<OrderDelivery[]>;
@@ -32,6 +32,11 @@ export const configureOrderDeliveriesModule = ({ OrderDeliveries, }) => {
32
32
  findDelivery: async ({ orderDeliveryId }, options) => {
33
33
  return OrderDeliveries.findOne(buildFindByIdSelector(orderDeliveryId), options);
34
34
  },
35
+ findDeliveries: async ({ orderDeliveryIds }, options) => {
36
+ if (!orderDeliveryIds?.length)
37
+ return [];
38
+ return OrderDeliveries.find({ _id: { $in: orderDeliveryIds } }, options).toArray();
39
+ },
35
40
  findDeliveryByProvidersId: async ({ deliveryProviderIds }, options) => {
36
41
  if (!deliveryProviderIds?.length)
37
42
  return [];
@@ -7,8 +7,10 @@ export declare const configureOrderDiscountsModule: ({ OrderDiscounts, }: {
7
7
  findOrderDiscount: ({ discountId }: {
8
8
  discountId: string;
9
9
  }, options?: mongodb.FindOptions) => Promise<OrderDiscount | null>;
10
- findOrderDiscounts: ({ orderId }: {
10
+ findOrderDiscounts: (query: {
11
11
  orderId: string;
12
+ } | {
13
+ orderIds: string[];
12
14
  }) => Promise<OrderDiscount[]>;
13
15
  create: (doc: Omit<OrderDiscount, "_id" | "created" | "trigger"> & Pick<Partial<OrderDiscount>, "_id" | "created" | "trigger">) => Promise<OrderDiscount>;
14
16
  delete: (orderDiscountId: string) => Promise<mongodb.WithId<OrderDiscount> | null>;
@@ -13,7 +13,10 @@ export const configureOrderDiscountsModule = ({ OrderDiscounts, }) => {
13
13
  findOrderDiscount: async ({ discountId }, options) => {
14
14
  return OrderDiscounts.findOne(buildFindOrderDiscountByIdSelector(discountId), options);
15
15
  },
16
- findOrderDiscounts: async ({ orderId }) => {
16
+ findOrderDiscounts: async (query) => {
17
+ if ('orderIds' in query && !query.orderIds.length)
18
+ return [];
19
+ const orderId = 'orderIds' in query ? { $in: query.orderIds } : query.orderId;
17
20
  const discounts = OrderDiscounts.find({ orderId }, { sort: { created: 1, _id: 1 } });
18
21
  return discounts.toArray();
19
22
  },
@@ -8,6 +8,9 @@ export declare const configureOrderPaymentsModule: ({ OrderPayments, }: {
8
8
  findOrderPayment: ({ orderPaymentId, }: {
9
9
  orderPaymentId: string;
10
10
  }, options?: mongodb.FindOptions) => Promise<OrderPayment | null>;
11
+ findOrderPayments: ({ orderPaymentIds }: {
12
+ orderPaymentIds: string[];
13
+ }, options?: mongodb.FindOptions) => Promise<OrderPayment[]>;
11
14
  findOrderPaymentsByProviderIds: ({ paymentProviderIds, }: {
12
15
  paymentProviderIds: string[];
13
16
  }, options?: mongodb.FindOptions) => Promise<OrderPayment[]>;
@@ -35,6 +35,11 @@ export const configureOrderPaymentsModule = ({ OrderPayments, }) => {
35
35
  findOrderPayment: async ({ orderPaymentId, }, options) => {
36
36
  return OrderPayments.findOne(buildFindOrderPaymentByIdSelector(orderPaymentId), options);
37
37
  },
38
+ findOrderPayments: async ({ orderPaymentIds }, options) => {
39
+ if (!orderPaymentIds?.length)
40
+ return [];
41
+ return OrderPayments.find({ _id: { $in: orderPaymentIds } }, options).toArray();
42
+ },
38
43
  findOrderPaymentsByProviderIds: async ({ paymentProviderIds, }, options) => {
39
44
  if (!paymentProviderIds?.length)
40
45
  return [];
@@ -23,8 +23,10 @@ export declare const configureOrderPositionsModule: ({ OrderPositions, }: {
23
23
  findOrderPosition: ({ itemId }: {
24
24
  itemId: string;
25
25
  }, options?: mongodb.FindOptions) => Promise<OrderPosition | null>;
26
- findOrderPositions: ({ orderId }: {
26
+ findOrderPositions: (query: {
27
27
  orderId: string;
28
+ } | {
29
+ orderIds: string[];
28
30
  }) => Promise<OrderPosition[]>;
29
31
  delete: (orderPositionId: string) => Promise<mongodb.WithId<OrderPosition> | null>;
30
32
  removePositions: ({ orderId }: {
@@ -13,7 +13,10 @@ export const configureOrderPositionsModule = ({ OrderPositions, }) => {
13
13
  findOrderPosition: async ({ itemId }, options) => {
14
14
  return OrderPositions.findOne(buildFindOrderPositionByIdSelector(itemId), options);
15
15
  },
16
- findOrderPositions: async ({ orderId }) => {
16
+ findOrderPositions: async (query) => {
17
+ if ('orderIds' in query && !query.orderIds.length)
18
+ return [];
19
+ const orderId = 'orderIds' in query ? { $in: query.orderIds } : query.orderId;
17
20
  const positions = OrderPositions.find({ orderId, quantity: { $gt: 0 } }, { sort: { created: 1, _id: 1 } });
18
21
  return positions.toArray();
19
22
  },
@@ -5,7 +5,7 @@ export declare const configureOrderModuleMutations: ({ Orders, OrderPositions, }
5
5
  Orders: mongodb.Collection<Order>;
6
6
  OrderPositions: mongodb.Collection<OrderPosition>;
7
7
  }) => {
8
- create: ({ userId, orderNumber, currencyCode, countryCode, billingAddress, contact, context, }: {
8
+ create: ({ userId, orderNumber, currencyCode, countryCode, billingAddress, contact, originEnrollmentId, context, }: {
9
9
  userId: string;
10
10
  billingAddress?: Address;
11
11
  contact?: Contact;
@@ -20,7 +20,7 @@ export const configureOrderModuleMutations = ({ Orders, OrderPositions, }) => {
20
20
  };
21
21
  };
22
22
  return {
23
- create: async ({ userId, orderNumber, currencyCode, countryCode, billingAddress, contact, context, }) => {
23
+ create: async ({ userId, orderNumber, currencyCode, countryCode, billingAddress, contact, originEnrollmentId, context, }) => {
24
24
  const { insertedId: orderId } = await Orders.insertOne({
25
25
  _id: generateDbObjectId(),
26
26
  created: new Date(),
@@ -33,6 +33,7 @@ export const configureOrderModuleMutations = ({ Orders, OrderPositions, }) => {
33
33
  calculation: [],
34
34
  log: [],
35
35
  orderNumber,
36
+ originEnrollmentId,
36
37
  context: context || {},
37
38
  });
38
39
  const order = (await Orders.findOne(generateDbFilterById(orderId), {}));
@@ -161,19 +161,26 @@ export const configureOrdersModuleQueries = ({ Orders }) => {
161
161
  created: 1,
162
162
  currencyCode: 1,
163
163
  itemAmount: {
164
- $let: {
165
- vars: {
166
- item: {
167
- $first: {
168
- $filter: {
169
- input: '$calculation',
170
- as: 'c',
171
- cond: { $eq: ['$$c.category', 'ITEMS'] },
172
- },
164
+ $reduce: {
165
+ input: {
166
+ $filter: {
167
+ input: { $ifNull: ['$calculation', []] },
168
+ as: 'c',
169
+ cond: {
170
+ $or: [
171
+ { $eq: ['$$c.category', 'ITEMS'] },
172
+ {
173
+ $and: [
174
+ { $eq: ['$$c.category', 'TAXES'] },
175
+ { $eq: ['$$c.baseCategory', 'ITEMS'] },
176
+ ],
177
+ },
178
+ ],
173
179
  },
174
180
  },
175
181
  },
176
- in: '$$item.amount',
182
+ initialValue: 0,
183
+ in: { $add: ['$$value', { $ifNull: ['$$this.amount', 0] }] },
177
184
  },
178
185
  },
179
186
  },
@@ -6,6 +6,9 @@ export declare const configureOrdersModule: ({ db, migrationRepository, options:
6
6
  findDelivery: ({ orderDeliveryId }: {
7
7
  orderDeliveryId: string;
8
8
  }, options?: mongodb.FindOptions) => Promise<import("../db/OrderDeliveriesCollection.ts").OrderDelivery | null>;
9
+ findDeliveries: ({ orderDeliveryIds }: {
10
+ orderDeliveryIds: string[];
11
+ }, options?: mongodb.FindOptions) => Promise<import("../db/OrderDeliveriesCollection.ts").OrderDelivery[]>;
9
12
  findDeliveryByProvidersId: ({ deliveryProviderIds }: {
10
13
  deliveryProviderIds: string[];
11
14
  }, options?: mongodb.FindOptions) => Promise<import("../db/OrderDeliveriesCollection.ts").OrderDelivery[]>;
@@ -25,8 +28,10 @@ export declare const configureOrdersModule: ({ db, migrationRepository, options:
25
28
  findOrderDiscount: ({ discountId }: {
26
29
  discountId: string;
27
30
  }, options?: mongodb.FindOptions) => Promise<import("../db/OrderDiscountsCollection.ts").OrderDiscount | null>;
28
- findOrderDiscounts: ({ orderId }: {
31
+ findOrderDiscounts: (query: {
29
32
  orderId: string;
33
+ } | {
34
+ orderIds: string[];
30
35
  }) => Promise<import("../db/OrderDiscountsCollection.ts").OrderDiscount[]>;
31
36
  create: (doc: Omit<import("../db/OrderDiscountsCollection.ts").OrderDiscount, "_id" | "created" | "trigger"> & Pick<Partial<import("../db/OrderDiscountsCollection.ts").OrderDiscount>, "_id" | "created" | "trigger">) => Promise<import("../db/OrderDiscountsCollection.ts").OrderDiscount>;
32
37
  delete: (orderDiscountId: string) => Promise<mongodb.WithId<import("../db/OrderDiscountsCollection.ts").OrderDiscount> | null>;
@@ -44,8 +49,10 @@ export declare const configureOrdersModule: ({ db, migrationRepository, options:
44
49
  findOrderPosition: ({ itemId }: {
45
50
  itemId: string;
46
51
  }, options?: mongodb.FindOptions) => Promise<import("../db/OrderPositionsCollection.ts").OrderPosition | null>;
47
- findOrderPositions: ({ orderId }: {
52
+ findOrderPositions: (query: {
48
53
  orderId: string;
54
+ } | {
55
+ orderIds: string[];
49
56
  }) => Promise<import("../db/OrderPositionsCollection.ts").OrderPosition[]>;
50
57
  delete: (orderPositionId: string) => Promise<mongodb.WithId<import("../db/OrderPositionsCollection.ts").OrderPosition> | null>;
51
58
  removePositions: ({ orderId }: {
@@ -84,6 +91,9 @@ export declare const configureOrdersModule: ({ db, migrationRepository, options:
84
91
  findOrderPayment: ({ orderPaymentId, }: {
85
92
  orderPaymentId: string;
86
93
  }, options?: mongodb.FindOptions) => Promise<import("../db/OrderPaymentsCollection.ts").OrderPayment | null>;
94
+ findOrderPayments: ({ orderPaymentIds }: {
95
+ orderPaymentIds: string[];
96
+ }, options?: mongodb.FindOptions) => Promise<import("../db/OrderPaymentsCollection.ts").OrderPayment[]>;
87
97
  findOrderPaymentsByProviderIds: ({ paymentProviderIds, }: {
88
98
  paymentProviderIds: string[];
89
99
  }, options?: mongodb.FindOptions) => Promise<import("../db/OrderPaymentsCollection.ts").OrderPayment[]>;
@@ -110,7 +120,7 @@ export declare const configureOrdersModule: ({ db, migrationRepository, options:
110
120
  }>;
111
121
  setDeliveryProvider: (orderId: string, deliveryProviderId: string) => Promise<mongodb.WithId<Order> | null>;
112
122
  setPaymentProvider: (orderId: string, paymentProviderId: string) => Promise<mongodb.WithId<Order> | null>;
113
- create: ({ userId, orderNumber, currencyCode, countryCode, billingAddress, contact, context, }: {
123
+ create: ({ userId, orderNumber, currencyCode, countryCode, billingAddress, contact, originEnrollmentId, context, }: {
114
124
  userId: string;
115
125
  billingAddress?: import("@unchainedshop/mongodb").Address;
116
126
  contact?: import("@unchainedshop/mongodb").Contact;
@@ -15,6 +15,7 @@ import { configureOrdersModuleQueries } from "./configureOrdersModule-queries.js
15
15
  import { emit, registerEvents } from '@unchainedshop/events';
16
16
  import renameCurrencyCode from "../migrations/20250502111800-currency-code.js";
17
17
  import normalizeOrderContactPhone from "../migrations/20260625120000-normalize-contact-phone.js";
18
+ import migrateOrderCalculationToNet from "../migrations/20260907120000-order-calculation-net.js";
18
19
  const ORDER_EVENTS = [
19
20
  'ORDER_CHECKOUT',
20
21
  'ORDER_CONFIRMED',
@@ -24,6 +25,7 @@ const ORDER_EVENTS = [
24
25
  export const configureOrdersModule = async ({ db, migrationRepository, options: orderOptions = {}, }) => {
25
26
  renameCurrencyCode(migrationRepository);
26
27
  normalizeOrderContactPhone(migrationRepository);
28
+ migrateOrderCalculationToNet(migrationRepository);
27
29
  registerEvents(ORDER_EVENTS);
28
30
  ordersSettings.configureSettings(orderOptions);
29
31
  const Orders = await OrdersCollection(db);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/core-orders",
3
3
  "description": "Order management module for the Unchained Engine",
4
- "version": "5.0.0-alpha.5",
4
+ "version": "5.0.0-alpha.8",
5
5
  "main": "lib/orders-index.js",
6
6
  "types": "lib/orders-index.d.ts",
7
7
  "type": "module",
@@ -35,9 +35,9 @@
35
35
  },
36
36
  "homepage": "https://github.com/unchainedshop/unchained#readme",
37
37
  "dependencies": {
38
- "@unchainedshop/events": "^5.0.0-alpha.5",
39
- "@unchainedshop/mongodb": "^5.0.0-alpha.5",
40
- "@unchainedshop/utils": "^5.0.0-alpha.5"
38
+ "@unchainedshop/events": "^5.0.0-alpha.8",
39
+ "@unchainedshop/mongodb": "^5.0.0-alpha.8",
40
+ "@unchainedshop/utils": "^5.0.0-alpha.8"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^26.2.0",