@darkpos/pricing 1.0.97 → 1.0.99
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.
|
@@ -236,4 +236,142 @@ describe('addItemModifier Function', () => {
|
|
|
236
236
|
pricingService.order.addItemModifier(invalidModifierMock, orderMock);
|
|
237
237
|
}).toThrow(Error); // Expect an error to be thrown with invalid input
|
|
238
238
|
});
|
|
239
|
+
|
|
240
|
+
test('Add department modifier with customerTagsExtend and confirm price is correct, then remove it and confirm correct price again.', () => {
|
|
241
|
+
const order = {
|
|
242
|
+
_id: '68532dec3d51e6291225ccd9',
|
|
243
|
+
|
|
244
|
+
items: [
|
|
245
|
+
{
|
|
246
|
+
pieces: 2,
|
|
247
|
+
|
|
248
|
+
total: 129,
|
|
249
|
+
price: 129,
|
|
250
|
+
quantity: 1,
|
|
251
|
+
modifiers: [],
|
|
252
|
+
tags: ['default'],
|
|
253
|
+
category: null,
|
|
254
|
+
__typename: 'OrderItem',
|
|
255
|
+
priceLevels: [
|
|
256
|
+
{
|
|
257
|
+
value: 129,
|
|
258
|
+
tags: ['default'],
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
value: 15,
|
|
262
|
+
tags: ['default', 'vip'],
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
value: 10,
|
|
266
|
+
tags: ['default', 'rich'],
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
costLevels: [],
|
|
270
|
+
itemId: '67fea241af24e570c032b319',
|
|
271
|
+
subTotals: {},
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
notes: [],
|
|
275
|
+
customer: {
|
|
276
|
+
_id: '67feae8eeb5aa1e1848374b9',
|
|
277
|
+
tags: ['default'],
|
|
278
|
+
},
|
|
279
|
+
start: {
|
|
280
|
+
location: {
|
|
281
|
+
name: 'Sunshine Cleaners',
|
|
282
|
+
locationType: 'store',
|
|
283
|
+
storeId: '67e1c09c05b96100127280a8',
|
|
284
|
+
},
|
|
285
|
+
requestDate: '2025-06-18T21:21:48.745Z',
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
_storeId: '',
|
|
289
|
+
__typename: 'Order',
|
|
290
|
+
subTotals: {},
|
|
291
|
+
};
|
|
292
|
+
const originalItem = {
|
|
293
|
+
_id: '67fea241af24e570c032b319',
|
|
294
|
+
_updatedAt: '2025-06-18T20:21:00.922Z',
|
|
295
|
+
_createdAt: '2025-04-15T18:15:30.262Z',
|
|
296
|
+
name: "2pc Men's Suit",
|
|
297
|
+
description: null,
|
|
298
|
+
pieces: 2,
|
|
299
|
+
weight: 0,
|
|
300
|
+
properties: {
|
|
301
|
+
url: null,
|
|
302
|
+
color: 'rgba(178,232,239,1)',
|
|
303
|
+
label: {
|
|
304
|
+
backgroundColor: 'rgba(255,235,59,1)',
|
|
305
|
+
align: null,
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
sku: null,
|
|
309
|
+
hasInventory: false,
|
|
310
|
+
inventoryType: 'push',
|
|
311
|
+
quantity: 0,
|
|
312
|
+
tags: ['default'],
|
|
313
|
+
category: null,
|
|
314
|
+
__typename: 'Item',
|
|
315
|
+
modifiers: [],
|
|
316
|
+
priceLevels: [
|
|
317
|
+
{
|
|
318
|
+
value: 129,
|
|
319
|
+
tags: ['default'],
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
value: 15,
|
|
323
|
+
tags: ['default', 'vip'],
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
value: 10,
|
|
327
|
+
tags: ['default', 'rich'],
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
costLevels: [],
|
|
331
|
+
};
|
|
332
|
+
let result = pricingService.order.addItemModifier({
|
|
333
|
+
itemIndex: 0,
|
|
334
|
+
modifier: {
|
|
335
|
+
_id: '67fea241af24e570c032b33f',
|
|
336
|
+
attributes: ['department'],
|
|
337
|
+
name: 'Dry Cleaning',
|
|
338
|
+
group: 'Department',
|
|
339
|
+
tags: ['default'],
|
|
340
|
+
included: true,
|
|
341
|
+
direct: true,
|
|
342
|
+
code: 'D',
|
|
343
|
+
properties: {
|
|
344
|
+
group: null,
|
|
345
|
+
department: {
|
|
346
|
+
tagSize: 'small',
|
|
347
|
+
customerTagsExtend: ['vip'],
|
|
348
|
+
autoSplit: false,
|
|
349
|
+
splitUnit: 'quantity',
|
|
350
|
+
maxItems: '3',
|
|
351
|
+
},
|
|
352
|
+
url: null,
|
|
353
|
+
color: null,
|
|
354
|
+
label: {
|
|
355
|
+
backgroundColor: null,
|
|
356
|
+
align: null,
|
|
357
|
+
},
|
|
358
|
+
sort: null,
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
order,
|
|
362
|
+
force: true,
|
|
363
|
+
originalItem,
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
expect(result.items[0].price).toBe(15);
|
|
367
|
+
|
|
368
|
+
result = pricingService.order.removeItemModifier({
|
|
369
|
+
order: result,
|
|
370
|
+
modifier: result.items[0].modifiers[0],
|
|
371
|
+
itemIndex: 0,
|
|
372
|
+
originalItem,
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
expect(result.items[0].price).toBe(129);
|
|
376
|
+
});
|
|
239
377
|
});
|
|
@@ -80,6 +80,8 @@ module.exports = ({ actions, itemActions, modifierActions, utils, _ }) => {
|
|
|
80
80
|
order,
|
|
81
81
|
modifier: _modifier,
|
|
82
82
|
item: itemProp,
|
|
83
|
+
customer,
|
|
84
|
+
originalItem,
|
|
83
85
|
onConditionsNotMet,
|
|
84
86
|
onError,
|
|
85
87
|
}) => {
|
|
@@ -115,6 +117,12 @@ module.exports = ({ actions, itemActions, modifierActions, utils, _ }) => {
|
|
|
115
117
|
...(item.properties || {}),
|
|
116
118
|
};
|
|
117
119
|
|
|
120
|
+
item.price = itemActions.getItemPrice({
|
|
121
|
+
item,
|
|
122
|
+
itemPriceLevels: originalItem ? originalItem.priceLevels : undefined,
|
|
123
|
+
customer,
|
|
124
|
+
});
|
|
125
|
+
|
|
118
126
|
return item;
|
|
119
127
|
};
|
|
120
128
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports = ({ actions, modifierActions, _ }) => {
|
|
1
|
+
module.exports = ({ actions, modifierActions, itemActions, _ }) => {
|
|
2
2
|
const removeModifier = ({ item, modifier }) => {
|
|
3
3
|
const nextItem = { ...item, modifiers: [] };
|
|
4
4
|
|
|
@@ -29,6 +29,7 @@ module.exports = ({ actions, modifierActions, _ }) => {
|
|
|
29
29
|
return order;
|
|
30
30
|
|
|
31
31
|
let item = actions.getSelectedItem({ order, itemIndex });
|
|
32
|
+
const customer = actions.getCustomer(order);
|
|
32
33
|
|
|
33
34
|
const contains = modifierActions.contains(item.modifiers, modifier);
|
|
34
35
|
|
|
@@ -41,6 +42,12 @@ module.exports = ({ actions, modifierActions, _ }) => {
|
|
|
41
42
|
originalItem,
|
|
42
43
|
});
|
|
43
44
|
|
|
45
|
+
item.price = itemActions.getItemPrice({
|
|
46
|
+
item,
|
|
47
|
+
itemPriceLevels: originalItem ? originalItem.priceLevels : undefined,
|
|
48
|
+
customer,
|
|
49
|
+
});
|
|
50
|
+
|
|
44
51
|
order.items[itemIndex] = item;
|
|
45
52
|
|
|
46
53
|
return order;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkpos/pricing",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.99",
|
|
4
4
|
"description": "Pricing calculator",
|
|
5
5
|
"author": "Dark POS",
|
|
6
6
|
"license": "ISC",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"supertest": "^6.2.3",
|
|
55
55
|
"supervisor": "^0.12.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "4c83ad5f183f5b887c0ebd70e00e143282bf85a4"
|
|
58
58
|
}
|