@managesome/eposmatic-toolkit 0.2.754 → 0.2.755
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,4 +1,8 @@
|
|
|
1
|
-
import { ITenantInventoryEntry, IWarehouseInventoryEntry, IWarehouseInventoryEntryItem } from '../../schemas';
|
|
1
|
+
import { ITenantInventoryEntry, IWarehouseInventoryEntry, IWarehouseInventoryEntryItem, IWarehouseInventoryEntryPreparationEntry } from '../../schemas';
|
|
2
|
+
/**
|
|
3
|
+
* Convert the quantities and costs on a batch ingredient map.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getPreparationWithPrice<T extends Partial<IWarehouseInventoryEntryPreparationEntry>>(preparation: Record<string, T>, convertToPrice: (price: number) => number): Record<string, T>;
|
|
2
6
|
/**
|
|
3
7
|
* Convert every quantity and money field on every inventory entry item.
|
|
4
8
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPreparationWithPrice = getPreparationWithPrice;
|
|
3
4
|
exports.getInventoryEntryItemsWithPrice = getInventoryEntryItemsWithPrice;
|
|
4
5
|
exports.getWarehouseInventoryEntryWithPrice = getWarehouseInventoryEntryWithPrice;
|
|
5
6
|
exports.getWarehouseInventoryEntriesWithPrice = getWarehouseInventoryEntriesWithPrice;
|
|
@@ -22,11 +23,11 @@ function getPreparationWithPrice(preparation, convertToPrice) {
|
|
|
22
23
|
for (const [key, value] of Object.entries(preparation)) {
|
|
23
24
|
converted[key] = {
|
|
24
25
|
...value,
|
|
25
|
-
usage_quantity: convertToPrice(value.usage_quantity),
|
|
26
|
-
waste_quantity: convertToPrice(value.waste_quantity),
|
|
27
|
-
unit_cost: convertToPrice(value.unit_cost),
|
|
28
|
-
final_cost: convertToPrice(value.final_cost),
|
|
29
|
-
waste_cost: convertToPrice(value.waste_cost),
|
|
26
|
+
...(typeof value.usage_quantity === 'number' ? { usage_quantity: convertToPrice(value.usage_quantity) } : {}),
|
|
27
|
+
...(typeof value.waste_quantity === 'number' ? { waste_quantity: convertToPrice(value.waste_quantity) } : {}),
|
|
28
|
+
...(typeof value.unit_cost === 'number' ? { unit_cost: convertToPrice(value.unit_cost) } : {}),
|
|
29
|
+
...(typeof value.final_cost === 'number' ? { final_cost: convertToPrice(value.final_cost) } : {}),
|
|
30
|
+
...(typeof value.waste_cost === 'number' ? { waste_cost: convertToPrice(value.waste_cost) } : {}),
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
return converted;
|
|
@@ -44,12 +44,10 @@ const TenantInventoryEntryItemSchema = new mongoose_1.Schema({
|
|
|
44
44
|
},
|
|
45
45
|
transaction_quantity: {
|
|
46
46
|
type: Number,
|
|
47
|
-
min: 0,
|
|
48
47
|
required: true,
|
|
49
48
|
},
|
|
50
49
|
stock_price: {
|
|
51
50
|
type: Number,
|
|
52
|
-
min: 0,
|
|
53
51
|
required: false,
|
|
54
52
|
},
|
|
55
53
|
preparation: {
|
|
@@ -110,7 +108,6 @@ exports.TenantInventoryEntrySchema = new mongoose_1.Schema({
|
|
|
110
108
|
},
|
|
111
109
|
total_stock_price: {
|
|
112
110
|
type: Number,
|
|
113
|
-
min: 0,
|
|
114
111
|
required: true,
|
|
115
112
|
default: 0,
|
|
116
113
|
},
|
|
@@ -44,12 +44,10 @@ const WarehouseInventoryEntryItemSchema = new mongoose_1.Schema({
|
|
|
44
44
|
},
|
|
45
45
|
transaction_quantity: {
|
|
46
46
|
type: Number,
|
|
47
|
-
min: 0,
|
|
48
47
|
required: true,
|
|
49
48
|
},
|
|
50
49
|
stock_price: {
|
|
51
50
|
type: Number,
|
|
52
|
-
min: 0,
|
|
53
51
|
required: false,
|
|
54
52
|
},
|
|
55
53
|
preparation: {
|
|
@@ -101,9 +99,9 @@ exports.WarehouseInventoryEntrySchema = new mongoose_1.Schema({
|
|
|
101
99
|
required: true,
|
|
102
100
|
default: 0,
|
|
103
101
|
},
|
|
102
|
+
// Negative when the entry only moves stock out of the warehouse.
|
|
104
103
|
total_stock_price: {
|
|
105
104
|
type: Number,
|
|
106
|
-
min: 0,
|
|
107
105
|
required: true,
|
|
108
106
|
default: 0,
|
|
109
107
|
},
|