@managesome/eposmatic-toolkit 0.2.461 → 0.2.463
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/lib/constants/WAREHOUSE_ANALYTICS.d.ts +1 -100
- package/lib/constants/WAREHOUSE_ANALYTICS.js +1 -11
- package/lib/constants/WAREHOUSE_ENUMS.d.ts +0 -6
- package/lib/constants/WAREHOUSE_ENUMS.js +1 -9
- package/lib/constants/WORKER_ENDPOINTS.d.ts +0 -4
- package/lib/constants/WORKER_ENDPOINTS.js +0 -4
- package/lib/constants/index.d.ts +0 -1
- package/lib/constants/index.js +0 -1
- package/lib/helpers/order/generate-warehouse-invoice.d.ts +3 -3
- package/lib/helpers/order/generate-warehouse-sale-order.d.ts +11 -0
- package/lib/helpers/order/generate-warehouse-sale-order.js +158 -0
- package/lib/helpers/order/index.d.ts +1 -1
- package/lib/helpers/order/index.js +1 -1
- package/lib/helpers/store/all-warehouse-sale-orders-actions.d.ts +12 -0
- package/lib/helpers/store/all-warehouse-sale-orders-actions.js +78 -0
- package/lib/helpers/store/common-warehouse-sale-order-actions.d.ts +26 -0
- package/lib/helpers/store/common-warehouse-sale-order-actions.js +428 -0
- package/lib/helpers/store/index.d.ts +2 -3
- package/lib/helpers/store/index.js +2 -3
- package/lib/helpers/store/warehouse-invoice-cart-actions.d.ts +2 -34
- package/lib/helpers/store/warehouse-sale-orders-cart-actions.d.ts +55 -0
- package/lib/helpers/store/warehouse-sale-orders-cart-actions.js +472 -0
- package/lib/helpers/types/index.d.ts +5 -5
- package/lib/helpers/types/index.js +5 -5
- package/lib/helpers/types/warehouse-sale-order-cart-actions.d.ts +26 -0
- package/lib/helpers/types/warehouse-sale-order-cart-actions.js +2 -0
- package/lib/helpers/types/workers.d.ts +4 -26
- package/lib/helpers/utils/index.d.ts +4 -4
- package/lib/helpers/utils/index.js +4 -4
- package/lib/helpers/utils/warehouse-sale-order-engine.d.ts +9 -0
- package/lib/helpers/utils/warehouse-sale-order-engine.js +34 -0
- package/lib/helpers/utils/warehouse-sale-order-receipt-engine.d.ts +89 -0
- package/lib/helpers/utils/warehouse-sale-order-receipt-engine.js +216 -0
- package/lib/helpers/utils/warehouse-void-sale-order-items-helpers.d.ts +3 -0
- package/lib/helpers/utils/warehouse-void-sale-order-items-helpers.js +38 -0
- package/lib/helpers/utils/warehouse-void-sale-order-items-report-helpers.d.ts +13 -0
- package/lib/helpers/utils/warehouse-void-sale-order-items-report-helpers.js +22 -0
- package/lib/schemas/models/index.d.ts +1 -2
- package/lib/schemas/models/index.js +1 -2
- package/lib/schemas/models/warehouse_void_sale_order_items.d.ts +176 -0
- package/lib/schemas/models/warehouse_void_sale_order_items.js +177 -0
- package/lib/schemas/types/index.d.ts +1 -2
- package/lib/schemas/types/index.js +1 -2
- package/lib/schemas/types/warehouse_sale_orders.d.ts +6 -0
- package/lib/schemas/types/warehouse_void_sale_order_items.d.ts +37 -0
- package/lib/schemas/types/warehouse_void_sale_order_items.js +2 -0
- package/package.json +1 -1
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.getWarehouseSaleOrdersFetchedData = getWarehouseSaleOrdersFetchedData;
|
|
4
7
|
exports.getWarehouseSaleOrderIterationsWithPrice = getWarehouseSaleOrderIterationsWithPrice;
|
|
5
8
|
exports.getWarehouseSaleOrderItemsWithPrice = getWarehouseSaleOrderItemsWithPrice;
|
|
6
9
|
exports.getWarehouseSaleOrderCategoriesWithPrice = getWarehouseSaleOrderCategoriesWithPrice;
|
|
7
10
|
exports.getWarehouseSaleOrderWithPrice = getWarehouseSaleOrderWithPrice;
|
|
11
|
+
exports.syncWarehouseSaleOrderData = syncWarehouseSaleOrderData;
|
|
12
|
+
exports.skipItemMetadataFromWarehouseSaleOrderCategories = skipItemMetadataFromWarehouseSaleOrderCategories;
|
|
13
|
+
exports.getWarehouseSaleOrderWithAllFields = getWarehouseSaleOrderWithAllFields;
|
|
14
|
+
exports.getWarehouseSaleOrderCartItemsObj = getWarehouseSaleOrderCartItemsObj;
|
|
15
|
+
exports.getVoidItemsWithReasonWarehouseSaleOrder = getVoidItemsWithReasonWarehouseSaleOrder;
|
|
16
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
17
|
+
const lodash_1 = require("lodash");
|
|
18
|
+
const constants_1 = require("../../constants");
|
|
8
19
|
const utils_1 = require("../utils");
|
|
9
20
|
const common_order_actions_1 = require("./common-order-actions");
|
|
21
|
+
const warehouse_sale_orders_cart_actions_1 = require("./warehouse-sale-orders-cart-actions");
|
|
10
22
|
function getWarehouseSaleOrdersFetchedData(data) {
|
|
11
23
|
return data.map((order) => getWarehouseSaleOrderWithPrice(order, false)).sort(common_order_actions_1.sortByCreatedAt);
|
|
12
24
|
}
|
|
@@ -68,3 +80,419 @@ function getWarehouseSaleOrderWithPrice(order, writeable) {
|
|
|
68
80
|
};
|
|
69
81
|
return payload;
|
|
70
82
|
}
|
|
83
|
+
function syncWarehouseSaleOrderData(order) {
|
|
84
|
+
const updatedOrder = {
|
|
85
|
+
...order,
|
|
86
|
+
iterations: [],
|
|
87
|
+
};
|
|
88
|
+
const newOrder = getWarehouseSaleOrderWithPrice((0, warehouse_sale_orders_cart_actions_1.calculateCartWarehouseSaleOrderInfoAndSyncData)(getWarehouseSaleOrderWithPrice(updatedOrder), true), true);
|
|
89
|
+
newOrder.iterations = order.iterations;
|
|
90
|
+
return newOrder;
|
|
91
|
+
}
|
|
92
|
+
function skipItemMetadataFromWarehouseSaleOrderCategories(categories, previousCategories) {
|
|
93
|
+
return categories.map((category) => {
|
|
94
|
+
const previousCategory = previousCategories?.find((prevCategory) => prevCategory.category_id === category.category_id);
|
|
95
|
+
return {
|
|
96
|
+
...category,
|
|
97
|
+
items: category.items.map((item) => {
|
|
98
|
+
const previousItem = previousCategory?.items.find((prevItem) => prevItem._id === item._id);
|
|
99
|
+
const void_reason = previousItem?.void_reason ?? item.void_reason;
|
|
100
|
+
const newItem = {
|
|
101
|
+
...item,
|
|
102
|
+
void_reason,
|
|
103
|
+
_discount_amount: 0,
|
|
104
|
+
_gst_amount: 0,
|
|
105
|
+
_gross_amount: 0,
|
|
106
|
+
_net_amount: 0,
|
|
107
|
+
};
|
|
108
|
+
return newItem;
|
|
109
|
+
}),
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function getCommonOptionalBoolFieldsSaleOrder(order, partial) {
|
|
114
|
+
const defaultValue = partial ? undefined : false;
|
|
115
|
+
return {
|
|
116
|
+
is_gst_inclusive: order['is_gst_inclusive'] || defaultValue,
|
|
117
|
+
is_reopened: order['is_reopened'] || defaultValue,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function getCommonOptionalNumFieldsSaleOrder(order, partial) {
|
|
121
|
+
const defaultValue = partial ? undefined : 0;
|
|
122
|
+
return {
|
|
123
|
+
gst: order['gst'] || defaultValue,
|
|
124
|
+
gst_amount: order['gst_amount'] || defaultValue,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function getWarehouseSaleOrderWithAllFields(order, skipItemMetadata) {
|
|
128
|
+
return {
|
|
129
|
+
...order,
|
|
130
|
+
...getCommonOptionalBoolFieldsSaleOrder(order, false),
|
|
131
|
+
...getCommonOptionalNumFieldsSaleOrder(order, false),
|
|
132
|
+
...(skipItemMetadata && order.categories != null
|
|
133
|
+
? {
|
|
134
|
+
categories: skipItemMetadataFromWarehouseSaleOrderCategories(order.categories),
|
|
135
|
+
}
|
|
136
|
+
: {}),
|
|
137
|
+
delete_reason: order['delete_reason'] ?? null,
|
|
138
|
+
cancel_reason: order['cancel_reason'] ?? null,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function getWarehouseSaleOrderCartItemsObj({ currentIterationCategories, previousIterationCategories, mappedItems, shouldSortItemsViaId = true, isAnEdit, sortType, }) {
|
|
142
|
+
const newMappedItems = { ...mappedItems };
|
|
143
|
+
if (Object.keys(newMappedItems).length === 0) {
|
|
144
|
+
previousIterationCategories?.forEach((category) => {
|
|
145
|
+
category.items.forEach((item) => {
|
|
146
|
+
if (newMappedItems[item.item_id] == null) {
|
|
147
|
+
newMappedItems[item.item_id] = {
|
|
148
|
+
_id: item.item_id,
|
|
149
|
+
name: item.name,
|
|
150
|
+
category_id: category.category_id,
|
|
151
|
+
category_name: category.name,
|
|
152
|
+
category_image_url: '',
|
|
153
|
+
image_url: '',
|
|
154
|
+
description: '',
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
currentIterationCategories?.forEach((category) => {
|
|
160
|
+
category.items.forEach((item) => {
|
|
161
|
+
if (newMappedItems[item.item_id] == null) {
|
|
162
|
+
newMappedItems[item.item_id] = {
|
|
163
|
+
_id: item.item_id,
|
|
164
|
+
name: item.name,
|
|
165
|
+
category_id: category.category_id,
|
|
166
|
+
category_name: category.name,
|
|
167
|
+
category_image_url: '',
|
|
168
|
+
image_url: '',
|
|
169
|
+
description: '',
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
// =====================><=====================
|
|
176
|
+
const getCartItems = (items) => {
|
|
177
|
+
const orderItems = items.map((item) => {
|
|
178
|
+
const selectedItem = newMappedItems[item.item_id] ?? {};
|
|
179
|
+
return {
|
|
180
|
+
orderItem: item,
|
|
181
|
+
image_url: selectedItem.image_url ?? '',
|
|
182
|
+
description: selectedItem.description ?? '',
|
|
183
|
+
category_name: selectedItem.category_name ?? '',
|
|
184
|
+
category_id: selectedItem.category_id ?? '',
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
if (shouldSortItemsViaId) {
|
|
188
|
+
if (sortType === constants_1.SORT_TYPE_ENUM.DESC) {
|
|
189
|
+
orderItems.sort((a, b) => (0, bson_objectid_1.default)(b.orderItem._id).getTimestamp().getTime() - (0, bson_objectid_1.default)(a.orderItem._id).getTimestamp().getTime());
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
orderItems.sort((a, b) => (0, bson_objectid_1.default)(a.orderItem._id).getTimestamp().getTime() - (0, bson_objectid_1.default)(b.orderItem._id).getTimestamp().getTime());
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return orderItems;
|
|
196
|
+
};
|
|
197
|
+
// =====================><=====================
|
|
198
|
+
let totalItemsInCart = 0;
|
|
199
|
+
const currentItems = [];
|
|
200
|
+
if (currentIterationCategories != null) {
|
|
201
|
+
for (let i = 0; i < currentIterationCategories.length; i++) {
|
|
202
|
+
const category = currentIterationCategories[i];
|
|
203
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
204
|
+
const item = { ...category.items[j] };
|
|
205
|
+
currentItems.push(item);
|
|
206
|
+
totalItemsInCart += item.quantity;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
let unChangedItems = currentItems;
|
|
211
|
+
const editedItems = [];
|
|
212
|
+
let removedItems = [];
|
|
213
|
+
let newItems = [];
|
|
214
|
+
let disabledReason = '';
|
|
215
|
+
const isAnUpdate = isAnEdit ?? (previousIterationCategories != null && previousIterationCategories.length > 0);
|
|
216
|
+
if (isAnUpdate) {
|
|
217
|
+
const currentItemsMap = currentItems.reduce((acc, currentItem) => {
|
|
218
|
+
acc[currentItem._id] = currentItem;
|
|
219
|
+
return acc;
|
|
220
|
+
}, {});
|
|
221
|
+
const prevItems = [];
|
|
222
|
+
const prevItemsMap = {};
|
|
223
|
+
const prevCategories = previousIterationCategories ?? [];
|
|
224
|
+
for (let i = 0; i < prevCategories.length; i++) {
|
|
225
|
+
const category = prevCategories[i];
|
|
226
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
227
|
+
const prevItem = category.items[j];
|
|
228
|
+
let item = prevItem;
|
|
229
|
+
const currentItem = currentItemsMap[prevItem._id];
|
|
230
|
+
if (currentItem != null && currentItem.is_ready != null) {
|
|
231
|
+
item = {
|
|
232
|
+
...item,
|
|
233
|
+
is_ready: currentItem.is_ready,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
prevItems.push(item);
|
|
237
|
+
prevItemsMap[item._id] = item;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
unChangedItems = [];
|
|
241
|
+
let totalTempRemovedItems = 0;
|
|
242
|
+
for (let i = 0; i < prevItems.length; i++) {
|
|
243
|
+
const prevItem = {
|
|
244
|
+
...prevItems[i],
|
|
245
|
+
};
|
|
246
|
+
const currentItem = {
|
|
247
|
+
...currentItemsMap[prevItem._id],
|
|
248
|
+
};
|
|
249
|
+
if (currentItemsMap[prevItem._id] == null) {
|
|
250
|
+
removedItems.push(prevItem);
|
|
251
|
+
}
|
|
252
|
+
else if ((0, lodash_1.isEqual)((0, warehouse_sale_orders_cart_actions_1.getWarehouseSaleOrderItemComparableData)(currentItem), (0, warehouse_sale_orders_cart_actions_1.getWarehouseSaleOrderItemComparableData)(prevItem))) {
|
|
253
|
+
unChangedItems.push(prevItem);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
const currQty = currentItem.quantity;
|
|
257
|
+
const prevQty = prevItem.quantity;
|
|
258
|
+
if (currQty !== prevQty) {
|
|
259
|
+
const subtotalForOne = currentItem.subtotal / currentItem.quantity;
|
|
260
|
+
const diff = currQty - prevQty;
|
|
261
|
+
const changeQty = Math.abs(diff);
|
|
262
|
+
const itm = {
|
|
263
|
+
...currentItem,
|
|
264
|
+
quantity: changeQty,
|
|
265
|
+
subtotal: (0, utils_1.parseNum)(changeQty * subtotalForOne),
|
|
266
|
+
};
|
|
267
|
+
if (diff > 0) {
|
|
268
|
+
newItems.push(itm);
|
|
269
|
+
const unchangedQty = currQty - changeQty;
|
|
270
|
+
const tempUnchangedItm = {
|
|
271
|
+
...currentItem,
|
|
272
|
+
quantity: unchangedQty,
|
|
273
|
+
subtotal: (0, utils_1.parseNum)(unchangedQty * subtotalForOne),
|
|
274
|
+
};
|
|
275
|
+
unChangedItems.push(tempUnchangedItm);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
itm.void_reason = prevItem.void_reason ?? currentItem.void_reason;
|
|
279
|
+
removedItems.push(itm);
|
|
280
|
+
const unchangedQty = prevQty - changeQty;
|
|
281
|
+
const tempUnchangedItm = {
|
|
282
|
+
...currentItem,
|
|
283
|
+
quantity: unchangedQty,
|
|
284
|
+
subtotal: (0, utils_1.parseNum)(unchangedQty * subtotalForOne),
|
|
285
|
+
};
|
|
286
|
+
unChangedItems.push(tempUnchangedItm);
|
|
287
|
+
totalTempRemovedItems++;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
const curr = {
|
|
292
|
+
_id: currentItem._id,
|
|
293
|
+
item_id: currentItem.item_id,
|
|
294
|
+
name: currentItem.name,
|
|
295
|
+
special_instructions: currentItem.special_instructions,
|
|
296
|
+
};
|
|
297
|
+
const prev = {
|
|
298
|
+
_id: prevItem._id,
|
|
299
|
+
item_id: prevItem.item_id,
|
|
300
|
+
name: prevItem.name,
|
|
301
|
+
special_instructions: prevItem.special_instructions,
|
|
302
|
+
};
|
|
303
|
+
const isBothEqual = (0, lodash_1.isEqual)(curr, prev);
|
|
304
|
+
if (isBothEqual) {
|
|
305
|
+
unChangedItems.push(currentItem);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
editedItems.push(currentItem);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
for (let i = 0; i < currentItems.length; i++) {
|
|
314
|
+
const item = currentItems[i];
|
|
315
|
+
if (prevItemsMap[item._id] == null) {
|
|
316
|
+
newItems.push(item);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (removedItems.length > 0 && newItems.length > 0) {
|
|
320
|
+
const newItemsMap = newItems.reduce((acc, item) => {
|
|
321
|
+
acc[item.item_id] = [...(acc[item.item_id] ?? []), item];
|
|
322
|
+
return acc;
|
|
323
|
+
}, {});
|
|
324
|
+
const revertedRemovedItems = [];
|
|
325
|
+
const revertedNewItems = [];
|
|
326
|
+
const additionalNewItems = [];
|
|
327
|
+
for (let i = 0; i < removedItems.length; i++) {
|
|
328
|
+
const removedItem = removedItems[i];
|
|
329
|
+
const newItemsForItem = newItemsMap[removedItem.item_id];
|
|
330
|
+
if (newItemsForItem == null)
|
|
331
|
+
continue;
|
|
332
|
+
if (newItemsForItem.length > 0) {
|
|
333
|
+
const newItemsForItemLength = newItemsForItem.length;
|
|
334
|
+
for (let j = 0; j < newItemsForItemLength; j++) {
|
|
335
|
+
const newItem = newItemsForItem[j];
|
|
336
|
+
const newI = {
|
|
337
|
+
item_id: newItem.item_id,
|
|
338
|
+
name: newItem.name,
|
|
339
|
+
price: newItem.price,
|
|
340
|
+
special_instructions: newItem.special_instructions,
|
|
341
|
+
};
|
|
342
|
+
const removedI = {
|
|
343
|
+
item_id: removedItem.item_id,
|
|
344
|
+
name: removedItem.name,
|
|
345
|
+
price: removedItem.price,
|
|
346
|
+
special_instructions: removedItem.special_instructions,
|
|
347
|
+
};
|
|
348
|
+
if ((0, lodash_1.isEqual)(newI, removedI)) {
|
|
349
|
+
if (newItem.quantity === removedItem.quantity) {
|
|
350
|
+
newItemsMap[removedItem.item_id] = newItemsForItem.filter((item) => item._id !== newItem._id);
|
|
351
|
+
if (newItemsMap[removedItem.item_id].length === 0) {
|
|
352
|
+
delete newItemsMap[removedItem.item_id];
|
|
353
|
+
}
|
|
354
|
+
revertedNewItems.push(newItem);
|
|
355
|
+
revertedRemovedItems.push(removedItem);
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
if (removedItem.quantity > newItem.quantity) {
|
|
360
|
+
newItemsMap[removedItem.item_id] = newItemsForItem.filter((item) => item._id !== newItem._id);
|
|
361
|
+
if (newItemsMap[removedItem.item_id].length === 0) {
|
|
362
|
+
delete newItemsMap[removedItem.item_id];
|
|
363
|
+
}
|
|
364
|
+
revertedNewItems.push(newItem);
|
|
365
|
+
const subtotalForSingle = removedItem.subtotal / removedItem.quantity;
|
|
366
|
+
const newQuantity = removedItem.quantity - newItem.quantity;
|
|
367
|
+
const newSubtotal = (0, utils_1.parseNum)(newQuantity * subtotalForSingle);
|
|
368
|
+
removedItem.quantity = newQuantity;
|
|
369
|
+
removedItem.subtotal = newSubtotal;
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
revertedRemovedItems.push(removedItem);
|
|
373
|
+
const nQuantity = newItem.quantity;
|
|
374
|
+
const subtotalForSingle = newItem.subtotal / nQuantity;
|
|
375
|
+
const newQuantity = nQuantity - removedItem.quantity;
|
|
376
|
+
const newSubtotal = (0, utils_1.parseNum)(newQuantity * subtotalForSingle);
|
|
377
|
+
newItem.quantity = newQuantity;
|
|
378
|
+
newItem.subtotal = newSubtotal;
|
|
379
|
+
const remainingQuantity = nQuantity - newQuantity;
|
|
380
|
+
const adItem = {
|
|
381
|
+
...newItem,
|
|
382
|
+
quantity: remainingQuantity,
|
|
383
|
+
subtotal: (0, utils_1.parseNum)(remainingQuantity * subtotalForSingle),
|
|
384
|
+
};
|
|
385
|
+
additionalNewItems.push(adItem);
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
delete newItemsMap[removedItem.item_id];
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
for (let i = 0; i < revertedRemovedItems.length; i++) {
|
|
397
|
+
const rItem = revertedRemovedItems[i];
|
|
398
|
+
removedItems = removedItems.filter((item) => item._id !== rItem._id);
|
|
399
|
+
}
|
|
400
|
+
for (let i = 0; i < revertedNewItems.length; i++) {
|
|
401
|
+
const nItem = revertedNewItems[i];
|
|
402
|
+
newItems = newItems.filter((item) => item._id !== nItem._id);
|
|
403
|
+
unChangedItems.push(nItem);
|
|
404
|
+
}
|
|
405
|
+
for (let i = 0; i < additionalNewItems.length; i++) {
|
|
406
|
+
const aItem = additionalNewItems[i];
|
|
407
|
+
unChangedItems.push(aItem);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
disabledReason =
|
|
411
|
+
unChangedItems.length === prevItems.length &&
|
|
412
|
+
newItems.length === 0 &&
|
|
413
|
+
removedItems.length === 0 &&
|
|
414
|
+
editedItems.length === 0
|
|
415
|
+
? 'No changes in the order'
|
|
416
|
+
: prevItems.length === removedItems.length - totalTempRemovedItems &&
|
|
417
|
+
editedItems.length === 0 &&
|
|
418
|
+
newItems.length === 0
|
|
419
|
+
? 'At least one item is required'
|
|
420
|
+
: '';
|
|
421
|
+
}
|
|
422
|
+
const cartItemsObj = {
|
|
423
|
+
unChangedItems: getCartItems(unChangedItems),
|
|
424
|
+
editedItems: getCartItems(editedItems),
|
|
425
|
+
removedItems: getCartItems(removedItems),
|
|
426
|
+
newItems: getCartItems(newItems),
|
|
427
|
+
totalSelectedItems: (0, utils_1.parseNum)(totalItemsInCart, true),
|
|
428
|
+
disabledReason,
|
|
429
|
+
isAnUpdate,
|
|
430
|
+
};
|
|
431
|
+
return cartItemsObj;
|
|
432
|
+
}
|
|
433
|
+
function getVoidItemsWithReasonWarehouseSaleOrder({ currentCategories, iterationsFromFrontend, previousCategories, }) {
|
|
434
|
+
const voidOrderItemReasonsMap = {};
|
|
435
|
+
const latestIterationCategories = iterationsFromFrontend?.[0]?.categories;
|
|
436
|
+
if (latestIterationCategories != null && latestIterationCategories.length > 0) {
|
|
437
|
+
for (let i = 0; i < latestIterationCategories.length; i++) {
|
|
438
|
+
const category = latestIterationCategories[i];
|
|
439
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
440
|
+
const item = category.items[j];
|
|
441
|
+
if (item.void_reason != null && item.void_reason.length > 0) {
|
|
442
|
+
voidOrderItemReasonsMap[item._id] = item.void_reason;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
const { newItems, removedItems } = getWarehouseSaleOrderCartItemsObj({
|
|
448
|
+
currentIterationCategories: currentCategories,
|
|
449
|
+
previousIterationCategories: previousCategories,
|
|
450
|
+
mappedItems: {},
|
|
451
|
+
shouldSortItemsViaId: false,
|
|
452
|
+
isAnEdit: true,
|
|
453
|
+
});
|
|
454
|
+
const hasNewItems = newItems.length > 0;
|
|
455
|
+
const voidOrderItems = [];
|
|
456
|
+
const newVoidOrderItemReasonsMap = {};
|
|
457
|
+
for (let i = 0; i < removedItems.length; i++) {
|
|
458
|
+
const { orderItem } = removedItems[i];
|
|
459
|
+
const voidReason = voidOrderItemReasonsMap[orderItem._id];
|
|
460
|
+
voidOrderItems.push({
|
|
461
|
+
...orderItem,
|
|
462
|
+
subtotal: Math.round(orderItem.subtotal),
|
|
463
|
+
void_reason: voidReason ?? '-',
|
|
464
|
+
});
|
|
465
|
+
if (voidReason != null) {
|
|
466
|
+
newVoidOrderItemReasonsMap[orderItem._id] = voidReason;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
const newIterationCategories = [];
|
|
470
|
+
for (let i = 0; i < previousCategories.length; i++) {
|
|
471
|
+
const category = previousCategories[i];
|
|
472
|
+
const newCategoryItems = [];
|
|
473
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
474
|
+
const prevItem = category.items[j];
|
|
475
|
+
const voidReason = newVoidOrderItemReasonsMap[prevItem._id];
|
|
476
|
+
const orderItem = {
|
|
477
|
+
...prevItem,
|
|
478
|
+
subtotal: Math.round(prevItem.subtotal),
|
|
479
|
+
};
|
|
480
|
+
if (voidReason != null) {
|
|
481
|
+
orderItem.void_reason = voidReason;
|
|
482
|
+
}
|
|
483
|
+
newCategoryItems.push(orderItem);
|
|
484
|
+
}
|
|
485
|
+
if (newCategoryItems.length === 0)
|
|
486
|
+
continue;
|
|
487
|
+
newIterationCategories.push({
|
|
488
|
+
...category,
|
|
489
|
+
items: newCategoryItems,
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
return {
|
|
493
|
+
categories: newIterationCategories,
|
|
494
|
+
voidOrderItems,
|
|
495
|
+
hasNewItems,
|
|
496
|
+
voidItemsCount: voidOrderItems.length,
|
|
497
|
+
};
|
|
498
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
export * from './all-orders-actions';
|
|
2
|
-
export * from './all-warehouse-invoice-actions';
|
|
3
2
|
export * from './all-warehouse-purchase-order-rfqs-actions';
|
|
4
3
|
export * from './all-warehouse-purchase-order-vendor-return-actions';
|
|
5
4
|
export * from './all-warehouse-purchase-orders-actions';
|
|
6
5
|
export * from './all-warehouse-sale-order-rfqs-actions';
|
|
6
|
+
export * from './all-warehouse-sale-orders-actions';
|
|
7
7
|
export * from './cart-actions';
|
|
8
8
|
export * from './catalog-actions';
|
|
9
9
|
export * from './common-order-actions';
|
|
10
10
|
export * from './common-tenant-purchase-order-actions';
|
|
11
|
-
export * from './common-warehouse-invoice-actions';
|
|
12
11
|
export * from './common-warehouse-internal-movement-actions';
|
|
13
12
|
export * from './common-warehouse-purchase-order-actions';
|
|
14
13
|
export * from './common-warehouse-purchase-order-receipt-actions';
|
|
@@ -19,7 +18,7 @@ export * from './common-warehouse-sale-order-invoice-actions';
|
|
|
19
18
|
export * from './common-warehouse-sale-order-rfq-actions';
|
|
20
19
|
export * from './offline-ordering';
|
|
21
20
|
export * from './tenant-purchase-orders-cart-actions';
|
|
22
|
-
export * from './warehouse-invoice-cart-actions';
|
|
23
21
|
export * from './warehouse-purchase-order-rfq-cart-actions';
|
|
24
22
|
export * from './warehouse-purchase-orders-cart-actions';
|
|
25
23
|
export * from './warehouse-sale-order-rfq-cart-actions';
|
|
24
|
+
export * from './warehouse-sale-orders-cart-actions';
|
|
@@ -15,16 +15,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./all-orders-actions"), exports);
|
|
18
|
-
__exportStar(require("./all-warehouse-invoice-actions"), exports);
|
|
19
18
|
__exportStar(require("./all-warehouse-purchase-order-rfqs-actions"), exports);
|
|
20
19
|
__exportStar(require("./all-warehouse-purchase-order-vendor-return-actions"), exports);
|
|
21
20
|
__exportStar(require("./all-warehouse-purchase-orders-actions"), exports);
|
|
22
21
|
__exportStar(require("./all-warehouse-sale-order-rfqs-actions"), exports);
|
|
22
|
+
__exportStar(require("./all-warehouse-sale-orders-actions"), exports);
|
|
23
23
|
__exportStar(require("./cart-actions"), exports);
|
|
24
24
|
__exportStar(require("./catalog-actions"), exports);
|
|
25
25
|
__exportStar(require("./common-order-actions"), exports);
|
|
26
26
|
__exportStar(require("./common-tenant-purchase-order-actions"), exports);
|
|
27
|
-
__exportStar(require("./common-warehouse-invoice-actions"), exports);
|
|
28
27
|
__exportStar(require("./common-warehouse-internal-movement-actions"), exports);
|
|
29
28
|
__exportStar(require("./common-warehouse-purchase-order-actions"), exports);
|
|
30
29
|
__exportStar(require("./common-warehouse-purchase-order-receipt-actions"), exports);
|
|
@@ -35,7 +34,7 @@ __exportStar(require("./common-warehouse-sale-order-invoice-actions"), exports);
|
|
|
35
34
|
__exportStar(require("./common-warehouse-sale-order-rfq-actions"), exports);
|
|
36
35
|
__exportStar(require("./offline-ordering"), exports);
|
|
37
36
|
__exportStar(require("./tenant-purchase-orders-cart-actions"), exports);
|
|
38
|
-
__exportStar(require("./warehouse-invoice-cart-actions"), exports);
|
|
39
37
|
__exportStar(require("./warehouse-purchase-order-rfq-cart-actions"), exports);
|
|
40
38
|
__exportStar(require("./warehouse-purchase-orders-cart-actions"), exports);
|
|
41
39
|
__exportStar(require("./warehouse-sale-order-rfq-cart-actions"), exports);
|
|
40
|
+
__exportStar(require("./warehouse-sale-orders-cart-actions"), exports);
|
|
@@ -1,39 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IWarehouseClientInvoice, IWarehouseClientInvoiceCategory, IWarehouseClientInvoiceItem, IWarehouseClientInvoiceIteration } from '../../schemas';
|
|
1
|
+
import { IWarehouseClientInvoice, IWarehouseClientInvoiceItem } from '../../schemas';
|
|
3
2
|
export declare const getWarehouseClientInvoiceItemComparableData: (item: IWarehouseClientInvoiceItem) => Partial<IWarehouseClientInvoiceItem>;
|
|
4
3
|
export declare function calculateCartWarehouseClientInvoiceInfoAndSyncData<T extends IWarehouseClientInvoice | Partial<IWarehouseClientInvoice>>(data: T, calculateItemMetadata?: boolean): T;
|
|
5
|
-
export declare function getUpdatedWarehouseInvoiceCartInfoOnInit(data: Partial<IWarehouseClientInvoice>, order: Partial<IWarehouseClientInvoice>):
|
|
6
|
-
_id?: string | undefined;
|
|
7
|
-
warehouse_id?: string | undefined;
|
|
8
|
-
client_id?: string | undefined;
|
|
9
|
-
client_name?: string | undefined;
|
|
10
|
-
iterations?: IWarehouseClientInvoiceIteration[] | undefined;
|
|
11
|
-
amount_collected?: number | undefined;
|
|
12
|
-
order_number?: number | null | undefined;
|
|
13
|
-
delete_reason?: string | null;
|
|
14
|
-
cancel_reason?: string | null;
|
|
15
|
-
is_deleted?: boolean | undefined;
|
|
16
|
-
order_status_updated_at?: Date | undefined;
|
|
17
|
-
is_reopened?: boolean;
|
|
18
|
-
deferred_settlement?: boolean;
|
|
19
|
-
order_settled_at?: Date | undefined;
|
|
20
|
-
order_settled_at_mins?: number | undefined;
|
|
21
|
-
createdAt_mins?: number | undefined;
|
|
22
|
-
createdAt?: Date | undefined;
|
|
23
|
-
categories?: IWarehouseClientInvoiceCategory[] | undefined;
|
|
24
|
-
payments?: import("../../schemas").IOrderPayment[] | undefined;
|
|
25
|
-
staff_details?: import("../../schemas").IStaffDetails | undefined;
|
|
26
|
-
is_gst_inclusive?: boolean;
|
|
27
|
-
gst?: number;
|
|
28
|
-
gst_amount?: number;
|
|
29
|
-
special_instructions?: string | undefined;
|
|
30
|
-
order_status?: WAREHOUSE_INVOICE_STATUS_ENUM | undefined;
|
|
31
|
-
price?: number | undefined;
|
|
32
|
-
amount_earned?: number | undefined;
|
|
33
|
-
grand_total?: number | undefined;
|
|
34
|
-
tax_number?: string | undefined;
|
|
35
|
-
updatedAt?: Date | undefined;
|
|
36
|
-
};
|
|
4
|
+
export declare function getUpdatedWarehouseInvoiceCartInfoOnInit(data: Partial<IWarehouseClientInvoice>, order: Partial<IWarehouseClientInvoice>): any;
|
|
37
5
|
export declare function getRemoveItemFromWarehouseInvoiceCartData(data: Partial<IWarehouseClientInvoice>, payload: {
|
|
38
6
|
_id: string;
|
|
39
7
|
void_reason?: string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { WAREHOUSE_SALES_ORDER_STATUS_ENUM } from '../../constants';
|
|
2
|
+
import { IWarehouseSaleOrder, IWarehouseSaleOrderCategory, IWarehouseSaleOrderItem, IWarehouseSaleOrderIteration } from '../../schemas';
|
|
3
|
+
export declare function calculateCartWarehouseSaleOrderInfoAndSyncData<T extends IWarehouseSaleOrder | Partial<IWarehouseSaleOrder>>(data: T, calculateItemMetadata?: boolean): T;
|
|
4
|
+
export declare const getWarehouseSaleOrderItemComparableData: (item: IWarehouseSaleOrderItem) => Partial<IWarehouseSaleOrderItem>;
|
|
5
|
+
export declare function getUpdatedWarehouseSaleOrderCartInfoOnInit(data: Partial<IWarehouseSaleOrder>, order: Partial<IWarehouseSaleOrder>): {
|
|
6
|
+
_id?: string | undefined;
|
|
7
|
+
warehouse_id?: string | undefined;
|
|
8
|
+
client_id?: string | undefined;
|
|
9
|
+
client_name?: string | undefined;
|
|
10
|
+
rfq_id?: string | null;
|
|
11
|
+
iterations?: IWarehouseSaleOrderIteration[] | undefined;
|
|
12
|
+
amount_collected?: number | undefined;
|
|
13
|
+
order_number?: number | null | undefined;
|
|
14
|
+
delete_reason?: string | null;
|
|
15
|
+
cancel_reason?: string | null;
|
|
16
|
+
is_deleted?: boolean | undefined;
|
|
17
|
+
order_status_updated_at?: Date | undefined;
|
|
18
|
+
is_reopened?: boolean;
|
|
19
|
+
order_settled_at?: Date | undefined;
|
|
20
|
+
order_settled_at_mins?: number | undefined;
|
|
21
|
+
createdAt_mins?: number | undefined;
|
|
22
|
+
createdAt?: Date | undefined;
|
|
23
|
+
categories?: IWarehouseSaleOrderCategory[] | undefined;
|
|
24
|
+
staff_details?: import("../../schemas").IStaffDetails | undefined;
|
|
25
|
+
is_gst_inclusive?: boolean;
|
|
26
|
+
gst?: number | null;
|
|
27
|
+
gst_amount?: number | null;
|
|
28
|
+
special_instructions?: string | undefined;
|
|
29
|
+
price?: number | undefined;
|
|
30
|
+
amount_earned?: number | undefined;
|
|
31
|
+
grand_total?: number | undefined;
|
|
32
|
+
order_status?: WAREHOUSE_SALES_ORDER_STATUS_ENUM | undefined;
|
|
33
|
+
updatedAt?: Date | undefined;
|
|
34
|
+
tax_number?: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
export declare function getRemoveItemFromWarehouseSaleOrderCartData(data: Partial<IWarehouseSaleOrder>, payload: {
|
|
37
|
+
_id: string;
|
|
38
|
+
void_reason?: string;
|
|
39
|
+
}): Partial<IWarehouseSaleOrder>;
|
|
40
|
+
export declare function getUpdateWarehouseSaleOrderCartInfoData(data: Partial<IWarehouseSaleOrder>, payload: Partial<IWarehouseSaleOrder>): Partial<IWarehouseSaleOrder>;
|
|
41
|
+
export interface ISetAddItemToSaleOrderCartActionPayload {
|
|
42
|
+
name: string;
|
|
43
|
+
category_id: string;
|
|
44
|
+
item: IWarehouseSaleOrderItem;
|
|
45
|
+
replace_id?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare function getAddItemToWarehouseSaleOrderCartData(data: Partial<IWarehouseSaleOrder>, payload: ISetAddItemToSaleOrderCartActionPayload): Partial<IWarehouseSaleOrder>;
|
|
48
|
+
export declare function getUpdateItemInWarehouseSaleOrderCartData(data: Partial<IWarehouseSaleOrder>, payload: Partial<IWarehouseSaleOrderItem>): Partial<IWarehouseSaleOrder>;
|
|
49
|
+
export declare function getUpdateItemsInWarehouseSaleOrderCartData(data: Partial<IWarehouseSaleOrder>, payload: Partial<IWarehouseSaleOrderItem>[]): Partial<IWarehouseSaleOrder>;
|
|
50
|
+
export interface IGetSplitSaleOrderCartItemToTwo {
|
|
51
|
+
data: Partial<IWarehouseSaleOrder>;
|
|
52
|
+
orderItemId: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function getSplitWarehouseSaleOrderCartItemToTwo({ data, orderItemId, }: IGetSplitSaleOrderCartItemToTwo): Partial<IWarehouseSaleOrder>;
|
|
55
|
+
export declare function getAddItemsToWarehouseSaleOrderCartData(data: Partial<IWarehouseSaleOrder>, payload: ISetAddItemToSaleOrderCartActionPayload[]): Partial<IWarehouseSaleOrder>;
|