@managesome/eposmatic-toolkit 0.2.770 → 0.2.772

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 (59) hide show
  1. package/lib/helpers/utils/receipt-engine.d.ts +7 -1
  2. package/lib/helpers/utils/receipt-engine.js +38 -33
  3. package/lib/tests/receipt-engine.test.js +86 -21
  4. package/package.json +1 -1
  5. package/lib/constants/MATERIALIZED_REPORTS.d.ts +0 -44
  6. package/lib/constants/MATERIALIZED_REPORTS.js +0 -58
  7. package/lib/constants/WAREHOUSE_INVOICE.d.ts +0 -14
  8. package/lib/constants/WAREHOUSE_INVOICE.js +0 -35
  9. package/lib/helpers/offer/generate-offer.d.ts +0 -11
  10. package/lib/helpers/offer/generate-offer.js +0 -143
  11. package/lib/helpers/offer/index.d.ts +0 -1
  12. package/lib/helpers/offer/index.js +0 -17
  13. package/lib/helpers/order/generate-warehouse-invoice.d.ts +0 -11
  14. package/lib/helpers/order/generate-warehouse-invoice.js +0 -196
  15. package/lib/helpers/store/all-warehouse-invoice-actions.d.ts +0 -13
  16. package/lib/helpers/store/all-warehouse-invoice-actions.js +0 -58
  17. package/lib/helpers/store/common-warehouse-invoice-actions.d.ts +0 -31
  18. package/lib/helpers/store/common-warehouse-invoice-actions.js +0 -545
  19. package/lib/helpers/store/warehouse-invoice-cart-actions.d.ts +0 -24
  20. package/lib/helpers/store/warehouse-invoice-cart-actions.js +0 -486
  21. package/lib/helpers/types/sockets.d.ts +0 -6
  22. package/lib/helpers/types/sockets.js +0 -2
  23. package/lib/helpers/types/warehouse-invoice-cart-actions.d.ts +0 -26
  24. package/lib/helpers/types/warehouse-invoice-cart-actions.js +0 -2
  25. package/lib/helpers/utils/materialized-report-helpers.d.ts +0 -35
  26. package/lib/helpers/utils/materialized-report-helpers.js +0 -73
  27. package/lib/helpers/utils/void-warehouse-invoice-items-helpers.d.ts +0 -3
  28. package/lib/helpers/utils/void-warehouse-invoice-items-helpers.js +0 -38
  29. package/lib/helpers/utils/void-warehouse-invoice-items-report-helpers.d.ts +0 -13
  30. package/lib/helpers/utils/void-warehouse-invoice-items-report-helpers.js +0 -22
  31. package/lib/helpers/utils/warehouse-invoice-order-engine.d.ts +0 -11
  32. package/lib/helpers/utils/warehouse-invoice-order-engine.js +0 -39
  33. package/lib/helpers/utils/warehouse-invoice-x-report-helpers.d.ts +0 -58
  34. package/lib/helpers/utils/warehouse-invoice-x-report-helpers.js +0 -1432
  35. package/lib/schemas/models/inventory_department_transactions.d.ts +0 -86
  36. package/lib/schemas/models/inventory_department_transactions.js +0 -116
  37. package/lib/schemas/models/inventory_department_utilities.d.ts +0 -108
  38. package/lib/schemas/models/inventory_department_utilities.js +0 -88
  39. package/lib/schemas/models/inventory_departments.d.ts +0 -53
  40. package/lib/schemas/models/inventory_departments.js +0 -58
  41. package/lib/schemas/models/inventory_entries.d.ts +0 -152
  42. package/lib/schemas/models/inventory_entries.js +0 -142
  43. package/lib/schemas/models/materialized_reports.d.ts +0 -277
  44. package/lib/schemas/models/materialized_reports.js +0 -60
  45. package/lib/schemas/models/warehouse_invoices.d.ts +0 -2675
  46. package/lib/schemas/models/warehouse_invoices.js +0 -327
  47. package/lib/schemas/models/warehouse_void_invoice_items.d.ts +0 -176
  48. package/lib/schemas/models/warehouse_void_invoice_items.js +0 -176
  49. package/lib/schemas/types/inventory_entries.d.ts +0 -41
  50. package/lib/schemas/types/inventory_entries.js +0 -2
  51. package/lib/schemas/types/materialized_reports.d.ts +0 -82
  52. package/lib/schemas/types/materialized_reports.js +0 -2
  53. package/lib/schemas/types/warehouse_invoices.d.ts +0 -69
  54. package/lib/schemas/types/warehouse_invoices.js +0 -2
  55. package/lib/schemas/types/warehouse_void_invoice_items.d.ts +0 -37
  56. package/lib/schemas/types/warehouse_void_invoice_items.js +0 -2
  57. package/lib/tests/materialized-report-helpers.test.d.ts +0 -1
  58. package/lib/tests/no-choice-modifier-selection.test.d.ts +0 -1
  59. package/lib/tests/no-choice-modifier-selection.test.js +0 -142
