@managesome/eposmatic-toolkit 0.2.452 → 0.2.454

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/lib/constants/INTERNAL_ENUMS.d.ts +41 -0
  2. package/lib/constants/INTERNAL_ENUMS.js +52 -0
  3. package/lib/constants/WORKER_ENDPOINTS.d.ts +1 -0
  4. package/lib/constants/WORKER_ENDPOINTS.js +1 -0
  5. package/lib/constants/index.d.ts +1 -0
  6. package/lib/constants/index.js +1 -0
  7. package/lib/helpers/store/common-tenant-purchase-order-actions.d.ts +8 -0
  8. package/lib/helpers/store/common-tenant-purchase-order-actions.js +107 -0
  9. package/lib/helpers/store/common-warehouse-sale-order-invoice-actions.d.ts +16 -0
  10. package/lib/helpers/store/common-warehouse-sale-order-invoice-actions.js +59 -0
  11. package/lib/helpers/store/index.d.ts +3 -0
  12. package/lib/helpers/store/index.js +3 -0
  13. package/lib/helpers/store/tenant-purchase-orders-cart-actions.d.ts +24 -0
  14. package/lib/helpers/store/tenant-purchase-orders-cart-actions.js +395 -0
  15. package/lib/helpers/types/workers.d.ts +5 -1
  16. package/lib/schemas/models/index.d.ts +2 -0
  17. package/lib/schemas/models/index.js +2 -0
  18. package/lib/schemas/models/internal_invoices.d.ts +3 -3
  19. package/lib/schemas/models/internal_operational_roles.d.ts +77 -0
  20. package/lib/schemas/models/internal_operational_roles.js +88 -0
  21. package/lib/schemas/models/internal_staffs.d.ts +59 -0
  22. package/lib/schemas/models/internal_staffs.js +68 -0
  23. package/lib/schemas/models/warehouse_internal_movements.d.ts +3 -3
  24. package/lib/schemas/models/warehouse_sale_deliveries.d.ts +3 -3
  25. package/lib/schemas/models/warehouse_sale_invoices.d.ts +6 -6
  26. package/lib/schemas/types/index.d.ts +2 -0
  27. package/lib/schemas/types/index.js +2 -0
  28. package/lib/schemas/types/internal_operational_roles.d.ts +22 -0
  29. package/lib/schemas/types/internal_operational_roles.js +19 -0
  30. package/lib/schemas/types/internal_staffs.d.ts +15 -0
  31. package/lib/schemas/types/internal_staffs.js +2 -0
  32. 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',
@@ -4,6 +4,7 @@ export * from './DELIVERY';
4
4
  export * from './ENUMS';
5
5
  export * from './FBR_ENUMS';
6
6
  export * from './HUBRISE_ENUMS';
7
+ export * from './INTERNAL_ENUMS';
7
8
  export * from './NOTIFICATIONS';
8
9
  export * from './ORDER';
9
10
  export * from './PRA_ENUMS';
