@managesome/eposmatic-toolkit 0.2.464 → 0.2.466

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.
@@ -0,0 +1,35 @@
1
+ import { WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS_ENUM, WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS_ENUM } from '../../constants';
2
+ import { IWarehouseSaleOrderFinancialDocStatus, IWarehouseSaleOrderInvoice } from '../../schemas';
3
+ export declare const DEFAULT_WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS: {
4
+ status: WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS_ENUM;
5
+ color: string;
6
+ contrast_color: string;
7
+ priority: number;
8
+ }[];
9
+ export declare const DEFAULT_WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS: {
10
+ status: WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS_ENUM;
11
+ color: string;
12
+ contrast_color: string;
13
+ priority: number;
14
+ }[];
15
+ export declare function getWarehouseSaleOrderInvoicesFetchedData(data: IWarehouseSaleOrderInvoice[]): IWarehouseSaleOrderInvoice[];
16
+ export declare function getWarehouseSaleOrderInvoicesPostedData(data: IWarehouseSaleOrderInvoice[], order: IWarehouseSaleOrderInvoice): IWarehouseSaleOrderInvoice[];
17
+ export declare function getWarehouseSaleOrderInvoicesUpdatedData(data: IWarehouseSaleOrderInvoice[], order: Partial<IWarehouseSaleOrderInvoice>): IWarehouseSaleOrderInvoice[];
18
+ export declare function getWarehouseSaleOrderInvoicesDeletedData(data: IWarehouseSaleOrderInvoice[], orderId: string): IWarehouseSaleOrderInvoice[];
19
+ interface IWarehouseGetSaleOrderInvoiceStatusInfoReturn {
20
+ currentOrderStatus: {
21
+ status: IWarehouseSaleOrderFinancialDocStatus;
22
+ color: string;
23
+ contrast_color: string;
24
+ priority: number;
25
+ } | null;
26
+ nextOrderStatus: {
27
+ status: IWarehouseSaleOrderFinancialDocStatus;
28
+ color: string;
29
+ contrast_color: string;
30
+ priority: number;
31
+ } | null;
32
+ orderProgress: number;
33
+ }
34
+ export declare function getWarehouseSaleOrderInvoiceStatusInfo(currentStatus: IWarehouseSaleOrderFinancialDocStatus): IWarehouseGetSaleOrderInvoiceStatusInfoReturn;
35
+ export {};
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS = exports.DEFAULT_WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS = void 0;
4
+ exports.getWarehouseSaleOrderInvoicesFetchedData = getWarehouseSaleOrderInvoicesFetchedData;
5
+ exports.getWarehouseSaleOrderInvoicesPostedData = getWarehouseSaleOrderInvoicesPostedData;
6
+ exports.getWarehouseSaleOrderInvoicesUpdatedData = getWarehouseSaleOrderInvoicesUpdatedData;
7
+ exports.getWarehouseSaleOrderInvoicesDeletedData = getWarehouseSaleOrderInvoicesDeletedData;
8
+ exports.getWarehouseSaleOrderInvoiceStatusInfo = getWarehouseSaleOrderInvoiceStatusInfo;
9
+ const constants_1 = require("../../constants");
10
+ const common_order_actions_1 = require("./common-order-actions");
11
+ const common_warehouse_sale_order_invoice_actions_1 = require("./common-warehouse-sale-order-invoice-actions");
12
+ exports.DEFAULT_WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS = [
13
+ {
14
+ status: constants_1.WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS_ENUM.DRAFT,
15
+ color: '#727472',
16
+ contrast_color: '#FFFFFF',
17
+ priority: 0,
18
+ },
19
+ {
20
+ status: constants_1.WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS_ENUM.POSTED,
21
+ color: '#0000FF',
22
+ contrast_color: '#FFFFFF',
23
+ priority: 1,
24
+ },
25
+ {
26
+ status: constants_1.WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS_ENUM.PARTIAL,
27
+ color: '#FFA500',
28
+ contrast_color: '#FFFFFF',
29
+ priority: 2,
30
+ },
31
+ {
32
+ status: constants_1.WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS_ENUM.PAID,
33
+ color: '#4CC417',
34
+ contrast_color: '#FFFFFF',
35
+ priority: 3,
36
+ },
37
+ {
38
+ status: constants_1.WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS_ENUM.CANCELLED,
39
+ color: '#FF0000',
40
+ contrast_color: '#FFFFFF',
41
+ priority: 4,
42
+ },
43
+ ];
44
+ exports.DEFAULT_WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS = [
45
+ {
46
+ status: constants_1.WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS_ENUM.DRAFT,
47
+ color: '#727472',
48
+ contrast_color: '#FFFFFF',
49
+ priority: 0,
50
+ },
51
+ {
52
+ status: constants_1.WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS_ENUM.CONFIRMED,
53
+ color: '#0000FF',
54
+ contrast_color: '#FFFFFF',
55
+ priority: 1,
56
+ },
57
+ {
58
+ status: constants_1.WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS_ENUM.REFUND_PENDING,
59
+ color: '#FFA500',
60
+ contrast_color: '#FFFFFF',
61
+ priority: 2,
62
+ },
63
+ {
64
+ status: constants_1.WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS_ENUM.REFUNDED,
65
+ color: '#4CC417',
66
+ contrast_color: '#FFFFFF',
67
+ priority: 3,
68
+ },
69
+ {
70
+ status: constants_1.WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS_ENUM.CANCELLED,
71
+ color: '#FF0000',
72
+ contrast_color: '#FFFFFF',
73
+ priority: 4,
74
+ },
75
+ ];
76
+ function getWarehouseSaleOrderInvoicesFetchedData(data) {
77
+ return data.map((order) => (0, common_warehouse_sale_order_invoice_actions_1.getWarehouseSaleOrderInvoiceWithPrice)(order, false)).sort(common_order_actions_1.sortByCreatedAt);
78
+ }
79
+ function getWarehouseSaleOrderInvoicesPostedData(data, order) {
80
+ const newOrders = data.filter((item) => item._id !== order._id).concat((0, common_warehouse_sale_order_invoice_actions_1.getWarehouseSaleOrderInvoiceWithPrice)(order));
81
+ return newOrders.sort(common_order_actions_1.sortByCreatedAt);
82
+ }
83
+ function getWarehouseSaleOrderInvoicesUpdatedData(data, order) {
84
+ const updatedOrder = (0, common_warehouse_sale_order_invoice_actions_1.getWarehouseSaleOrderInvoiceWithPrice)(order);
85
+ const newOrders = data.map((item) => item._id === updatedOrder._id ? { ...item, ...updatedOrder } : item);
86
+ return newOrders;
87
+ }
88
+ function getWarehouseSaleOrderInvoicesDeletedData(data, orderId) {
89
+ return data.filter((item) => item._id !== orderId);
90
+ }
91
+ function getStatusPriority(status) {
92
+ for (const entry of exports.DEFAULT_WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS) {
93
+ if (entry.status === status)
94
+ return entry.priority;
95
+ }
96
+ for (const entry of exports.DEFAULT_WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS) {
97
+ if (entry.status === status)
98
+ return entry.priority;
99
+ }
100
+ return undefined;
101
+ }
102
+ function isCancelledStatus(status) {
103
+ return (status === constants_1.WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS_ENUM.CANCELLED ||
104
+ status === constants_1.WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS_ENUM.CANCELLED);
105
+ }
106
+ function getWarehouseSaleOrderInvoiceStatusInfo(currentStatus) {
107
+ const info = {
108
+ orderProgress: 0,
109
+ nextOrderStatus: null,
110
+ currentOrderStatus: null,
111
+ };
112
+ // Determine which status array to use based on the status value
113
+ const isInvoiceStatus = Object.values(constants_1.WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS_ENUM).includes(currentStatus);
114
+ const statusArray = isInvoiceStatus
115
+ ? exports.DEFAULT_WAREHOUSE_SALE_ORDER_INVOICE_PAYMENT_STATUS
116
+ : exports.DEFAULT_WAREHOUSE_SALE_ORDER_CREDIT_NOTE_STATUS;
117
+ let currentStatusIndex;
118
+ for (let i = 0; i < statusArray.length; i++) {
119
+ const obj = statusArray[i];
120
+ if (obj.status === currentStatus) {
121
+ info.currentOrderStatus = obj;
122
+ currentStatusIndex = i;
123
+ if (!isCancelledStatus(currentStatus)) {
124
+ // Total is -2 because we don't want to count draft and cancelled
125
+ const total = statusArray.length - 2;
126
+ info.orderProgress = Math.round((obj.priority / total) * 100);
127
+ }
128
+ break;
129
+ }
130
+ }
131
+ if (currentStatusIndex == null) {
132
+ return info;
133
+ }
134
+ const nextObj = statusArray[currentStatusIndex + 1];
135
+ if (!nextObj || isCancelledStatus(nextObj.status)) {
136
+ return info;
137
+ }
138
+ info.nextOrderStatus = nextObj;
139
+ return info;
140
+ }
@@ -81,7 +81,7 @@ function syncTenantPurchaseOrderData(order) {
81
81
  ...order,
82
82
  iterations: [],
83
83
  };
