@rytass/wms-module-core 0.8.1 → 0.9.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.
Files changed (73) hide show
  1. package/index.cjs.js +1689 -199
  2. package/index.js +11 -1
  3. package/lib/constants/consumption-change-kind.d.ts +17 -0
  4. package/lib/constants/consumption-change-kind.js +20 -0
  5. package/lib/constants/index.d.ts +2 -0
  6. package/lib/constants/operations.d.ts +1 -1
  7. package/lib/constants/operations.js +9 -0
  8. package/lib/constants/order-type.d.ts +30 -0
  9. package/lib/constants/order-type.js +33 -0
  10. package/lib/constants/stock-status.d.ts +4 -1
  11. package/lib/constants/stock-status.js +6 -0
  12. package/lib/core.module.js +87 -3
  13. package/lib/events/index.d.ts +2 -1
  14. package/lib/events/stock-change.subscriber.d.ts +26 -1
  15. package/lib/events/stock-change.subscriber.js +98 -15
  16. package/lib/events/wms-event.tokens.d.ts +2 -0
  17. package/lib/events/wms-event.tokens.js +3 -1
  18. package/lib/events/wms-event.types.d.ts +38 -6
  19. package/lib/events/wms-operation-runner.d.ts +57 -0
  20. package/lib/events/wms-operation-runner.js +101 -0
  21. package/lib/models/extensions/consumption-order/consumption-order-change.entity.d.ts +19 -0
  22. package/lib/models/extensions/consumption-order/consumption-order-change.entity.js +59 -0
  23. package/lib/models/extensions/consumption-order/consumption-order-item.entity.d.ts +26 -0
  24. package/lib/models/extensions/consumption-order/consumption-order-item.entity.js +114 -0
  25. package/lib/models/extensions/consumption-order/consumption-order.entity.d.ts +32 -0
  26. package/lib/models/extensions/consumption-order/consumption-order.entity.js +69 -0
  27. package/lib/models/extensions/consumption-order/index.d.ts +3 -0
  28. package/lib/models/extensions/index.d.ts +4 -0
  29. package/lib/models/extensions/inventory-count-order/inventory-count-order-item.entity.d.ts +13 -1
  30. package/lib/models/extensions/inventory-count-order/inventory-count-order-item.entity.js +17 -1
  31. package/lib/models/extensions/order-reference/index.d.ts +1 -0
  32. package/lib/models/extensions/order-reference/order-reference.entity.d.ts +49 -0
  33. package/lib/models/extensions/order-reference/order-reference.entity.js +95 -0
  34. package/lib/models/metadata/batch.entity.d.ts +46 -0
  35. package/lib/models/metadata/batch.entity.js +58 -0
  36. package/lib/models/models.module.js +8 -0
  37. package/lib/services/allocate-inventory-order.service.js +4 -0
  38. package/lib/services/base-order.service.d.ts +18 -3
  39. package/lib/services/base-order.service.js +76 -0
  40. package/lib/services/batch.service.d.ts +17 -0
  41. package/lib/services/batch.service.js +41 -1
  42. package/lib/services/consumption-order.service.d.ts +75 -0
  43. package/lib/services/consumption-order.service.js +504 -0
  44. package/lib/services/hold-inventory-order.service.js +4 -0
  45. package/lib/services/index.d.ts +3 -0
  46. package/lib/services/inventory-count-order.service.js +7 -0
  47. package/lib/services/loader.service.js +4 -0
  48. package/lib/services/location.service.js +4 -0
  49. package/lib/services/material.service.js +4 -0
  50. package/lib/services/merge-batch-order.service.js +4 -0
  51. package/lib/services/order-reference.service.d.ts +50 -0
  52. package/lib/services/order-reference.service.js +136 -0
  53. package/lib/services/quality-inspection-order.service.js +4 -0
  54. package/lib/services/receive-inventory-order.service.js +132 -78
  55. package/lib/services/reclassify-inventory-order.service.js +4 -0
  56. package/lib/services/scrape.service.js +4 -0
  57. package/lib/services/ship-inventory-order.service.js +4 -0
  58. package/lib/services/split-batch-order.service.js +69 -46
  59. package/lib/services/stock.service.js +32 -2
  60. package/lib/services/transfer-customer-order.service.js +4 -0
  61. package/lib/services/transfer-order.service.js +4 -0
  62. package/lib/services/transfer-vendor-order.service.js +4 -0
  63. package/lib/services/unit.service.js +4 -0
  64. package/lib/typings/aggregated-stock.d.ts +6 -0
  65. package/lib/typings/consumption-order.input.d.ts +72 -0
  66. package/lib/typings/core-module-options.d.ts +34 -1
  67. package/lib/typings/custom-change-table.d.ts +70 -0
  68. package/lib/typings/find-stock.input.d.ts +14 -0
  69. package/lib/typings/get-batch.input.d.ts +16 -0
  70. package/lib/typings/index.d.ts +3 -0
  71. package/lib/typings/order-reference.input.d.ts +28 -0
  72. package/lib/typings/split-batch.input.d.ts +11 -0
  73. package/package.json +1 -1
