@managesome/eposmatic-toolkit 0.2.452 → 0.2.454
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/INTERNAL_ENUMS.d.ts +41 -0
- package/lib/constants/INTERNAL_ENUMS.js +52 -0
- package/lib/constants/WORKER_ENDPOINTS.d.ts +1 -0
- package/lib/constants/WORKER_ENDPOINTS.js +1 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +1 -0
- package/lib/helpers/store/common-tenant-purchase-order-actions.d.ts +8 -0
- package/lib/helpers/store/common-tenant-purchase-order-actions.js +107 -0
- package/lib/helpers/store/common-warehouse-sale-order-invoice-actions.d.ts +16 -0
- package/lib/helpers/store/common-warehouse-sale-order-invoice-actions.js +59 -0
- package/lib/helpers/store/index.d.ts +3 -0
- package/lib/helpers/store/index.js +3 -0
- package/lib/helpers/store/tenant-purchase-orders-cart-actions.d.ts +24 -0
- package/lib/helpers/store/tenant-purchase-orders-cart-actions.js +395 -0
- package/lib/helpers/types/workers.d.ts +5 -1
- package/lib/schemas/models/index.d.ts +2 -0
- package/lib/schemas/models/index.js +2 -0
- package/lib/schemas/models/internal_invoices.d.ts +3 -3
- package/lib/schemas/models/internal_operational_roles.d.ts +77 -0
- package/lib/schemas/models/internal_operational_roles.js +88 -0
- package/lib/schemas/models/internal_staffs.d.ts +59 -0
- package/lib/schemas/models/internal_staffs.js +68 -0
- package/lib/schemas/models/warehouse_internal_movements.d.ts +3 -3
- package/lib/schemas/models/warehouse_sale_deliveries.d.ts +3 -3
- package/lib/schemas/models/warehouse_sale_invoices.d.ts +6 -6
- package/lib/schemas/types/index.d.ts +2 -0
- package/lib/schemas/types/index.js +2 -0
- package/lib/schemas/types/internal_operational_roles.d.ts +22 -0
- package/lib/schemas/types/internal_operational_roles.js +19 -0
- package/lib/schemas/types/internal_staffs.d.ts +15 -0
- package/lib/schemas/types/internal_staffs.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getTenantPurchaseOrderItemComparableData = void 0;
|
|
7
|
+
exports.calculateCartTenantPurchaseOrderInfoAndSyncData = calculateCartTenantPurchaseOrderInfoAndSyncData;
|
|
8
|
+
exports.getUpdatedTenantPurchaseOrderCartInfoOnInit = getUpdatedTenantPurchaseOrderCartInfoOnInit;
|
|
9
|
+
exports.getRemoveItemFromTenantPurchaseOrderCartData = getRemoveItemFromTenantPurchaseOrderCartData;
|
|
10
|
+
exports.getUpdateTenantPurchaseOrderCartInfoData = getUpdateTenantPurchaseOrderCartInfoData;
|
|
11
|
+
exports.getAddItemToTenantPurchaseOrderCartData = getAddItemToTenantPurchaseOrderCartData;
|
|
12
|
+
exports.getUpdateItemInTenantPurchaseOrderCartData = getUpdateItemInTenantPurchaseOrderCartData;
|
|
13
|
+
exports.getUpdateItemsInTenantPurchaseOrderCartData = getUpdateItemsInTenantPurchaseOrderCartData;
|
|
14
|
+
exports.getSplitTenantPurchaseOrderCartItemToTwo = getSplitTenantPurchaseOrderCartItemToTwo;
|
|
15
|
+
exports.getAddItemsToTenantPurchaseOrderCartData = getAddItemsToTenantPurchaseOrderCartData;
|
|
16
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
17
|
+
const lodash_1 = require("lodash");
|
|
18
|
+
const constants_1 = require("../../constants");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
20
|
+
function calculateCartTenantPurchaseOrderInfoAndSyncData(data, calculateItemMetadata) {
|
|
21
|
+
const isCompleted = data.order_status === constants_1.TENANT_PURCHASE_ORDER_STATUS_ENUM.COMPLETED;
|
|
22
|
+
let subtotal = 0;
|
|
23
|
+
const categories = [];
|
|
24
|
+
const length = data.categories?.length ?? 0;
|
|
25
|
+
for (let c = 0; c < length; c++) {
|
|
26
|
+
const category = data.categories[c];
|
|
27
|
+
const newItems = [];
|
|
28
|
+
const itemsLength = category.items.length;
|
|
29
|
+
for (let i = 0; i < itemsLength; i++) {
|
|
30
|
+
const item = category.items[i];
|
|
31
|
+
const itemSubtotal = (0, utils_1.parseNum)(item.price * item.quantity);
|
|
32
|
+
const newItem = {
|
|
33
|
+
...item,
|
|
34
|
+
is_ready: item.is_ready || isCompleted,
|
|
35
|
+
subtotal: itemSubtotal,
|
|
36
|
+
_discount_amount: 0,
|
|
37
|
+
_gross_amount: 0,
|
|
38
|
+
_gst_amount: 0,
|
|
39
|
+
_net_amount: 0,
|
|
40
|
+
};
|
|
41
|
+
delete newItem.void_reason;
|
|
42
|
+
newItems.push(newItem);
|
|
43
|
+
subtotal += itemSubtotal;
|
|
44
|
+
}
|
|
45
|
+
categories.push({
|
|
46
|
+
...category,
|
|
47
|
+
items: newItems,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
let grand_total = subtotal;
|
|
51
|
+
let gst_amount = 0;
|
|
52
|
+
const gst = data.gst ?? 0;
|
|
53
|
+
if (data.is_gst_inclusive) {
|
|
54
|
+
gst_amount = (0, utils_1.parseFloatCeil)((grand_total * gst) / (100 + gst));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
gst_amount = (0, utils_1.getPercentageAmount)(grand_total, gst);
|
|
58
|
+
grand_total += gst_amount;
|
|
59
|
+
}
|
|
60
|
+
const { cardCharges, amountCollected } = (0, utils_1.getCardChargesAndAmountCollected)(data.payments);
|
|
61
|
+
grand_total += cardCharges;
|
|
62
|
+
grand_total = (0, utils_1.parseNum)(grand_total);
|
|
63
|
+
const amount_collected = (0, utils_1.parseNum)(amountCollected);
|
|
64
|
+
const amount_earned = (0, utils_1.parseNum)(grand_total - cardCharges);
|
|
65
|
+
if (calculateItemMetadata) {
|
|
66
|
+
let leftGrossAmount = subtotal;
|
|
67
|
+
let leftNetAmount = subtotal;
|
|
68
|
+
let leftDiscountAmount = 0;
|
|
69
|
+
let leftGstAmount = gst_amount;
|
|
70
|
+
categories.forEach((category, categoryIndex) => {
|
|
71
|
+
const isLastCategory = categoryIndex === categories.length - 1;
|
|
72
|
+
category.items.forEach((item, itemIndex) => {
|
|
73
|
+
const isLastItem = isLastCategory && itemIndex === category.items.length - 1;
|
|
74
|
+
let grossAmount = item.subtotal;
|
|
75
|
+
let netAmount = item.subtotal;
|
|
76
|
+
let itemTotalDiscountAmount = 0;
|
|
77
|
+
let itemGst = 0;
|
|
78
|
+
if (gst_amount > 0) {
|
|
79
|
+
itemGst = (item.subtotal / subtotal) * gst_amount;
|
|
80
|
+
}
|
|
81
|
+
grossAmount = (0, utils_1.parseFloatCeil)(grossAmount);
|
|
82
|
+
const netAmountParsed = (0, utils_1.parseFloatCeil)(netAmount);
|
|
83
|
+
const itemTotalDiscountAmountParsed = (0, utils_1.parseFloatCeil)(itemTotalDiscountAmount);
|
|
84
|
+
itemGst = (0, utils_1.parseFloatCeil)(itemGst);
|
|
85
|
+
leftGrossAmount -= grossAmount;
|
|
86
|
+
leftNetAmount -= netAmountParsed;
|
|
87
|
+
leftDiscountAmount -= itemTotalDiscountAmountParsed;
|
|
88
|
+
leftGstAmount -= itemGst;
|
|
89
|
+
if (isLastItem) {
|
|
90
|
+
grossAmount += leftGrossAmount;
|
|
91
|
+
netAmount += leftNetAmount;
|
|
92
|
+
itemTotalDiscountAmount += leftDiscountAmount;
|
|
93
|
+
itemGst += leftGstAmount;
|
|
94
|
+
}
|
|
95
|
+
item._gross_amount = Math.max(grossAmount, 0);
|
|
96
|
+
item._net_amount = Math.max(netAmount, 0);
|
|
97
|
+
item._discount_amount = Math.max(itemTotalDiscountAmount, 0);
|
|
98
|
+
item._gst_amount = Math.max(itemGst, 0);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const cartData = {
|
|
103
|
+
...data,
|
|
104
|
+
categories,
|
|
105
|
+
amount_collected,
|
|
106
|
+
amount_earned,
|
|
107
|
+
gst_amount,
|
|
108
|
+
price: (0, utils_1.parseNum)(subtotal),
|
|
109
|
+
grand_total,
|
|
110
|
+
};
|
|
111
|
+
return cartData;
|
|
112
|
+
}
|
|
113
|
+
const getTenantPurchaseOrderItemComparableData = (item) => ({
|
|
114
|
+
item_id: item.item_id,
|
|
115
|
+
name: item.name,
|
|
116
|
+
price: item.price,
|
|
117
|
+
special_instructions: item.special_instructions,
|
|
118
|
+
_id: item._id,
|
|
119
|
+
quantity: item.quantity,
|
|
120
|
+
});
|
|
121
|
+
exports.getTenantPurchaseOrderItemComparableData = getTenantPurchaseOrderItemComparableData;
|
|
122
|
+
const getUpdatedTenantPurchaseOrderItem = (item) => ({
|
|
123
|
+
item_id: item.item_id,
|
|
124
|
+
name: item.name,
|
|
125
|
+
price: item.price,
|
|
126
|
+
special_instructions: item.special_instructions,
|
|
127
|
+
});
|
|
128
|
+
function getUpdatedTenantPurchaseOrderCartInfoOnInit(data, order) {
|
|
129
|
+
const merged = { ...data, ...order };
|
|
130
|
+
return calculateCartTenantPurchaseOrderInfoAndSyncData(merged);
|
|
131
|
+
}
|
|
132
|
+
function getRemoveItemFromTenantPurchaseOrderCartData(data, payload) {
|
|
133
|
+
const orderItemIdsMap = {};
|
|
134
|
+
let categories;
|
|
135
|
+
if (data.categories != null) {
|
|
136
|
+
categories = [];
|
|
137
|
+
for (let i = 0; i < data.categories.length; i++) {
|
|
138
|
+
const category = data.categories[i];
|
|
139
|
+
const items = [];
|
|
140
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
141
|
+
const item = category.items[j];
|
|
142
|
+
if (item._id !== payload._id) {
|
|
143
|
+
items.push(item);
|
|
144
|
+
orderItemIdsMap[item._id] = item.quantity;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (items.length > 0) {
|
|
148
|
+
categories.push({ ...category, items });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const iterations = [];
|
|
153
|
+
if (data.iterations != null && data.iterations.length > 0) {
|
|
154
|
+
const [firstIteration, ...restIterations] = data.iterations;
|
|
155
|
+
const firstIterationCategories = [];
|
|
156
|
+
for (let i = 0; i < firstIteration.categories.length; i++) {
|
|
157
|
+
const category = firstIteration.categories[i];
|
|
158
|
+
const allPrevItems = [];
|
|
159
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
160
|
+
const prevItem = category.items[j];
|
|
161
|
+
if (prevItem._id === payload._id && payload.void_reason != null) {
|
|
162
|
+
allPrevItems.push({ ...prevItem, void_reason: payload.void_reason });
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const currentItemQuantity = orderItemIdsMap[prevItem._id];
|
|
166
|
+
const isRemovedItem = !currentItemQuantity || currentItemQuantity < prevItem.quantity;
|
|
167
|
+
if (isRemovedItem) {
|
|
168
|
+
allPrevItems.push(prevItem);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
const updatedPrevItem = { ...prevItem };
|
|
172
|
+
delete updatedPrevItem.void_reason;
|
|
173
|
+
allPrevItems.push(updatedPrevItem);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (allPrevItems.length > 0) {
|
|
178
|
+
firstIterationCategories.push({ ...category, items: allPrevItems });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
iterations.push({ ...firstIteration, categories: firstIterationCategories });
|
|
182
|
+
iterations.push(...restIterations);
|
|
183
|
+
}
|
|
184
|
+
const order = {
|
|
185
|
+
...data,
|
|
186
|
+
...(iterations.length > 0 && { iterations }),
|
|
187
|
+
categories,
|
|
188
|
+
};
|
|
189
|
+
return calculateCartTenantPurchaseOrderInfoAndSyncData(order);
|
|
190
|
+
}
|
|
191
|
+
function getUpdateTenantPurchaseOrderCartInfoData(data, payload) {
|
|
192
|
+
const order = { ...data, ...payload };
|
|
193
|
+
return calculateCartTenantPurchaseOrderInfoAndSyncData(order);
|
|
194
|
+
}
|
|
195
|
+
function getAddItemToTenantPurchaseOrderCartData(data, payload) {
|
|
196
|
+
const { category_id, name, item, replace_id } = payload;
|
|
197
|
+
const orderData = { ...data };
|
|
198
|
+
const categories = [...(orderData.categories ?? [])];
|
|
199
|
+
let didFindCategory = false;
|
|
200
|
+
for (let i = 0; i < categories.length; i++) {
|
|
201
|
+
const category = categories[i];
|
|
202
|
+
if (category.category_id !== category_id)
|
|
203
|
+
continue;
|
|
204
|
+
const updatedItem = getUpdatedTenantPurchaseOrderItem(item);
|
|
205
|
+
const allItems = [...category.items];
|
|
206
|
+
let didFindItem = false;
|
|
207
|
+
let itemExists = false;
|
|
208
|
+
for (let j = 0; j < allItems.length; j++) {
|
|
209
|
+
if (allItems[j]._id === item._id) {
|
|
210
|
+
allItems[j] = item;
|
|
211
|
+
didFindItem = true;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
if (allItems[j].item_id === item.item_id) {
|
|
215
|
+
itemExists = true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (!didFindItem && itemExists) {
|
|
219
|
+
for (let j = 0; j < allItems.length; j++) {
|
|
220
|
+
const itm = allItems[j];
|
|
221
|
+
if (itm.item_id === item.item_id &&
|
|
222
|
+
(0, lodash_1.isEqual)(getUpdatedTenantPurchaseOrderItem(itm), updatedItem)) {
|
|
223
|
+
allItems[j] = {
|
|
224
|
+
...item,
|
|
225
|
+
_id: replace_id ?? itm._id,
|
|
226
|
+
quantity: item.quantity + itm.quantity,
|
|
227
|
+
};
|
|
228
|
+
didFindItem = true;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (!didFindItem) {
|
|
234
|
+
allItems.push(item);
|
|
235
|
+
}
|
|
236
|
+
categories[i] = { ...category, items: allItems };
|
|
237
|
+
didFindCategory = true;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
if (!didFindCategory) {
|
|
241
|
+
categories.push({ category_id, name, items: [item] });
|
|
242
|
+
}
|
|
243
|
+
const iterations = [];
|
|
244
|
+
if (orderData.iterations != null && orderData.iterations.length > 0) {
|
|
245
|
+
const orderItemIdsMap = {};
|
|
246
|
+
for (const cat of categories) {
|
|
247
|
+
for (const itm of cat.items) {
|
|
248
|
+
orderItemIdsMap[itm._id] = itm.quantity;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const [firstIteration, ...restIterations] = orderData.iterations;
|
|
252
|
+
const firstIterationCategories = [];
|
|
253
|
+
for (const cat of firstIteration.categories) {
|
|
254
|
+
const allPrevItems = [];
|
|
255
|
+
for (const prevItem of cat.items) {
|
|
256
|
+
const currentItemQuantity = orderItemIdsMap[prevItem._id];
|
|
257
|
+
const isRemovedItem = !currentItemQuantity || currentItemQuantity < prevItem.quantity;
|
|
258
|
+
if (isRemovedItem) {
|
|
259
|
+
allPrevItems.push(prevItem);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
const updatedPrevItem = { ...prevItem };
|
|
263
|
+
delete updatedPrevItem.void_reason;
|
|
264
|
+
allPrevItems.push(updatedPrevItem);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (allPrevItems.length > 0) {
|
|
268
|
+
firstIterationCategories.push({ ...cat, items: allPrevItems });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
iterations.push({ ...firstIteration, categories: firstIterationCategories });
|
|
272
|
+
iterations.push(...restIterations);
|
|
273
|
+
}
|
|
274
|
+
const order = {
|
|
275
|
+
...orderData,
|
|
276
|
+
...(iterations.length > 0 && { iterations }),
|
|
277
|
+
categories,
|
|
278
|
+
};
|
|
279
|
+
return calculateCartTenantPurchaseOrderInfoAndSyncData(order);
|
|
280
|
+
}
|
|
281
|
+
function getUpdateItemInTenantPurchaseOrderCartData(data, payload) {
|
|
282
|
+
const orderItemIdsMap = {};
|
|
283
|
+
let categories;
|
|
284
|
+
if (data.categories != null) {
|
|
285
|
+
categories = [];
|
|
286
|
+
for (let i = 0; i < data.categories.length; i++) {
|
|
287
|
+
const category = data.categories[i];
|
|
288
|
+
const items = [];
|
|
289
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
290
|
+
const item = category.items[j];
|
|
291
|
+
let newItem = item;
|
|
292
|
+
if (item._id === payload._id) {
|
|
293
|
+
newItem = { ...item, ...payload };
|
|
294
|
+
}
|
|
295
|
+
if (newItem.quantity > 0) {
|
|
296
|
+
items.push(newItem);
|
|
297
|
+
orderItemIdsMap[newItem._id] = newItem.quantity;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (items.length > 0) {
|
|
301
|
+
categories.push({ ...category, items });
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
const iterations = [];
|
|
306
|
+
if (payload.quantity != null && data.iterations != null && data.iterations.length > 0) {
|
|
307
|
+
const [firstIteration, ...restIterations] = data.iterations;
|
|
308
|
+
const firstIterationCategories = [];
|
|
309
|
+
for (const cat of firstIteration.categories) {
|
|
310
|
+
const allPrevItems = [];
|
|
311
|
+
for (const prevItem of cat.items) {
|
|
312
|
+
if (prevItem._id === payload._id && payload.void_reason != null) {
|
|
313
|
+
allPrevItems.push({ ...prevItem, void_reason: payload.void_reason });
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
const currentItemQuantity = orderItemIdsMap[prevItem._id];
|
|
317
|
+
const isRemovedItem = !currentItemQuantity || currentItemQuantity < prevItem.quantity;
|
|
318
|
+
if (isRemovedItem) {
|
|
319
|
+
allPrevItems.push(prevItem);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
const updatedPrevItem = { ...prevItem };
|
|
323
|
+
delete updatedPrevItem.void_reason;
|
|
324
|
+
allPrevItems.push(updatedPrevItem);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (allPrevItems.length > 0) {
|
|
329
|
+
firstIterationCategories.push({ ...cat, items: allPrevItems });
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
iterations.push({ ...firstIteration, categories: firstIterationCategories });
|
|
333
|
+
iterations.push(...restIterations);
|
|
334
|
+
}
|
|
335
|
+
const order = {
|
|
336
|
+
...data,
|
|
337
|
+
...(iterations.length > 0 && { iterations }),
|
|
338
|
+
categories,
|
|
339
|
+
};
|
|
340
|
+
return calculateCartTenantPurchaseOrderInfoAndSyncData(order);
|
|
341
|
+
}
|
|
342
|
+
function getUpdateItemsInTenantPurchaseOrderCartData(data, payload) {
|
|
343
|
+
return payload.reduce((acc, item) => getUpdateItemInTenantPurchaseOrderCartData(acc, item), data);
|
|
344
|
+
}
|
|
345
|
+
function getSplitTenantPurchaseOrderCartItemToTwo({ data, orderItemId, }) {
|
|
346
|
+
if (data.categories == null)
|
|
347
|
+
return data;
|
|
348
|
+
const newCategories = [];
|
|
349
|
+
for (let i = 0; i < data.categories.length; i++) {
|
|
350
|
+
const category = data.categories[i];
|
|
351
|
+
const newItems = [];
|
|
352
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
353
|
+
const item = {
|
|
354
|
+
...category.items[j],
|
|
355
|
+
};
|
|
356
|
+
if (item._id !== orderItemId) {
|
|
357
|
+
newItems.push(item);
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (item.quantity === 1) {
|
|
361
|
+
newItems.push(item);
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
const prevQuantity = item.quantity;
|
|
365
|
+
const newQuantity = item.quantity - 1;
|
|
366
|
+
const prevItem = {
|
|
367
|
+
...item,
|
|
368
|
+
quantity: newQuantity,
|
|
369
|
+
subtotal: (0, utils_1.parseNum)(item.price * newQuantity),
|
|
370
|
+
};
|
|
371
|
+
newItems.push(prevItem);
|
|
372
|
+
const _id = new bson_objectid_1.default(Math.floor(new bson_objectid_1.default(item._id).getTimestamp().getTime() / 1000) + 1).toHexString();
|
|
373
|
+
newItems.push({
|
|
374
|
+
...item,
|
|
375
|
+
_id,
|
|
376
|
+
quantity: 1,
|
|
377
|
+
subtotal: (0, utils_1.parseNum)(item.price * 1),
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
newCategories.push({
|
|
381
|
+
...category,
|
|
382
|
+
items: newItems,
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
const order = {
|
|
386
|
+
...data,
|
|
387
|
+
categories: newCategories,
|
|
388
|
+
};
|
|
389
|
+
const newData = calculateCartTenantPurchaseOrderInfoAndSyncData(order);
|
|
390
|
+
return newData;
|
|
391
|
+
}
|
|
392
|
+
function getAddItemsToTenantPurchaseOrderCartData(data, payload) {
|
|
393
|
+
const newData = payload.reduce((acc, item) => getAddItemToTenantPurchaseOrderCartData(acc, item), data);
|
|
394
|
+
return newData;
|
|
395
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CARD_PROCESSING_PROVIDERS_ENUM, CURRENCY_SYMBOL_ENUM, DELIVERY_STATUS_ENUM, ORDER_STATUS_ENUM, PLATFORM_TYPE_ENUM, PLATFORMS_ENUM, VOID_ORDER_ITEM_TYPE_ENUM, WALLET_ASSET_TYPE_ENUM, WALLET_ASSIGNMENT_BEHAVIOR_ENUM, WAREHOUSE_INTERNAL_MOVEMENT_STATUS_ENUM, WAREHOUSE_INVOICE_STATUS_ENUM, WAREHOUSE_REMOVAL_STRATEGY_ENUM, WAREHOUSE_TRACKING_MODE_ENUM } from '../../constants';
|
|
2
|
-
import { IDineinTableFingerprint, IInternalLead, IModifierExtra, IOrder, IOrderItem, IOrderPayment, IWarehouseClientInvoice, IWarehouseInternalMovement, IWarehousePurchaseOrder, IWarehousePurchaseOrderReceipt, IWarehousePurchaseOrderVendorReturn, IWarehouseSaleOrder, IWarehouseSaleOrderDelivery } from '../../schemas';
|
|
2
|
+
import { IDineinTableFingerprint, IInternalLead, IModifierExtra, IOrder, IOrderItem, IOrderPayment, ITenantPurchaseOrder, IWarehouseClientInvoice, IWarehouseInternalMovement, IWarehousePurchaseOrder, IWarehousePurchaseOrderReceipt, IWarehousePurchaseOrderVendorReturn, IWarehouseSaleOrder, IWarehouseSaleOrderDelivery } from '../../schemas';
|
|
3
3
|
import { ISwitchPayEWalletRequestBody, ISwitchPayRefundRequestBody } from './switchpay';
|
|
4
4
|
export interface IWorker_CreateDelivery {
|
|
5
5
|
order: IOrder;
|
|
@@ -229,6 +229,10 @@ export interface IWorker_UpdateTenantInventoryOnRevertSplitOrder {
|
|
|
229
229
|
isInventoryEnabled: boolean;
|
|
230
230
|
currency_symbol: CURRENCY_SYMBOL_ENUM | undefined;
|
|
231
231
|
}
|
|
232
|
+
export interface IWorker_UpdateTenantInventoryOnPurchaseOrderReceive {
|
|
233
|
+
purchaseOrder: ITenantPurchaseOrder;
|
|
234
|
+
currency_symbol: CURRENCY_SYMBOL_ENUM | undefined;
|
|
235
|
+
}
|
|
232
236
|
export interface IWorker_AlertUnconfirmedOrder {
|
|
233
237
|
order_id: string;
|
|
234
238
|
tenantName: string;
|
|
@@ -25,6 +25,8 @@ export * from './instore_shifts';
|
|
|
25
25
|
export * from './internal_customers';
|
|
26
26
|
export * from './internal_invoices';
|
|
27
27
|
export * from './internal_leads';
|
|
28
|
+
export * from './internal_operational_roles';
|
|
29
|
+
export * from './internal_staffs';
|
|
28
30
|
export * from './inventories';
|
|
29
31
|
export * from './inventory_categories';
|
|
30
32
|
export * from './inventory_transactions';
|
|
@@ -41,6 +41,8 @@ __exportStar(require("./instore_shifts"), exports);
|
|
|
41
41
|
__exportStar(require("./internal_customers"), exports);
|
|
42
42
|
__exportStar(require("./internal_invoices"), exports);
|
|
43
43
|
__exportStar(require("./internal_leads"), exports);
|
|
44
|
+
__exportStar(require("./internal_operational_roles"), exports);
|
|
45
|
+
__exportStar(require("./internal_staffs"), exports);
|
|
44
46
|
__exportStar(require("./inventories"), exports);
|
|
45
47
|
__exportStar(require("./inventory_categories"), exports);
|
|
46
48
|
__exportStar(require("./inventory_transactions"), exports);
|
|
@@ -22,9 +22,9 @@ export declare const InternalInvoiceSchema: Schema<any, import("mongoose").Model
|
|
|
22
22
|
subtotal: number;
|
|
23
23
|
payment_terms: string;
|
|
24
24
|
notes: string;
|
|
25
|
+
invoice_type: import("../../constants").INTERNAL_INVOICE_TYPE_ENUM;
|
|
25
26
|
customer_id: import("mongoose").Types.ObjectId;
|
|
26
27
|
invoice_number: string;
|
|
27
|
-
invoice_type: import("../../constants").INTERNAL_INVOICE_TYPE_ENUM;
|
|
28
28
|
hardware: string[];
|
|
29
29
|
currency: import("../../constants").CURRENCY_CODE_ENUM;
|
|
30
30
|
dqrc: string;
|
|
@@ -50,9 +50,9 @@ export declare const InternalInvoiceSchema: Schema<any, import("mongoose").Model
|
|
|
50
50
|
subtotal: number;
|
|
51
51
|
payment_terms: string;
|
|
52
52
|
notes: string;
|
|
53
|
+
invoice_type: import("../../constants").INTERNAL_INVOICE_TYPE_ENUM;
|
|
53
54
|
customer_id: import("mongoose").Types.ObjectId;
|
|
54
55
|
invoice_number: string;
|
|
55
|
-
invoice_type: import("../../constants").INTERNAL_INVOICE_TYPE_ENUM;
|
|
56
56
|
hardware: string[];
|
|
57
57
|
currency: import("../../constants").CURRENCY_CODE_ENUM;
|
|
58
58
|
dqrc: string;
|
|
@@ -78,9 +78,9 @@ export declare const InternalInvoiceSchema: Schema<any, import("mongoose").Model
|
|
|
78
78
|
subtotal: number;
|
|
79
79
|
payment_terms: string;
|
|
80
80
|
notes: string;
|
|
81
|
+
invoice_type: import("../../constants").INTERNAL_INVOICE_TYPE_ENUM;
|
|
81
82
|
customer_id: import("mongoose").Types.ObjectId;
|
|
82
83
|
invoice_number: string;
|
|
83
|
-
invoice_type: import("../../constants").INTERNAL_INVOICE_TYPE_ENUM;
|
|
84
84
|
hardware: string[];
|
|
85
85
|
currency: import("../../constants").CURRENCY_CODE_ENUM;
|
|
86
86
|
dqrc: string;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
export declare const InternalOperationalRolesSchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
3
|
+
timestamps: true;
|
|
4
|
+
versionKey: false;
|
|
5
|
+
minimize: false;
|
|
6
|
+
}, {
|
|
7
|
+
createdAt: NativeDate;
|
|
8
|
+
updatedAt: NativeDate;
|
|
9
|
+
} & {
|
|
10
|
+
_id: import("mongoose").Types.ObjectId;
|
|
11
|
+
createdAt: NativeDate;
|
|
12
|
+
updatedAt: NativeDate;
|
|
13
|
+
roles: {
|
|
14
|
+
SUPER_ADMIN: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
15
|
+
HOD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
16
|
+
SUPPORT_HEAD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
17
|
+
SUPPORT_TEAM: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
18
|
+
SALES_HEAD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
19
|
+
SALES_TEAM: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
20
|
+
MARKETING_HEAD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
21
|
+
MARKETING_TEAM: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
22
|
+
HR_HEAD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
23
|
+
HR_TEAM: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
24
|
+
DEVELOPER: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
25
|
+
FINANCE: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
26
|
+
VIEWER: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
27
|
+
};
|
|
28
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
29
|
+
createdAt: NativeDate;
|
|
30
|
+
updatedAt: NativeDate;
|
|
31
|
+
} & {
|
|
32
|
+
_id: import("mongoose").Types.ObjectId;
|
|
33
|
+
createdAt: NativeDate;
|
|
34
|
+
updatedAt: NativeDate;
|
|
35
|
+
roles: {
|
|
36
|
+
SUPER_ADMIN: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
37
|
+
HOD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
38
|
+
SUPPORT_HEAD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
39
|
+
SUPPORT_TEAM: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
40
|
+
SALES_HEAD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
41
|
+
SALES_TEAM: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
42
|
+
MARKETING_HEAD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
43
|
+
MARKETING_TEAM: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
44
|
+
HR_HEAD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
45
|
+
HR_TEAM: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
46
|
+
DEVELOPER: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
47
|
+
FINANCE: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
48
|
+
VIEWER: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
49
|
+
};
|
|
50
|
+
}>> & import("mongoose").FlatRecord<{
|
|
51
|
+
createdAt: NativeDate;
|
|
52
|
+
updatedAt: NativeDate;
|
|
53
|
+
} & {
|
|
54
|
+
_id: import("mongoose").Types.ObjectId;
|
|
55
|
+
createdAt: NativeDate;
|
|
56
|
+
updatedAt: NativeDate;
|
|
57
|
+
roles: {
|
|
58
|
+
SUPER_ADMIN: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
59
|
+
HOD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
60
|
+
SUPPORT_HEAD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
61
|
+
SUPPORT_TEAM: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
62
|
+
SALES_HEAD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
63
|
+
SALES_TEAM: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
64
|
+
MARKETING_HEAD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
65
|
+
MARKETING_TEAM: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
66
|
+
HR_HEAD: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
67
|
+
HR_TEAM: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
68
|
+
DEVELOPER: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
69
|
+
FINANCE: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
70
|
+
VIEWER: import("../../constants").INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
71
|
+
};
|
|
72
|
+
}> & Required<{
|
|
73
|
+
_id: import("mongoose").Types.ObjectId;
|
|
74
|
+
}> & {
|
|
75
|
+
__v: number;
|
|
76
|
+
}>;
|
|
77
|
+
export declare const INTERNAL_OPERATIONAL_ROLES_COLLECTION_NAME = "internal_operational_roles";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INTERNAL_OPERATIONAL_ROLES_COLLECTION_NAME = exports.InternalOperationalRolesSchema = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const internal_operational_roles_1 = require("../types/internal_operational_roles");
|
|
7
|
+
const InternalUserPermissionsSchema = { type: String, enum: constants_1.ALL_INTERNAL_USER_PERMISSIONS };
|
|
8
|
+
const InternalRolesSchema = new mongoose_1.Schema({
|
|
9
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.SUPER_ADMIN]: {
|
|
10
|
+
type: [InternalUserPermissionsSchema],
|
|
11
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.SUPER_ADMIN],
|
|
12
|
+
},
|
|
13
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.HOD]: {
|
|
14
|
+
type: [InternalUserPermissionsSchema],
|
|
15
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.HOD],
|
|
16
|
+
},
|
|
17
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.SUPPORT_HEAD]: {
|
|
18
|
+
type: [InternalUserPermissionsSchema],
|
|
19
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.SUPPORT_HEAD],
|
|
20
|
+
},
|
|
21
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.SUPPORT_TEAM]: {
|
|
22
|
+
type: [InternalUserPermissionsSchema],
|
|
23
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.SUPPORT_TEAM],
|
|
24
|
+
},
|
|
25
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.SALES_HEAD]: {
|
|
26
|
+
type: [InternalUserPermissionsSchema],
|
|
27
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.SALES_HEAD],
|
|
28
|
+
},
|
|
29
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.SALES_TEAM]: {
|
|
30
|
+
type: [InternalUserPermissionsSchema],
|
|
31
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.SALES_TEAM],
|
|
32
|
+
},
|
|
33
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.MARKETING_HEAD]: {
|
|
34
|
+
type: [InternalUserPermissionsSchema],
|
|
35
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.MARKETING_HEAD],
|
|
36
|
+
},
|
|
37
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.MARKETING_TEAM]: {
|
|
38
|
+
type: [InternalUserPermissionsSchema],
|
|
39
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.MARKETING_TEAM],
|
|
40
|
+
},
|
|
41
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.HR_HEAD]: {
|
|
42
|
+
type: [InternalUserPermissionsSchema],
|
|
43
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.HR_HEAD],
|
|
44
|
+
},
|
|
45
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.HR_TEAM]: {
|
|
46
|
+
type: [InternalUserPermissionsSchema],
|
|
47
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.HR_TEAM],
|
|
48
|
+
},
|
|
49
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.DEVELOPER]: {
|
|
50
|
+
type: [InternalUserPermissionsSchema],
|
|
51
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.DEVELOPER],
|
|
52
|
+
},
|
|
53
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.FINANCE]: {
|
|
54
|
+
type: [InternalUserPermissionsSchema],
|
|
55
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.FINANCE],
|
|
56
|
+
},
|
|
57
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.VIEWER]: {
|
|
58
|
+
type: [InternalUserPermissionsSchema],
|
|
59
|
+
default: internal_operational_roles_1.DefaultInternalOperationalRoles[constants_1.INTERNAL_USER_ROLES_ENUM.VIEWER],
|
|
60
|
+
},
|
|
61
|
+
}, { _id: false, minimize: false });
|
|
62
|
+
exports.InternalOperationalRolesSchema = new mongoose_1.Schema({
|
|
63
|
+
_id: {
|
|
64
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
65
|
+
required: true,
|
|
66
|
+
immutable: true,
|
|
67
|
+
},
|
|
68
|
+
roles: {
|
|
69
|
+
type: InternalRolesSchema,
|
|
70
|
+
required: true,
|
|
71
|
+
},
|
|
72
|
+
createdAt: {
|
|
73
|
+
type: mongoose_1.Schema.Types.Date,
|
|
74
|
+
required: true,
|
|
75
|
+
default: () => new Date(),
|
|
76
|
+
immutable: true,
|
|
77
|
+
},
|
|
78
|
+
updatedAt: {
|
|
79
|
+
type: mongoose_1.Schema.Types.Date,
|
|
80
|
+
required: true,
|
|
81
|
+
default: () => new Date(),
|
|
82
|
+
},
|
|
83
|
+
}, {
|
|
84
|
+
timestamps: true,
|
|
85
|
+
versionKey: false,
|
|
86
|
+
minimize: false,
|
|
87
|
+
});
|
|
88
|
+
exports.INTERNAL_OPERATIONAL_ROLES_COLLECTION_NAME = 'internal_operational_roles';
|