@@ -1,196 +0,0 @@
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.generateWarehouseClientInvoiceCategories = generateWarehouseClientInvoiceCategories;
7
- exports.generateWarehouseClientInvoiceIteration = generateWarehouseClientInvoiceIteration;
8
- exports.generateWarehouseClientInvoiceOnCreate = generateWarehouseClientInvoiceOnCreate;
9
- exports.generateWarehouseClientInvoiceOnUpdate = generateWarehouseClientInvoiceOnUpdate;
10
- const mongoose_1 = __importDefault(require("mongoose"));
11
- const constants_1 = require("../../constants");
12
- const common_warehouse_invoice_actions_1 = require("../store/common-warehouse-invoice-actions");
13
- function generateWarehouseClientInvoiceCategories(categories) {
14
- if (!categories)
15
- return [];
16
- return categories.map((category) => ({
17
- ...category,
18
- category_id: new mongoose_1.default.Types.ObjectId(category.category_id),
19
- items: category.items.map((item) => ({
20
- ...item,
21
- _id: new mongoose_1.default.Types.ObjectId(item._id),
22
- item_id: new mongoose_1.default.Types.ObjectId(item.item_id),
23
- })),
24
- }));
25
- }
26
- function getCommonOptionalBoolFieldsWarehouseClientInvoiceIteration(order, partial) {
27
- const defaultValue = partial ? undefined : false;
28
- return {
29
- is_gst_inclusive: order.is_gst_inclusive || defaultValue,
30
- };
31
- }
32
- function getCommonOptionalNumFieldsWarehouseClientInvoiceIteration(order, partial) {
33
- const defaultValue = partial ? undefined : 0;
34
- return {
35
- gst: order.gst || defaultValue,
36
- gst_amount: order.gst_amount || defaultValue,
37
- };
38
- }
39
- function generateWarehouseClientInvoiceIteration(order, partial = true, skipItemMetadata) {
40
- const iteration = {
41
- ...getCommonOptionalBoolFieldsWarehouseClientInvoiceIteration(order, partial),
42
- ...getCommonOptionalNumFieldsWarehouseClientInvoiceIteration(order, partial),
43
- ...(skipItemMetadata && order.categories != null
44
- ? {
45
- categories: (0, common_warehouse_invoice_actions_1.skipItemMetadataFromWarehouseClientInvoiceCategories)(order.categories),
46
- }
47
- : {
48
- categories: generateWarehouseClientInvoiceCategories(order.categories),
49
- }),
50
- payments: order.payments,
51
- staff_details: order.staff_details,
52
- special_instructions: order.special_instructions,
53
- order_status: order.order_status,
54
- price: order.price,
55
- amount_earned: order.amount_earned,
56
- grand_total: order.grand_total,
57
- tax_number: order.tax_number,
58
- updatedAt: order.updatedAt,
59
- };
60
- if (partial) {
61
- Object.keys(iteration).forEach((key) => {
62
- if (iteration[key] === undefined) {
63
- delete iteration[key];
64
- }
65
- });
66
- }
67
- return iteration;
68
- }
69
- function getWarehouseClientInvoiceIterations(iterations) {
70
- if (!iterations)
71
- return [];
72
- return iterations.map((iteration) => ({
73
- ...iteration,
74
- categories: generateWarehouseClientInvoiceCategories(iteration.categories),
75
- updatedAt: new Date(iteration.updatedAt),
76
- }));
77
- }
78
- function generateWarehouseClientInvoiceOnCreate(order, withIterations) {
79
- const newOrder = {
80
- ...order,
81
- ...(order.payments != null
82
- ? {
83
- payments: order.payments.map((payment) => ({
84
- ...payment,
85
- _id: new mongoose_1.default.Types.ObjectId(payment._id),
86
- })),
87
- }
88
- : {}),
89
- ...(order.categories != null ? { categories: generateWarehouseClientInvoiceCategories(order.categories) } : {}),
90
- _id: new mongoose_1.default.Types.ObjectId(order._id),
91
- iterations: withIterations ? getWarehouseClientInvoiceIterations(order.iterations) : [],
92
- };
93
- if (!newOrder.delete_reason) {
94
- delete newOrder.delete_reason;
95
- }
96
- if (!newOrder.cancel_reason) {
97
- delete newOrder.cancel_reason;
98
- }
99
- if (!newOrder.is_reopened) {
100
- delete newOrder.is_reopened;
101
- }
102
- if (!newOrder.staff_details) {
103
- delete newOrder.staff_details;
104
- }
105
- if (!newOrder.gst) {
106
- delete newOrder.gst;
107
- delete newOrder.gst_amount;
108
- delete newOrder.is_gst_inclusive;
109
- }
110
- else {
111
- if (newOrder.gst_amount === 0) {
112
- delete newOrder.gst_amount;
113
- }
114
- if (newOrder.is_gst_inclusive === false) {
115
- delete newOrder.is_gst_inclusive;
116
- }
117
- }
118
- if (newOrder.payments?.some((payment) => payment.payment_type === constants_1.PAYMENT_TYPE_ENUM.PAY_LATER && payment.payment_status === constants_1.PAYMENT_STATUS_ENUM.PENDING)) {
119
- newOrder.deferred_settlement = true;
120
- }
121
- else {
122
- delete newOrder.deferred_settlement;
123
- }
124
- return newOrder;
125
- }
126
- function generateWarehouseClientInvoiceOnUpdate(partialUpdatedOrder) {
127
- const partialResponseOrder = {
128
- ...partialUpdatedOrder,
129
- };
130
- const unset = {};
131
- const set = {
132
- ...partialUpdatedOrder,
133
- ...(partialUpdatedOrder.iterations != null
134
- ? {
135
- iterations: getWarehouseClientInvoiceIterations(partialUpdatedOrder.iterations),
136
- }
137
- : {}),
138
- ...(partialUpdatedOrder.payments != null
139
- ? {
140
- payments: partialUpdatedOrder.payments.map((payment) => ({
141
- ...payment,
142
- _id: new mongoose_1.default.Types.ObjectId(payment._id),
143
- })),
144
- }
145
- : {}),
146
- ...(partialUpdatedOrder.categories != null
147
- ? { categories: generateWarehouseClientInvoiceCategories(partialUpdatedOrder.categories) }
148
- : {}),
149
- };
150
- if (set.delete_reason === null) {
151
- delete set.delete_reason;
152
- unset['delete_reason'] = '';
153
- }
154
- if (set.cancel_reason === null) {
155
- delete set.cancel_reason;
156
- unset['cancel_reason'] = '';
157
- }
158
- if (set.is_reopened === false) {
159
- delete set.is_reopened;
160
- unset['is_reopened'] = '';
161
- }
162
- if (set.staff_details === null) {
163
- delete set.staff_details;
164
- unset['staff_details'] = '';
165
- }
166
- if (set.gst === 0) {
167
- delete set.gst;
168
- delete set.gst_amount;
169
- unset['gst'] = '';
170
- unset['gst_amount'] = '';
171
- }
172
- else {
173
- if (set.gst_amount === 0) {
174
- delete set.gst_amount;
175
- unset['gst_amount'] = '';
176
- }
177
- if (set.is_gst_inclusive === false) {
178
- delete set.is_gst_inclusive;
179
- unset['is_gst_inclusive'] = '';
180
- }
181
- }
182
- if (set.payments != null) {
183
- if (set.payments.some((payment) => payment.payment_type === constants_1.PAYMENT_TYPE_ENUM.PAY_LATER &&
184
- payment.payment_status === constants_1.PAYMENT_STATUS_ENUM.PENDING)) {
185
- set.deferred_settlement = true;
186
- }
187
- else {
188
- unset['deferred_settlement'] = '';
189
- }
190
- }
191
- const updateOperation = {
192
- ...(Object.keys(set).length > 0 ? { $set: set } : {}),
193
- ...(Object.keys(unset).length > 0 ? { $unset: unset } : {}),
194
- };
195
- return { updateOperation, partialResponseOrder };
196
- }
@@ -1,13 +0,0 @@
1
- import { IWarehouseInvoiceStatus, WAREHOUSE_INVOICE_STATUS_ENUM } from '../../constants';
2
- import { IWarehouseClientInvoice } from '../../schemas';
3
- export declare function getWarehouseClientInvoicesFetchedData(data: IWarehouseClientInvoice[]): IWarehouseClientInvoice[];
4
- export declare function getWarehouseClientInvoicesPostedData(data: IWarehouseClientInvoice[], invoice: IWarehouseClientInvoice): IWarehouseClientInvoice[];
5
- export declare function getWarehouseClientInvoicesUpdatedData(data: IWarehouseClientInvoice[], invoice: Partial<IWarehouseClientInvoice>): IWarehouseClientInvoice[];
6
- export declare function getWarehouseClientInvoicesDeletedData(data: IWarehouseClientInvoice[], invoiceId: string): IWarehouseClientInvoice[];
7
- interface IGetWarehouseClientInvoiceStatusInfoReturn {
8
- currentOrderStatus: IWarehouseInvoiceStatus | null;
9
- nextOrderStatus: IWarehouseInvoiceStatus | null;
10
- orderProgress: number;
11
- }
12
- export declare function getWarehouseClientInvoiceStatusInfo(currentStatus: WAREHOUSE_INVOICE_STATUS_ENUM): IGetWarehouseClientInvoiceStatusInfoReturn;
13
- export {};
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWarehouseClientInvoicesFetchedData = getWarehouseClientInvoicesFetchedData;
4
- exports.getWarehouseClientInvoicesPostedData = getWarehouseClientInvoicesPostedData;
5
- exports.getWarehouseClientInvoicesUpdatedData = getWarehouseClientInvoicesUpdatedData;
6
- exports.getWarehouseClientInvoicesDeletedData = getWarehouseClientInvoicesDeletedData;
7
- exports.getWarehouseClientInvoiceStatusInfo = getWarehouseClientInvoiceStatusInfo;
8
- const constants_1 = require("../../constants");
9
- const common_order_actions_1 = require("./common-order-actions");
10
- const common_warehouse_invoice_actions_1 = require("./common-warehouse-invoice-actions");
11
- function getWarehouseClientInvoicesFetchedData(data) {
12
- return data.map((invoice) => (0, common_warehouse_invoice_actions_1.getWarehouseClientInvoiceWithPrice)(invoice, false)).sort(common_order_actions_1.sortByCreatedAt);
13
- }
14
- function getWarehouseClientInvoicesPostedData(data, invoice) {
15
- const newInvoices = data
16
- .filter((item) => item._id !== invoice._id)
17
- .concat((0, common_warehouse_invoice_actions_1.getWarehouseClientInvoiceWithPrice)(invoice));
18
- return newInvoices.sort(common_order_actions_1.sortByCreatedAt);
19
- }
20
- function getWarehouseClientInvoicesUpdatedData(data, invoice) {
21
- const updatedInvoice = (0, common_warehouse_invoice_actions_1.getWarehouseClientInvoiceWithPrice)(invoice);
22
- const newInvoices = data.map((item) => item._id === updatedInvoice._id ? { ...item, ...updatedInvoice } : item);
23
- return newInvoices;
24
- }
25
- function getWarehouseClientInvoicesDeletedData(data, invoiceId) {
26
- const filteredInvoices = data.filter((item) => item._id !== invoiceId);
27
- return filteredInvoices;
28
- }
29
- function getWarehouseClientInvoiceStatusInfo(currentStatus) {
30
- const info = {
31
- orderProgress: 0,
32
- nextOrderStatus: null,
33
- currentOrderStatus: null,
34
- };
35
- let currentStatusIndex;
36
- for (let i = 0; i < constants_1.DEFAULT_WAREHOUSE_INVOICE_STATUS.length; i++) {
37
- const status = constants_1.DEFAULT_WAREHOUSE_INVOICE_STATUS[i];
38
- if (status.status === currentStatus) {
39
- info.currentOrderStatus = status;
40
- currentStatusIndex = i;
41
- if (status.status !== constants_1.WAREHOUSE_INVOICE_STATUS_ENUM.CANCELLED) {
42
- const progressStatuses = constants_1.DEFAULT_WAREHOUSE_INVOICE_STATUS.filter((item) => item.status !== constants_1.WAREHOUSE_INVOICE_STATUS_ENUM.CANCELLED);
43
- const maxPriority = progressStatuses.reduce((max, item) => Math.max(max, item.priority), 0) || 1;
44
- info.orderProgress = Math.round((status.priority / maxPriority) * 100);
45
- }
46
- break;
47
- }
48
- }
49
- if (currentStatusIndex == null) {
50
- return info;
51
- }
52
- const nextStatus = constants_1.DEFAULT_WAREHOUSE_INVOICE_STATUS[currentStatusIndex + 1];
53
- if (!nextStatus || nextStatus.status === constants_1.WAREHOUSE_INVOICE_STATUS_ENUM.CANCELLED) {
54
- return info;
55
- }
56
- info.nextOrderStatus = nextStatus;
57
- return info;
58
- }
@@ -1,31 +0,0 @@
1
- import { SORT_TYPE_ENUM } from '../../constants';
2
- import { IOrderPayment, IWarehouseClientInvoice, IWarehouseClientInvoiceCategory, IWarehouseClientInvoiceItem, IWarehouseClientInvoiceIteration } from '../../schemas';
3
- import { IGeneralWarehouseClientInvoiceItem, IWarehouseClientInvoiceCartItemsObj } from '../types';
4
- export declare function getWarehouseClientInvoiceIterationsWithPrice(iterations?: IWarehouseClientInvoiceIteration[] | undefined, writeable?: boolean): IWarehouseClientInvoiceIteration[];
5
- export declare function getWarehouseClientInvoicePaymentsWithPrice(payments: IOrderPayment[] | undefined, convertToPrice: (price: number) => number): IOrderPayment[];
6
- export declare function getWarehouseClientInvoiceItemsWithPrice(items: IWarehouseClientInvoiceItem[] | undefined, convertToPrice: (price: number) => number): IWarehouseClientInvoiceItem[];
7
- export declare function getWarehouseClientInvoiceCategoriesWithPrice(categories: IWarehouseClientInvoiceCategory[] | undefined, convertToPrice: (price: number) => number): IWarehouseClientInvoiceCategory[];
8
- export declare function getWarehouseClientInvoiceWithPrice<T extends Partial<IWarehouseClientInvoice> | IWarehouseClientInvoice | IWarehouseClientInvoiceIteration>(order: T, writeable?: boolean): T;
9
- export declare function syncWarehouseClientInvoiceData(order: IWarehouseClientInvoice): IWarehouseClientInvoice;
10
- export declare function skipItemMetadataFromWarehouseClientInvoiceCategories(categories: IWarehouseClientInvoice['categories'], previousCategories?: IWarehouseClientInvoice['categories']): IWarehouseClientInvoice['categories'];
11
- export declare function getWarehouseClientInvoiceWithAllFields<T extends IWarehouseClientInvoice | Partial<IWarehouseClientInvoice>>(order: T, skipItemMetadata?: boolean): T;
12
- export interface IGetWarehouseClientInvoiceCartItemsObjPayload {
13
- currentIterationCategories: IWarehouseClientInvoiceCategory[] | undefined;
14
- previousIterationCategories: IWarehouseClientInvoiceCategory[] | undefined;
15
- mappedItems: Record<string, IGeneralWarehouseClientInvoiceItem>;
16
- shouldSortItemsViaId?: boolean;
17
- isAnEdit?: boolean;
18
- sortType?: SORT_TYPE_ENUM;
19
- }
20
- export declare function getWarehouseClientInvoiceCartItemsObj({ currentIterationCategories, previousIterationCategories, mappedItems, shouldSortItemsViaId, isAnEdit, sortType, }: IGetWarehouseClientInvoiceCartItemsObjPayload): IWarehouseClientInvoiceCartItemsObj;
21
- interface IGetVoidItemsWithReasonWarehouseClientInvoice {
22
- currentCategories: IWarehouseClientInvoiceCategory[];
23
- iterationsFromFrontend: IWarehouseClientInvoiceIteration[] | undefined;
24
- previousCategories: IWarehouseClientInvoiceCategory[];
25
- }
26
- export declare function getVoidItemsWithReasonWarehouseClientInvoice({ currentCategories, iterationsFromFrontend, previousCategories, }: IGetVoidItemsWithReasonWarehouseClientInvoice): {
27
- newIterationCategories: IWarehouseClientInvoiceCategory[];
28
- voidOrderItems: IWarehouseClientInvoiceItem[];
29
- hasNewItems: boolean;
30
- };
31
- export {};