@@ -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
+ }
@@ -0,0 +1,16 @@
1
+ import { IWarehouseSaleOrderFinancialLine, IWarehouseSaleOrderInvoice } from '../../schemas';
2
+ /**
3
+ * Convert unit_price on every financial line (invoice items).
4
+ */
5
+ export declare function getWarehouseSaleOrderInvoiceLinesWithPrice(lines: IWarehouseSaleOrderFinancialLine[] | undefined, convertToPrice: (price: number) => number): IWarehouseSaleOrderFinancialLine[];
6
+ /**
7
+ * Convert payments on a sale-order invoice.
8
+ */
9
+ export declare function getWarehouseSaleOrderInvoicePaymentsWithPrice(payments: IWarehouseSaleOrderInvoice['payments'] | undefined, convertToPrice: (price: number) => number): IWarehouseSaleOrderInvoice['payments'];
10
+ /**
11
+ * Convert all monetary fields on a sale-order invoice / credit note.
12
+ *
13
+ * - `writeable = true` → decimal → cents (before sending to backend)
14
+ * - `writeable = false` → cents → decimal (after receiving from backend)
15
+ */
16
+ export declare function getWarehouseSaleOrderInvoiceWithPrice<T extends Partial<IWarehouseSaleOrderInvoice> | IWarehouseSaleOrderInvoice>(order: T, writeable?: boolean): T;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWarehouseSaleOrderInvoiceLinesWithPrice = getWarehouseSaleOrderInvoiceLinesWithPrice;
4
+ exports.getWarehouseSaleOrderInvoicePaymentsWithPrice = getWarehouseSaleOrderInvoicePaymentsWithPrice;
5
+ exports.getWarehouseSaleOrderInvoiceWithPrice = getWarehouseSaleOrderInvoiceWithPrice;
6
+ const utils_1 = require("../utils");
7
+ const common_order_actions_1 = require("./common-order-actions");
8
+ /**
9
+ * Convert unit_price on every financial line (invoice items).
10
+ */
11
+ function getWarehouseSaleOrderInvoiceLinesWithPrice(lines, convertToPrice) {
12
+ if (!lines)
13
+ return [];
14
+ return lines.map((line) => ({
15
+ ...line,
16
+ unit_price: convertToPrice(line.unit_price),
17
+ }));
18
+ }
19
+ /**
20
+ * Convert payments on a sale-order invoice.
21
+ */
22
+ function getWarehouseSaleOrderInvoicePaymentsWithPrice(payments, convertToPrice) {
23
+ if (!payments)
24
+ return [];
25
+ return payments.map((payment) => ({
26
+ ...payment,
27
+ card_details: (0, common_order_actions_1.getOrderPaymentsCardDetailsWithPrice)(payment.card_details, convertToPrice),
28
+ amount_paid: convertToPrice(payment.amount_paid),
29
+ amount_due: convertToPrice(payment.amount_due),
30
+ amount_refunded: convertToPrice(payment.amount_refunded),
31
+ }));
32
+ }
33
+ /**
34
+ * Convert all monetary fields on a sale-order invoice / credit note.
35
+ *
36
+ * - `writeable = true` → decimal → cents (before sending to backend)
37
+ * - `writeable = false` → cents → decimal (after receiving from backend)
38
+ */
39
+ function getWarehouseSaleOrderInvoiceWithPrice(order, writeable) {
40
+ const convertToPrice = writeable ? utils_1.convertDecimalToInt : utils_1.convertIntToDecimal;
41
+ return {
42
+ ...order,
43
+ ...(order.items != null
44
+ ? {
45
+ items: getWarehouseSaleOrderInvoiceLinesWithPrice(order.items, convertToPrice),
46
+ }
47
+ : {}),
48
+ ...(order.payments != null
49
+ ? {
50
+ payments: getWarehouseSaleOrderInvoicePaymentsWithPrice(order.payments, convertToPrice),
51
+ }
52
+ : {}),
53
+ ...(order.amount != null ? { amount: convertToPrice(order.amount) } : {}),
54
+ ...(order.amount_paid != null ? { amount_paid: convertToPrice(order.amount_paid) } : {}),
55
+ ...(order.down_payment_value != null ? { down_payment_value: convertToPrice(order.down_payment_value) } : {}),
56
+ ...(order.gst != null ? { gst: convertToPrice(order.gst) } : {}),
57
+ ...(order.gst_amount != null ? { gst_amount: convertToPrice(order.gst_amount) } : {}),
58
+ };
59
+ }
@@ -7,13 +7,16 @@ 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';
13
14
  export * from './common-warehouse-purchase-order-vendor-return-actions';
14
15
  export * from './common-warehouse-sale-order-actions';
16
+ export * from './common-warehouse-sale-order-invoice-actions';
15
17
  export * from './common-warehouse-sale-order-rfq-actions';
16
18
  export * from './offline-ordering';
19
+ export * from './tenant-purchase-orders-cart-actions';
17
20
  export * from './warehouse-invoice-cart-actions';
18
21
  export * from './warehouse-purchase-order-rfq-cart-actions';
19
22
  export * from './warehouse-purchase-orders-cart-actions';
@@ -23,13 +23,16 @@ __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);
29
30
  __exportStar(require("./common-warehouse-purchase-order-vendor-return-actions"), exports);
30
31
  __exportStar(require("./common-warehouse-sale-order-actions"), exports);
32
+ __exportStar(require("./common-warehouse-sale-order-invoice-actions"), exports);
31
33
  __exportStar(require("./common-warehouse-sale-order-rfq-actions"), exports);
32
34
  __exportStar(require("./offline-ordering"), exports);
35
+ __exportStar(require("./tenant-purchase-orders-cart-actions"), exports);
33
36
  __exportStar(require("./warehouse-invoice-cart-actions"), exports);
34
37
  __exportStar(require("./warehouse-purchase-order-rfq-cart-actions"), exports);
35
38
  __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>;