@managesome/eposmatic-toolkit 0.2.597 → 0.2.601

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.
@@ -1,2 +1,3 @@
1
- import { IWarehouseInternalMovement } from '../../schemas';
1
+ import { IWarehouseInternalMovement, IWarehouseInternalMovementIteration } from '../../schemas';
2
+ export declare function generateWarehouseInternalMovementIteration(movement: IWarehouseInternalMovement | IWarehouseInternalMovementIteration, partial?: boolean): IWarehouseInternalMovementIteration;
2
3
  export declare function generateWarehouseInternalMovementOnCreate<T extends IWarehouseInternalMovement | Partial<IWarehouseInternalMovement>>(movement: T): T;
@@ -3,8 +3,53 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateWarehouseInternalMovementIteration = generateWarehouseInternalMovementIteration;
6
7
  exports.generateWarehouseInternalMovementOnCreate = generateWarehouseInternalMovementOnCreate;
7
8
  const mongoose_1 = __importDefault(require("mongoose"));
9
+ function generateWarehouseInternalMovementIteration(movement, partial = true) {
10
+ const iteration = {
11
+ items: movement.items != null
12
+ ? movement.items.map((item) => ({
13
+ ...item,
14
+ _id: new mongoose_1.default.Types.ObjectId(item._id),
15
+ item_id: new mongoose_1.default.Types.ObjectId(item.item_id),
16
+ }))
17
+ : movement.items,
18
+ total_items: movement.total_items,
19
+ total_quantity: movement.total_quantity,
20
+ grand_total: movement.grand_total,
21
+ payments: movement.payments,
22
+ amount_collected: movement.amount_collected,
23
+ amount_earned: movement.amount_earned,
24
+ is_gst_inclusive: movement.is_gst_inclusive,
25
+ gst: movement.gst,
26
+ gst_amount: movement.gst_amount,
27
+ notes: movement.notes,
28
+ status: movement.status,
29
+ updatedAt: movement.updatedAt,
30
+ };
31
+ if (partial) {
32
+ Object.keys(iteration).forEach((key) => {
33
+ if (iteration[key] === undefined) {
34
+ delete iteration[key];
35
+ }
36
+ });
37
+ }
38
+ return iteration;
39
+ }
40
+ function getInternalMovementIterations(iterations) {
41
+ if (!iterations)
42
+ return [];
43
+ return iterations.map((iteration) => ({
44
+ ...iteration,
45
+ items: iteration.items.map((item) => ({
46
+ ...item,
47
+ _id: new mongoose_1.default.Types.ObjectId(item._id),
48
+ item_id: new mongoose_1.default.Types.ObjectId(item.item_id),
49
+ })),
50
+ updatedAt: new Date(iteration.updatedAt),
51
+ }));
52
+ }
8
53
  function generateWarehouseInternalMovementOnCreate(movement) {
9
54
  const newMovement = {
10
55
  ...movement,
@@ -18,6 +63,11 @@ function generateWarehouseInternalMovementOnCreate(movement) {
18
63
  }
19
64
  : {}),
20
65
  _id: new mongoose_1.default.Types.ObjectId(movement._id),
66
+ ...(movement.iterations != null
67
+ ? {
68
+ iterations: getInternalMovementIterations(movement.iterations),
69
+ }
70
+ : {}),
21
71
  ...(movement.parent_movement_id != null
22
72
  ? {
23
73
  parent_movement_id: new mongoose_1.default.Types.ObjectId(movement.parent_movement_id),
@@ -1,15 +1,19 @@
1
- import { IWarehouseInternalMovement, IWarehouseInternalMovementItem } from '../../schemas';
1
+ import { IWarehouseInternalMovement, IWarehouseInternalMovementItem, IWarehouseInternalMovementIteration } from '../../schemas';
2
2
  /**
3
3
  * Convert unit_price on every internal movement item.
4
4
  */
5
5
  export declare function getWarehouseInternalMovementItemsWithPrice(items: IWarehouseInternalMovementItem[] | undefined, convertToPrice: (price: number) => number): IWarehouseInternalMovementItem[];
6
+ /**
7
+ * Convert all monetary fields on every internal movement iteration.
8
+ */
9
+ export declare function getWarehouseInternalMovementIterationsWithPrice(iterations?: IWarehouseInternalMovementIteration[] | undefined, writeable?: boolean): IWarehouseInternalMovementIteration[];
6
10
  /**
7
11
  * Convert all monetary fields on an internal movement.
8
12
  *
9
13
  * - `writeable = true` → decimal → cents (before sending to backend)
10
14
  * - `writeable = false` → cents → decimal (after receiving from backend)
11
15
  */
12
- export declare function getWarehouseInternalMovementWithPrice<T extends Partial<IWarehouseInternalMovement> | IWarehouseInternalMovement>(order: T, writeable?: boolean): T;
16
+ export declare function getWarehouseInternalMovementWithPrice<T extends Partial<IWarehouseInternalMovement> | IWarehouseInternalMovement | IWarehouseInternalMovementIteration>(order: T, writeable?: boolean): T;
13
17
  /**
14
18
  * Recalculate financial totals for an internal movement — mirrors
15
19
  * `calculateCartWarehousePurchaseOrderInfoAndSyncData` but for the flat
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWarehouseInternalMovementItemsWithPrice = getWarehouseInternalMovementItemsWithPrice;
4
+ exports.getWarehouseInternalMovementIterationsWithPrice = getWarehouseInternalMovementIterationsWithPrice;
4
5
  exports.getWarehouseInternalMovementWithPrice = getWarehouseInternalMovementWithPrice;
5
6
  exports.calculateCartInternalMovementInfoAndSyncData = calculateCartInternalMovementInfoAndSyncData;
6
7
  const utils_1 = require("../utils");
@@ -30,6 +31,14 @@ function getPaymentsWithPrice(payments, convertToPrice) {
30
31
  amount_refunded: payment.amount_refunded != null ? convertToPrice(payment.amount_refunded) : payment.amount_refunded,
31
32
  }));
32
33
  }
34
+ /**
35
+ * Convert all monetary fields on every internal movement iteration.
36
+ */
37
+ function getWarehouseInternalMovementIterationsWithPrice(iterations, writeable) {
38
+ if (!iterations)
39
+ return [];
40
+ return iterations.map((iteration) => getWarehouseInternalMovementWithPrice(iteration, writeable));
41
+ }
33
42
  /**
34
43
  * Convert all monetary fields on an internal movement.
35
44
  *
@@ -40,6 +49,11 @@ function getWarehouseInternalMovementWithPrice(order, writeable) {
40
49
  const convertToPrice = writeable ? utils_1.convertDecimalToInt : utils_1.convertIntToDecimal;
41
50
  return {
42
51
  ...order,
52
+ ...(order.iterations != null
53
+ ? {
54
+ iterations: getWarehouseInternalMovementIterationsWithPrice(order.iterations, writeable),
55
+ }
56
+ : {}),
43
57
  ...(order.grand_total != null ? { grand_total: convertToPrice(order.grand_total) } : {}),
44
58
  ...(order.gst_amount != null ? { gst_amount: convertToPrice(order.gst_amount) } : {}),
45
59
  ...(order.amount_collected != null ? { amount_collected: convertToPrice(order.amount_collected) } : {}),
@@ -1,4 +1,3 @@
1
1
  import { IExpenseDetails } from '../../schemas';
2
- export declare function getExpenseDetailsWithCents<T extends Partial<IExpenseDetails> | IExpenseDetails>(expense: T): T;
3
2
  export declare function getExpenseDetailsFromCents<T extends Partial<IExpenseDetails> | IExpenseDetails>(expense: T): T;
4
3
  export declare function getFetchedExpenseDetails(expenses: IExpenseDetails[]): IExpenseDetails[];
@@ -1,25 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getExpenseDetailsWithCents = getExpenseDetailsWithCents;
4
3
  exports.getExpenseDetailsFromCents = getExpenseDetailsFromCents;
5
4
  exports.getFetchedExpenseDetails = getFetchedExpenseDetails;
6
- const store_1 = require("../store");
7
5
  const price_conversion_1 = require("./price-conversion");
8
- function getExpenseDetailsWithCents(expense) {
9
- return {
10
- ...expense,
11
- ...(typeof expense.amount === 'number'
12
- ? {
13
- amount: (0, price_conversion_1.convertPriceToCents)(expense.amount),
14
- }
15
- : {}),
16
- ...(expense.payments != null
17
- ? {
18
- payments: (0, store_1.getOrderPaymentsWithPrice)(expense.payments, price_conversion_1.convertPriceToCents),
19
- }
20
- : {}),
21
- };
22
- }
23
6
  function getExpenseDetailsFromCents(expense) {
24
7
  return {
25
8
  ...expense,
@@ -28,11 +11,6 @@ function getExpenseDetailsFromCents(expense) {
28
11
  amount: (0, price_conversion_1.convertPriceFromCents)(expense.amount),
29
12
  }
30
13
  : {}),
31
- ...(expense.payments != null
32
- ? {
33
- payments: (0, store_1.getOrderPaymentsWithPrice)(expense.payments, price_conversion_1.convertPriceFromCents),
34
- }
35
- : {}),
36
14
  };
37
15
  }
38
16
  function getFetchedExpenseDetails(expenses) {
@@ -19,67 +19,6 @@ export declare const ExpenseDetailsSchema: Schema<any, import("mongoose").Model<
19
19
  expense_sub_category_id: import("mongoose").Types.ObjectId;
20
20
  amount: number;
21
21
  payment_method: string;
22
- payments: import("mongoose").Types.DocumentArray<{
23
- payment_type: string;
24
- payment_status: import("../../constants").PAYMENT_STATUS_ENUM;
25
- card_details: {
26
- transaction_id: string;
27
- payment_provider_linked_customer_id: string;
28
- card_number: string;
29
- card_type: string;
30
- card_holder_name: string;
31
- card_charges: number;
32
- card_country_code: string;
33
- payment_provider: import("../../constants").PAYMENT_PROVIDERS_ENUM;
34
- };
35
- amount_paid: number;
36
- amount_due: number;
37
- amount_refunded: number;
38
- payment_id: string;
39
- _id?: import("mongoose").Types.ObjectId | null | undefined;
40
- refund_reason?: string | null | undefined;
41
- note?: string | null | undefined;
42
- }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId | null | undefined, any, {
43
- payment_type: string;
44
- payment_status: import("../../constants").PAYMENT_STATUS_ENUM;
45
- card_details: {
46
- transaction_id: string;
47
- payment_provider_linked_customer_id: string;
48
- card_number: string;
49
- card_type: string;
50
- card_holder_name: string;
51
- card_charges: number;
52
- card_country_code: string;
53
- payment_provider: import("../../constants").PAYMENT_PROVIDERS_ENUM;
54
- };
55
- amount_paid: number;
56
- amount_due: number;
57
- amount_refunded: number;
58
- payment_id: string;
59
- _id?: import("mongoose").Types.ObjectId | null | undefined;
60
- refund_reason?: string | null | undefined;
61
- note?: string | null | undefined;
62
- }> & {
63
- payment_type: string;
64
- payment_status: import("../../constants").PAYMENT_STATUS_ENUM;
65
- card_details: {
66
- transaction_id: string;
67
- payment_provider_linked_customer_id: string;
68
- card_number: string;
69
- card_type: string;
70
- card_holder_name: string;
71
- card_charges: number;
72
- card_country_code: string;
73
- payment_provider: import("../../constants").PAYMENT_PROVIDERS_ENUM;
74
- };
75
- amount_paid: number;
76
- amount_due: number;
77
- amount_refunded: number;
78
- payment_id: string;
79
- _id?: import("mongoose").Types.ObjectId | null | undefined;
80
- refund_reason?: string | null | undefined;
81
- note?: string | null | undefined;
82
- }>;
83
22
  date_incurred: NativeDate;
84
23
  date_incurred_mins: number;
85
24
  receipt_image?: string | null | undefined;
@@ -104,67 +43,6 @@ export declare const ExpenseDetailsSchema: Schema<any, import("mongoose").Model<
104
43
  expense_sub_category_id: import("mongoose").Types.ObjectId;
105
44
  amount: number;
106
45
  payment_method: string;
107
- payments: import("mongoose").Types.DocumentArray<{
108
- payment_type: string;
109
- payment_status: import("../../constants").PAYMENT_STATUS_ENUM;
110
- card_details: {
111
- transaction_id: string;
112
- payment_provider_linked_customer_id: string;
113
- card_number: string;
114
- card_type: string;
115
- card_holder_name: string;
116
- card_charges: number;
117
- card_country_code: string;
118
- payment_provider: import("../../constants").PAYMENT_PROVIDERS_ENUM;
119
- };
120
- amount_paid: number;
121
- amount_due: number;
122
- amount_refunded: number;
123
- payment_id: string;
124
- _id?: import("mongoose").Types.ObjectId | null | undefined;
125
- refund_reason?: string | null | undefined;
126
- note?: string | null | undefined;
127
- }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId | null | undefined, any, {
128
- payment_type: string;
129
- payment_status: import("../../constants").PAYMENT_STATUS_ENUM;
130
- card_details: {
131
- transaction_id: string;
132
- payment_provider_linked_customer_id: string;
133
- card_number: string;
134
- card_type: string;
135
- card_holder_name: string;
136
- card_charges: number;
137
- card_country_code: string;
138
- payment_provider: import("../../constants").PAYMENT_PROVIDERS_ENUM;
139
- };
140
- amount_paid: number;
141
- amount_due: number;
142
- amount_refunded: number;
143
- payment_id: string;
144
- _id?: import("mongoose").Types.ObjectId | null | undefined;
145
- refund_reason?: string | null | undefined;
146
- note?: string | null | undefined;
147
- }> & {
148
- payment_type: string;
149
- payment_status: import("../../constants").PAYMENT_STATUS_ENUM;
150
- card_details: {
151
- transaction_id: string;
152
- payment_provider_linked_customer_id: string;
153
- card_number: string;
154
- card_type: string;
155
- card_holder_name: string;
156
- card_charges: number;
157
- card_country_code: string;
158
- payment_provider: import("../../constants").PAYMENT_PROVIDERS_ENUM;
159
- };
160
- amount_paid: number;
161
- amount_due: number;
162
- amount_refunded: number;
163
- payment_id: string;
164
- _id?: import("mongoose").Types.ObjectId | null | undefined;
165
- refund_reason?: string | null | undefined;
166
- note?: string | null | undefined;
167
- }>;
168
46
  date_incurred: NativeDate;
169
47
  date_incurred_mins: number;
170
48
  receipt_image?: string | null | undefined;
@@ -189,67 +67,6 @@ export declare const ExpenseDetailsSchema: Schema<any, import("mongoose").Model<
189
67
  expense_sub_category_id: import("mongoose").Types.ObjectId;
190
68
  amount: number;
191
69
  payment_method: string;
192
- payments: import("mongoose").Types.DocumentArray<{
193
- payment_type: string;
194
- payment_status: import("../../constants").PAYMENT_STATUS_ENUM;
195
- card_details: {
196
- transaction_id: string;
197
- payment_provider_linked_customer_id: string;
198
- card_number: string;
199
- card_type: string;
200
- card_holder_name: string;
201
- card_charges: number;
202
- card_country_code: string;
203
- payment_provider: import("../../constants").PAYMENT_PROVIDERS_ENUM;
204
- };
205
- amount_paid: number;
206
- amount_due: number;
207
- amount_refunded: number;
208
- payment_id: string;
209
- _id?: import("mongoose").Types.ObjectId | null | undefined;
210
- refund_reason?: string | null | undefined;
211
- note?: string | null | undefined;
212
- }, import("mongoose").Types.Subdocument<import("mongoose").Types.ObjectId | null | undefined, any, {
213
- payment_type: string;
214
- payment_status: import("../../constants").PAYMENT_STATUS_ENUM;
215
- card_details: {
216
- transaction_id: string;
217
- payment_provider_linked_customer_id: string;
218
- card_number: string;
219
- card_type: string;
220
- card_holder_name: string;
221
- card_charges: number;
222
- card_country_code: string;
223
- payment_provider: import("../../constants").PAYMENT_PROVIDERS_ENUM;
224
- };
225
- amount_paid: number;
226
- amount_due: number;
227
- amount_refunded: number;
228
- payment_id: string;
229
- _id?: import("mongoose").Types.ObjectId | null | undefined;
230
- refund_reason?: string | null | undefined;
231
- note?: string | null | undefined;
232
- }> & {
233
- payment_type: string;
234
- payment_status: import("../../constants").PAYMENT_STATUS_ENUM;
235
- card_details: {
236
- transaction_id: string;
237
- payment_provider_linked_customer_id: string;
238
- card_number: string;
239
- card_type: string;
240
- card_holder_name: string;
241
- card_charges: number;
242
- card_country_code: string;
243
- payment_provider: import("../../constants").PAYMENT_PROVIDERS_ENUM;
244
- };
245
- amount_paid: number;
246
- amount_due: number;
247
- amount_refunded: number;
248
- payment_id: string;
249
- _id?: import("mongoose").Types.ObjectId | null | undefined;
250
- refund_reason?: string | null | undefined;
251
- note?: string | null | undefined;
252
- }>;
253
70
  date_incurred: NativeDate;
254
71
  date_incurred_mins: number;
255
72
  receipt_image?: string | null | undefined;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EXPENSE_DETAILS_COLLECTION_NAME = exports.ExpenseDetailsSchema = void 0;
4
4
  const mongoose_1 = require("mongoose");
5
5
  const constants_1 = require("../../constants");
6
- const common_models_1 = require("./common-models");
7
6
  const ExpenseReacurringSchema = new mongoose_1.Schema({
8
7
  is_recurring: {
9
8
  type: Boolean,
@@ -59,10 +58,6 @@ exports.ExpenseDetailsSchema = new mongoose_1.Schema({
59
58
  type: String,
60
59
  default: '',
61
60
  },
62
- payments: {
63
- type: [common_models_1.PaymentsSchema],
64
- default: [],
65
- },
66
61
  recurring: {
67
62
  type: ExpenseReacurringSchema,
68
63
  required: false,