@managesome/eposmatic-toolkit 0.2.598 → 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.
- package/lib/helpers/order/generate-warehouse-internal-movement.d.ts +2 -1
- package/lib/helpers/order/generate-warehouse-internal-movement.js +50 -0
- package/lib/helpers/store/common-warehouse-internal-movement-actions.d.ts +6 -2
- package/lib/helpers/store/common-warehouse-internal-movement-actions.js +14 -0
- package/lib/schemas/models/warehouse_internal_movements.d.ts +1260 -0
- package/lib/schemas/models/warehouse_internal_movements.js +78 -1
- package/lib/schemas/types/warehouse_internal_movements.d.ts +17 -13
- package/package.json +1 -1
|
@@ -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) } : {}),
|