@@ -55,6 +55,10 @@ import '../models/extensions/scrape-order/scrape-order-change.entity.js';
55
55
  import '../models/extensions/inventory-count-order/inventory-count-order.entity.js';
56
56
  import '../models/extensions/inventory-count-order/inventory-count-order-item.entity.js';
57
57
  import '../models/extensions/inventory-count-order/inventory-count-order-change.entity.js';
58
+ import '../models/extensions/consumption-order/consumption-order.entity.js';
59
+ import '../models/extensions/consumption-order/consumption-order-item.entity.js';
60
+ import '../models/extensions/consumption-order/consumption-order-change.entity.js';
61
+ import '../models/extensions/order-reference/order-reference.entity.js';
58
62
  import { WMS_CORE_MODULE_OPTIONS } from '../typings/core-module-options.js';
59
63
 
60
64
  let StockService = class StockService {
@@ -106,6 +110,7 @@ let StockService = class StockService {
106
110
  .addSelect('b."held"', 'held')
107
111
  .addSelect('b."inShipment"', 'inShipment')
108
112
  .addSelect('b."inspectionResult"', 'inspectionResult')
113
+ .addSelect('b."requiresInspection"', 'requiresInspection')
109
114
  .addSelect('b."saleId"', 'saleId')
110
115
  .addSelect('b."vendorId"', 'vendorId')
111
116
  .addSelect('b."customerId"', 'customerId')
@@ -116,6 +121,7 @@ let StockService = class StockService {
116
121
  .addSelect('stock_status.held', 'held')
117
122
  .addSelect('stock_status."inShipment"', 'inShipment')
118
123
  .addSelect('stock_status."inspectionResult"', 'inspectionResult')
124
+ .addSelect('stock_status."requiresInspection"', 'requiresInspection')
119
125
  .addSelect('stock_status."saleId"', 'saleId')
120
126
  .addSelect('stock_status."vendorId"', 'vendorId')
121
127
  .addSelect('stock_status."customerId"', 'customerId')
@@ -178,6 +184,8 @@ let StockService = class StockService {
178
184
  queryBuilder.andWhere('stock."locationId" = :locationId', {
179
185
  locationId: options.locationId,
180
186
  });
187
+ if (options.excludeLocationIds?.length)
188
+ queryBuilder.andWhere('stock."locationId" NOT IN (:...excludeLocationIds)', { excludeLocationIds: options.excludeLocationIds });
181
189
  if (options.loaderId)
182
190
  queryBuilder.andWhere('stock."loaderId" = :loaderId', {
183
191
  loaderId: options.loaderId,
@@ -195,7 +203,13 @@ let StockService = class StockService {
195
203
  if (options.status) {
196
204
  switch (options.status) {
197
205
  case StockStatus.PENDING_INSPECTION:
198
- queryBuilder.andWhere('stock_status."inspectionResult" IS NULL');
206
+ /*
207
+ * Both halves are required. `inspectionResult IS NULL` alone is the
208
+ * resting state of every batch nobody ever asked to inspect, so on
209
+ * its own it reported the whole warehouse as awaiting inspection --
210
+ * a wrong answer that looked plausible because it was never zero.
211
+ */
212
+ queryBuilder.andWhere('stock_status."requiresInspection" = true AND stock_status."inspectionResult" IS NULL');
199
213
  break;
200
214
  case StockStatus.INSPECTION_FAILED:
201
215
  queryBuilder.andWhere('stock_status."inspectionResult" = false');
@@ -219,7 +233,7 @@ let StockService = class StockService {
219
233
  if (options.negateStatus) {
220
234
  switch (options.negateStatus) {
221
235
  case StockStatus.PENDING_INSPECTION:
222
- queryBuilder.andWhere('stock_status."inspectionResult" IS NOT NULL');
236
+ queryBuilder.andWhere('NOT (stock_status."requiresInspection" = true AND stock_status."inspectionResult" IS NULL)');
223
237
  break;
224
238
  case StockStatus.INSPECTION_FAILED:
225
239
  queryBuilder.andWhere('(stock_status."inspectionResult" IS NULL OR stock_status."inspectionResult" != false)');
@@ -306,6 +320,16 @@ let StockService = class StockService {
306
320
  queryBuilder.addSelect('b."customerId"', 'customerId');
307
321
  queryBuilder.addSelect('b."vendorId"', 'vendorId');
308
322
  queryBuilder.addSelect('b."inspectionResult"', 'inspectionResult');
323
+ queryBuilder.addSelect('b."requiresInspection"', 'requiresInspection');
324
+ /*
325
+ * Lineage and the host's own attributes, carried along the same way the
326
+ * commercial attributes above are. Both are functionally dependent on
327
+ * `batchId`, which is already a grouping key, but SQL still wants them
328
+ * named in GROUP BY. `attributes` is jsonb, which groups fine — jsonb has
329
+ * equality and a btree opclass.
330
+ */
331
+ queryBuilder.addSelect('b."parentBatchId"', 'parentBatchId');
332
+ queryBuilder.addSelect('b."attributes"', 'attributes');
309
333
  queryBuilder.addSelect('SUM(stock.quantity)', 'quantity');
310
334
  queryBuilder.groupBy('stock."materialId"');
311
335
  queryBuilder.addGroupBy('stock."batchId"');
@@ -320,6 +344,9 @@ let StockService = class StockService {
320
344
  queryBuilder.addGroupBy('b."customerId"');
321
345
  queryBuilder.addGroupBy('b."vendorId"');
322
346
  queryBuilder.addGroupBy('b."inspectionResult"');
347
+ queryBuilder.addGroupBy('b."requiresInspection"');
348
+ queryBuilder.addGroupBy('b."parentBatchId"');
349
+ queryBuilder.addGroupBy('b."attributes"');
323
350
  queryBuilder.having('SUM(stock.quantity) <> 0');
324
351
  if (options.aggregatedKeys?.length)
325
352
  queryBuilder.andHaving([
@@ -404,6 +431,9 @@ let StockService = class StockService {
404
431
  paginatedQueryBuilder.addSelect('agg."customerId"', 'customerId');
405
432
  paginatedQueryBuilder.addSelect('agg."vendorId"', 'vendorId');
406
433
  paginatedQueryBuilder.addSelect('agg."inspectionResult"', 'inspectionResult');
434
+ paginatedQueryBuilder.addSelect('agg."requiresInspection"', 'requiresInspection');
435
+ paginatedQueryBuilder.addSelect('agg."parentBatchId"', 'parentBatchId');
436
+ paginatedQueryBuilder.addSelect('agg."attributes"', 'attributes');
407
437
  // Apply pagination to the outer query
408
438
  if (options.offset !== undefined && options.offset >= 0) {
409
439
  paginatedQueryBuilder.skip(options.offset);
@@ -53,6 +53,10 @@ import '../models/extensions/scrape-order/scrape-order-change.entity.js';
53
53
  import '../models/extensions/inventory-count-order/inventory-count-order.entity.js';
54
54
  import '../models/extensions/inventory-count-order/inventory-count-order-item.entity.js';
55
55
  import '../models/extensions/inventory-count-order/inventory-count-order-change.entity.js';
56
+ import '../models/extensions/consumption-order/consumption-order.entity.js';
57
+ import '../models/extensions/consumption-order/consumption-order-item.entity.js';
58
+ import '../models/extensions/consumption-order/consumption-order-change.entity.js';
59
+ import '../models/extensions/order-reference/order-reference.entity.js';
56
60
  import { DataSource, Not, IsNull } from 'typeorm';
57
61
  import { HelperService } from './helper.service.js';
58
62
  import { MaterialService } from './material.service.js';
@@ -53,6 +53,10 @@ import '../models/extensions/scrape-order/scrape-order-change.entity.js';
53
53
  import '../models/extensions/inventory-count-order/inventory-count-order.entity.js';
54
54
  import '../models/extensions/inventory-count-order/inventory-count-order-item.entity.js';
55
55
  import '../models/extensions/inventory-count-order/inventory-count-order-change.entity.js';
56
+ import '../models/extensions/consumption-order/consumption-order.entity.js';
57
+ import '../models/extensions/consumption-order/consumption-order-item.entity.js';
58
+ import '../models/extensions/consumption-order/consumption-order-change.entity.js';
59
+ import '../models/extensions/order-reference/order-reference.entity.js';
56
60
  import { DataSource, In } from 'typeorm';
57
61
  import { StockStatus } from '../constants/stock-status.js';
58
62
  import { HelperService } from './helper.service.js';
@@ -53,6 +53,10 @@ import '../models/extensions/scrape-order/scrape-order-change.entity.js';
53
53
  import '../models/extensions/inventory-count-order/inventory-count-order.entity.js';
54
54
  import '../models/extensions/inventory-count-order/inventory-count-order-item.entity.js';
55
55
  import '../models/extensions/inventory-count-order/inventory-count-order-change.entity.js';
56
+ import '../models/extensions/consumption-order/consumption-order.entity.js';
57
+ import '../models/extensions/consumption-order/consumption-order-item.entity.js';
58
+ import '../models/extensions/consumption-order/consumption-order-change.entity.js';
59
+ import '../models/extensions/order-reference/order-reference.entity.js';
56
60
  import { DataSource, Not, IsNull } from 'typeorm';
57
61
  import { HelperService } from './helper.service.js';
58
62
  import { MaterialService } from './material.service.js';
@@ -54,6 +54,10 @@ import '../models/extensions/scrape-order/scrape-order-change.entity.js';
54
54
  import '../models/extensions/inventory-count-order/inventory-count-order.entity.js';
55
55
  import '../models/extensions/inventory-count-order/inventory-count-order-item.entity.js';
56
56
  import '../models/extensions/inventory-count-order/inventory-count-order-change.entity.js';
57
+ import '../models/extensions/consumption-order/consumption-order.entity.js';
58
+ import '../models/extensions/consumption-order/consumption-order-item.entity.js';
59
+ import '../models/extensions/consumption-order/consumption-order-change.entity.js';
60
+ import '../models/extensions/order-reference/order-reference.entity.js';
57
61
 
58
62
  let UnitService = class UnitService {
59
63
  dataSource;
@@ -9,6 +9,12 @@ export type AggregatedStock = Pick<StockEntityClass, 'materialId' | 'batchId' |
9
9
  customerId?: string | null;
10
10
  vendorId?: string | null;
11
11
  inspectionResult?: boolean;
12
+ /** Whether anyone actually asked for this batch to be inspected. */
13
+ requiresInspection?: boolean;
14
+ /** The batch this one was split out of; `null` for a batch created outright. */
15
+ parentBatchId?: string | null;
16
+ /** The host's own attributes on the batch, stored verbatim. */
17
+ attributes?: Record<string, unknown> | null;
12
18
  };
13
19
  export interface ValidateStockDeductionParams {
14
20
  materialId: string;
@@ -0,0 +1,72 @@
1
+ import { PaginationInput } from './paginations';
2
+ export type CreateConsumptionOrderItemInput = {
3
+ materialId: string;
4
+ batchId: string;
5
+ /** Where the material is issued from. Defaults to the module's default location. */
6
+ locationId?: string;
7
+ loaderId?: string;
8
+ unitId?: string;
9
+ quantity: number;
10
+ /** Where it sits while the process holds it. Defaults to the source location. */
11
+ targetLocationId?: string;
12
+ targetLoaderId?: string;
13
+ };
14
+ export type CreateConsumptionOrderInput = {
15
+ description?: string;
16
+ createdBy?: string;
17
+ items: CreateConsumptionOrderItemInput[];
18
+ };
19
+ export type UpdateConsumptionOrderInput = {
20
+ id: string;
21
+ description?: string;
22
+ items?: CreateConsumptionOrderItemInput[];
23
+ };
24
+ /**
25
+ * One line of an issue / return / settle call.
26
+ *
27
+ * `quantity` is in the line's own unit, the same as `targetConsumedQuantity`,
28
+ * and is converted to base units before it is compared with anything. Omitting
29
+ * it means "whatever is outstanding on that line", which is what makes the
30
+ * common case — issue the whole order, settle everything still out there — a
31
+ * call with no line list at all.
32
+ */
33
+ export type ConsumptionOrderLineInput = {
34
+ itemId: string;
35
+ quantity?: number;
36
+ };
37
+ export type ConsumptionOrderActionInput = {
38
+ orderId: string;
39
+ /** Omit to act on every line of the order. */
40
+ items?: ConsumptionOrderLineInput[];
41
+ };
42
+ export type FindConsumptionOrderInput = PaginationInput & {
43
+ ids?: string[];
44
+ key?: string;
45
+ description?: string;
46
+ materialId?: string;
47
+ batchId?: string;
48
+ locationId?: string;
49
+ createdBy?: string;
50
+ createdAtFrom?: Date;
51
+ createdAtTo?: Date;
52
+ includeRemoved?: boolean;
53
+ };
54
+ /**
55
+ * How much of one line has moved, **in base units** — the unit the stock ledger
56
+ * and `quantityChanged` are written in, not the unit the line was ordered in.
57
+ *
58
+ * `target` is therefore `targetConsumedQuantity` already multiplied by the
59
+ * line's conversion factor, so every field here can be compared with every
60
+ * other. Reporting the target in the line's own unit next to totals in base
61
+ * units is what made a whole-order settle ask for twelve times what was there.
62
+ */
63
+ export type ConsumptionOrderItemProgress = {
64
+ itemId: string;
65
+ /** `targetConsumedQuantity` converted to base units. */
66
+ target: number;
67
+ issued: number;
68
+ returned: number;
69
+ settled: number;
70
+ /** Issued minus returned minus settled: what the process still holds. */
71
+ outstanding: number;
72
+ };
@@ -1,6 +1,32 @@
1
+ import type { Provider } from '@nestjs/common';
1
2
  import type { WMSBaseModuleAsyncOptions } from '@rytass/wms-base-nestjs-module';
3
+ import type { WmsActorExtractor, WmsAfterListenerMap, WmsBeforeHookMap } from '../events/wms-event.types';
4
+ import type { WmsCustomChangeTable } from './custom-change-table';
2
5
  export declare const WMS_CORE_MODULE_OPTIONS: unique symbol;
3
- export interface WmsModuleCoreModuleOptions {
6
+ /**
7
+ * The event/hook wiring, accepted here rather than only on the graphql module.
8
+ *
9
+ * `WmsOperationRunner` gives a host the same guarantee for a direct service
10
+ * call that the interceptor gives a GraphQL mutation, so a consumer that never
11
+ * installs `@rytass/wms-module-graphql` still needs somewhere to declare its
12
+ * hooks and listeners. `WmsModuleGraphqlModule.forRootAsync` forwards its own
13
+ * event options straight down to here, so there is exactly one binding of each
14
+ * token no matter which module a consumer imports.
15
+ */
16
+ export interface WmsEventWiringOptions {
17
+ readonly beforeHooks?: WmsBeforeHookMap;
18
+ readonly afterListeners?: WmsAfterListenerMap;
19
+ /** Populates `payload.actor` on every event. */
20
+ readonly actorExtractor?: WmsActorExtractor;
21
+ /**
22
+ * A provider for `WMS_EVENT_EMITTER_BRIDGE` — pass
23
+ * `wmsEventEmitterBridgeProvider` from
24
+ * `@rytass/wms-module-graphql/adapters/event-emitter` to also fan events out
25
+ * to `@nestjs/event-emitter`.
26
+ */
27
+ readonly eventEmitterBridge?: Provider;
28
+ }
29
+ export interface WmsModuleCoreModuleOptions extends WmsEventWiringOptions {
4
30
  defaultLoaderSerialId: string;
5
31
  defaultLoaderTypeKey: string;
6
32
  defaultLocationKey: string;
@@ -11,5 +37,12 @@ export interface WmsModuleCoreModuleOptions {
11
37
  * `forRootAsync({ enrichStockEvents })`, which forwards it here.
12
38
  */
13
39
  enrichStockEvents?: boolean;
40
+ /**
41
+ * Change tables this package does not own, so a host's own order family still
42
+ * emits `stock.*` events. Everything else a custom family needs -- the
43
+ * transaction, the availability check, the inventory count lock -- it already
44
+ * has. See {@link WmsCustomChangeTable}.
45
+ */
46
+ customChangeTables?: readonly WmsCustomChangeTable[];
14
47
  }
15
48
  export type WmsModuleCoreModuleAsyncOptions = WMSBaseModuleAsyncOptions & WmsModuleCoreModuleOptions;
@@ -0,0 +1,70 @@
1
+ import type { ChangeType } from '../constants/stock-status';
2
+ /**
3
+ * A `*_order_changes` row as the stock subscriber sees it, immediately after
4
+ * insert and before any relation is loaded.
5
+ *
6
+ * The shape is deliberately loose past the three columns every change table in
7
+ * this package agrees on: a host's own table may carry whatever else it needs,
8
+ * and its resolver is the only thing that reads those extras.
9
+ */
10
+ export interface WmsStockChangeRow {
11
+ /** The base order id, which is also the change's own primary key. */
12
+ readonly id: string;
13
+ /** The order item this change applies to. */
14
+ readonly itemId: string;
15
+ /** Signed: positive brings stock into a state, negative takes it out. */
16
+ readonly quantityChanged: number | string;
17
+ readonly [column: string]: unknown;
18
+ }
19
+ /**
20
+ * A change table this package does not own, registered so its rows still emit
21
+ * `stock.*` events.
22
+ *
23
+ * ### What a host gets without this
24
+ *
25
+ * More than you would expect. A host that writes its own order family already
26
+ * inherits, for free:
27
+ *
28
+ * - **transactions and stock arithmetic** — `dataSource.transaction` and
29
+ * `StockService.validateStockAvailability` are ordinary public API;
30
+ * - **the inventory count lock** — `InventoryCountLockSubscriber` keys off
31
+ * `tableName.endsWith('_order_changes')`, so any table following the naming
32
+ * convention is covered, provided its change row reaches an order item
33
+ * carrying a `locationId` through an `item` relation;
34
+ * - **the change history**, since the ledger is `stocks` rows, not a table this
35
+ * package has to know about.
36
+ *
37
+ * The one thing it does not get is an event, because `StockChangeSubscriber`
38
+ * maps table name to `ChangeType` through a closed table. This registers into
39
+ * that map, and is deliberately the *only* extension point of its kind: opening
40
+ * up order types, resolvers or the GraphQL schema would trade the module's one
41
+ * real guarantee — that it knows what every movement in it means — for
42
+ * something a host can already do with an entity of its own.
43
+ *
44
+ * ### The bargain
45
+ *
46
+ * A movement the module cannot classify is a hole in its reports: it can see
47
+ * that stock moved, not what the movement was. Mapping onto an existing
48
+ * {@link ChangeType} avoids that and should be preferred whenever the movement
49
+ * genuinely is a receipt, a shipment, a scrap. A host-defined string is for the
50
+ * cases where it genuinely is not — and those belong in a proposal upstream,
51
+ * not here, once they stop being one deployment's special case.
52
+ */
53
+ export interface WmsCustomChangeTable {
54
+ /**
55
+ * The table name TypeORM reports for the change entity. Must end in
56
+ * `_order_changes` like every other change table, or the inventory count lock
57
+ * will not see it either.
58
+ */
59
+ readonly table: string;
60
+ /**
61
+ * What kind of movement this row is.
62
+ *
63
+ * Return a {@link ChangeType} member to reuse this package's vocabulary — the
64
+ * row then emits that type's own `stock.*` event and counts in reports like
65
+ * any built-in movement. Return any other string to emit `stock.custom`
66
+ * carrying it as `customChangeType`. Return `null` to emit nothing, which is
67
+ * the right answer for a row that does not move stock at all.
68
+ */
69
+ readonly changeType: (change: WmsStockChangeRow) => ChangeType | string | null;
70
+ }
@@ -4,6 +4,20 @@ export type FindStockInput<U extends object> = PaginationInput & {
4
4
  materialId?: string;
5
5
  batchId?: string;
6
6
  locationId?: string;
7
+ /**
8
+ * Locations to leave out of the result, whatever else matches.
9
+ *
10
+ * `locationId` narrows to one place; this widens from "everywhere" by
11
+ * subtraction, which is what a stock report needs when some locations do not
12
+ * represent available inventory — a staging lane, a quarantine bay, a
13
+ * work-in-progress location a host issues material into. The module has no
14
+ * opinion on what those locations mean, so it takes ids rather than a
15
+ * classification: the host already knows which of its locations to leave out,
16
+ * and it can change that answer without a schema migration.
17
+ *
18
+ * An empty array is treated as "not filtering", the same as omitting it.
19
+ */
20
+ excludeLocationIds?: string[];
7
21
  loaderId?: string;
8
22
  description?: string;
9
23
  wildcard?: {
@@ -7,8 +7,24 @@ export type SplitBatchInput = {
7
7
  transferId?: string | null;
8
8
  held?: boolean;
9
9
  inShipment?: boolean;
10
+ /** Marks the child as awaiting an inspection somebody actually asked for. */
11
+ requiresInspection?: boolean;
12
+ /**
13
+ * Host-defined attributes for the child batch. Part of the batch's identity
14
+ * for the purposes of reuse: a split asking for attributes the existing
15
+ * sibling does not carry produces a new batch rather than reusing it.
16
+ */
17
+ attributes?: Record<string, unknown> | null;
10
18
  };
11
19
  export type GetBatchInput = {
12
20
  key: string;
13
21
  materialId: string;
22
+ /**
23
+ * Recorded on the batch when this call creates it. Ignored when an existing
24
+ * batch with the same key is reused — `parentBatchId` is written once and
25
+ * never rewritten.
26
+ */
27
+ parentBatchId?: string | null;
28
+ /** Applied when this call creates the batch; ignored when one is reused. */
29
+ attributes?: Record<string, unknown> | null;
14
30
  };
@@ -12,6 +12,9 @@ export * from './find-material.input';
12
12
  export * from './find-receive-inventory-order.input';
13
13
  export * from './find-ship-inventory-order.input';
14
14
  export * from './find-stock.input';
15
+ export * from './consumption-order.input';
16
+ export * from './custom-change-table';
17
+ export * from './order-reference.input';
15
18
  export * from './reclassify-inventory-order.input';
16
19
  export * from './paginations';
17
20
  export * from './cancel-ship-inventory-order.input';
@@ -0,0 +1,28 @@
1
+ import { WmsOrderType } from '../constants/order-type';
2
+ import { PaginationInput } from './paginations';
3
+ /** One link from an order to a document in the host system. */
4
+ export type OrderReferenceInput = {
5
+ /** Host-defined kind of document, e.g. `work-order`, `purchase-order`. */
6
+ referenceType: string;
7
+ /** The document's identifier, as the host knows it. */
8
+ referenceId: string;
9
+ /** The line within that document, when it has lines. */
10
+ referenceLine?: string | null;
11
+ /** The order item this link is about; omit for an order-level link. */
12
+ itemId?: string | null;
13
+ /** Anything else worth carrying along. Stored verbatim, never interpreted. */
14
+ metadata?: Record<string, unknown> | null;
15
+ };
16
+ export type AttachOrderReferencesInput = {
17
+ orderType: WmsOrderType;
18
+ orderId: string;
19
+ references: OrderReferenceInput[];
20
+ };
21
+ export type FindOrderReferenceInput = PaginationInput & {
22
+ orderType?: WmsOrderType;
23
+ orderId?: string;
24
+ itemId?: string;
25
+ referenceType?: string;
26
+ referenceId?: string;
27
+ referenceLine?: string;
28
+ };
@@ -6,5 +6,16 @@ export type SplitBatchInput = {
6
6
  quantity: number;
7
7
  locationId?: string;
8
8
  loaderId?: string;
9
+ /**
10
+ * Host-defined attributes for this child batch, applied **only when the
11
+ * split creates it** — an existing `batchKey` is returned as it stands,
12
+ * attributes and all.
13
+ *
14
+ * Children are distinguished by `batchKey`, never by attributes: `batches`
15
+ * carries `UNIQUE (key, materialId)`, so one test run sorting a batch into
16
+ * several grades gives each grade its own key and hangs the grade off it as
17
+ * an attribute. Two items sharing a key is refused outright.
18
+ */
19
+ attributes?: Record<string, unknown> | null;
9
20
  }[];
10
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rytass/wms-module-core",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "Rytass WMS Module — NestJS services and TypeORM entities for warehouse management",
5
5
  "keywords": [
6
6
  "rytass",