@managesome/eposmatic-toolkit 0.2.452 → 0.2.453
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/index.d.ts +2 -0
- package/lib/helpers/store/index.js +2 -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_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/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,41 @@
|
|
|
1
|
+
export declare enum INTERNAL_USER_ROLES_ENUM {
|
|
2
|
+
SUPER_ADMIN = "SUPER_ADMIN",
|
|
3
|
+
HOD = "HOD",
|
|
4
|
+
SUPPORT_HEAD = "SUPPORT_HEAD",
|
|
5
|
+
SUPPORT_TEAM = "SUPPORT_TEAM",
|
|
6
|
+
SALES_HEAD = "SALES_HEAD",
|
|
7
|
+
SALES_TEAM = "SALES_TEAM",
|
|
8
|
+
MARKETING_HEAD = "MARKETING_HEAD",
|
|
9
|
+
MARKETING_TEAM = "MARKETING_TEAM",
|
|
10
|
+
HR_HEAD = "HR_HEAD",
|
|
11
|
+
HR_TEAM = "HR_TEAM",
|
|
12
|
+
DEVELOPER = "DEVELOPER",
|
|
13
|
+
FINANCE = "FINANCE",
|
|
14
|
+
VIEWER = "VIEWER"
|
|
15
|
+
}
|
|
16
|
+
export declare const ALL_INTERNAL_USER_ROLES: INTERNAL_USER_ROLES_ENUM[];
|
|
17
|
+
export declare enum INTERNAL_USER_PERMISSIONS_ENUM {
|
|
18
|
+
INTERNAL_VIEW_DASHBOARD = "INTERNAL_VIEW_DASHBOARD",
|
|
19
|
+
INTERNAL_VIEW_ANALYTICS = "INTERNAL_VIEW_ANALYTICS",
|
|
20
|
+
INTERNAL_VIEW_CUSTOMERS = "INTERNAL_VIEW_CUSTOMERS",
|
|
21
|
+
INTERNAL_VIEW_INVOICES = "INTERNAL_VIEW_INVOICES",
|
|
22
|
+
INTERNAL_VIEW_LEADS = "INTERNAL_VIEW_LEADS",
|
|
23
|
+
INTERNAL_VIEW_STAFF = "INTERNAL_VIEW_STAFF",
|
|
24
|
+
INTERNAL_VIEW_ROLES = "INTERNAL_VIEW_ROLES",
|
|
25
|
+
INTERNAL_VIEW_SETTINGS = "INTERNAL_VIEW_SETTINGS",
|
|
26
|
+
INTERNAL_CREATE_CUSTOMER = "INTERNAL_CREATE_CUSTOMER",
|
|
27
|
+
INTERNAL_CREATE_INVOICE = "INTERNAL_CREATE_INVOICE",
|
|
28
|
+
INTERNAL_CREATE_LEAD = "INTERNAL_CREATE_LEAD",
|
|
29
|
+
INTERNAL_CREATE_STAFF = "INTERNAL_CREATE_STAFF",
|
|
30
|
+
INTERNAL_UPDATE_CUSTOMER = "INTERNAL_UPDATE_CUSTOMER",
|
|
31
|
+
INTERNAL_UPDATE_INVOICE = "INTERNAL_UPDATE_INVOICE",
|
|
32
|
+
INTERNAL_UPDATE_LEAD = "INTERNAL_UPDATE_LEAD",
|
|
33
|
+
INTERNAL_UPDATE_STAFF = "INTERNAL_UPDATE_STAFF",
|
|
34
|
+
INTERNAL_UPDATE_ROLES = "INTERNAL_UPDATE_ROLES",
|
|
35
|
+
INTERNAL_UPDATE_SETTINGS = "INTERNAL_UPDATE_SETTINGS",
|
|
36
|
+
INTERNAL_DELETE_CUSTOMER = "INTERNAL_DELETE_CUSTOMER",
|
|
37
|
+
INTERNAL_DELETE_INVOICE = "INTERNAL_DELETE_INVOICE",
|
|
38
|
+
INTERNAL_DELETE_LEAD = "INTERNAL_DELETE_LEAD",
|
|
39
|
+
INTERNAL_DELETE_STAFF = "INTERNAL_DELETE_STAFF"
|
|
40
|
+
}
|
|
41
|
+
export declare const ALL_INTERNAL_USER_PERMISSIONS: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALL_INTERNAL_USER_PERMISSIONS = exports.INTERNAL_USER_PERMISSIONS_ENUM = exports.ALL_INTERNAL_USER_ROLES = exports.INTERNAL_USER_ROLES_ENUM = void 0;
|
|
4
|
+
// ======================>> <<====================== //
|
|
5
|
+
var INTERNAL_USER_ROLES_ENUM;
|
|
6
|
+
(function (INTERNAL_USER_ROLES_ENUM) {
|
|
7
|
+
INTERNAL_USER_ROLES_ENUM["SUPER_ADMIN"] = "SUPER_ADMIN";
|
|
8
|
+
INTERNAL_USER_ROLES_ENUM["HOD"] = "HOD";
|
|
9
|
+
INTERNAL_USER_ROLES_ENUM["SUPPORT_HEAD"] = "SUPPORT_HEAD";
|
|
10
|
+
INTERNAL_USER_ROLES_ENUM["SUPPORT_TEAM"] = "SUPPORT_TEAM";
|
|
11
|
+
INTERNAL_USER_ROLES_ENUM["SALES_HEAD"] = "SALES_HEAD";
|
|
12
|
+
INTERNAL_USER_ROLES_ENUM["SALES_TEAM"] = "SALES_TEAM";
|
|
13
|
+
INTERNAL_USER_ROLES_ENUM["MARKETING_HEAD"] = "MARKETING_HEAD";
|
|
14
|
+
INTERNAL_USER_ROLES_ENUM["MARKETING_TEAM"] = "MARKETING_TEAM";
|
|
15
|
+
INTERNAL_USER_ROLES_ENUM["HR_HEAD"] = "HR_HEAD";
|
|
16
|
+
INTERNAL_USER_ROLES_ENUM["HR_TEAM"] = "HR_TEAM";
|
|
17
|
+
INTERNAL_USER_ROLES_ENUM["DEVELOPER"] = "DEVELOPER";
|
|
18
|
+
INTERNAL_USER_ROLES_ENUM["FINANCE"] = "FINANCE";
|
|
19
|
+
INTERNAL_USER_ROLES_ENUM["VIEWER"] = "VIEWER";
|
|
20
|
+
})(INTERNAL_USER_ROLES_ENUM || (exports.INTERNAL_USER_ROLES_ENUM = INTERNAL_USER_ROLES_ENUM = {}));
|
|
21
|
+
exports.ALL_INTERNAL_USER_ROLES = Object.values(INTERNAL_USER_ROLES_ENUM);
|
|
22
|
+
// ======================>> <<====================== //
|
|
23
|
+
var INTERNAL_USER_PERMISSIONS_ENUM;
|
|
24
|
+
(function (INTERNAL_USER_PERMISSIONS_ENUM) {
|
|
25
|
+
/* =================>VIEW OPERATIONS<================= */
|
|
26
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_VIEW_DASHBOARD"] = "INTERNAL_VIEW_DASHBOARD";
|
|
27
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_VIEW_ANALYTICS"] = "INTERNAL_VIEW_ANALYTICS";
|
|
28
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_VIEW_CUSTOMERS"] = "INTERNAL_VIEW_CUSTOMERS";
|
|
29
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_VIEW_INVOICES"] = "INTERNAL_VIEW_INVOICES";
|
|
30
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_VIEW_LEADS"] = "INTERNAL_VIEW_LEADS";
|
|
31
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_VIEW_STAFF"] = "INTERNAL_VIEW_STAFF";
|
|
32
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_VIEW_ROLES"] = "INTERNAL_VIEW_ROLES";
|
|
33
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_VIEW_SETTINGS"] = "INTERNAL_VIEW_SETTINGS";
|
|
34
|
+
/* =================>CREATE OPERATIONS<================= */
|
|
35
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_CREATE_CUSTOMER"] = "INTERNAL_CREATE_CUSTOMER";
|
|
36
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_CREATE_INVOICE"] = "INTERNAL_CREATE_INVOICE";
|
|
37
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_CREATE_LEAD"] = "INTERNAL_CREATE_LEAD";
|
|
38
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_CREATE_STAFF"] = "INTERNAL_CREATE_STAFF";
|
|
39
|
+
/* =================>UPDATE OPERATIONS<================= */
|
|
40
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_UPDATE_CUSTOMER"] = "INTERNAL_UPDATE_CUSTOMER";
|
|
41
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_UPDATE_INVOICE"] = "INTERNAL_UPDATE_INVOICE";
|
|
42
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_UPDATE_LEAD"] = "INTERNAL_UPDATE_LEAD";
|
|
43
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_UPDATE_STAFF"] = "INTERNAL_UPDATE_STAFF";
|
|
44
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_UPDATE_ROLES"] = "INTERNAL_UPDATE_ROLES";
|
|
45
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_UPDATE_SETTINGS"] = "INTERNAL_UPDATE_SETTINGS";
|
|
46
|
+
/* =================>DELETE OPERATIONS<================= */
|
|
47
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_DELETE_CUSTOMER"] = "INTERNAL_DELETE_CUSTOMER";
|
|
48
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_DELETE_INVOICE"] = "INTERNAL_DELETE_INVOICE";
|
|
49
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_DELETE_LEAD"] = "INTERNAL_DELETE_LEAD";
|
|
50
|
+
INTERNAL_USER_PERMISSIONS_ENUM["INTERNAL_DELETE_STAFF"] = "INTERNAL_DELETE_STAFF";
|
|
51
|
+
})(INTERNAL_USER_PERMISSIONS_ENUM || (exports.INTERNAL_USER_PERMISSIONS_ENUM = INTERNAL_USER_PERMISSIONS_ENUM = {}));
|
|
52
|
+
exports.ALL_INTERNAL_USER_PERMISSIONS = Object.values(INTERNAL_USER_PERMISSIONS_ENUM);
|
|
@@ -41,6 +41,7 @@ export declare const WORKER_ENDPOINTS: {
|
|
|
41
41
|
readonly UPDATE_TENANT_INVENTORY_ON_OFFLINE_SYNC: "/update-tenant-inventory-on-offline-sync";
|
|
42
42
|
readonly UPDATE_TENANT_INVENTORY_ON_SPLIT_ORDER: "/update-tenant-inventory-on-split-order";
|
|
43
43
|
readonly UPDATE_TENANT_INVENTORY_ON_REVERT_SPLIT_ORDER: "/update-tenant-inventory-on-revert-split-order";
|
|
44
|
+
readonly UPDATE_TENANT_INVENTORY_ON_PURCHASE_ORDER_RECEIVE: "/update-tenant-inventory-on-purchase-order-receive";
|
|
44
45
|
readonly UPDATE_WAREHOUSE_INVENTORY_ON_COMPLETE_PURCHASE_ORDER: "/update-warehouse-inventory-on-complete-purchase-order";
|
|
45
46
|
readonly UPDATE_WAREHOUSE_INVENTORY_ON_CREATE_INVOICE: "/update-warehouse-inventory-on-create-invoice";
|
|
46
47
|
readonly UPDATE_WAREHOUSE_INVENTORY_ON_UPDATE_INVOICE: "/update-warehouse-inventory-on-update-invoice";
|
|
@@ -52,6 +52,7 @@ exports.WORKER_ENDPOINTS = {
|
|
|
52
52
|
UPDATE_TENANT_INVENTORY_ON_OFFLINE_SYNC: '/update-tenant-inventory-on-offline-sync',
|
|
53
53
|
UPDATE_TENANT_INVENTORY_ON_SPLIT_ORDER: '/update-tenant-inventory-on-split-order',
|
|
54
54
|
UPDATE_TENANT_INVENTORY_ON_REVERT_SPLIT_ORDER: '/update-tenant-inventory-on-revert-split-order',
|
|
55
|
+
UPDATE_TENANT_INVENTORY_ON_PURCHASE_ORDER_RECEIVE: '/update-tenant-inventory-on-purchase-order-receive',
|
|
55
56
|
// ========================>> Warehouse Inventory <<======================= //
|
|
56
57
|
UPDATE_WAREHOUSE_INVENTORY_ON_COMPLETE_PURCHASE_ORDER: '/update-warehouse-inventory-on-complete-purchase-order',
|
|
57
58
|
UPDATE_WAREHOUSE_INVENTORY_ON_CREATE_INVOICE: '/update-warehouse-inventory-on-create-invoice',
|
package/lib/constants/index.d.ts
CHANGED
package/lib/constants/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./DELIVERY"), exports);
|
|
|
20
20
|
__exportStar(require("./ENUMS"), exports);
|
|
21
21
|
__exportStar(require("./FBR_ENUMS"), exports);
|
|
22
22
|
__exportStar(require("./HUBRISE_ENUMS"), exports);
|
|
23
|
+
__exportStar(require("./INTERNAL_ENUMS"), exports);
|
|
23
24
|
__exportStar(require("./NOTIFICATIONS"), exports);
|
|
24
25
|
__exportStar(require("./ORDER"), exports);
|
|
25
26
|
__exportStar(require("./PRA_ENUMS"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IOrderPayment, ITenantPurchaseOrder, ITenantPurchaseOrderCategory, ITenantPurchaseOrderItem, ITenantPurchaseOrderIteration } from '../../schemas';
|
|
2
|
+
export declare function getTenantPurchaseOrderIterationsWithPrice(iterations?: ITenantPurchaseOrderIteration[] | undefined, writeable?: boolean): ITenantPurchaseOrderIteration[];
|
|
3
|
+
export declare function getTenantPurchaseOrderPaymentsWithPrice(payments: IOrderPayment[] | undefined, convertToPrice: (price: number) => number): IOrderPayment[];
|
|
4
|
+
export declare function getTenantPurchaseOrderItemsWithPrice(items: ITenantPurchaseOrderItem[] | undefined, convertToPrice: (price: number) => number): ITenantPurchaseOrderItem[];
|
|
5
|
+
export declare function getTenantPurchaseOrderCategoriesWithPrice(categories: ITenantPurchaseOrderCategory[] | undefined, convertToPrice: (price: number) => number): ITenantPurchaseOrderCategory[];
|
|
6
|
+
export declare function getTenantPurchaseOrderWithPrice<T extends Partial<ITenantPurchaseOrder> | ITenantPurchaseOrder | ITenantPurchaseOrderIteration>(order: T, writeable?: boolean): T;
|
|
7
|
+
export declare function syncTenantPurchaseOrderData(order: ITenantPurchaseOrder): ITenantPurchaseOrder;
|
|
8
|
+
export declare function skipItemMetadataFromTenantPurchaseOrderCategories(categories: ITenantPurchaseOrder['categories'], previousCategories?: ITenantPurchaseOrder['categories']): ITenantPurchaseOrder['categories'];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTenantPurchaseOrderIterationsWithPrice = getTenantPurchaseOrderIterationsWithPrice;
|
|
4
|
+
exports.getTenantPurchaseOrderPaymentsWithPrice = getTenantPurchaseOrderPaymentsWithPrice;
|
|
5
|
+
exports.getTenantPurchaseOrderItemsWithPrice = getTenantPurchaseOrderItemsWithPrice;
|
|
6
|
+
exports.getTenantPurchaseOrderCategoriesWithPrice = getTenantPurchaseOrderCategoriesWithPrice;
|
|
7
|
+
exports.getTenantPurchaseOrderWithPrice = getTenantPurchaseOrderWithPrice;
|
|
8
|
+
exports.syncTenantPurchaseOrderData = syncTenantPurchaseOrderData;
|
|
9
|
+
exports.skipItemMetadataFromTenantPurchaseOrderCategories = skipItemMetadataFromTenantPurchaseOrderCategories;
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const common_order_actions_1 = require("./common-order-actions");
|
|
12
|
+
const tenant_purchase_orders_cart_actions_1 = require("./tenant-purchase-orders-cart-actions");
|
|
13
|
+
function getTenantPurchaseOrderIterationsWithPrice(iterations, writeable) {
|
|
14
|
+
if (!iterations)
|
|
15
|
+
return [];
|
|
16
|
+
return iterations.map((iteration) => getTenantPurchaseOrderWithPrice(iteration, writeable));
|
|
17
|
+
}
|
|
18
|
+
function getTenantPurchaseOrderPaymentsWithPrice(payments, convertToPrice) {
|
|
19
|
+
if (!payments)
|
|
20
|
+
return [];
|
|
21
|
+
return payments.map((payment) => ({
|
|
22
|
+
...payment,
|
|
23
|
+
card_details: (0, common_order_actions_1.getOrderPaymentsCardDetailsWithPrice)(payment.card_details, convertToPrice),
|
|
24
|
+
amount_paid: convertToPrice(payment.amount_paid),
|
|
25
|
+
amount_due: convertToPrice(payment.amount_due),
|
|
26
|
+
amount_refunded: convertToPrice(payment.amount_refunded),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
function getTenantPurchaseOrderItemsWithPrice(items, convertToPrice) {
|
|
30
|
+
if (!items)
|
|
31
|
+
return [];
|
|
32
|
+
return items.map((item) => ({
|
|
33
|
+
...item,
|
|
34
|
+
quantity: (0, utils_1.parseNum)(item.quantity || 1, true),
|
|
35
|
+
price: convertToPrice(item.price ?? 0),
|
|
36
|
+
subtotal: convertToPrice(item.subtotal ?? 0),
|
|
37
|
+
_gst_amount: convertToPrice(item._gst_amount ?? 0),
|
|
38
|
+
_net_amount: convertToPrice(item._net_amount ?? 0),
|
|
39
|
+
_gross_amount: convertToPrice(item._gross_amount ?? 0),
|
|
40
|
+
_discount_amount: convertToPrice(item._discount_amount ?? 0),
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
function getTenantPurchaseOrderCategoriesWithPrice(categories, convertToPrice) {
|
|
44
|
+
if (!categories)
|
|
45
|
+
return [];
|
|
46
|
+
return categories.map((category) => ({
|
|
47
|
+
...category,
|
|
48
|
+
items: getTenantPurchaseOrderItemsWithPrice(category.items, convertToPrice),
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
function getTenantPurchaseOrderWithPrice(order, writeable) {
|
|
52
|
+
const convertToPrice = writeable ? utils_1.convertDecimalToInt : utils_1.convertIntToDecimal;
|
|
53
|
+
const payload = {
|
|
54
|
+
...order,
|
|
55
|
+
...(order.iterations != null
|
|
56
|
+
? {
|
|
57
|
+
iterations: getTenantPurchaseOrderIterationsWithPrice(order.iterations, writeable),
|
|
58
|
+
}
|
|
59
|
+
: {}),
|
|
60
|
+
...(order.categories != null
|
|
61
|
+
? {
|
|
62
|
+
categories: getTenantPurchaseOrderCategoriesWithPrice(order.categories, convertToPrice),
|
|
63
|
+
}
|
|
64
|
+
: {}),
|
|
65
|
+
...(order.payments != null
|
|
66
|
+
? { payments: getTenantPurchaseOrderPaymentsWithPrice(order.payments, convertToPrice) }
|
|
67
|
+
: {}),
|
|
68
|
+
...(order.gst != null ? { gst: convertToPrice(order.gst) } : {}),
|
|
69
|
+
...(order.gst_amount != null ? { gst_amount: convertToPrice(order.gst_amount) } : {}),
|
|
70
|
+
...(order.amount_collected != null
|
|
71
|
+
? { amount_collected: convertToPrice(order.amount_collected) }
|
|
72
|
+
: {}),
|
|
73
|
+
...(order.amount_earned != null ? { amount_earned: convertToPrice(order.amount_earned) } : {}),
|
|
74
|
+
...(order.grand_total != null ? { grand_total: convertToPrice(order.grand_total) } : {}),
|
|
75
|
+
...(order.price != null ? { price: convertToPrice(order.price) } : {}),
|
|
76
|
+
};
|
|
77
|
+
return payload;
|
|
78
|
+
}
|
|
79
|
+
function syncTenantPurchaseOrderData(order) {
|
|
80
|
+
const updatedOrder = {
|
|
81
|
+
...order,
|
|
82
|
+
iterations: [],
|
|
83
|
+
};
|
|
84
|
+
const newOrder = getTenantPurchaseOrderWithPrice((0, tenant_purchase_orders_cart_actions_1.calculateCartTenantPurchaseOrderInfoAndSyncData)(getTenantPurchaseOrderWithPrice(updatedOrder, true), true), true);
|
|
85
|
+
newOrder.iterations = order.iterations;
|
|
86
|
+
return newOrder;
|
|
87
|
+
}
|
|
88
|
+
function skipItemMetadataFromTenantPurchaseOrderCategories(categories, previousCategories) {
|
|
89
|
+
return categories.map((category) => {
|
|
90
|
+
const previousCategory = previousCategories?.find((prevCategory) => prevCategory.category_id === category.category_id);
|
|
91
|
+
return {
|
|
92
|
+
...category,
|
|
93
|
+
items: category.items.map((item) => {
|
|
94
|
+
const previousItem = previousCategory?.items.find((prevItem) => prevItem._id === item._id);
|
|
95
|
+
const void_reason = previousItem?.void_reason ?? item.void_reason;
|
|
96
|
+
return {
|
|
97
|
+
...item,
|
|
98
|
+
void_reason,
|
|
99
|
+
_discount_amount: 0,
|
|
100
|
+
_gst_amount: 0,
|
|
101
|
+
_gross_amount: 0,
|
|
102
|
+
_net_amount: 0,
|
|
103
|
+
};
|
|
104
|
+
}),
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
}
|
|
@@ -7,6 +7,7 @@ export * from './all-warehouse-sale-order-rfqs-actions';
|
|
|
7
7
|
export * from './cart-actions';
|
|
8
8
|
export * from './catalog-actions';
|
|
9
9
|
export * from './common-order-actions';
|
|
10
|
+
export * from './common-tenant-purchase-order-actions';
|
|
10
11
|
export * from './common-warehouse-invoice-actions';
|
|
11
12
|
export * from './common-warehouse-purchase-order-actions';
|
|
12
13
|
export * from './common-warehouse-purchase-order-rfq-actions';
|
|
@@ -14,6 +15,7 @@ export * from './common-warehouse-purchase-order-vendor-return-actions';
|
|
|
14
15
|
export * from './common-warehouse-sale-order-actions';
|
|
15
16
|
export * from './common-warehouse-sale-order-rfq-actions';
|
|
16
17
|
export * from './offline-ordering';
|
|
18
|
+
export * from './tenant-purchase-orders-cart-actions';
|
|
17
19
|
export * from './warehouse-invoice-cart-actions';
|
|
18
20
|
export * from './warehouse-purchase-order-rfq-cart-actions';
|
|
19
21
|
export * from './warehouse-purchase-orders-cart-actions';
|
|
@@ -23,6 +23,7 @@ __exportStar(require("./all-warehouse-sale-order-rfqs-actions"), exports);
|
|
|
23
23
|
__exportStar(require("./cart-actions"), exports);
|
|
24
24
|
__exportStar(require("./catalog-actions"), exports);
|
|
25
25
|
__exportStar(require("./common-order-actions"), exports);
|
|
26
|
+
__exportStar(require("./common-tenant-purchase-order-actions"), exports);
|
|
26
27
|
__exportStar(require("./common-warehouse-invoice-actions"), exports);
|
|
27
28
|
__exportStar(require("./common-warehouse-purchase-order-actions"), exports);
|
|
28
29
|
__exportStar(require("./common-warehouse-purchase-order-rfq-actions"), exports);
|
|
@@ -30,6 +31,7 @@ __exportStar(require("./common-warehouse-purchase-order-vendor-return-actions"),
|
|
|
30
31
|
__exportStar(require("./common-warehouse-sale-order-actions"), exports);
|
|
31
32
|
__exportStar(require("./common-warehouse-sale-order-rfq-actions"), exports);
|
|
32
33
|
__exportStar(require("./offline-ordering"), exports);
|
|
34
|
+
__exportStar(require("./tenant-purchase-orders-cart-actions"), exports);
|
|
33
35
|
__exportStar(require("./warehouse-invoice-cart-actions"), exports);
|
|
34
36
|
__exportStar(require("./warehouse-purchase-order-rfq-cart-actions"), exports);
|
|
35
37
|
__exportStar(require("./warehouse-purchase-orders-cart-actions"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ITenantPurchaseOrder, ITenantPurchaseOrderItem } from '../../schemas';
|
|
2
|
+
export declare function calculateCartTenantPurchaseOrderInfoAndSyncData<T extends ITenantPurchaseOrder | Partial<ITenantPurchaseOrder>>(data: T, calculateItemMetadata?: boolean): T;
|
|
3
|
+
export declare const getTenantPurchaseOrderItemComparableData: (item: ITenantPurchaseOrderItem) => Partial<ITenantPurchaseOrderItem>;
|
|
4
|
+
export declare function getUpdatedTenantPurchaseOrderCartInfoOnInit(data: Partial<ITenantPurchaseOrder>, order: Partial<ITenantPurchaseOrder>): Partial<ITenantPurchaseOrder>;
|
|
5
|
+
export declare function getRemoveItemFromTenantPurchaseOrderCartData(data: Partial<ITenantPurchaseOrder>, payload: {
|
|
6
|
+
_id: string;
|
|
7
|
+
void_reason?: string;
|
|
8
|
+
}): Partial<ITenantPurchaseOrder>;
|
|
9
|
+
export declare function getUpdateTenantPurchaseOrderCartInfoData(data: Partial<ITenantPurchaseOrder>, payload: Partial<ITenantPurchaseOrder>): Partial<ITenantPurchaseOrder>;
|
|
10
|
+
export interface ISetAddItemToTenantPurchaseOrderCartActionPayload {
|
|
11
|
+
name: string;
|
|
12
|
+
category_id: string;
|
|
13
|
+
item: ITenantPurchaseOrderItem;
|
|
14
|
+
replace_id?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function getAddItemToTenantPurchaseOrderCartData(data: Partial<ITenantPurchaseOrder>, payload: ISetAddItemToTenantPurchaseOrderCartActionPayload): Partial<ITenantPurchaseOrder>;
|
|
17
|
+
export declare function getUpdateItemInTenantPurchaseOrderCartData(data: Partial<ITenantPurchaseOrder>, payload: Partial<ITenantPurchaseOrderItem>): Partial<ITenantPurchaseOrder>;
|
|
18
|
+
export declare function getUpdateItemsInTenantPurchaseOrderCartData(data: Partial<ITenantPurchaseOrder>, payload: Partial<ITenantPurchaseOrderItem>[]): Partial<ITenantPurchaseOrder>;
|
|
19
|
+
export interface IGetSplitTenantPurchaseOrderCartItemToTwo {
|
|
20
|
+
data: Partial<ITenantPurchaseOrder>;
|
|
21
|
+
orderItemId: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function getSplitTenantPurchaseOrderCartItemToTwo({ data, orderItemId, }: IGetSplitTenantPurchaseOrderCartItemToTwo): Partial<ITenantPurchaseOrder>;
|
|
24
|
+
export declare function getAddItemsToTenantPurchaseOrderCartData(data: Partial<ITenantPurchaseOrder>, payload: ISetAddItemToTenantPurchaseOrderCartActionPayload[]): Partial<ITenantPurchaseOrder>;
|
|
@@ -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);
|
|
@@ -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';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Schema } from 'mongoose';
|
|
2
|
+
export declare const InternalStaffSchema: 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
|
+
image_url: string;
|
|
14
|
+
phone_number: string;
|
|
15
|
+
uid: string;
|
|
16
|
+
display_name: string;
|
|
17
|
+
email: string;
|
|
18
|
+
email_verified: boolean;
|
|
19
|
+
phone_number_verified: boolean;
|
|
20
|
+
is_disabled: boolean;
|
|
21
|
+
role: import("../../constants").INTERNAL_USER_ROLES_ENUM;
|
|
22
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
23
|
+
createdAt: NativeDate;
|
|
24
|
+
updatedAt: NativeDate;
|
|
25
|
+
} & {
|
|
26
|
+
_id: import("mongoose").Types.ObjectId;
|
|
27
|
+
createdAt: NativeDate;
|
|
28
|
+
updatedAt: NativeDate;
|
|
29
|
+
image_url: string;
|
|
30
|
+
phone_number: string;
|
|
31
|
+
uid: string;
|
|
32
|
+
display_name: string;
|
|
33
|
+
email: string;
|
|
34
|
+
email_verified: boolean;
|
|
35
|
+
phone_number_verified: boolean;
|
|
36
|
+
is_disabled: boolean;
|
|
37
|
+
role: import("../../constants").INTERNAL_USER_ROLES_ENUM;
|
|
38
|
+
}>> & import("mongoose").FlatRecord<{
|
|
39
|
+
createdAt: NativeDate;
|
|
40
|
+
updatedAt: NativeDate;
|
|
41
|
+
} & {
|
|
42
|
+
_id: import("mongoose").Types.ObjectId;
|
|
43
|
+
createdAt: NativeDate;
|
|
44
|
+
updatedAt: NativeDate;
|
|
45
|
+
image_url: string;
|
|
46
|
+
phone_number: string;
|
|
47
|
+
uid: string;
|
|
48
|
+
display_name: string;
|
|
49
|
+
email: string;
|
|
50
|
+
email_verified: boolean;
|
|
51
|
+
phone_number_verified: boolean;
|
|
52
|
+
is_disabled: boolean;
|
|
53
|
+
role: import("../../constants").INTERNAL_USER_ROLES_ENUM;
|
|
54
|
+
}> & Required<{
|
|
55
|
+
_id: import("mongoose").Types.ObjectId;
|
|
56
|
+
}> & {
|
|
57
|
+
__v: number;
|
|
58
|
+
}>;
|
|
59
|
+
export declare const INTERNAL_STAFF_COLLECTION_NAME = "internal_staffs";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INTERNAL_STAFF_COLLECTION_NAME = exports.InternalStaffSchema = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
exports.InternalStaffSchema = new mongoose_1.Schema({
|
|
7
|
+
_id: {
|
|
8
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
9
|
+
required: true,
|
|
10
|
+
immutable: true,
|
|
11
|
+
},
|
|
12
|
+
uid: {
|
|
13
|
+
type: String,
|
|
14
|
+
required: true,
|
|
15
|
+
immutable: true,
|
|
16
|
+
},
|
|
17
|
+
phone_number: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true,
|
|
20
|
+
minlength: 10,
|
|
21
|
+
immutable: true,
|
|
22
|
+
},
|
|
23
|
+
email: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: null,
|
|
26
|
+
},
|
|
27
|
+
email_verified: {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
default: false,
|
|
30
|
+
},
|
|
31
|
+
display_name: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: null,
|
|
34
|
+
},
|
|
35
|
+
image_url: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: null,
|
|
38
|
+
},
|
|
39
|
+
is_disabled: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false,
|
|
42
|
+
},
|
|
43
|
+
phone_number_verified: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: false,
|
|
46
|
+
},
|
|
47
|
+
role: {
|
|
48
|
+
type: String,
|
|
49
|
+
required: true,
|
|
50
|
+
enum: constants_1.ALL_INTERNAL_USER_ROLES,
|
|
51
|
+
},
|
|
52
|
+
createdAt: {
|
|
53
|
+
type: Date,
|
|
54
|
+
required: true,
|
|
55
|
+
immutable: true,
|
|
56
|
+
default: () => new Date(),
|
|
57
|
+
},
|
|
58
|
+
updatedAt: {
|
|
59
|
+
type: Date,
|
|
60
|
+
required: true,
|
|
61
|
+
default: () => new Date(),
|
|
62
|
+
},
|
|
63
|
+
}, {
|
|
64
|
+
timestamps: true,
|
|
65
|
+
versionKey: false,
|
|
66
|
+
minimize: false,
|
|
67
|
+
});
|
|
68
|
+
exports.INTERNAL_STAFF_COLLECTION_NAME = 'internal_staffs';
|
|
@@ -27,6 +27,8 @@ export * from './instore_shifts';
|
|
|
27
27
|
export * from './internal_customers';
|
|
28
28
|
export * from './internal_invoices';
|
|
29
29
|
export * from './internal_leads';
|
|
30
|
+
export * from './internal_operational_roles';
|
|
31
|
+
export * from './internal_staffs';
|
|
30
32
|
export * from './inventories';
|
|
31
33
|
export * from './inventory_categories';
|
|
32
34
|
export * from './inventory_transactions';
|
|
@@ -43,6 +43,8 @@ __exportStar(require("./instore_shifts"), exports);
|
|
|
43
43
|
__exportStar(require("./internal_customers"), exports);
|
|
44
44
|
__exportStar(require("./internal_invoices"), exports);
|
|
45
45
|
__exportStar(require("./internal_leads"), exports);
|
|
46
|
+
__exportStar(require("./internal_operational_roles"), exports);
|
|
47
|
+
__exportStar(require("./internal_staffs"), exports);
|
|
46
48
|
__exportStar(require("./inventories"), exports);
|
|
47
49
|
__exportStar(require("./inventory_categories"), exports);
|
|
48
50
|
__exportStar(require("./inventory_transactions"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { INTERNAL_USER_PERMISSIONS_ENUM, INTERNAL_USER_ROLES_ENUM } from '../../constants';
|
|
2
|
+
export interface IInternalOperationalRoles {
|
|
3
|
+
_id: string;
|
|
4
|
+
roles: {
|
|
5
|
+
[INTERNAL_USER_ROLES_ENUM.SUPER_ADMIN]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
6
|
+
[INTERNAL_USER_ROLES_ENUM.HOD]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
7
|
+
[INTERNAL_USER_ROLES_ENUM.SUPPORT_HEAD]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
8
|
+
[INTERNAL_USER_ROLES_ENUM.SUPPORT_TEAM]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
9
|
+
[INTERNAL_USER_ROLES_ENUM.SALES_HEAD]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
10
|
+
[INTERNAL_USER_ROLES_ENUM.SALES_TEAM]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
11
|
+
[INTERNAL_USER_ROLES_ENUM.MARKETING_HEAD]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
12
|
+
[INTERNAL_USER_ROLES_ENUM.MARKETING_TEAM]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
13
|
+
[INTERNAL_USER_ROLES_ENUM.HR_HEAD]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
14
|
+
[INTERNAL_USER_ROLES_ENUM.HR_TEAM]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
15
|
+
[INTERNAL_USER_ROLES_ENUM.DEVELOPER]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
16
|
+
[INTERNAL_USER_ROLES_ENUM.FINANCE]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
17
|
+
[INTERNAL_USER_ROLES_ENUM.VIEWER]: INTERNAL_USER_PERMISSIONS_ENUM[];
|
|
18
|
+
};
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
updatedAt: Date;
|
|
21
|
+
}
|
|
22
|
+
export declare const DefaultInternalOperationalRoles: IInternalOperationalRoles['roles'];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultInternalOperationalRoles = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
exports.DefaultInternalOperationalRoles = {
|
|
6
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.SUPER_ADMIN]: constants_1.ALL_INTERNAL_USER_PERMISSIONS,
|
|
7
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.HOD]: [],
|
|
8
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.SUPPORT_HEAD]: [],
|
|
9
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.SUPPORT_TEAM]: [],
|
|
10
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.SALES_HEAD]: [],
|
|
11
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.SALES_TEAM]: [],
|
|
12
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.MARKETING_HEAD]: [],
|
|
13
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.MARKETING_TEAM]: [],
|
|
14
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.HR_HEAD]: [],
|
|
15
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.HR_TEAM]: [],
|
|
16
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.DEVELOPER]: [],
|
|
17
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.FINANCE]: [],
|
|
18
|
+
[constants_1.INTERNAL_USER_ROLES_ENUM.VIEWER]: [],
|
|
19
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { INTERNAL_USER_ROLES_ENUM } from '../../constants';
|
|
2
|
+
export interface IInternalStaff {
|
|
3
|
+
_id: string;
|
|
4
|
+
uid: string;
|
|
5
|
+
email: string | null;
|
|
6
|
+
email_verified: boolean;
|
|
7
|
+
display_name: string | null;
|
|
8
|
+
image_url: string | null;
|
|
9
|
+
phone_number: string;
|
|
10
|
+
phone_number_verified: boolean;
|
|
11
|
+
role: INTERNAL_USER_ROLES_ENUM;
|
|
12
|
+
is_disabled: boolean;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
}
|