84
- const newOrder = getTenantPurchaseOrderWithPrice((0, tenant_purchase_orders_cart_actions_1.calculateCartTenantPurchaseOrderInfoAndSyncData)(getTenantPurchaseOrderWithPrice(updatedOrder, true), true), true);
84
+ const newOrder = getTenantPurchaseOrderWithPrice((0, tenant_purchase_orders_cart_actions_1.calculateCartTenantPurchaseOrderInfoAndSyncData)(getTenantPurchaseOrderWithPrice(updatedOrder), true), true);
85
85
  newOrder.iterations = order.iterations;
86
86
  return newOrder;
87
87
  }
@@ -2,6 +2,7 @@ export * from './all-orders-actions';
2
2
  export * from './all-warehouse-purchase-order-rfqs-actions';
3
3
  export * from './all-warehouse-purchase-order-vendor-return-actions';
4
4
  export * from './all-warehouse-purchase-orders-actions';
5
+ export * from './all-warehouse-sale-order-invoices-actions';
5
6
  export * from './all-warehouse-sale-order-rfqs-actions';
6
7
  export * from './all-warehouse-sale-orders-actions';
7
8
  export * from './cart-actions';
@@ -18,6 +18,7 @@ __exportStar(require("./all-orders-actions"), exports);
18
18
  __exportStar(require("./all-warehouse-purchase-order-rfqs-actions"), exports);
