@rytass/wms-module-core 0.4.0 → 0.6.0
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/README.md +69 -7
- package/docs/api-reference.md +58 -10
- package/docs/custom-entities.md +105 -68
- package/index.cjs.js +1263 -151
- package/index.js +10 -0
- package/lib/constants/index.d.ts +2 -0
- package/lib/constants/inventory-count-status.d.ts +19 -0
- package/lib/constants/inventory-count-status.js +22 -0
- package/lib/constants/operations.d.ts +34 -0
- package/lib/constants/operations.js +66 -0
- package/lib/constants/stock-status.d.ts +2 -0
- package/lib/constants/stock-status.js +4 -0
- package/lib/core.module.js +91 -30
- package/lib/events/index.d.ts +1 -0
- package/lib/events/inventory-count-lock.subscriber.d.ts +38 -0
- package/lib/events/inventory-count-lock.subscriber.js +98 -0
- package/lib/events/stock-change.subscriber.js +6 -0
- package/lib/events/wms-event.types.d.ts +2 -2
- package/lib/models/extensions/allocate-inventory-order/allocate-inventory-order-item.entity.js +1 -0
- package/lib/models/extensions/hold-inventory-order/hold-inventory-order-item.entity.js +1 -0
- package/lib/models/extensions/index.d.ts +3 -0
- package/lib/models/extensions/inventory-count-order/inventory-count-order-change.entity.d.ts +20 -0
- package/lib/models/extensions/inventory-count-order/inventory-count-order-change.entity.js +50 -0
- package/lib/models/extensions/inventory-count-order/inventory-count-order-item.entity.d.ts +39 -0
- package/lib/models/extensions/inventory-count-order/inventory-count-order-item.entity.js +123 -0
- package/lib/models/extensions/inventory-count-order/inventory-count-order.entity.d.ts +50 -0
- package/lib/models/extensions/inventory-count-order/inventory-count-order.entity.js +155 -0
- package/lib/models/extensions/merge-batch-order/merge-batch-order-item.entity.js +1 -0
- package/lib/models/extensions/quality-inspection-order/quality-inspection-order-item.entity.js +1 -0
- package/lib/models/extensions/reclassify-inventory-order/reclassify-inventory-order-item.entity.js +1 -0
- package/lib/models/extensions/scrape-order/scrape-order-item.entity.js +1 -0
- package/lib/models/extensions/split-batch-order/split-batch-order-item.entity.js +1 -0
- package/lib/models/extensions/transfer-customer-order/transfer-customer-order-item.entity.js +1 -0
- package/lib/models/extensions/transfer-order/transfer-order-item.entity.js +1 -0
- package/lib/models/extensions/transfer-vendor-order/transfer-vendor-order-item.entity.js +1 -0
- package/lib/models/index.d.ts +1 -0
- package/lib/models/metadata/index.d.ts +1 -0
- package/lib/models/metadata/order.entity.d.ts +9 -0
- package/lib/models/metadata/order.entity.js +5 -0
- package/lib/models/models.module.js +22 -8
- package/lib/models/wms-entities.d.ts +45 -0
- package/lib/models/wms-entities.js +82 -0
- package/lib/services/allocate-inventory-order.service.d.ts +3 -1
- package/lib/services/allocate-inventory-order.service.js +13 -6
- package/lib/services/batch.service.js +8 -3
- package/lib/services/hold-inventory-order.service.d.ts +3 -1
- package/lib/services/hold-inventory-order.service.js +13 -6
- package/lib/services/index.d.ts +1 -0
- package/lib/services/inventory-count-order.service.d.ts +143 -0
- package/lib/services/inventory-count-order.service.js +521 -0
- package/lib/services/loader.service.js +5 -0
- package/lib/services/location.service.js +5 -0
- package/lib/services/material.service.d.ts +1 -15
- package/lib/services/material.service.js +5 -20
- package/lib/services/merge-batch-order.service.d.ts +3 -1
- package/lib/services/merge-batch-order.service.js +16 -9
- package/lib/services/quality-inspection-order.service.d.ts +3 -1
- package/lib/services/quality-inspection-order.service.js +15 -8
- package/lib/services/receive-inventory-order.service.d.ts +3 -1
- package/lib/services/receive-inventory-order.service.js +18 -11
- package/lib/services/reclassify-inventory-order.service.d.ts +3 -1
- package/lib/services/reclassify-inventory-order.service.js +16 -9
- package/lib/services/scrape.service.d.ts +3 -1
- package/lib/services/scrape.service.js +12 -5
- package/lib/services/ship-inventory-order.service.d.ts +3 -1
- package/lib/services/ship-inventory-order.service.js +21 -14
- package/lib/services/split-batch-order.service.d.ts +3 -1
- package/lib/services/split-batch-order.service.js +16 -9
- package/lib/services/stock.service.d.ts +3 -1
- package/lib/services/stock.service.js +17 -10
- package/lib/services/transfer-customer-order.service.d.ts +3 -1
- package/lib/services/transfer-customer-order.service.js +15 -8
- package/lib/services/transfer-order.service.d.ts +3 -1
- package/lib/services/transfer-order.service.js +14 -7
- package/lib/services/transfer-vendor-order.service.d.ts +3 -1
- package/lib/services/transfer-vendor-order.service.js +15 -8
- package/lib/services/unit.service.js +5 -0
- package/lib/services/warehouse-map.service.d.ts +14 -2
- package/lib/services/warehouse-map.service.js +21 -9
- package/package.json +2 -2
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { __decorate, __metadata } from 'tslib';
|
|
2
|
+
import { OrderEntity } from '@rytass/wms-base-nestjs-module';
|
|
3
|
+
import { PrimaryGeneratedColumn, Column, OneToOne, JoinColumn, ManyToOne, Entity } from 'typeorm';
|
|
4
|
+
import { InventoryCountOrderItemEntityClass } from './inventory-count-order-item.entity.js';
|
|
5
|
+
|
|
6
|
+
const InventoryCountOrderChangeEntity = Symbol('InventoryCountOrderChangeEntity');
|
|
7
|
+
/**
|
|
8
|
+
* The stock movement a settled count line produced.
|
|
9
|
+
*
|
|
10
|
+
* `quantityChanged` carries the sign, exactly like every other `*_order_change`
|
|
11
|
+
* table: positive is a surplus (盤盈), negative a shortage (盤虧).
|
|
12
|
+
* `StockChangeSubscriber` reads the sign to pick between `stock.count-gained`
|
|
13
|
+
* and `stock.count-lost`, so nothing here has to emit events itself.
|
|
14
|
+
*
|
|
15
|
+
* Lines whose count matched the books produce no row at all.
|
|
16
|
+
*/
|
|
17
|
+
let InventoryCountOrderChangeEntityClass = class InventoryCountOrderChangeEntityClass {
|
|
18
|
+
id;
|
|
19
|
+
itemId;
|
|
20
|
+
quantityChanged;
|
|
21
|
+
order;
|
|
22
|
+
item;
|
|
23
|
+
};
|
|
24
|
+
__decorate([
|
|
25
|
+
PrimaryGeneratedColumn('uuid'),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], InventoryCountOrderChangeEntityClass.prototype, "id", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
Column({ type: 'uuid' }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], InventoryCountOrderChangeEntityClass.prototype, "itemId", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
Column({ type: 'numeric' }),
|
|
34
|
+
__metadata("design:type", Number)
|
|
35
|
+
], InventoryCountOrderChangeEntityClass.prototype, "quantityChanged", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
OneToOne('orders'),
|
|
38
|
+
JoinColumn({ name: 'id', referencedColumnName: 'id' }),
|
|
39
|
+
__metadata("design:type", OrderEntity)
|
|
40
|
+
], InventoryCountOrderChangeEntityClass.prototype, "order", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
ManyToOne('inventory_count_order_items', (item) => item.changes),
|
|
43
|
+
JoinColumn({ name: 'itemId', referencedColumnName: 'id' }),
|
|
44
|
+
__metadata("design:type", InventoryCountOrderItemEntityClass)
|
|
45
|
+
], InventoryCountOrderChangeEntityClass.prototype, "item", void 0);
|
|
46
|
+
InventoryCountOrderChangeEntityClass = __decorate([
|
|
47
|
+
Entity('inventory_count_order_changes')
|
|
48
|
+
], InventoryCountOrderChangeEntityClass);
|
|
49
|
+
|
|
50
|
+
export { InventoryCountOrderChangeEntity, InventoryCountOrderChangeEntityClass };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LoadersEntityClass, LocationEntityClass } from '../../metadata';
|
|
2
|
+
import { InventoryCountOrderEntityClass } from './inventory-count-order.entity';
|
|
3
|
+
import { InventoryCountOrderChangeEntityClass } from './inventory-count-order-change.entity';
|
|
4
|
+
export declare const InventoryCountOrderItemEntity: unique symbol;
|
|
5
|
+
/**
|
|
6
|
+
* One line of the count sheet.
|
|
7
|
+
*
|
|
8
|
+
* Two flavours share the table, told apart by {@link isAddition}:
|
|
9
|
+
*
|
|
10
|
+
* - a **scoped line**, expanded from the order's locations when the order is
|
|
11
|
+
* created. `bookQuantity` is the snapshot taken at "開始盤點".
|
|
12
|
+
* - an **addition** (盤盈), added by hand during counting for stock the books do
|
|
13
|
+
* not know about at all. `bookQuantity` is `0` by definition, and it is the
|
|
14
|
+
* only flavour a user may delete.
|
|
15
|
+
*/
|
|
16
|
+
export declare class InventoryCountOrderItemEntityClass {
|
|
17
|
+
id: string;
|
|
18
|
+
orderId: string;
|
|
19
|
+
materialId: string;
|
|
20
|
+
batchId: string;
|
|
21
|
+
locationId: string | null;
|
|
22
|
+
loaderId: string | null;
|
|
23
|
+
/**
|
|
24
|
+
* The unit the counted quantity is expressed in; `null` means the material's
|
|
25
|
+
* base unit. Settlement converts through the material's conversion factor
|
|
26
|
+
* before comparing with {@link bookQuantity}, which is always in base units.
|
|
27
|
+
*/
|
|
28
|
+
unitId: string | null;
|
|
29
|
+
/** Ledger quantity in base units, frozen when counting started. */
|
|
30
|
+
bookQuantity: number;
|
|
31
|
+
/** What was actually found, in {@link unitId}. `null` until someone counts. */
|
|
32
|
+
countedQuantity: number | null;
|
|
33
|
+
/** `true` for a line added during counting for unbooked stock (盤盈). */
|
|
34
|
+
isAddition: boolean;
|
|
35
|
+
location: LocationEntityClass;
|
|
36
|
+
loader: LoadersEntityClass;
|
|
37
|
+
order: InventoryCountOrderEntityClass;
|
|
38
|
+
changes: InventoryCountOrderChangeEntityClass[];
|
|
39
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { __decorate, __metadata } from 'tslib';
|
|
2
|
+
import { PrimaryGeneratedColumn, Column, Index, ManyToOne, JoinColumn, OneToMany, Entity, TableInheritance } from 'typeorm';
|
|
3
|
+
import '../../metadata/batch.entity.js';
|
|
4
|
+
import '../../metadata/batch-group.entity.js';
|
|
5
|
+
import { LoadersEntityClass } from '../../metadata/loader.entity.js';
|
|
6
|
+
import '../../metadata/loader-type.entity.js';
|
|
7
|
+
import '../../metadata/loader-unit.entity.js';
|
|
8
|
+
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
|
+
import '../../metadata/material.entity.js';
|
|
10
|
+
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
12
|
+
import '../../metadata/sale-order.entity.js';
|
|
13
|
+
import '../../metadata/stock.entity.js';
|
|
14
|
+
import '../../metadata/unit.entity.js';
|
|
15
|
+
import { InventoryCountOrderEntityClass } from './inventory-count-order.entity.js';
|
|
16
|
+
|
|
17
|
+
const InventoryCountOrderItemEntity = Symbol('InventoryCountOrderItemEntity');
|
|
18
|
+
/**
|
|
19
|
+
* One line of the count sheet.
|
|
20
|
+
*
|
|
21
|
+
* Two flavours share the table, told apart by {@link isAddition}:
|
|
22
|
+
*
|
|
23
|
+
* - a **scoped line**, expanded from the order's locations when the order is
|
|
24
|
+
* created. `bookQuantity` is the snapshot taken at "開始盤點".
|
|
25
|
+
* - an **addition** (盤盈), added by hand during counting for stock the books do
|
|
26
|
+
* not know about at all. `bookQuantity` is `0` by definition, and it is the
|
|
27
|
+
* only flavour a user may delete.
|
|
28
|
+
*/
|
|
29
|
+
let InventoryCountOrderItemEntityClass = class InventoryCountOrderItemEntityClass {
|
|
30
|
+
id;
|
|
31
|
+
orderId;
|
|
32
|
+
materialId;
|
|
33
|
+
batchId;
|
|
34
|
+
locationId;
|
|
35
|
+
loaderId;
|
|
36
|
+
/**
|
|
37
|
+
* The unit the counted quantity is expressed in; `null` means the material's
|
|
38
|
+
* base unit. Settlement converts through the material's conversion factor
|
|
39
|
+
* before comparing with {@link bookQuantity}, which is always in base units.
|
|
40
|
+
*/
|
|
41
|
+
unitId;
|
|
42
|
+
/** Ledger quantity in base units, frozen when counting started. */
|
|
43
|
+
bookQuantity;
|
|
44
|
+
/** What was actually found, in {@link unitId}. `null` until someone counts. */
|
|
45
|
+
countedQuantity;
|
|
46
|
+
/** `true` for a line added during counting for unbooked stock (盤盈). */
|
|
47
|
+
isAddition;
|
|
48
|
+
location;
|
|
49
|
+
loader;
|
|
50
|
+
order;
|
|
51
|
+
changes;
|
|
52
|
+
};
|
|
53
|
+
__decorate([
|
|
54
|
+
PrimaryGeneratedColumn('uuid'),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], InventoryCountOrderItemEntityClass.prototype, "id", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
Column({ type: 'uuid' }),
|
|
59
|
+
Index(),
|
|
60
|
+
__metadata("design:type", String)
|
|
61
|
+
], InventoryCountOrderItemEntityClass.prototype, "orderId", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
Column({ type: 'uuid' }),
|
|
64
|
+
Index(),
|
|
65
|
+
__metadata("design:type", String)
|
|
66
|
+
], InventoryCountOrderItemEntityClass.prototype, "materialId", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
Column({ type: 'uuid' }),
|
|
69
|
+
Index(),
|
|
70
|
+
__metadata("design:type", String)
|
|
71
|
+
], InventoryCountOrderItemEntityClass.prototype, "batchId", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
Column({ type: 'uuid', nullable: true }),
|
|
74
|
+
Index(),
|
|
75
|
+
__metadata("design:type", Object)
|
|
76
|
+
], InventoryCountOrderItemEntityClass.prototype, "locationId", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
Column({ type: 'uuid', nullable: true }),
|
|
79
|
+
Index(),
|
|
80
|
+
__metadata("design:type", Object)
|
|
81
|
+
], InventoryCountOrderItemEntityClass.prototype, "loaderId", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
Column({ type: 'uuid', nullable: true }),
|
|
84
|
+
Index(),
|
|
85
|
+
__metadata("design:type", Object)
|
|
86
|
+
], InventoryCountOrderItemEntityClass.prototype, "unitId", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
Column({ type: 'numeric', default: 0 }),
|
|
89
|
+
__metadata("design:type", Number)
|
|
90
|
+
], InventoryCountOrderItemEntityClass.prototype, "bookQuantity", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
Column({ type: 'numeric', nullable: true }),
|
|
93
|
+
__metadata("design:type", Object)
|
|
94
|
+
], InventoryCountOrderItemEntityClass.prototype, "countedQuantity", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
Column({ type: 'boolean', default: false }),
|
|
97
|
+
__metadata("design:type", Boolean)
|
|
98
|
+
], InventoryCountOrderItemEntityClass.prototype, "isAddition", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
ManyToOne('locations'),
|
|
101
|
+
JoinColumn({ name: 'locationId', referencedColumnName: 'id' }),
|
|
102
|
+
__metadata("design:type", LocationEntityClass)
|
|
103
|
+
], InventoryCountOrderItemEntityClass.prototype, "location", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
ManyToOne('loaders'),
|
|
106
|
+
JoinColumn({ name: 'loaderId', referencedColumnName: 'id' }),
|
|
107
|
+
__metadata("design:type", LoadersEntityClass)
|
|
108
|
+
], InventoryCountOrderItemEntityClass.prototype, "loader", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
ManyToOne('inventory_count_orders', (order) => order.items),
|
|
111
|
+
JoinColumn({ name: 'orderId', referencedColumnName: 'id' }),
|
|
112
|
+
__metadata("design:type", InventoryCountOrderEntityClass)
|
|
113
|
+
], InventoryCountOrderItemEntityClass.prototype, "order", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
OneToMany('inventory_count_order_changes', (change) => change.item),
|
|
116
|
+
__metadata("design:type", Array)
|
|
117
|
+
], InventoryCountOrderItemEntityClass.prototype, "changes", void 0);
|
|
118
|
+
InventoryCountOrderItemEntityClass = __decorate([
|
|
119
|
+
Entity('inventory_count_order_items'),
|
|
120
|
+
TableInheritance({ column: { type: 'varchar', name: 'entityName' } })
|
|
121
|
+
], InventoryCountOrderItemEntityClass);
|
|
122
|
+
|
|
123
|
+
export { InventoryCountOrderItemEntity, InventoryCountOrderItemEntityClass };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LocationEntityClass } from '../../metadata';
|
|
2
|
+
import { InventoryCountStatus } from '../../../constants/inventory-count-status';
|
|
3
|
+
import { InventoryCountOrderItemEntityClass } from './inventory-count-order-item.entity';
|
|
4
|
+
export declare const InventoryCountOrderEntity: unique symbol;
|
|
5
|
+
export declare class InventoryCountOrderEntityClass {
|
|
6
|
+
id: string;
|
|
7
|
+
key: string;
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* The count's base date, chosen when the order is created.
|
|
11
|
+
*
|
|
12
|
+
* It is the *business* date of the whole exercise: the settlement's stock
|
|
13
|
+
* adjustments are reported under this date, not under the day someone happened
|
|
14
|
+
* to press "執行盤差". `createdAt` keeps the real wall-clock time for auditing,
|
|
15
|
+
* so the two never have to lie for each other.
|
|
16
|
+
*/
|
|
17
|
+
countDate: string;
|
|
18
|
+
status: InventoryCountStatus;
|
|
19
|
+
/** Who created the order, in whatever id space the host uses. */
|
|
20
|
+
createdBy: string | null;
|
|
21
|
+
/** When counting started — the moment `bookQuantity` was snapshotted. */
|
|
22
|
+
startedAt: Date | null;
|
|
23
|
+
/** When the variance was settled. */
|
|
24
|
+
settledAt: Date | null;
|
|
25
|
+
cancelledAt: Date | null;
|
|
26
|
+
createdAt: Date;
|
|
27
|
+
items: InventoryCountOrderItemEntityClass[];
|
|
28
|
+
locations: InventoryCountOrderLocationEntityClass[];
|
|
29
|
+
}
|
|
30
|
+
export declare const InventoryCountOrderLocationEntity: unique symbol;
|
|
31
|
+
/**
|
|
32
|
+
* One row per location in the order's scope, **already expanded** to include
|
|
33
|
+
* every descendant of the locations the user picked.
|
|
34
|
+
*
|
|
35
|
+
* The scope is materialised at creation instead of being recomputed from the
|
|
36
|
+
* chosen roots because it is read on the hot path: while an order is counting,
|
|
37
|
+
* every single stock movement in the system has to ask "is this location
|
|
38
|
+
* locked?". `LocationEntity` is a plain `parent`/`children` adjacency list with
|
|
39
|
+
* no materialised path, so answering that from the tree would mean a recursive
|
|
40
|
+
* CTE per movement.
|
|
41
|
+
*/
|
|
42
|
+
export declare class InventoryCountOrderLocationEntityClass {
|
|
43
|
+
id: string;
|
|
44
|
+
orderId: string;
|
|
45
|
+
locationId: string;
|
|
46
|
+
/** `true` for the locations the user picked, `false` for descendants. */
|
|
47
|
+
isRoot: boolean;
|
|
48
|
+
order: InventoryCountOrderEntityClass;
|
|
49
|
+
location: LocationEntityClass;
|
|
50
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { __decorate, __metadata } from 'tslib';
|
|
2
|
+
import { PrimaryGeneratedColumn, Column, Index, CreateDateColumn, OneToMany, Entity, TableInheritance, ManyToOne, JoinColumn } from 'typeorm';
|
|
3
|
+
import '../../metadata/batch.entity.js';
|
|
4
|
+
import '../../metadata/batch-group.entity.js';
|
|
5
|
+
import '../../metadata/loader.entity.js';
|
|
6
|
+
import '../../metadata/loader-type.entity.js';
|
|
7
|
+
import '../../metadata/loader-unit.entity.js';
|
|
8
|
+
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
|
+
import '../../metadata/material.entity.js';
|
|
10
|
+
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
12
|
+
import '../../metadata/sale-order.entity.js';
|
|
13
|
+
import '../../metadata/stock.entity.js';
|
|
14
|
+
import '../../metadata/unit.entity.js';
|
|
15
|
+
import { InventoryCountStatus } from '../../../constants/inventory-count-status.js';
|
|
16
|
+
|
|
17
|
+
const InventoryCountOrderEntity = Symbol('InventoryCountOrderEntity');
|
|
18
|
+
let InventoryCountOrderEntityClass = class InventoryCountOrderEntityClass {
|
|
19
|
+
id;
|
|
20
|
+
key;
|
|
21
|
+
name;
|
|
22
|
+
/**
|
|
23
|
+
* The count's base date, chosen when the order is created.
|
|
24
|
+
*
|
|
25
|
+
* It is the *business* date of the whole exercise: the settlement's stock
|
|
26
|
+
* adjustments are reported under this date, not under the day someone happened
|
|
27
|
+
* to press "執行盤差". `createdAt` keeps the real wall-clock time for auditing,
|
|
28
|
+
* so the two never have to lie for each other.
|
|
29
|
+
*/
|
|
30
|
+
countDate;
|
|
31
|
+
status;
|
|
32
|
+
/** Who created the order, in whatever id space the host uses. */
|
|
33
|
+
createdBy;
|
|
34
|
+
/** When counting started — the moment `bookQuantity` was snapshotted. */
|
|
35
|
+
startedAt;
|
|
36
|
+
/** When the variance was settled. */
|
|
37
|
+
settledAt;
|
|
38
|
+
cancelledAt;
|
|
39
|
+
createdAt;
|
|
40
|
+
items;
|
|
41
|
+
locations;
|
|
42
|
+
};
|
|
43
|
+
__decorate([
|
|
44
|
+
PrimaryGeneratedColumn('uuid'),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], InventoryCountOrderEntityClass.prototype, "id", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
Column({ type: 'varchar', unique: true }),
|
|
49
|
+
Index(),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], InventoryCountOrderEntityClass.prototype, "key", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
Column({ type: 'varchar' }),
|
|
54
|
+
__metadata("design:type", String)
|
|
55
|
+
], InventoryCountOrderEntityClass.prototype, "name", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
Column({ type: 'date' }),
|
|
58
|
+
Index(),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], InventoryCountOrderEntityClass.prototype, "countDate", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
Column({
|
|
63
|
+
type: 'enum',
|
|
64
|
+
enum: InventoryCountStatus,
|
|
65
|
+
default: InventoryCountStatus.PENDING,
|
|
66
|
+
}),
|
|
67
|
+
Index(),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], InventoryCountOrderEntityClass.prototype, "status", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
Column({ type: 'varchar', nullable: true }),
|
|
72
|
+
__metadata("design:type", Object)
|
|
73
|
+
], InventoryCountOrderEntityClass.prototype, "createdBy", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
Column({ type: 'timestamptz', nullable: true }),
|
|
76
|
+
__metadata("design:type", Object)
|
|
77
|
+
], InventoryCountOrderEntityClass.prototype, "startedAt", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
Column({ type: 'timestamptz', nullable: true }),
|
|
80
|
+
__metadata("design:type", Object)
|
|
81
|
+
], InventoryCountOrderEntityClass.prototype, "settledAt", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
Column({ type: 'timestamptz', nullable: true }),
|
|
84
|
+
__metadata("design:type", Object)
|
|
85
|
+
], InventoryCountOrderEntityClass.prototype, "cancelledAt", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
CreateDateColumn({ type: 'timestamptz' }),
|
|
88
|
+
__metadata("design:type", Date)
|
|
89
|
+
], InventoryCountOrderEntityClass.prototype, "createdAt", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
OneToMany('inventory_count_order_items', (item) => item.order),
|
|
92
|
+
__metadata("design:type", Array)
|
|
93
|
+
], InventoryCountOrderEntityClass.prototype, "items", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
OneToMany('inventory_count_order_locations', (scope) => scope.order),
|
|
96
|
+
__metadata("design:type", Array)
|
|
97
|
+
], InventoryCountOrderEntityClass.prototype, "locations", void 0);
|
|
98
|
+
InventoryCountOrderEntityClass = __decorate([
|
|
99
|
+
Entity('inventory_count_orders'),
|
|
100
|
+
TableInheritance({ column: { type: 'varchar', name: 'entityName' } })
|
|
101
|
+
], InventoryCountOrderEntityClass);
|
|
102
|
+
const InventoryCountOrderLocationEntity = Symbol('InventoryCountOrderLocationEntity');
|
|
103
|
+
/**
|
|
104
|
+
* One row per location in the order's scope, **already expanded** to include
|
|
105
|
+
* every descendant of the locations the user picked.
|
|
106
|
+
*
|
|
107
|
+
* The scope is materialised at creation instead of being recomputed from the
|
|
108
|
+
* chosen roots because it is read on the hot path: while an order is counting,
|
|
109
|
+
* every single stock movement in the system has to ask "is this location
|
|
110
|
+
* locked?". `LocationEntity` is a plain `parent`/`children` adjacency list with
|
|
111
|
+
* no materialised path, so answering that from the tree would mean a recursive
|
|
112
|
+
* CTE per movement.
|
|
113
|
+
*/
|
|
114
|
+
let InventoryCountOrderLocationEntityClass = class InventoryCountOrderLocationEntityClass {
|
|
115
|
+
id;
|
|
116
|
+
orderId;
|
|
117
|
+
locationId;
|
|
118
|
+
/** `true` for the locations the user picked, `false` for descendants. */
|
|
119
|
+
isRoot;
|
|
120
|
+
order;
|
|
121
|
+
location;
|
|
122
|
+
};
|
|
123
|
+
__decorate([
|
|
124
|
+
PrimaryGeneratedColumn('uuid'),
|
|
125
|
+
__metadata("design:type", String)
|
|
126
|
+
], InventoryCountOrderLocationEntityClass.prototype, "id", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
Column({ type: 'uuid' }),
|
|
129
|
+
Index(),
|
|
130
|
+
__metadata("design:type", String)
|
|
131
|
+
], InventoryCountOrderLocationEntityClass.prototype, "orderId", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
Column({ type: 'uuid' }),
|
|
134
|
+
Index(),
|
|
135
|
+
__metadata("design:type", String)
|
|
136
|
+
], InventoryCountOrderLocationEntityClass.prototype, "locationId", void 0);
|
|
137
|
+
__decorate([
|
|
138
|
+
Column({ type: 'boolean', default: false }),
|
|
139
|
+
__metadata("design:type", Boolean)
|
|
140
|
+
], InventoryCountOrderLocationEntityClass.prototype, "isRoot", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
ManyToOne('inventory_count_orders', (order) => order.locations),
|
|
143
|
+
JoinColumn({ name: 'orderId', referencedColumnName: 'id' }),
|
|
144
|
+
__metadata("design:type", InventoryCountOrderEntityClass)
|
|
145
|
+
], InventoryCountOrderLocationEntityClass.prototype, "order", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
ManyToOne('locations'),
|
|
148
|
+
JoinColumn({ name: 'locationId', referencedColumnName: 'id' }),
|
|
149
|
+
__metadata("design:type", LocationEntityClass)
|
|
150
|
+
], InventoryCountOrderLocationEntityClass.prototype, "location", void 0);
|
|
151
|
+
InventoryCountOrderLocationEntityClass = __decorate([
|
|
152
|
+
Entity('inventory_count_order_locations')
|
|
153
|
+
], InventoryCountOrderLocationEntityClass);
|
|
154
|
+
|
|
155
|
+
export { InventoryCountOrderEntity, InventoryCountOrderEntityClass, InventoryCountOrderLocationEntity, InventoryCountOrderLocationEntityClass };
|
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
package/lib/models/extensions/quality-inspection-order/quality-inspection-order-item.entity.js
CHANGED
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
package/lib/models/extensions/reclassify-inventory-order/reclassify-inventory-order-item.entity.js
CHANGED
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
package/lib/models/extensions/transfer-customer-order/transfer-customer-order-item.entity.js
CHANGED
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
|
@@ -8,6 +8,7 @@ import '../../metadata/loader-unit.entity.js';
|
|
|
8
8
|
import { LocationEntityClass } from '../../metadata/location.entity.js';
|
|
9
9
|
import '../../metadata/material.entity.js';
|
|
10
10
|
import '../../metadata/material-unit.entity.js';
|
|
11
|
+
import '@rytass/wms-base-nestjs-module';
|
|
11
12
|
import '../../metadata/sale-order.entity.js';
|
|
12
13
|
import '../../metadata/stock.entity.js';
|
|
13
14
|
import '../../metadata/unit.entity.js';
|
package/lib/models/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from './loader-unit.entity';
|
|
|
6
6
|
export * from './location.entity';
|
|
7
7
|
export * from './material.entity';
|
|
8
8
|
export * from './material-unit.entity';
|
|
9
|
+
export * from './order.entity';
|
|
9
10
|
export * from './sale-order.entity';
|
|
10
11
|
export * from './stock.entity';
|
|
11
12
|
export * from './unit.entity';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OrderEntity as BaseOrderEntity } from '@rytass/wms-base-nestjs-module';
|
|
2
|
+
export declare const OrderEntity: unique symbol;
|
|
3
|
+
/**
|
|
4
|
+
* Orders are the one domain this package adds no columns to, so the entity the
|
|
5
|
+
* `OrderEntity` Symbol falls back to is the base class itself. The alias exists
|
|
6
|
+
* for symmetry with every other entity in this folder — services and DTOs can
|
|
7
|
+
* keep referring to `OrderEntityClass` without caring where it is declared.
|
|
8
|
+
*/
|
|
9
|
+
export { BaseOrderEntity as OrderEntityClass };
|
|
@@ -11,6 +11,7 @@ import { LoaderUnitEntity, LoaderUnitEntityClass } from './metadata/loader-unit.
|
|
|
11
11
|
import { LocationEntity, LocationEntityClass, WarehouseMapEntity } from './metadata/location.entity.js';
|
|
12
12
|
import { MaterialEntity, MaterialEntityClass } from './metadata/material.entity.js';
|
|
13
13
|
import { MaterialUnitEntity, MaterialUnitEntityClass } from './metadata/material-unit.entity.js';
|
|
14
|
+
import '@rytass/wms-base-nestjs-module';
|
|
14
15
|
import { SaleOrderEntity, SaleOrderEntityClass } from './metadata/sale-order.entity.js';
|
|
15
16
|
import { StockEntity, StockEntityClass } from './metadata/stock.entity.js';
|
|
16
17
|
import { UnitEntity, UnitEntityClass } from './metadata/unit.entity.js';
|
|
@@ -51,6 +52,9 @@ import { TransferCustomerOrderChangeEntity, TransferCustomerOrderChangeEntityCla
|
|
|
51
52
|
import { ScrapeOrderEntity, ScrapeOrderEntityClass } from './extensions/scrape-order/scrape-order.entity.js';
|
|
52
53
|
import { ScrapeOrderItemEntity, ScrapeOrderItemEntityClass } from './extensions/scrape-order/scrape-order-item.entity.js';
|
|
53
54
|
import { ScrapeOrderChangeEntity, ScrapeOrderChangeEntityClass } from './extensions/scrape-order/scrape-order-change.entity.js';
|
|
55
|
+
import { InventoryCountOrderEntity, InventoryCountOrderEntityClass, InventoryCountOrderLocationEntity, InventoryCountOrderLocationEntityClass } from './extensions/inventory-count-order/inventory-count-order.entity.js';
|
|
56
|
+
import { InventoryCountOrderItemEntity, InventoryCountOrderItemEntityClass } from './extensions/inventory-count-order/inventory-count-order-item.entity.js';
|
|
57
|
+
import { InventoryCountOrderChangeEntity, InventoryCountOrderChangeEntityClass } from './extensions/inventory-count-order/inventory-count-order-change.entity.js';
|
|
54
58
|
|
|
55
59
|
const entities = [
|
|
56
60
|
[UnitEntity, UnitEntityClass],
|
|
@@ -105,18 +109,28 @@ const entities = [
|
|
|
105
109
|
[ScrapeOrderEntity, ScrapeOrderEntityClass],
|
|
106
110
|
[ScrapeOrderItemEntity, ScrapeOrderItemEntityClass],
|
|
107
111
|
[ScrapeOrderChangeEntity, ScrapeOrderChangeEntityClass],
|
|
112
|
+
[InventoryCountOrderEntity, InventoryCountOrderEntityClass],
|
|
113
|
+
[InventoryCountOrderLocationEntity, InventoryCountOrderLocationEntityClass],
|
|
114
|
+
[InventoryCountOrderItemEntity, InventoryCountOrderItemEntityClass],
|
|
115
|
+
[InventoryCountOrderChangeEntity, InventoryCountOrderChangeEntityClass],
|
|
108
116
|
];
|
|
109
117
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* importing `WMSBaseModule` can read. Binding
|
|
113
|
-
* live bindings for one token, and the loser would be
|
|
114
|
-
* injector happened to reach first.
|
|
118
|
+
* The overridable entities are deliberately absent: `WmsModuleCoreModule` binds
|
|
119
|
+
* each of them to whatever the matching `WMSBaseModuleOptions` entity resolved
|
|
120
|
+
* to, which only a module importing `WMSBaseModule` can read. Binding them here
|
|
121
|
+
* as well would leave two live bindings for one token, and the loser would be
|
|
122
|
+
* whichever module the injector happened to reach first.
|
|
115
123
|
*
|
|
116
|
-
*
|
|
117
|
-
* root of the single-table hierarchy a consumer's override extends.
|
|
124
|
+
* Their classes stay in `entities` above so TypeORM still registers them — each
|
|
125
|
+
* is the root of the single-table hierarchy a consumer's override extends.
|
|
118
126
|
*/
|
|
119
|
-
const EXTERNALLY_BOUND_ENTITIES = new Set([
|
|
127
|
+
const EXTERNALLY_BOUND_ENTITIES = new Set([
|
|
128
|
+
MaterialEntity,
|
|
129
|
+
BatchEntity,
|
|
130
|
+
LocationEntity,
|
|
131
|
+
StockEntity,
|
|
132
|
+
WarehouseMapEntity,
|
|
133
|
+
]);
|
|
120
134
|
const ResolvedEntitiesProviders = entities
|
|
121
135
|
.filter(([token]) => !EXTERNALLY_BOUND_ENTITIES.has(token))
|
|
122
136
|
.map(([token, entity]) => ({
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Type } from '@nestjs/common';
|
|
2
|
+
import { DataSource } from 'typeorm';
|
|
3
|
+
import { WarehouseMapEntity as WarehouseMapEntityClass } from '@rytass/wms-base-nestjs-module/models/warehouse-map.entity';
|
|
4
|
+
import { BatchEntityClass } from './metadata/batch.entity';
|
|
5
|
+
import { LocationEntityClass } from './metadata/location.entity';
|
|
6
|
+
import { MaterialEntityClass } from './metadata/material.entity';
|
|
7
|
+
import { OrderEntityClass } from './metadata/order.entity';
|
|
8
|
+
import { StockEntityClass } from './metadata/stock.entity';
|
|
9
|
+
/**
|
|
10
|
+
* The entity classes this package actually reads and writes, after applying the
|
|
11
|
+
* consumer's `WMSBaseModuleOptions` entity overrides.
|
|
12
|
+
*
|
|
13
|
+
* Every overridable entity is bound to a `Symbol` that `WmsModuleCoreModule`
|
|
14
|
+
* resolves from the base module's `PROVIDE_*_ENTITY` tokens. Injecting them one
|
|
15
|
+
* by one works, but most services and resolvers need three or four at once, so
|
|
16
|
+
* this collects them behind a single dependency.
|
|
17
|
+
*
|
|
18
|
+
* Only entities the base module lets a consumer replace are here. Entities this
|
|
19
|
+
* package owns outright — batch groups, loaders, units, every order extension —
|
|
20
|
+
* have no override to follow and are referenced by class directly.
|
|
21
|
+
*/
|
|
22
|
+
export declare class WmsEntities {
|
|
23
|
+
readonly material: Type<MaterialEntityClass>;
|
|
24
|
+
readonly batch: Type<BatchEntityClass>;
|
|
25
|
+
readonly location: Type<LocationEntityClass>;
|
|
26
|
+
readonly stock: Type<StockEntityClass>;
|
|
27
|
+
readonly order: Type<OrderEntityClass>;
|
|
28
|
+
readonly warehouseMap: Type<WarehouseMapEntityClass>;
|
|
29
|
+
constructor(dataSource: DataSource, material: Type<MaterialEntityClass>, batch: Type<BatchEntityClass>, location: Type<LocationEntityClass>, stock: Type<StockEntityClass>, order: Type<OrderEntityClass>, warehouseMap: Type<WarehouseMapEntityClass>);
|
|
30
|
+
/**
|
|
31
|
+
* Fail during instantiation if an override was never registered with TypeORM.
|
|
32
|
+
*
|
|
33
|
+
* The module cannot register it: `TypeOrmModule.forFeature()` runs while the
|
|
34
|
+
* module graph is assembled, and an override is only known once the options
|
|
35
|
+
* resolve. Registering the built-in class does bring the override's *columns*
|
|
36
|
+
* into the table (TypeORM copies a single-table child's columns into its
|
|
37
|
+
* parent), which makes the omission easy to miss — everything looks right
|
|
38
|
+
* until the first query fails with a bare `EntityMetadataNotFoundError` from
|
|
39
|
+
* somewhere deep in a resolver.
|
|
40
|
+
*
|
|
41
|
+
* This runs in the constructor rather than `onModuleInit` so it lands before
|
|
42
|
+
* any service's own startup work touches the database.
|
|
43
|
+
*/
|
|
44
|
+
private assertRegistered;
|
|
45
|
+
}
|