@managesome/eposmatic-toolkit 0.2.429 → 0.2.431
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/ENUMS.d.ts +9 -2
- package/lib/constants/ENUMS.js +14 -3
- package/lib/helpers/order/generate-purchase-order-rfq.d.ts +3 -0
- package/lib/helpers/order/generate-purchase-order-rfq.js +64 -0
- package/lib/helpers/order/index.d.ts +1 -0
- package/lib/helpers/order/index.js +1 -0
- package/lib/helpers/store/index.d.ts +1 -0
- package/lib/helpers/store/index.js +1 -0
- package/lib/helpers/store/purchase-order-rfq-cart-actions.d.ts +19 -0
- package/lib/helpers/store/purchase-order-rfq-cart-actions.js +373 -0
- package/lib/helpers/utils/inventory.js +6 -0
- package/lib/helpers/utils/warehouse-inventory.js +9 -0
- package/lib/schemas/types/inventories.d.ts +2 -0
- package/lib/schemas/types/warehouse_items.d.ts +3 -0
- package/package.json +1 -1
package/lib/constants/ENUMS.d.ts
CHANGED
|
@@ -868,7 +868,9 @@ export declare enum INVENTORY_TRANSACTION_CATEGORY_ENUM {
|
|
|
868
868
|
CONSUMPTION = "CONSUMPTION",
|
|
869
869
|
RETURNS = "RETURNS",
|
|
870
870
|
SHORT = "SHORT",
|
|
871
|
-
VARIANCE = "VARIANCE"
|
|
871
|
+
VARIANCE = "VARIANCE",
|
|
872
|
+
TRANSFER = "TRANSFER",
|
|
873
|
+
SALE_ORDER = "SALE_ORDER"
|
|
872
874
|
}
|
|
873
875
|
export declare const ALL_INVENTORY_TRANSACTION_CATEGORIES: INVENTORY_TRANSACTION_CATEGORY_ENUM[];
|
|
874
876
|
export declare const INVENTORY_INBOUND_TRANSACTIONS: INVENTORY_TRANSACTION_CATEGORY_ENUM[];
|
|
@@ -1053,7 +1055,8 @@ export declare const ALL_INTERNAL_MOVEMENT_EDIT_REQUEST_STATUS_NAMES: INTERNAL_M
|
|
|
1053
1055
|
export declare enum INTERNAL_MOVEMENT_FLOW_ENUM {
|
|
1054
1056
|
WH_TO_WH = "WH_TO_WH",
|
|
1055
1057
|
WH_TO_BRANCH = "WH_TO_BRANCH",
|
|
1056
|
-
BRANCH_TO_WH = "BRANCH_TO_WH"
|
|
1058
|
+
BRANCH_TO_WH = "BRANCH_TO_WH",
|
|
1059
|
+
BRANCH_TO_BRANCH = "BRANCH_TO_BRANCH"
|
|
1057
1060
|
}
|
|
1058
1061
|
export declare const ALL_INTERNAL_MOVEMENT_FLOW_NAMES: INTERNAL_MOVEMENT_FLOW_ENUM[];
|
|
1059
1062
|
export declare enum INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM {
|
|
@@ -1061,6 +1064,10 @@ export declare enum INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM {
|
|
|
1061
1064
|
BRANCH = "BRANCH"
|
|
1062
1065
|
}
|
|
1063
1066
|
export declare const ALL_INTERNAL_MOVEMENT_LOCATION_TYPE_NAMES: INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM[];
|
|
1067
|
+
export declare enum INTERNAL_MOVEMENT_DIRECTION_ENUM {
|
|
1068
|
+
INBOUND = "INBOUND",
|
|
1069
|
+
OUTBOUND = "OUTBOUND"
|
|
1070
|
+
}
|
|
1064
1071
|
export declare enum PURCHASE_ORDER_RECEIPT_STATUS_ENUM {
|
|
1065
1072
|
DRAFT = "DRAFT",
|
|
1066
1073
|
VALIDATED = "VALIDATED",
|
package/lib/constants/ENUMS.js
CHANGED
|
@@ -4,9 +4,9 @@ exports.COUNTRY_NAME_ENUM = exports.ALL_COUNTRY_ALPHA_3_TYPES = exports.COUNTRY_
|
|
|
4
4
|
exports.EMAIL_STATUS_ENUM = exports.ALL_COMMUNICATION_CHANNELS = exports.COMMUNICATION_CHANNEL_ENUM = exports.ALL_EMAIL_DOCUMENT_KINDS = exports.EMAIL_DOCUMENT_KIND_ENUM = exports.ALL_EMAIL_PROCESSING_PROVIDERS = exports.EMAIL_PROCESSING_PROVIDERS_ENUM = exports.ALL_SMS_PROCESSING_PROVIDERS = exports.SMS_PROCESSING_PROVIDERS_ENUM = exports.ALL_SUPPORT_SPECIALIST_PERMISSIONS = exports.ALL_MODERATOR_PERMISSIONS = exports.ALL_USER_PERMISSIONS = exports.USER_PERMISSIONS_ENUM = exports.ALL_REWARDS_USAGE_REF_TYPES = exports.REWARDS_USAGE_REF_TYPE_ENUM = exports.ALL_PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPES = exports.PATHWAY_TO_UNLOCK_TYPE_ORDERS_SCOPE_ENUM = exports.ALL_PATHWAY_TO_UNLOCK_TYPES = exports.PATHWAY_TO_UNLOCK_TYPE_ENUM = exports.ALL_MYSTERY_GIFT_POPUP_TYPES = exports.MYSTERY_GIFT_POPUP_TYPE_ENUM = exports.ALL_MYSTERY_GIFT_TYPES = exports.MYSTERY_GIFT_TYPE_ENUM = exports.ALL_GIFT_CARD_REWARD_TYPES = exports.GIFT_CARD_REWARD_TYPE_ENUM = exports.ALL_CUSTOMER_REDEMPTION_TYPES = exports.CUSTOMER_REDEMPTION_TYPE_ENUM = exports.ALL_CUSTOMER_REDEMPTION_SOURCE_TYPES = exports.CUSTOMER_REDEMPTION_SOURCE_ENUM = exports.ALL_OFFER_REWARD_TYPES = exports.OFFER_REWARD_TYPE_ENUM = exports.ALL_USER_ROLES = exports.USER_ROLES_ENUM = exports.ALL_PLATFORM_TYPES = exports.PLATFORM_TYPE_ENUM = exports.ALL_ORDER_NUMBER_GROUPING_TYPES = exports.ORDER_NUMBER_GROUPING_TYPE_ENUM = exports.ALL_TRACK_ORDER_NUMBER_TYPES = exports.TRACK_ORDER_NUMBER_ENUM = exports.ALL_TABLE_TYPES = exports.TABLE_TYPE_ENUM = exports.ALL_CATEGORY_DISPLAY_TYPES = exports.CATEGORY_DISPLAY_TYPE_ENUM = exports.ALL_PAYMENT_METHOD_EXPECTED = exports.PAYMENT_METHOD_EXPECTED_ENUM = exports.ALL_WEB_UNPAID_PAYMENT_TYPES = exports.WEB_UNPAID_PAYMENT_TYPE_ENUM = exports.ALL_COUNTRY_FLAG_TYPES = exports.COUNTRY_FLAG_ENUM = exports.ALL_COUNTRY_NAME_TYPES = void 0;
|
|
5
5
|
exports.EXPENSE_REACCURING_TYPE_ENUM = exports.PAYMENT_EXTENSION_ENUM = exports.ALL_PRINTER_INTERFACES = exports.PRINTER_INTERFACE_ENUM = exports.RECEIPT_WIDTHS = exports.ALL_NUM_OF_COLUMNS = exports.NUM_OF_COLUMNS_ENUM = exports.SPLIT_SYNC_SOURCE_ENUM = exports.ALL_SPLIT_BILL_TYPES = exports.SPLIT_BILL_TYPE_ENUM = exports.ALL_RIDER_FEE_TYPES = exports.RIDER_FEE_TYPE_ENUM = exports.ALL_DELIVERY_AREAS_SEARCH_TYPES = exports.DELIVERY_AREAS_SEARCH_TYPE_ENUM = exports.ALL_WEB_AUTH_TYPES = exports.WEB_AUTH_TYPE_ENUM = exports.KITCHEN_RECEIPT_TYPE_ENUM = exports.PRINTER_EVENT_TYPE_ENUM = exports.SORT_TYPE_ENUM = exports.WHITELISTED_API_SMS_COUNTRY_CODES = exports.BLACKLISTED_SMS_COUNTRY_CODES = exports.ALL_OTP_TYPES = exports.OTP_TYPE_ENUM = exports.ALL_TAX_INVOICE_PROVIDERS = exports.TAX_INVOICE_PROVIDER_ENUM = exports.ALL_RESERVATION_STATUS_TYPES = exports.RESERVATION_STATUS_ENUM = exports.TENANT_AMOUNT_DUE_TYPE_ENUM = exports.ALL_KITCHEN_DOCKET_FONT_TYPES = exports.KITCHEN_DOCKET_FONT_TYPE_ENUM = exports.ALL_SORT_ORDER_BY_TYPES = exports.SORT_ORDER_BY_ENUM = exports.RECEIPT_IMAGE_TYPE_ENUM = exports.ALL_RECEIPT_TYPES = exports.RECEIPT_TYPE_ENUM = exports.ALL_PRINTING_PREFERENCES = exports.PRINTING_PREFERENCE_ENUM = exports.ALL_PRINTER_BRAND_TYPES = exports.PRINTER_BRAND_TYPE_ENUM = exports.ALL_ORDER_ITEM_TYPES = exports.ORDER_ITEM_TYPE_ENUM = exports.ALL_PLATFORM_PROVIDER_IDS = exports.PLATFORM_PROVIDER_IDS_ENUM = exports.ALL_MARKETING_RECEIPIENT_TYPES = exports.MARKETING_RECEIPIENT_ENUM = exports.ALL_MARKETING_TYPES = exports.MARKETING_TYPE_ENUM = exports.ALL_TOKEN_TYPES = exports.TOKEN_TYPE_ENUM = exports.ALL_EMAIL_STATUS = void 0;
|
|
6
6
|
exports.ALL_SALE_ORDER_FIN_DOC_KIND_NAMES = exports.SALE_ORDER_FIN_DOC_KIND_ENUM = exports.ALL_SALES_ORDER_STATUS_NAMES = exports.SALES_ORDER_STATUS_ENUM = exports.ALL_SALE_ORDER_RFQ_STATUS_NAMES = exports.SALE_ORDER_RFQ_STATUS_ENUM = exports.ALL_RFQ_VENDOR_STATUS_NAMES = exports.RFQ_VENDOR_STATUS_ENUM = exports.ALL_PURCHASE_ORDER_RFQ_STATUS_NAMES = exports.PURCHASE_ORDER_RFQ_STATUS_ENUM = exports.ALL_PURCHASE_ORDER_STATUS_NAMES = exports.PURCHASE_ORDER_STATUS_ENUM = exports.ALL_DELIVERY_STATUS = exports.DELIVERY_STATUS_ENUM = exports.ALL_INVENTORY_ITEM_TYPES = exports.INVENTORY_ITEM_TYPE_ENUM = exports.ALL_RATING_TYPES = exports.RATING_TYPE_ENUM = exports.ALL_SUBSCRIPTION_STATUS = exports.SUBSCRIPTION_STATUS_ENUM = exports.ALL_VOID_WAREHOUSE_INVOICE_ITEM_TYPES = exports.VOID_WAREHOUSE_INVOICE_ITEM_TYPE_ENUM = exports.ALL_VOID_PURCHASE_ORDER_ITEM_TYPES = exports.VOID_PURCHASE_ORDER_ITEM_TYPE_ENUM = exports.ALL_VOID_ORDER_ITEM_TYPES = exports.VOID_ORDER_ITEM_TYPE_ENUM = exports.COMPARISON_REPORT_TYPE_ENUM = exports.ALL_MULTI_TENANT_WEBSITE_TYPES = exports.MULTI_TENANT_WEBSITE_TYPE_ENUM = exports.ALL_TIME_RANGE_ENUMS = exports.TIME_RANGE_ENUM = exports.ALL_ITEM_TRANSACTION_TYPES = exports.ITEM_TRANSACTION_TYPE_ENUM = exports.INVENTORY_OUTBOUND_TRANSACTIONS = exports.INVENTORY_INBOUND_TRANSACTIONS = exports.ALL_INVENTORY_TRANSACTION_CATEGORIES = exports.INVENTORY_TRANSACTION_CATEGORY_ENUM = exports.ALL_INVENTORY_TRANSACTION_TYPES = exports.INVENTORY_TRANSACTION_TYPE_ENUM = exports.ALL_REMOVAL_STRATEGY_TYPES = exports.REMOVAL_STRATEGY_ENUM = exports.ALL_LOT_SERIAL_MOVEMENT_SOURCES = exports.LOT_SERIAL_MOVEMENT_SOURCE_ENUM = exports.ALL_LOT_SERIAL_DOC_TYPES = exports.LOT_SERIAL_DOC_TYPE_ENUM = exports.ALL_TRACKING_MODES = exports.TRACKING_MODE_ENUM = exports.ALL_GST_TYPES = exports.GST_TYPE_ENUM = exports.ALL_EXPENSE_REACCURING_TYPES = void 0;
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.ALL_INTERNAL_CUSTOMER_PAYMENT_METHOD_NAMES = exports.INTERNAL_CUSTOMER_PAYMENT_METHOD_ENUM = exports.ALL_INTERNAL_CUSTOMER_SUBSCRIPTION_SERVICE_NAMES = void 0;
|
|
7
|
+
exports.ALL_DISCOUNT_TYPES = exports.DISCOUNT_TYPE_ENUM = exports.EMAIL_TEMPLATES_TYPE_ENUM = exports.ALL_ALERT_NOTIFICATIONS_TYPES = exports.ALERT_NOTIFICATIONS_TYPE_ENUM = exports.ALL_WALLET_TRANSACTION_STATUS = exports.WALLET_TRANSACTION_STATUS_ENUM = exports.ALL_WALLET_TRANSACTION_CATEGORIES = exports.WALLET_TRANSACTION_CATEGORY_ENUM = exports.ALL_WALLET_TRANSACTION_TYPES = exports.WALLET_TRANSACTION_TYPE_ENUM = exports.ALL_WAREHOUSE_SUPPORT_SPECIALIST_PERMISSIONS = exports.ALL_WAREHOUSE_MODERATOR_PERMISSIONS = exports.ALL_WAREHOUSE_USER_PERMISSIONS = exports.WAREHOUSE_USER_PERMISSIONS_ENUM = exports.ALL_WAREHOUSE_INVOICE_STATUS_NAMES = exports.WAREHOUSE_INVOICE_STATUS_ENUM = exports.TActivityLogSeverity = exports.ACTIVITY_LOG_ACTIONS = exports.TActivityLogAction = exports.TActivityLogEntityType = exports.ALL_PURCHASE_ORDER_VENDOR_RETURN_STATUS_NAMES = exports.PURCHASE_ORDER_VENDOR_RETURN_STATUS_ENUM = exports.ALL_PURCHASE_ORDER_RECEIPT_STATUS_NAMES = exports.PURCHASE_ORDER_RECEIPT_STATUS_ENUM = exports.INTERNAL_MOVEMENT_DIRECTION_ENUM = exports.ALL_INTERNAL_MOVEMENT_LOCATION_TYPE_NAMES = exports.INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM = exports.ALL_INTERNAL_MOVEMENT_FLOW_NAMES = exports.INTERNAL_MOVEMENT_FLOW_ENUM = exports.ALL_INTERNAL_MOVEMENT_EDIT_REQUEST_STATUS_NAMES = exports.INTERNAL_MOVEMENT_EDIT_REQUEST_STATUS_ENUM = exports.ALL_INTERNAL_MOVEMENT_STATUS_NAMES = exports.INTERNAL_MOVEMENT_STATUS_ENUM = exports.ALL_INTERNAL_MOVEMENT_RECORD_TYPE_NAMES = exports.INTERNAL_MOVEMENT_RECORD_TYPE_ENUM = exports.ALL_REF_TYPES = exports.REF_TYPE_ENUM = exports.ALL_SALE_ORDER_DELIVERY_RETURN_STATUS_NAMES = exports.SALE_ORDER_DELIVERY_RETURN_STATUS_ENUM = exports.ALL_SALE_ORDER_DELIVERY_STATUS_NAMES = exports.SALE_ORDER_DELIVERY_STATUS_ENUM = exports.ALL_SALE_ORDER_PHYSICAL_DOC_KIND_NAMES = exports.SALE_ORDER_PHYSICAL_DOC_KIND_ENUM = exports.ALL_SALE_ORDER_CREDIT_NOTE_STATUS_NAMES = exports.SALE_ORDER_CREDIT_NOTE_STATUS_ENUM = exports.ALL_SALE_ORDER_INVOICE_PAYMENT_STATUS_NAMES = exports.SALE_ORDER_INVOICE_PAYMENT_STATUS_ENUM = exports.ALL_SALE_ORDER_INVOICE_TYPE_NAMES = exports.SALE_ORDER_INVOICE_TYPE_ENUM = void 0;
|
|
8
|
+
exports.ALL_INTERNAL_CUSTOMER_SUBSCRIPTION_PLAN_NAMES = exports.INTERNAL_CUSTOMER_SUBSCRIPTION_PLAN_ENUM = exports.ALL_INTERNAL_CUSTOMER_BILLING_CYCLE_NAMES = exports.INTERNAL_CUSTOMER_BILLING_CYCLE_ENUM = exports.ALL_INTERNAL_CUSTOMER_TYPE_NAMES = exports.INTERNAL_CUSTOMER_TYPE_ENUM = exports.ALL_INTERNAL_INVOICE_TYPE_NAMES = exports.INTERNAL_INVOICE_TYPE_ENUM = exports.ALL_INTERNAL_INVOICE_STATUS_NAMES = exports.INTERNAL_INVOICE_STATUS_ENUM = exports.ALL_SUBSCRIPTION_HARDWARE_NAMES = exports.SUBSCRIPTION_HARDWARE_ENUM = exports.ALL_CUSTOMER_TARGET_MODES = exports.CUSTOMER_TARGET_MODE_ENUM = exports.ALL_WALLET_ASSIGNMENT_BEHAVIORS = exports.WALLET_ASSIGNMENT_BEHAVIOR_ENUM = exports.ALL_WALLET_ASSET_TYPES = exports.WALLET_ASSET_TYPE_ENUM = exports.ALL_RECEIPT_QR_CODE_TYPES = exports.RECEIPT_QR_CODE_TYPE_ENUM = exports.ALL_INTERNAL_LEAD_STATUS = exports.INTERNAL_LEAD_STATUS_ENUM = exports.ALL_INTERNAL_LEAD_SOURCES = exports.INTERNAL_LEAD_SOURCE_ENUM = exports.ALL_CASH_DRAWER_STATUS = exports.CASH_DRAWER_STATUS_ENUM = exports.ALL_CASH_IN_HAND_TRANSACTION_CATEGORIES = exports.CASH_IN_HAND_TRANSACTION_CATEGORY_ENUM = exports.ALL_CASH_IN_HAND_TRANSACTION_TYPES = exports.CASH_IN_HAND_TRANSACTION_TYPE_ENUM = exports.ALL_CASH_IN_OUT_TYPES = exports.CASH_IN_OUT_TYPE_ENUM = exports.ALL_POS_SHIFT_STATUS = exports.POS_SHIFT_STATUS_ENUM = exports.ALL_POS_DAY_STATUS = exports.POS_DAY_STATUS_ENUM = exports.ALL_MODIFIER_OPTION_REF_TYPES = exports.MODIFIER_OPTION_REF_TYPE_ENUM = exports.ALL_WAREHOUSE_CLIENT_TYPES = exports.WAREHOUSE_CLIENT_TYPE_ENUM = exports.ALL_ONLINE_ORDERING_DESIGN_TYPES = exports.ONLINE_ORDERING_DESIGN_TYPE_ENUM = exports.ALL_NOTIFICATION_PROVIDERS = exports.NOTIFICATION_PROVIDER_ENUM = exports.ALL_ORDER_COMPLETION_TYPES = exports.ORDER_COMPLETION_TYPE_ENUM = exports.ITEM_COMPARISON_FIELD_ENUM = exports.VOID_ITEM_STAFF_REPORT_ENUM = exports.ALL_DISCOUNT_APPLICABILITY_TYPES = exports.DISCOUNT_APPLICABILITY_ENUM = void 0;
|
|
9
|
+
exports.ALL_INTERNAL_CUSTOMER_PAYMENT_METHOD_NAMES = exports.INTERNAL_CUSTOMER_PAYMENT_METHOD_ENUM = exports.ALL_INTERNAL_CUSTOMER_SUBSCRIPTION_SERVICE_NAMES = exports.INTERNAL_CUSTOMER_SUBSCRIPTION_SERVICE_ENUM = void 0;
|
|
10
10
|
var ORDER_FROM_ENUM;
|
|
11
11
|
(function (ORDER_FROM_ENUM) {
|
|
12
12
|
ORDER_FROM_ENUM["WEB"] = "WEB";
|
|
@@ -1473,18 +1473,23 @@ var INVENTORY_TRANSACTION_CATEGORY_ENUM;
|
|
|
1473
1473
|
INVENTORY_TRANSACTION_CATEGORY_ENUM["RETURNS"] = "RETURNS";
|
|
1474
1474
|
INVENTORY_TRANSACTION_CATEGORY_ENUM["SHORT"] = "SHORT";
|
|
1475
1475
|
INVENTORY_TRANSACTION_CATEGORY_ENUM["VARIANCE"] = "VARIANCE";
|
|
1476
|
+
INVENTORY_TRANSACTION_CATEGORY_ENUM["TRANSFER"] = "TRANSFER";
|
|
1477
|
+
INVENTORY_TRANSACTION_CATEGORY_ENUM["SALE_ORDER"] = "SALE_ORDER";
|
|
1476
1478
|
})(INVENTORY_TRANSACTION_CATEGORY_ENUM || (exports.INVENTORY_TRANSACTION_CATEGORY_ENUM = INVENTORY_TRANSACTION_CATEGORY_ENUM = {}));
|
|
1477
1479
|
exports.ALL_INVENTORY_TRANSACTION_CATEGORIES = Object.values(INVENTORY_TRANSACTION_CATEGORY_ENUM);
|
|
1478
1480
|
// ======================>> <<====================== //
|
|
1479
1481
|
exports.INVENTORY_INBOUND_TRANSACTIONS = [
|
|
1480
1482
|
INVENTORY_TRANSACTION_CATEGORY_ENUM.NEW_STOCK,
|
|
1481
1483
|
INVENTORY_TRANSACTION_CATEGORY_ENUM.VARIANCE,
|
|
1484
|
+
INVENTORY_TRANSACTION_CATEGORY_ENUM.TRANSFER,
|
|
1482
1485
|
];
|
|
1483
1486
|
exports.INVENTORY_OUTBOUND_TRANSACTIONS = [
|
|
1484
1487
|
INVENTORY_TRANSACTION_CATEGORY_ENUM.WASTAGE,
|
|
1485
1488
|
INVENTORY_TRANSACTION_CATEGORY_ENUM.RETURNS,
|
|
1486
1489
|
INVENTORY_TRANSACTION_CATEGORY_ENUM.SHORT,
|
|
1487
1490
|
INVENTORY_TRANSACTION_CATEGORY_ENUM.VARIANCE,
|
|
1491
|
+
INVENTORY_TRANSACTION_CATEGORY_ENUM.TRANSFER,
|
|
1492
|
+
INVENTORY_TRANSACTION_CATEGORY_ENUM.SALE_ORDER,
|
|
1488
1493
|
];
|
|
1489
1494
|
// ======================>> <<====================== //
|
|
1490
1495
|
var ITEM_TRANSACTION_TYPE_ENUM;
|
|
@@ -1712,6 +1717,7 @@ var INTERNAL_MOVEMENT_FLOW_ENUM;
|
|
|
1712
1717
|
INTERNAL_MOVEMENT_FLOW_ENUM["WH_TO_WH"] = "WH_TO_WH";
|
|
1713
1718
|
INTERNAL_MOVEMENT_FLOW_ENUM["WH_TO_BRANCH"] = "WH_TO_BRANCH";
|
|
1714
1719
|
INTERNAL_MOVEMENT_FLOW_ENUM["BRANCH_TO_WH"] = "BRANCH_TO_WH";
|
|
1720
|
+
INTERNAL_MOVEMENT_FLOW_ENUM["BRANCH_TO_BRANCH"] = "BRANCH_TO_BRANCH";
|
|
1715
1721
|
})(INTERNAL_MOVEMENT_FLOW_ENUM || (exports.INTERNAL_MOVEMENT_FLOW_ENUM = INTERNAL_MOVEMENT_FLOW_ENUM = {}));
|
|
1716
1722
|
exports.ALL_INTERNAL_MOVEMENT_FLOW_NAMES = Object.values(INTERNAL_MOVEMENT_FLOW_ENUM);
|
|
1717
1723
|
var INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM;
|
|
@@ -1720,6 +1726,11 @@ var INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM;
|
|
|
1720
1726
|
INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM["BRANCH"] = "BRANCH";
|
|
1721
1727
|
})(INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM || (exports.INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM = INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM = {}));
|
|
1722
1728
|
exports.ALL_INTERNAL_MOVEMENT_LOCATION_TYPE_NAMES = Object.values(INTERNAL_MOVEMENT_LOCATION_TYPE_ENUM);
|
|
1729
|
+
var INTERNAL_MOVEMENT_DIRECTION_ENUM;
|
|
1730
|
+
(function (INTERNAL_MOVEMENT_DIRECTION_ENUM) {
|
|
1731
|
+
INTERNAL_MOVEMENT_DIRECTION_ENUM["INBOUND"] = "INBOUND";
|
|
1732
|
+
INTERNAL_MOVEMENT_DIRECTION_ENUM["OUTBOUND"] = "OUTBOUND";
|
|
1733
|
+
})(INTERNAL_MOVEMENT_DIRECTION_ENUM || (exports.INTERNAL_MOVEMENT_DIRECTION_ENUM = INTERNAL_MOVEMENT_DIRECTION_ENUM = {}));
|
|
1723
1734
|
// ======================>> <<====================== //
|
|
1724
1735
|
var PURCHASE_ORDER_RECEIPT_STATUS_ENUM;
|
|
1725
1736
|
(function (PURCHASE_ORDER_RECEIPT_STATUS_ENUM) {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IPurchaseOrderRFQ, IPurchaseOrderRFQIteration } from '../../schemas';
|
|
2
|
+
export declare function generatePurchaseOrderRfqCategories(categories?: IPurchaseOrderRFQ['categories']): IPurchaseOrderRFQ['categories'];
|
|
3
|
+
export declare function generatePurchaseOrderRfqIteration(order: IPurchaseOrderRFQ | IPurchaseOrderRFQIteration, partial?: boolean, skipItemMetadata?: boolean): IPurchaseOrderRFQIteration;
|
|
@@ -0,0 +1,64 @@
|
|
|
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.generatePurchaseOrderRfqCategories = generatePurchaseOrderRfqCategories;
|
|
7
|
+
exports.generatePurchaseOrderRfqIteration = generatePurchaseOrderRfqIteration;
|
|
8
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
9
|
+
const common_purchase_order_actions_1 = require("../store/common-purchase-order-actions");
|
|
10
|
+
function generatePurchaseOrderRfqCategories(categories) {
|
|
11
|
+
if (!categories)
|
|
12
|
+
return [];
|
|
13
|
+
return categories.map((category) => ({
|
|
14
|
+
...category,
|
|
15
|
+
category_id: new mongoose_1.default.Types.ObjectId(category.category_id),
|
|
16
|
+
items: category.items.map((item) => ({
|
|
17
|
+
...item,
|
|
18
|
+
_id: new mongoose_1.default.Types.ObjectId(item._id),
|
|
19
|
+
item_id: new mongoose_1.default.Types.ObjectId(item.item_id),
|
|
20
|
+
})),
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
function getCommonOptionalBoolFieldsRfqIteration(order, partial) {
|
|
24
|
+
const defaultValue = partial ? undefined : false;
|
|
25
|
+
return {
|
|
26
|
+
is_gst_inclusive: order.is_gst_inclusive || defaultValue,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function getCommonOptionalNumFieldsRfqIteration(order, partial) {
|
|
30
|
+
const defaultValue = partial ? undefined : 0;
|
|
31
|
+
return {
|
|
32
|
+
gst: order.gst || defaultValue,
|
|
33
|
+
gst_amount: order.gst_amount || defaultValue,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function generatePurchaseOrderRfqIteration(order, partial = true, skipItemMetadata) {
|
|
37
|
+
const iteration = {
|
|
38
|
+
...getCommonOptionalBoolFieldsRfqIteration(order, partial),
|
|
39
|
+
...getCommonOptionalNumFieldsRfqIteration(order, partial),
|
|
40
|
+
...(skipItemMetadata && order.categories != null
|
|
41
|
+
? {
|
|
42
|
+
categories: (0, common_purchase_order_actions_1.skipItemMetadataFromPurchaseOrderCategories)(order.categories),
|
|
43
|
+
}
|
|
44
|
+
: {
|
|
45
|
+
categories: generatePurchaseOrderRfqCategories(order.categories),
|
|
46
|
+
}),
|
|
47
|
+
staff_details: order.staff_details,
|
|
48
|
+
special_instructions: order.special_instructions,
|
|
49
|
+
order_status: order.order_status,
|
|
50
|
+
price: order.price,
|
|
51
|
+
amount_earned: order.amount_earned,
|
|
52
|
+
grand_total: order.grand_total,
|
|
53
|
+
tax_number: order.tax_number,
|
|
54
|
+
updatedAt: order.updatedAt,
|
|
55
|
+
};
|
|
56
|
+
if (partial) {
|
|
57
|
+
Object.keys(iteration).forEach((key) => {
|
|
58
|
+
if (iteration[key] === undefined) {
|
|
59
|
+
delete iteration[key];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return iteration;
|
|
64
|
+
}
|
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./generate-order"), exports);
|
|
18
18
|
__exportStar(require("./generate-purchase-order"), exports);
|
|
19
|
+
__exportStar(require("./generate-purchase-order-rfq"), exports);
|
|
19
20
|
__exportStar(require("./generate-warehouse-invoice"), exports);
|
|
@@ -9,5 +9,6 @@ export * from './common-purchase-order-actions';
|
|
|
9
9
|
export * from './common-sale-order-actions';
|
|
10
10
|
export * from './common-warehouse-invoice-actions';
|
|
11
11
|
export * from './offline-ordering';
|
|
12
|
+
export * from './purchase-order-rfq-cart-actions';
|
|
12
13
|
export * from './purchase-orders-cart-actions';
|
|
13
14
|
export * from './warehouse-invoice-cart-actions';
|
|
@@ -25,5 +25,6 @@ __exportStar(require("./common-purchase-order-actions"), exports);
|
|
|
25
25
|
__exportStar(require("./common-sale-order-actions"), exports);
|
|
26
26
|
__exportStar(require("./common-warehouse-invoice-actions"), exports);
|
|
27
27
|
__exportStar(require("./offline-ordering"), exports);
|
|
28
|
+
__exportStar(require("./purchase-order-rfq-cart-actions"), exports);
|
|
28
29
|
__exportStar(require("./purchase-orders-cart-actions"), exports);
|
|
29
30
|
__exportStar(require("./warehouse-invoice-cart-actions"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IPurchaseOrderRFQ, IPurchaseOrderRFQItem } from '../../schemas';
|
|
2
|
+
export declare function calculateCartRfqOrderInfoAndSyncData<T extends IPurchaseOrderRFQ | Partial<IPurchaseOrderRFQ>>(data: T, calculateItemMetadata?: boolean): T;
|
|
3
|
+
export declare function getRemoveItemFromRfqCartData(data: Partial<IPurchaseOrderRFQ>, payload: {
|
|
4
|
+
_id: string;
|
|
5
|
+
void_reason?: string;
|
|
6
|
+
}): Partial<IPurchaseOrderRFQ>;
|
|
7
|
+
export declare function getUpdateRfqCartInfoData(data: Partial<IPurchaseOrderRFQ>, payload: Partial<IPurchaseOrderRFQ>): Partial<IPurchaseOrderRFQ>;
|
|
8
|
+
interface ISetAddItemToRfqCartActionPayload {
|
|
9
|
+
name: string;
|
|
10
|
+
category_id: string;
|
|
11
|
+
item: IPurchaseOrderRFQItem;
|
|
12
|
+
replace_id?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function getAddItemToRfqCartData(data: Partial<IPurchaseOrderRFQ>, payload: ISetAddItemToRfqCartActionPayload): Partial<IPurchaseOrderRFQ>;
|
|
15
|
+
export declare function getUpdateItemInRfqCartData(data: Partial<IPurchaseOrderRFQ>, payload: Partial<IPurchaseOrderRFQItem>): Partial<IPurchaseOrderRFQ>;
|
|
16
|
+
export declare function getUpdateItemsInRfqCartData(data: Partial<IPurchaseOrderRFQ>, payload: Partial<IPurchaseOrderRFQItem>[]): Partial<IPurchaseOrderRFQ>;
|
|
17
|
+
export declare function getSplitRfqCartItemToTwo(data: Partial<IPurchaseOrderRFQ>, orderItemId: string): Partial<IPurchaseOrderRFQ>;
|
|
18
|
+
export declare function getAddItemsToRfqCartData(data: Partial<IPurchaseOrderRFQ>, payload: ISetAddItemToRfqCartActionPayload[]): Partial<IPurchaseOrderRFQ>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,373 @@
|
|
|
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.calculateCartRfqOrderInfoAndSyncData = calculateCartRfqOrderInfoAndSyncData;
|
|
7
|
+
exports.getRemoveItemFromRfqCartData = getRemoveItemFromRfqCartData;
|
|
8
|
+
exports.getUpdateRfqCartInfoData = getUpdateRfqCartInfoData;
|
|
9
|
+
exports.getAddItemToRfqCartData = getAddItemToRfqCartData;
|
|
10
|
+
exports.getUpdateItemInRfqCartData = getUpdateItemInRfqCartData;
|
|
11
|
+
exports.getUpdateItemsInRfqCartData = getUpdateItemsInRfqCartData;
|
|
12
|
+
exports.getSplitRfqCartItemToTwo = getSplitRfqCartItemToTwo;
|
|
13
|
+
exports.getAddItemsToRfqCartData = getAddItemsToRfqCartData;
|
|
14
|
+
const bson_objectid_1 = __importDefault(require("bson-objectid"));
|
|
15
|
+
const lodash_1 = require("lodash");
|
|
16
|
+
const constants_1 = require("../../constants");
|
|
17
|
+
const utils_1 = require("../utils");
|
|
18
|
+
/* =================================================================
|
|
19
|
+
* RFQ cart helpers — fully typed, no delegation to PO functions.
|
|
20
|
+
* IPurchaseOrderRFQCategory ≡ IPurchaseOrderCategory (same type),
|
|
21
|
+
* IPurchaseOrderRFQItem ≡ IPurchaseOrderItem (same type).
|
|
22
|
+
* ================================================================= */
|
|
23
|
+
function calculateCartRfqOrderInfoAndSyncData(data, calculateItemMetadata) {
|
|
24
|
+
const isConfirmed = data.order_status === constants_1.PURCHASE_ORDER_RFQ_STATUS_ENUM.CONFIRMED;
|
|
25
|
+
let subtotal = 0;
|
|
26
|
+
const categories = [];
|
|
27
|
+
const length = data.categories?.length ?? 0;
|
|
28
|
+
for (let c = 0; c < length; c++) {
|
|
29
|
+
const category = data.categories[c];
|
|
30
|
+
const newItems = [];
|
|
31
|
+
const itemsLength = category.items.length;
|
|
32
|
+
for (let i = 0; i < itemsLength; i++) {
|
|
33
|
+
const item = category.items[i];
|
|
34
|
+
const itemSubtotal = (0, utils_1.parseNum)(item.price * item.quantity);
|
|
35
|
+
const newItem = {
|
|
36
|
+
...item,
|
|
37
|
+
is_ready: item.is_ready || isConfirmed,
|
|
38
|
+
subtotal: itemSubtotal,
|
|
39
|
+
_discount_amount: 0,
|
|
40
|
+
_gross_amount: 0,
|
|
41
|
+
_gst_amount: 0,
|
|
42
|
+
_net_amount: 0,
|
|
43
|
+
};
|
|
44
|
+
delete newItem.void_reason;
|
|
45
|
+
newItems.push(newItem);
|
|
46
|
+
subtotal += itemSubtotal;
|
|
47
|
+
}
|
|
48
|
+
categories.push({ ...category, items: newItems });
|
|
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
|
+
grand_total = (0, utils_1.parseNum)(grand_total);
|
|
61
|
+
const amount_earned = (0, utils_1.parseNum)(grand_total);
|
|
62
|
+
if (calculateItemMetadata) {
|
|
63
|
+
let leftGrossAmount = subtotal;
|
|
64
|
+
let leftNetAmount = subtotal;
|
|
65
|
+
let leftDiscountAmount = 0;
|
|
66
|
+
let leftGstAmount = gst_amount;
|
|
67
|
+
categories.forEach((category, categoryIndex) => {
|
|
68
|
+
const isLastCategory = categoryIndex === categories.length - 1;
|
|
69
|
+
category.items.forEach((item, itemIndex) => {
|
|
70
|
+
const isLastItem = isLastCategory && itemIndex === category.items.length - 1;
|
|
71
|
+
let grossAmount = item.subtotal;
|
|
72
|
+
let netAmount = item.subtotal;
|
|
73
|
+
let itemTotalDiscountAmount = 0;
|
|
74
|
+
let itemGst = 0;
|
|
75
|
+
if (gst_amount > 0) {
|
|
76
|
+
itemGst = (item.subtotal / subtotal) * gst_amount;
|
|
77
|
+
}
|
|
78
|
+
grossAmount = (0, utils_1.parseFloatCeil)(grossAmount);
|
|
79
|
+
const netAmountParsed = (0, utils_1.parseFloatCeil)(netAmount);
|
|
80
|
+
const itemTotalDiscountAmountParsed = (0, utils_1.parseFloatCeil)(itemTotalDiscountAmount);
|
|
81
|
+
itemGst = (0, utils_1.parseFloatCeil)(itemGst);
|
|
82
|
+
leftGrossAmount -= grossAmount;
|
|
83
|
+
leftNetAmount -= netAmountParsed;
|
|
84
|
+
leftDiscountAmount -= itemTotalDiscountAmountParsed;
|
|
85
|
+
leftGstAmount -= itemGst;
|
|
86
|
+
if (isLastItem) {
|
|
87
|
+
grossAmount += leftGrossAmount;
|
|
88
|
+
netAmount += leftNetAmount;
|
|
89
|
+
itemTotalDiscountAmount += leftDiscountAmount;
|
|
90
|
+
itemGst += leftGstAmount;
|
|
91
|
+
}
|
|
92
|
+
item._gross_amount = Math.max(grossAmount, 0);
|
|
93
|
+
item._net_amount = Math.max(netAmount, 0);
|
|
94
|
+
item._discount_amount = Math.max(itemTotalDiscountAmount, 0);
|
|
95
|
+
item._gst_amount = Math.max(itemGst, 0);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
...data,
|
|
101
|
+
categories,
|
|
102
|
+
amount_earned,
|
|
103
|
+
gst_amount,
|
|
104
|
+
price: (0, utils_1.parseNum)(subtotal),
|
|
105
|
+
grand_total,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// ── Shared ──
|
|
109
|
+
const getUpdatedRfqItem = (item) => ({
|
|
110
|
+
item_id: item.item_id,
|
|
111
|
+
name: item.name,
|
|
112
|
+
price: item.price,
|
|
113
|
+
special_instructions: item.special_instructions,
|
|
114
|
+
});
|
|
115
|
+
// ── Remove ──
|
|
116
|
+
function getRemoveItemFromRfqCartData(data, payload) {
|
|
117
|
+
const orderItemIdsMap = {};
|
|
118
|
+
let categories;
|
|
119
|
+
if (data.categories != null) {
|
|
120
|
+
categories = [];
|
|
121
|
+
for (let i = 0; i < data.categories.length; i++) {
|
|
122
|
+
const category = data.categories[i];
|
|
123
|
+
const items = [];
|
|
124
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
125
|
+
const item = category.items[j];
|
|
126
|
+
if (item._id !== payload._id) {
|
|
127
|
+
items.push(item);
|
|
128
|
+
orderItemIdsMap[item._id] = item.quantity;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (items.length > 0) {
|
|
132
|
+
categories.push({ ...category, items });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const iterations = [];
|
|
137
|
+
if (data.iterations != null && data.iterations.length > 0) {
|
|
138
|
+
const [firstIteration, ...restIterations] = data.iterations;
|
|
139
|
+
const firstIterationCategories = [];
|
|
140
|
+
for (let i = 0; i < firstIteration.categories.length; i++) {
|
|
141
|
+
const category = firstIteration.categories[i];
|
|
142
|
+
const allPrevItems = [];
|
|
143
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
144
|
+
const prevItem = category.items[j];
|
|
145
|
+
if (prevItem._id === payload._id && payload.void_reason != null) {
|
|
146
|
+
allPrevItems.push({ ...prevItem, void_reason: payload.void_reason });
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const currentItemQuantity = orderItemIdsMap[prevItem._id];
|
|
150
|
+
const isRemovedItem = !currentItemQuantity || currentItemQuantity < prevItem.quantity;
|
|
151
|
+
if (isRemovedItem) {
|
|
152
|
+
allPrevItems.push(prevItem);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
const updatedPrevItem = { ...prevItem };
|
|
156
|
+
delete updatedPrevItem.void_reason;
|
|
157
|
+
allPrevItems.push(updatedPrevItem);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (allPrevItems.length > 0) {
|
|
162
|
+
firstIterationCategories.push({ ...category, items: allPrevItems });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
iterations.push({ ...firstIteration, categories: firstIterationCategories }, ...restIterations);
|
|
166
|
+
}
|
|
167
|
+
return calculateCartRfqOrderInfoAndSyncData({
|
|
168
|
+
...data,
|
|
169
|
+
...(iterations.length > 0 && { iterations }),
|
|
170
|
+
categories,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
// ── Update Info ──
|
|
174
|
+
function getUpdateRfqCartInfoData(data, payload) {
|
|
175
|
+
return calculateCartRfqOrderInfoAndSyncData({ ...data, ...payload });
|
|
176
|
+
}
|
|
177
|
+
function getAddItemToRfqCartData(data, payload) {
|
|
178
|
+
const { category_id, name, item, replace_id } = payload;
|
|
179
|
+
let mainItemId = item._id;
|
|
180
|
+
const orderData = { ...data };
|
|
181
|
+
const categories = [...(orderData.categories ?? [])];
|
|
182
|
+
let didFindCategory = false;
|
|
183
|
+
for (let i = 0; i < categories.length; i++) {
|
|
184
|
+
const category = categories[i];
|
|
185
|
+
if (category.category_id !== category_id)
|
|
186
|
+
continue;
|
|
187
|
+
const updatedItem = getUpdatedRfqItem(item);
|
|
188
|
+
const allItems = [...category.items];
|
|
189
|
+
let didFindItem = false;
|
|
190
|
+
let itemExists = false;
|
|
191
|
+
for (let j = 0; j < allItems.length; j++) {
|
|
192
|
+
const itm = allItems[j];
|
|
193
|
+
if (itm._id === item._id) {
|
|
194
|
+
allItems[j] = item;
|
|
195
|
+
didFindItem = true;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
if (itm.item_id === item.item_id) {
|
|
199
|
+
itemExists = true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (!didFindItem && itemExists) {
|
|
203
|
+
for (let j = 0; j < allItems.length; j++) {
|
|
204
|
+
const itm = allItems[j];
|
|
205
|
+
if (itm.item_id === item.item_id && (0, lodash_1.isEqual)(getUpdatedRfqItem(itm), updatedItem)) {
|
|
206
|
+
mainItemId = replace_id ?? itm._id;
|
|
207
|
+
allItems[j] = {
|
|
208
|
+
...item,
|
|
209
|
+
_id: mainItemId,
|
|
210
|
+
quantity: item.quantity + itm.quantity,
|
|
211
|
+
};
|
|
212
|
+
didFindItem = true;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (!didFindItem) {
|
|
218
|
+
allItems.push(item);
|
|
219
|
+
}
|
|
220
|
+
categories[i] = { ...category, items: allItems };
|
|
221
|
+
didFindCategory = true;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
if (!didFindCategory) {
|
|
225
|
+
categories.push({ category_id, name, items: [item] });
|
|
226
|
+
}
|
|
227
|
+
const iterations = [];
|
|
228
|
+
if (orderData.iterations != null && orderData.iterations.length > 0) {
|
|
229
|
+
const orderItemIdsMap = {};
|
|
230
|
+
for (let i = 0; i < categories.length; i++) {
|
|
231
|
+
for (let j = 0; j < categories[i].items.length; j++) {
|
|
232
|
+
orderItemIdsMap[categories[i].items[j]._id] = categories[i].items[j].quantity;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const [firstIteration, ...restIterations] = orderData.iterations;
|
|
236
|
+
const firstIterationCategories = [];
|
|
237
|
+
for (let i = 0; i < firstIteration.categories.length; i++) {
|
|
238
|
+
const category = firstIteration.categories[i];
|
|
239
|
+
const allPrevItems = [];
|
|
240
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
241
|
+
const prevItem = category.items[j];
|
|
242
|
+
const currentItemQuantity = orderItemIdsMap[prevItem._id];
|
|
243
|
+
const isRemovedItem = !currentItemQuantity || currentItemQuantity < prevItem.quantity;
|
|
244
|
+
if (isRemovedItem) {
|
|
245
|
+
allPrevItems.push(prevItem);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
const updatedPrevItem = { ...prevItem };
|
|
249
|
+
delete updatedPrevItem.void_reason;
|
|
250
|
+
allPrevItems.push(updatedPrevItem);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (allPrevItems.length > 0) {
|
|
254
|
+
firstIterationCategories.push({ ...category, items: allPrevItems });
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
iterations.push({ ...firstIteration, categories: firstIterationCategories }, ...restIterations);
|
|
258
|
+
}
|
|
259
|
+
return calculateCartRfqOrderInfoAndSyncData({
|
|
260
|
+
...orderData,
|
|
261
|
+
...(iterations.length > 0 && { iterations }),
|
|
262
|
+
categories,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
// ── Update Item ──
|
|
266
|
+
function getUpdateItemInRfqCartData(data, payload) {
|
|
267
|
+
const orderItemIdsMap = {};
|
|
268
|
+
let categories;
|
|
269
|
+
if (data.categories != null) {
|
|
270
|
+
categories = [];
|
|
271
|
+
for (let i = 0; i < data.categories.length; i++) {
|
|
272
|
+
const category = data.categories[i];
|
|
273
|
+
const items = [];
|
|
274
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
275
|
+
const item = category.items[j];
|
|
276
|
+
let newItem = item;
|
|
277
|
+
if (item._id === payload._id) {
|
|
278
|
+
newItem = { ...item, ...payload };
|
|
279
|
+
}
|
|
280
|
+
if (newItem.quantity > 0) {
|
|
281
|
+
items.push(newItem);
|
|
282
|
+
orderItemIdsMap[newItem._id] = newItem.quantity;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (items.length > 0) {
|
|
286
|
+
categories.push({ ...category, items });
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
const iterations = [];
|
|
291
|
+
if (payload.quantity != null && data.iterations != null && data.iterations.length > 0) {
|
|
292
|
+
const [firstIteration, ...restIterations] = data.iterations;
|
|
293
|
+
const firstIterationCategories = [];
|
|
294
|
+
for (let i = 0; i < firstIteration.categories.length; i++) {
|
|
295
|
+
const category = firstIteration.categories[i];
|
|
296
|
+
const allPrevItems = [];
|
|
297
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
298
|
+
const prevItem = category.items[j];
|
|
299
|
+
if (prevItem._id === payload._id && payload.void_reason != null) {
|
|
300
|
+
allPrevItems.push({ ...prevItem, void_reason: payload.void_reason });
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
const currentItemQuantity = orderItemIdsMap[prevItem._id];
|
|
304
|
+
const isRemovedItem = !currentItemQuantity || currentItemQuantity < prevItem.quantity;
|
|
305
|
+
if (isRemovedItem) {
|
|
306
|
+
allPrevItems.push(prevItem);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
const updatedPrevItem = { ...prevItem };
|
|
310
|
+
delete updatedPrevItem.void_reason;
|
|
311
|
+
allPrevItems.push(updatedPrevItem);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (allPrevItems.length > 0) {
|
|
316
|
+
firstIterationCategories.push({ ...category, items: allPrevItems });
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
iterations.push({ ...firstIteration, categories: firstIterationCategories }, ...restIterations);
|
|
320
|
+
}
|
|
321
|
+
return calculateCartRfqOrderInfoAndSyncData({
|
|
322
|
+
...data,
|
|
323
|
+
...(iterations.length > 0 && { iterations }),
|
|
324
|
+
categories,
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
// ── Update Items (batch) ──
|
|
328
|
+
function getUpdateItemsInRfqCartData(data, payload) {
|
|
329
|
+
return payload.reduce((acc, item) => getUpdateItemInRfqCartData(acc, item), data);
|
|
330
|
+
}
|
|
331
|
+
// ── Split Item ──
|
|
332
|
+
function getSplitRfqCartItemToTwo(data, orderItemId) {
|
|
333
|
+
if (data.categories == null)
|
|
334
|
+
return data;
|
|
335
|
+
const newCategories = [];
|
|
336
|
+
for (let i = 0; i < data.categories.length; i++) {
|
|
337
|
+
const category = data.categories[i];
|
|
338
|
+
const newItems = [];
|
|
339
|
+
for (let j = 0; j < category.items.length; j++) {
|
|
340
|
+
const item = { ...category.items[j] };
|
|
341
|
+
if (item._id !== orderItemId) {
|
|
342
|
+
newItems.push(item);
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
if (item.quantity === 1) {
|
|
346
|
+
newItems.push(item);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
const newQuantity = item.quantity - 1;
|
|
350
|
+
newItems.push({
|
|
351
|
+
...item,
|
|
352
|
+
quantity: newQuantity,
|
|
353
|
+
subtotal: (0, utils_1.parseNum)(item.price * newQuantity),
|
|
354
|
+
});
|
|
355
|
+
const newId = new bson_objectid_1.default(Math.floor(new bson_objectid_1.default(item._id).getTimestamp().getTime() / 1000) + 1).toHexString();
|
|
356
|
+
newItems.push({
|
|
357
|
+
...item,
|
|
358
|
+
_id: newId,
|
|
359
|
+
quantity: 1,
|
|
360
|
+
subtotal: (0, utils_1.parseNum)(item.price * 1),
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
newCategories.push({ ...category, items: newItems });
|
|
364
|
+
}
|
|
365
|
+
return calculateCartRfqOrderInfoAndSyncData({
|
|
366
|
+
...data,
|
|
367
|
+
categories: newCategories,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
// ── Add Items (batch) ──
|
|
371
|
+
function getAddItemsToRfqCartData(data, payload) {
|
|
372
|
+
return payload.reduce((acc, item) => getAddItemToRfqCartData(acc, item), data);
|
|
373
|
+
}
|
|
@@ -100,6 +100,12 @@ function getKitchenInventoryWithDecimal(inventory) {
|
|
|
100
100
|
...(typeof inventory.variance_quantity === 'number'
|
|
101
101
|
? { variance_quantity: (0, price_conversion_1.convertIntToDecimal)(inventory.variance_quantity) }
|
|
102
102
|
: {}),
|
|
103
|
+
...(typeof inventory.transfer_quantity === 'number'
|
|
104
|
+
? { transfer_quantity: (0, price_conversion_1.convertIntToDecimal)(inventory.transfer_quantity) }
|
|
105
|
+
: {}),
|
|
106
|
+
...(typeof inventory.return_quantity === 'number'
|
|
107
|
+
? { return_quantity: (0, price_conversion_1.convertIntToDecimal)(inventory.return_quantity) }
|
|
108
|
+
: {}),
|
|
103
109
|
...(typeof inventory.new_stock_price === 'number'
|
|
104
110
|
? { new_stock_price: (0, price_conversion_1.convertIntToDecimal)(inventory.new_stock_price) }
|
|
105
111
|
: {}),
|
|
@@ -36,6 +36,15 @@ function getWarehouseInventoryWithDecimal(inventory) {
|
|
|
36
36
|
...(typeof inventory.variance_quantity === 'number'
|
|
37
37
|
? { variance_quantity: (0, price_conversion_1.convertIntToDecimal)(inventory.variance_quantity) }
|
|
38
38
|
: {}),
|
|
39
|
+
...(typeof inventory.transfer_quantity === 'number'
|
|
40
|
+
? { transfer_quantity: (0, price_conversion_1.convertIntToDecimal)(inventory.transfer_quantity) }
|
|
41
|
+
: {}),
|
|
42
|
+
...(typeof inventory.return_quantity === 'number'
|
|
43
|
+
? { return_quantity: (0, price_conversion_1.convertIntToDecimal)(inventory.return_quantity) }
|
|
44
|
+
: {}),
|
|
45
|
+
...(typeof inventory.sale_quantity === 'number'
|
|
46
|
+
? { sale_quantity: (0, price_conversion_1.convertIntToDecimal)(inventory.sale_quantity) }
|
|
47
|
+
: {}),
|
|
39
48
|
...(typeof inventory.unit_price === 'number' ? { unit_price: (0, price_conversion_1.convertIntToDecimal)(inventory.unit_price) } : {}),
|
|
40
49
|
...(typeof inventory.remaining_stock_price === 'number'
|
|
41
50
|
? { remaining_stock_price: (0, price_conversion_1.convertIntToDecimal)(inventory.remaining_stock_price) }
|
|
@@ -55,6 +55,9 @@ export interface IWarehouseInventory {
|
|
|
55
55
|
quantity_wasted: number;
|
|
56
56
|
quantity_short: number;
|
|
57
57
|
variance_quantity: number;
|
|
58
|
+
transfer_quantity: number;
|
|
59
|
+
return_quantity: number;
|
|
60
|
+
sale_quantity: number;
|
|
58
61
|
total_transactions: number;
|
|
59
62
|
new_stock_price: number;
|
|
60
63
|
}
|