@rytass/wms-module-core 0.8.0 → 0.8.1

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.
@@ -248,6 +248,10 @@ WmsModuleCoreModule.forRootAsync({
248
248
 
249
249
  **庫存**
250
250
  - `FindStockInput<U extends object>` (extends `PaginationInput`) — 來源: `lib/typings/find-stock.input.ts`
251
+ - `aggregated` 已 **deprecated 且被忽略**,下一個 minor 移除。每個讀這個 input 的方法都自己決定要不要聚合:
252
+ `findAggregatedStocks` / `findAggregatedStock` 一律聚合,`findMany` / `findChangeLogs` 一律不聚合。
253
+ 在 0.8.0 之前對 `findAggregatedStocks` 傳 `false`(或省略)會拋 `column agg."saleSerialId" does not exist`,
254
+ 而不是回傳未聚合的列——所以沒有任何行為依賴它。
251
255
  - 除了 `materialKey` / `batchKey` / `locationKey` / `loaderKey`(皆為 ILIKE 模糊比對),另可用批號上的四個商業屬性
252
256
  `vendorId` / `customerId` / `saleId` / `saleSerialId` 篩選。這四個是**完全比對**,不是模糊比對——它們是上游系統的識別碼,
253
257
  模糊比對會讓 `SO-1` 撈到 `SO-10`。傳 `null` 等同不篩選。
package/index.cjs.js CHANGED
@@ -3194,7 +3194,14 @@ exports.StockService = class StockService {
3194
3194
  }
3195
3195
  async findAggregatedStocks(options) {
3196
3196
  // Create the aggregated subquery without pagination
3197
- const aggregateSubquery = this.pipeSelectOptionsToQueryBuilder({ ...options, offset: undefined, limit: undefined }, this.selectQueryBuilder('stock'), options.aggregated ? true : false);
3197
+ const aggregateSubquery = this.pipeSelectOptionsToQueryBuilder({ ...options, offset: undefined, limit: undefined }, this.selectQueryBuilder('stock'),
3198
+ // Always aggregated. The outer projection below is hard-wired to the
3199
+ // aggregated shape (it selects agg."saleSerialId" and friends), so letting
3200
+ // the caller switch the inner subquery off asked the outer query for a
3201
+ // column the inner one never produced — a hard `column agg."saleSerialId"
3202
+ // does not exist`. There was never a working `false` here: this method
3203
+ // returns AggregatedStock[], so aggregating is its only meaning.
3204
+ true);
3198
3205
  // Wrap the aggregated subquery and apply pagination on top
3199
3206
  const paginatedQueryBuilder = this.dataSource
3200
3207
  .createQueryBuilder()
@@ -3219,7 +3226,14 @@ exports.StockService = class StockService {
3219
3226
  paginatedQueryBuilder.take(options.limit);
3220
3227
  }
3221
3228
  // Get total count from the aggregated subquery
3222
- const countBuilder = this.pipeSelectOptionsToQueryBuilder({ ...options, offset: undefined, limit: undefined }, this.selectQueryBuilder('stock'), options.aggregated ? true : false);
3229
+ const countBuilder = this.pipeSelectOptionsToQueryBuilder({ ...options, offset: undefined, limit: undefined }, this.selectQueryBuilder('stock'),
3230
+ // Always aggregated. The outer projection below is hard-wired to the
3231
+ // aggregated shape (it selects agg."saleSerialId" and friends), so letting
3232
+ // the caller switch the inner subquery off asked the outer query for a
3233
+ // column the inner one never produced — a hard `column agg."saleSerialId"
3234
+ // does not exist`. There was never a working `false` here: this method
3235
+ // returns AggregatedStock[], so aggregating is its only meaning.
3236
+ true);
3223
3237
  const countResult = await this.dataSource
3224
3238
  .createQueryBuilder()
3225
3239
  .select('COUNT(*)', 'count')
@@ -5100,7 +5114,6 @@ exports.TransferOrderService = class TransferOrderService {
5100
5114
  for (const srcLoaderId of wholeLoaderSourceIds) {
5101
5115
  const [aggRows] = await this.stockService.findAggregatedStocks({
5102
5116
  loaderId: srcLoaderId,
5103
- aggregated: true,
5104
5117
  });
5105
5118
  // Gate 1
5106
5119
  const nonFree = aggRows.filter((r) => r.status !== exports.StockStatus.FREE);
@@ -5331,7 +5344,6 @@ exports.TransferOrderService = class TransferOrderService {
5331
5344
  for (const [srcLoaderId, subTotalQty] of wholeLoaderGroupSums) {
5332
5345
  const [aggRows] = await this.stockService.findAggregatedStocks({
5333
5346
  loaderId: srcLoaderId,
5334
- aggregated: true,
5335
5347
  });
5336
5348
  const loaderTotalQty = aggRows.reduce((s, r) => s + Number(r.quantity), 0);
5337
5349
  if (subTotalQty !== loaderTotalQty) {
@@ -380,7 +380,14 @@ let StockService = class StockService {
380
380
  }
381
381
  async findAggregatedStocks(options) {
382
382
  // Create the aggregated subquery without pagination
383
- const aggregateSubquery = this.pipeSelectOptionsToQueryBuilder({ ...options, offset: undefined, limit: undefined }, this.selectQueryBuilder('stock'), options.aggregated ? true : false);
383
+ const aggregateSubquery = this.pipeSelectOptionsToQueryBuilder({ ...options, offset: undefined, limit: undefined }, this.selectQueryBuilder('stock'),
384
+ // Always aggregated. The outer projection below is hard-wired to the
385
+ // aggregated shape (it selects agg."saleSerialId" and friends), so letting
386
+ // the caller switch the inner subquery off asked the outer query for a
387
+ // column the inner one never produced — a hard `column agg."saleSerialId"
388
+ // does not exist`. There was never a working `false` here: this method
389
+ // returns AggregatedStock[], so aggregating is its only meaning.
390
+ true);
384
391
  // Wrap the aggregated subquery and apply pagination on top
385
392
  const paginatedQueryBuilder = this.dataSource
386
393
  .createQueryBuilder()
@@ -405,7 +412,14 @@ let StockService = class StockService {
405
412
  paginatedQueryBuilder.take(options.limit);
406
413
  }
407
414
  // Get total count from the aggregated subquery
408
- const countBuilder = this.pipeSelectOptionsToQueryBuilder({ ...options, offset: undefined, limit: undefined }, this.selectQueryBuilder('stock'), options.aggregated ? true : false);
415
+ const countBuilder = this.pipeSelectOptionsToQueryBuilder({ ...options, offset: undefined, limit: undefined }, this.selectQueryBuilder('stock'),
416
+ // Always aggregated. The outer projection below is hard-wired to the
417
+ // aggregated shape (it selects agg."saleSerialId" and friends), so letting
418
+ // the caller switch the inner subquery off asked the outer query for a
419
+ // column the inner one never produced — a hard `column agg."saleSerialId"
420
+ // does not exist`. There was never a working `false` here: this method
421
+ // returns AggregatedStock[], so aggregating is its only meaning.
422
+ true);
409
423
  const countResult = await this.dataSource
410
424
  .createQueryBuilder()
411
425
  .select('COUNT(*)', 'count')
@@ -304,7 +304,6 @@ let TransferOrderService = class TransferOrderService {
304
304
  for (const srcLoaderId of wholeLoaderSourceIds) {
305
305
  const [aggRows] = await this.stockService.findAggregatedStocks({
306
306
  loaderId: srcLoaderId,
307
- aggregated: true,
308
307
  });
309
308
  // Gate 1
310
309
  const nonFree = aggRows.filter((r) => r.status !== StockStatus.FREE);
@@ -535,7 +534,6 @@ let TransferOrderService = class TransferOrderService {
535
534
  for (const [srcLoaderId, subTotalQty] of wholeLoaderGroupSums) {
536
535
  const [aggRows] = await this.stockService.findAggregatedStocks({
537
536
  loaderId: srcLoaderId,
538
- aggregated: true,
539
537
  });
540
538
  const loaderTotalQty = aggRows.reduce((s, r) => s + Number(r.quantity), 0);
541
539
  if (subTotalQty !== loaderTotalQty) {
@@ -12,6 +12,15 @@ export type FindStockInput<U extends object> = PaginationInput & {
12
12
  };
13
13
  status?: StockStatus;
14
14
  negateStatus?: StockStatus;
15
+ /**
16
+ * @deprecated Ignored, and slated for removal in the next minor.
17
+ *
18
+ * Every method that reads this input already fixes its own aggregation:
19
+ * `findAggregatedStocks` and `findAggregatedStock` always aggregate,
20
+ * `findMany` and `findChangeLogs` never do. Passing `false` to an
21
+ * `findAggregated*` call used to produce a SQL error rather than un-aggregated
22
+ * rows, which is how we know nobody was relying on it.
23
+ */
15
24
  aggregated?: boolean;
16
25
  aggregatedKeys?: string[];
17
26
  materialKey?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rytass/wms-module-core",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Rytass WMS Module — NestJS services and TypeORM entities for warehouse management",
5
5
  "keywords": [
6
6
  "rytass",