@darkpos/pricing 1.0.58 → 1.0.59
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.
|
@@ -3106,4 +3106,70 @@ describe('Order actions', () => {
|
|
|
3106
3106
|
description: '12 USD discount',
|
|
3107
3107
|
});
|
|
3108
3108
|
});
|
|
3109
|
+
|
|
3110
|
+
test('CU-86dvhyxyq - Calling SetCustomer with and without a customer', () => {
|
|
3111
|
+
const order = {
|
|
3112
|
+
items: [
|
|
3113
|
+
{
|
|
3114
|
+
_id: 1,
|
|
3115
|
+
price: 10,
|
|
3116
|
+
quantity: 2,
|
|
3117
|
+
modifiers: [
|
|
3118
|
+
{
|
|
3119
|
+
name: 'modi-vip',
|
|
3120
|
+
tags: ['vip'],
|
|
3121
|
+
},
|
|
3122
|
+
],
|
|
3123
|
+
},
|
|
3124
|
+
],
|
|
3125
|
+
};
|
|
3126
|
+
|
|
3127
|
+
const updatedOrder = pricingService.order.setCustomer({
|
|
3128
|
+
order,
|
|
3129
|
+
customer: {},
|
|
3130
|
+
cache: {},
|
|
3131
|
+
});
|
|
3132
|
+
|
|
3133
|
+
expect(updatedOrder).toStrictEqual({
|
|
3134
|
+
items: [
|
|
3135
|
+
{
|
|
3136
|
+
_id: 1,
|
|
3137
|
+
price: 10,
|
|
3138
|
+
quantity: 2,
|
|
3139
|
+
modifiers: [
|
|
3140
|
+
{
|
|
3141
|
+
name: 'modi-vip',
|
|
3142
|
+
tags: ['vip'],
|
|
3143
|
+
},
|
|
3144
|
+
],
|
|
3145
|
+
},
|
|
3146
|
+
],
|
|
3147
|
+
customer: {
|
|
3148
|
+
isEmbedded: true,
|
|
3149
|
+
tags: [],
|
|
3150
|
+
},
|
|
3151
|
+
});
|
|
3152
|
+
|
|
3153
|
+
const updatedOrder2 = pricingService.order.setCustomer({
|
|
3154
|
+
order,
|
|
3155
|
+
customer: { _id: 'abd', tags: [] },
|
|
3156
|
+
cache: {},
|
|
3157
|
+
});
|
|
3158
|
+
|
|
3159
|
+
expect(updatedOrder2).toStrictEqual({
|
|
3160
|
+
items: [
|
|
3161
|
+
{
|
|
3162
|
+
_id: 1,
|
|
3163
|
+
price: 10,
|
|
3164
|
+
quantity: 2,
|
|
3165
|
+
modifiers: [],
|
|
3166
|
+
},
|
|
3167
|
+
],
|
|
3168
|
+
customer: {
|
|
3169
|
+
_id: 'abd',
|
|
3170
|
+
isEmbedded: true,
|
|
3171
|
+
tags: [],
|
|
3172
|
+
},
|
|
3173
|
+
});
|
|
3174
|
+
});
|
|
3109
3175
|
});
|
package/lib/order/setCustomer.js
CHANGED
|
@@ -6,18 +6,17 @@ module.exports = ({ itemActions, modifierActions, _ }) => {
|
|
|
6
6
|
if (!order) return null;
|
|
7
7
|
|
|
8
8
|
const { items = [] } = order;
|
|
9
|
-
const
|
|
9
|
+
const customerId = customer && customer._id;
|
|
10
10
|
|
|
11
11
|
const nextOrder = _.cloneDeep(order);
|
|
12
|
-
if (customer) {
|
|
13
|
-
nextOrder.customer = {
|
|
14
|
-
..._.cloneDeep(customer),
|
|
15
|
-
isEmbedded: true,
|
|
16
|
-
tags,
|
|
17
|
-
};
|
|
18
|
-
} else nextOrder.customer = null;
|
|
19
12
|
|
|
20
|
-
|
|
13
|
+
nextOrder.customer = {
|
|
14
|
+
..._.cloneDeep(customer),
|
|
15
|
+
isEmbedded: true,
|
|
16
|
+
tags: getTags(customer),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if (!items.length || !customerId) return nextOrder;
|
|
21
20
|
|
|
22
21
|
nextOrder.items = items.map(nextItem => {
|
|
23
22
|
const { itemModifiers, ...item } = nextItem;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkpos/pricing",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.59",
|
|
4
4
|
"description": "Pricing calculator",
|
|
5
5
|
"author": "Dark POS",
|
|
6
6
|
"license": "ISC",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"supertest": "^6.2.3",
|
|
46
46
|
"supervisor": "^0.12.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "a18ca520a52fa2ab8acc3a61e70e559e8759accf"
|
|
49
49
|
}
|