@managesome/eposmatic-toolkit 0.2.462 → 0.2.464
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-rfq.d.ts +3 -0
- package/lib/helpers/order/generate-warehouse-sale-order-rfq.js +64 -0
- 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 +2 -1
- package/lib/helpers/order/index.js +2 -1
- package/lib/helpers/store/all-warehouse-sale-orders-actions.d.ts +13 -0
- package/lib/helpers/store/all-warehouse-sale-orders-actions.js +79 -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/common-warehouse-sale-order-rfq-actions.d.ts +0 -1
- package/lib/helpers/store/common-warehouse-sale-order-rfq-actions.js +2 -88
- 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-order-rfq-cart-actions.d.ts +1 -0
- package/lib/helpers/store/warehouse-sale-order-rfq-cart-actions.js +93 -7
- 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 +2 -24
- 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,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;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IWarehouseSaleOrderRFQ, IWarehouseSaleOrderRFQItem } from '../../schemas';
|
|
2
|
+
export declare function calculateCartWarehouseSaleOrderRfqOrderInfoAndSyncData<T extends IWarehouseSaleOrderRFQ | Partial<IWarehouseSaleOrderRFQ>>(data: T, calculateItemMetadata?: boolean): T;
|
|
2
3
|
export declare function getRemoveItemFromWarehouseSaleOrderRfqCartData(data: Partial<IWarehouseSaleOrderRFQ>, payload: {
|
|
3
4
|
_id: string;
|
|
4
5
|
void_reason?: string;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.calculateCartWarehouseSaleOrderRfqOrderInfoAndSyncData = calculateCartWarehouseSaleOrderRfqOrderInfoAndSyncData;
|
|
6
7
|
exports.getRemoveItemFromWarehouseSaleOrderRfqCartData = getRemoveItemFromWarehouseSaleOrderRfqCartData;
|
|
7
8
|
exports.getUpdateWarehouseSaleOrderRfqCartInfoData = getUpdateWarehouseSaleOrderRfqCartInfoData;
|
|
8
9
|
exports.getAddItemToWarehouseSaleOrderRfqCartData = getAddItemToWarehouseSaleOrderRfqCartData;
|
|
@@ -12,12 +13,97 @@ exports.getSplitWarehouseSaleOrderRfqCartItemToTwo = getSplitWarehouseSaleOrderR
|
|
|
12
13
|
exports.getAddItemsToWarehouseSaleOrderRfqCartData = getAddItemsToWarehouseSaleOrderRfqCartData;
|
|
13
14
|
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
14
15
|
const lodash_1 = require("lodash");
|
|
16
|
+
const constants_1 = require("../../constants");
|
|
15
17
|
const utils_1 = require("../utils");
|
|
16
|
-
const common_warehouse_sale_order_rfq_actions_1 = require("./common-warehouse-sale-order-rfq-actions");
|
|
17
18
|
/* =================================================================
|
|
18
|
-
* Sale-order RFQ cart helpers —
|
|
19
|
+
* Sale-order RFQ cart helpers — fully typed, no delegation to SO functions.
|
|
19
20
|
* Mirrors warehouse-purchase-order-rfq-cart-actions.ts for sale RFQ types.
|
|
20
21
|
* ================================================================= */
|
|
22
|
+
function calculateCartWarehouseSaleOrderRfqOrderInfoAndSyncData(data, calculateItemMetadata) {
|
|
23
|
+
const isConfirmed = data.order_status === constants_1.WAREHOUSE_SALE_ORDER_RFQ_STATUS_ENUM.CONFIRMED;
|
|
24
|
+
let subtotal = 0;
|
|
25
|
+
const categories = [];
|
|
26
|
+
const length = data.categories?.length ?? 0;
|
|
27
|
+
for (let c = 0; c < length; c++) {
|
|
28
|
+
const category = data.categories[c];
|
|
29
|
+
const newItems = [];
|
|
30
|
+
const itemsLength = category.items.length;
|
|
31
|
+
for (let i = 0; i < itemsLength; i++) {
|
|
32
|
+
const item = category.items[i];
|
|
33
|
+
const itemSubtotal = (0, utils_1.parseNum)(item.price * item.quantity);
|
|
34
|
+
const newItem = {
|
|
35
|
+
...item,
|
|
36
|
+
is_ready: item.is_ready || isConfirmed,
|
|
37
|
+
subtotal: itemSubtotal,
|
|
38
|
+
_discount_amount: 0,
|
|
39
|
+
_gross_amount: 0,
|
|
40
|
+
_gst_amount: 0,
|
|
41
|
+
_net_amount: 0,
|
|
42
|
+
};
|
|
43
|
+
delete newItem.void_reason;
|
|
44
|
+
newItems.push(newItem);
|
|
45
|
+
subtotal += itemSubtotal;
|
|
46
|
+
}
|
|
47
|
+
categories.push({ ...category, items: newItems });
|
|
48
|
+
}
|
|
49
|
+
let grand_total = subtotal;
|
|
50
|
+
let gst_amount = 0;
|
|
51
|
+
const gst = data.gst ?? 0;
|
|
52
|
+
if (data.is_gst_inclusive) {
|
|
53
|
+
gst_amount = (0, utils_1.parseFloatCeil)((grand_total * gst) / (100 + gst));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
gst_amount = (0, utils_1.getPercentageAmount)(grand_total, gst);
|
|
57
|
+
grand_total += gst_amount;
|
|
58
|
+
}
|
|
59
|
+
grand_total = (0, utils_1.parseNum)(grand_total);
|
|
60
|
+
const amount_earned = (0, utils_1.parseNum)(grand_total);
|
|
61
|
+
if (calculateItemMetadata) {
|
|
62
|
+
let leftGrossAmount = subtotal;
|
|
63
|
+
let leftNetAmount = subtotal;
|
|
64
|
+
let leftDiscountAmount = 0;
|
|
65
|
+
let leftGstAmount = gst_amount;
|
|
66
|
+
categories.forEach((category, categoryIndex) => {
|
|
67
|
+
const isLastCategory = categoryIndex === categories.length - 1;
|
|
68
|
+
category.items.forEach((item, itemIndex) => {
|
|
69
|
+
const isLastItem = isLastCategory && itemIndex === category.items.length - 1;
|
|
70
|
+
let grossAmount = item.subtotal;
|
|
71
|
+
let netAmount = item.subtotal;
|
|
72
|
+
let itemTotalDiscountAmount = 0;
|
|
73
|
+
let itemGst = 0;
|
|
74
|
+
if (gst_amount > 0) {
|
|
75
|
+
itemGst = (item.subtotal / subtotal) * gst_amount;
|
|
76
|
+
}
|
|
77
|
+
grossAmount = (0, utils_1.parseFloatCeil)(grossAmount);
|
|
78
|
+
const netAmountParsed = (0, utils_1.parseFloatCeil)(netAmount);
|
|
79
|
+
const itemTotalDiscountAmountParsed = (0, utils_1.parseFloatCeil)(itemTotalDiscountAmount);
|
|
80
|
+
itemGst = (0, utils_1.parseFloatCeil)(itemGst);
|
|
81
|
+
leftGrossAmount -= grossAmount;
|
|
82
|
+
leftNetAmount -= netAmountParsed;
|
|
83
|
+
leftDiscountAmount -= itemTotalDiscountAmountParsed;
|
|
84
|
+
leftGstAmount -= itemGst;
|
|
85
|
+
if (isLastItem) {
|
|
86
|
+
grossAmount += leftGrossAmount;
|
|
87
|
+
netAmount += leftNetAmount;
|
|
88
|
+
itemTotalDiscountAmount += leftDiscountAmount;
|
|
89
|
+
itemGst += leftGstAmount;
|
|
90
|
+
}
|
|
91
|
+
item._gross_amount = Math.max(grossAmount, 0);
|
|
92
|
+
item._net_amount = Math.max(netAmount, 0);
|
|
93
|
+
item._discount_amount = Math.max(itemTotalDiscountAmount, 0);
|
|
94
|
+
item._gst_amount = Math.max(itemGst, 0);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
...data,
|
|
100
|
+
categories,
|
|
101
|
+
amount_earned,
|
|
102
|
+
gst_amount,
|
|
103
|
+
price: (0, utils_1.parseNum)(subtotal),
|
|
104
|
+
grand_total,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
21
107
|
// ── Shared ──
|
|
22
108
|
const getUpdatedSaleOrderRfqItem = (item) => ({
|
|
23
109
|
item_id: item.item_id,
|
|
@@ -77,7 +163,7 @@ function getRemoveItemFromWarehouseSaleOrderRfqCartData(data, payload) {
|
|
|
77
163
|
}
|
|
78
164
|
iterations.push({ ...firstIteration, categories: firstIterationCategories }, ...restIterations);
|
|
79
165
|
}
|
|
80
|
-
return
|
|
166
|
+
return calculateCartWarehouseSaleOrderRfqOrderInfoAndSyncData({
|
|
81
167
|
...data,
|
|
82
168
|
...(iterations.length > 0 && { iterations }),
|
|
83
169
|
categories,
|
|
@@ -85,7 +171,7 @@ function getRemoveItemFromWarehouseSaleOrderRfqCartData(data, payload) {
|
|
|
85
171
|
}
|
|
86
172
|
// ── Update Info ──
|
|
87
173
|
function getUpdateWarehouseSaleOrderRfqCartInfoData(data, payload) {
|
|
88
|
-
return
|
|
174
|
+
return calculateCartWarehouseSaleOrderRfqOrderInfoAndSyncData({ ...data, ...payload });
|
|
89
175
|
}
|
|
90
176
|
function getAddItemToWarehouseSaleOrderRfqCartData(data, payload) {
|
|
91
177
|
const { category_id, name, item, replace_id } = payload;
|
|
@@ -169,7 +255,7 @@ function getAddItemToWarehouseSaleOrderRfqCartData(data, payload) {
|
|
|
169
255
|
}
|
|
170
256
|
iterations.push({ ...firstIteration, categories: firstIterationCategories }, ...restIterations);
|
|
171
257
|
}
|
|
172
|
-
return
|
|
258
|
+
return calculateCartWarehouseSaleOrderRfqOrderInfoAndSyncData({
|
|
173
259
|
...orderData,
|
|
174
260
|
...(iterations.length > 0 && { iterations }),
|
|
175
261
|
categories,
|
|
@@ -231,7 +317,7 @@ function getUpdateItemInWarehouseSaleOrderRfqCartData(data, payload) {
|
|
|
231
317
|
}
|
|
232
318
|
iterations.push({ ...firstIteration, categories: firstIterationCategories }, ...restIterations);
|
|
233
319
|
}
|
|
234
|
-
return
|
|
320
|
+
return calculateCartWarehouseSaleOrderRfqOrderInfoAndSyncData({
|
|
235
321
|
...data,
|
|
236
322
|
...(iterations.length > 0 && { iterations }),
|
|
237
323
|
categories,
|
|
@@ -275,7 +361,7 @@ function getSplitWarehouseSaleOrderRfqCartItemToTwo(data, orderItemId) {
|
|
|
275
361
|
}
|
|
276
362
|
newCategories.push({ ...category, items: newItems });
|
|
277
363
|
}
|
|
278
|
-
return
|
|
364
|
+
return calculateCartWarehouseSaleOrderRfqOrderInfoAndSyncData({
|
|
279
365
|
...data,
|
|
280
366
|
categories: newCategories,
|
|
281
367
|
});
|
|
@@ -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>;
|