19
19
  __exportStar(require("./all-warehouse-purchase-order-vendor-return-actions"), exports);
20
20
  __exportStar(require("./all-warehouse-purchase-orders-actions"), exports);
21
+ __exportStar(require("./all-warehouse-sale-order-invoices-actions"), exports);
21
22
  __exportStar(require("./all-warehouse-sale-order-rfqs-actions"), exports);
22
23
  __exportStar(require("./all-warehouse-sale-orders-actions"), exports);
23
24
  __exportStar(require("./cart-actions"), exports);
@@ -396,7 +396,8 @@ export interface IWorker_PostWarehouseActivityLogs {
396
396
  title: string;
397
397
  description?: string | null;
398
398
  changes?: IWarehouseActivityLogChange[];
399
- staff_id?: string;
399
+ staff_id?: string | null;
400
+ staff_name?: string | null;
400
401
  severity?: WAREHOUSE_ACTIVITY_LOG_SEVERITY_ENUM;
401
402
  }[];
402
403
  }
@@ -46,8 +46,8 @@ export declare const WarehouseInternalMovementsSchema: Schema<any, import("mongo
46
46
  name: string;
47
47
  uid: string;
48
48
  };
49
- ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
50
49
  doc_number: string;
50
+ ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
51
51
  record_type: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_RECORD_TYPE_ENUM;
52
52
  flow: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM;
53
53
  source_id: string;
@@ -164,8 +164,8 @@ export declare const WarehouseInternalMovementsSchema: Schema<any, import("mongo
164
164
  name: string;
165
165
  uid: string;
166
166
  };
167
- ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
168
167
  doc_number: string;
168
+ ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
169
169
  record_type: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_RECORD_TYPE_ENUM;
170
170
  flow: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM;
171
171
  source_id: string;
@@ -282,8 +282,8 @@ export declare const WarehouseInternalMovementsSchema: Schema<any, import("mongo
282
282
  name: string;
283
283
  uid: string;
284
284
  };
285
- ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
286
285
  doc_number: string;
286
+ ref_type: import("../../constants").WAREHOUSE_REF_TYPE_ENUM;
287
287
  record_type: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_RECORD_TYPE_ENUM;
288
288
  flow: import("../../constants").WAREHOUSE_INTERNAL_MOVEMENT_FLOW_ENUM;
289
289
  source_id: string;
@@ -44,12 +44,12 @@ export declare const SaleOrderDeliveriesSchema: Schema<any, import("mongoose").M
44
44
  name: string;
45
45
  } | null | undefined;
46
46
  cancelled_at?: NativeDate | null | undefined;
47
+ applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
47
48
  delivered_at?: NativeDate | null | undefined;
48
49
  delivered_by?: {
49
50
  _id: string;
50
51
  name: string;
51
52
  } | null | undefined;
52
- applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
53
53
  inventory_restocked?: boolean | null | undefined;
54
54
  returned_by?: {
55
55
  _id: string;
@@ -96,12 +96,12 @@ export declare const SaleOrderDeliveriesSchema: Schema<any, import("mongoose").M
96
96
  name: string;
97
97
  } | null | undefined;
98
98
  cancelled_at?: NativeDate | null | undefined;
99
+ applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
99
100
  delivered_at?: NativeDate | null | undefined;
100
101
  delivered_by?: {
101
102
  _id: string;
102
103
  name: string;
103
104
  } | null | undefined;
104
- applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
105
105
  inventory_restocked?: boolean | null | undefined;
106
106
  returned_by?: {
107
107
  _id: string;
@@ -148,12 +148,12 @@ export declare const SaleOrderDeliveriesSchema: Schema<any, import("mongoose").M
148
148
  name: string;
149
149
  } | null | undefined;
150
150
  cancelled_at?: NativeDate | null | undefined;
151
+ applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
151
152
  delivered_at?: NativeDate | null | undefined;
152
153
  delivered_by?: {
153
154
  _id: string;
154
155
  name: string;
155
156
  } | null | undefined;
156
- applied_to_doc_id?: import("mongoose").Types.ObjectId | null | undefined;
157
157
  inventory_restocked?: boolean | null | undefined;
158
158
  returned_by?: {
159
159
  _id: string;
@@ -35,9 +35,9 @@ export declare const WarehouseSaleOrderInvoiceSchema: Schema<any, import("mongoo
35
35
  amount: number;
36
36
  payments: any[];
37
37
  warehouse_id: string;
38
- doc_number: number;
39
38
  doc_kind: import("../../constants").WAREHOUSE_SALE_ORDER_FIN_DOC_KIND_ENUM;
40
39
  sale_order_id: import("mongoose").Types.ObjectId;
40
+ doc_number: number;
41
41
  invoice_type: import("../../constants").WAREHOUSE_SALE_ORDER_INVOICE_TYPE_ENUM;
42
42
  amount_paid?: number | null | undefined;
43
43
  cancel_reason?: string | null | undefined;
@@ -107,9 +107,9 @@ export declare const WarehouseSaleOrderInvoiceSchema: Schema<any, import("mongoo
107
107
  amount: number;
108
108
  payments: any[];
109
109
  warehouse_id: string;
110
- doc_number: number;
111
110
  doc_kind: import("../../constants").WAREHOUSE_SALE_ORDER_FIN_DOC_KIND_ENUM;
112
111
  sale_order_id: import("mongoose").Types.ObjectId;
112
+ doc_number: number;
113
113
  invoice_type: import("../../constants").WAREHOUSE_SALE_ORDER_INVOICE_TYPE_ENUM;
114
114
  amount_paid?: number | null | undefined;
115
115
  cancel_reason?: string | null | undefined;
@@ -179,9 +179,9 @@ export declare const WarehouseSaleOrderInvoiceSchema: Schema<any, import("mongoo
179
179
  amount: number;
180
180
  payments: any[];
181
181
  warehouse_id: string;
182
- doc_number: number;
183
182
  doc_kind: import("../../constants").WAREHOUSE_SALE_ORDER_FIN_DOC_KIND_ENUM;
184
183
  sale_order_id: import("mongoose").Types.ObjectId;
184
+ doc_number: number;
185
185
  invoice_type: import("../../constants").WAREHOUSE_SALE_ORDER_INVOICE_TYPE_ENUM;
186
186
  amount_paid?: number | null | undefined;
187
187
  cancel_reason?: string | null | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.464",
3
+ "version": "0.2.466",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",