@things-factory/sales-base 4.3.355 → 4.3.358

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 (40) hide show
  1. package/dist-server/constants/order.js +22 -1
  2. package/dist-server/constants/order.js.map +1 -1
  3. package/dist-server/service/index.js +7 -0
  4. package/dist-server/service/index.js.map +1 -1
  5. package/dist-server/service/inventory-check/inventory-check-query.js +58 -9
  6. package/dist-server/service/inventory-check/inventory-check-query.js.map +1 -1
  7. package/dist-server/service/inventory-check/inventory-check-types.js +3 -3
  8. package/dist-server/service/inventory-check/inventory-check-types.js.map +1 -1
  9. package/dist-server/service/inventory-check/inventory-check.js +4 -4
  10. package/dist-server/service/inventory-check/inventory-check.js.map +1 -1
  11. package/dist-server/service/inventory-check-item/index.js +25 -0
  12. package/dist-server/service/inventory-check-item/index.js.map +1 -0
  13. package/dist-server/service/inventory-check-item/inventory-check-item-mutation.js +120 -0
  14. package/dist-server/service/inventory-check-item/inventory-check-item-mutation.js.map +1 -0
  15. package/dist-server/service/inventory-check-item/inventory-check-item-query.js +122 -0
  16. package/dist-server/service/inventory-check-item/inventory-check-item-query.js.map +1 -0
  17. package/dist-server/service/inventory-check-item/inventory-check-item-types.js +121 -0
  18. package/dist-server/service/inventory-check-item/inventory-check-item-types.js.map +1 -0
  19. package/dist-server/service/inventory-check-item/inventory-check-item.js +191 -0
  20. package/dist-server/service/inventory-check-item/inventory-check-item.js.map +1 -0
  21. package/dist-server/service/others/other-types.js +8 -0
  22. package/dist-server/service/others/other-types.js.map +1 -1
  23. package/dist-server/utils/inventory-util.js +84 -101
  24. package/dist-server/utils/inventory-util.js.map +1 -1
  25. package/dist-server/utils/order-no-generator.js +3 -0
  26. package/dist-server/utils/order-no-generator.js.map +1 -1
  27. package/package.json +6 -6
  28. package/server/constants/order.ts +23 -0
  29. package/server/service/index.ts +9 -2
  30. package/server/service/inventory-check/inventory-check-query.ts +58 -8
  31. package/server/service/inventory-check/inventory-check-types.ts +3 -3
  32. package/server/service/inventory-check/inventory-check.ts +4 -4
  33. package/server/service/inventory-check-item/index.ts +9 -0
  34. package/server/service/inventory-check-item/inventory-check-item-mutation.ts +113 -0
  35. package/server/service/inventory-check-item/inventory-check-item-query.ts +88 -0
  36. package/server/service/inventory-check-item/inventory-check-item-types.ts +77 -0
  37. package/server/service/inventory-check-item/inventory-check-item.ts +159 -0
  38. package/server/service/others/other-types.ts +6 -0
  39. package/server/utils/inventory-util.ts +85 -101
  40. package/server/utils/order-no-generator.ts +4 -0
@@ -0,0 +1,77 @@
1
+ import { Field, Float, InputType, Int, ObjectType } from 'type-graphql'
2
+ import { NewProduct } from '@things-factory/product-base'
3
+ import { InventoryPatch } from '@things-factory/warehouse-base'
4
+ import { ObjectRef } from '@things-factory/shell'
5
+ import { InventoryCheckItem } from './inventory-check-item'
6
+
7
+ @ObjectType()
8
+ export class InventoryCheckItemList {
9
+ @Field(type => [InventoryCheckItem], { nullable: true })
10
+ items: InventoryCheckItem[]
11
+
12
+ @Field(type => Int, { nullable: true })
13
+ total: number
14
+ }
15
+
16
+ @InputType()
17
+ export class NewInventoryCheckItem {
18
+ @Field()
19
+ name: string
20
+
21
+ @Field({ nullable: true })
22
+ status: string
23
+
24
+ @Field(type => InventoryPatch, { nullable: true })
25
+ inventory: InventoryPatch
26
+
27
+ @Field(type => NewProduct, { nullable: true })
28
+ product: NewProduct
29
+
30
+ @Field(type => ObjectRef, { nullable: true })
31
+ productDetail: ObjectRef
32
+
33
+ @Field({ nullable: true })
34
+ type: string
35
+ }
36
+
37
+ @InputType()
38
+ export class InventoryCheckItemPatch {
39
+ @Field({ nullable: true })
40
+ id: string
41
+
42
+ @Field({ nullable: true })
43
+ name: string
44
+
45
+ @Field(type => ObjectRef, { nullable: true })
46
+ inventory: ObjectRef
47
+
48
+ @Field({ nullable: true })
49
+ batchId: string
50
+
51
+ @Field({ nullable: true })
52
+ batchIdRef: string
53
+
54
+ @Field(type => Int, { nullable: true })
55
+ inspectedQty: number
56
+
57
+ @Field(type => Float, { nullable: true })
58
+ inspectedUomValue: number
59
+
60
+ @Field(type => ObjectRef, { nullable: true })
61
+ inspectedLocation: ObjectRef
62
+
63
+ @Field({ nullable: true })
64
+ inspectedBatchNo: string
65
+
66
+ @Field(type => ObjectRef, { nullable: true })
67
+ product: ObjectRef
68
+
69
+ @Field({ nullable: true })
70
+ productId: string
71
+
72
+ @Field({ nullable: true })
73
+ productDetailId: string
74
+
75
+ @Field({ nullable: true })
76
+ status: string
77
+ }
@@ -0,0 +1,159 @@
1
+ import { User } from '@things-factory/auth-base'
2
+ import { Bizplace } from '@things-factory/biz-base'
3
+ import { Domain } from '@things-factory/shell'
4
+ import { Field, ID, ObjectType } from 'type-graphql'
5
+ import { Inventory, Location } from '@things-factory/warehouse-base'
6
+ import { Product, ProductDetail } from '@things-factory/product-base'
7
+ import {
8
+ Column,
9
+ CreateDateColumn,
10
+ Entity,
11
+ Index,
12
+ ManyToOne,
13
+ PrimaryGeneratedColumn,
14
+ RelationId,
15
+ UpdateDateColumn
16
+ } from 'typeorm'
17
+ import { InventoryCheck } from '..'
18
+
19
+ @Entity()
20
+ @Index(
21
+ 'ix_inventory-check-item_0',
22
+ (inventoryCheckItem: InventoryCheckItem) => [inventoryCheckItem.domain, inventoryCheckItem.name],
23
+ {
24
+ unique: true
25
+ }
26
+ )
27
+ @Index(
28
+ 'ix_inventory-check-item_1',
29
+ (inventoryCheckItem: InventoryCheckItem) => [
30
+ inventoryCheckItem.bizplace,
31
+ inventoryCheckItem.inventoryCheck,
32
+ inventoryCheckItem.inventory,
33
+ inventoryCheckItem.countNo
34
+ ],
35
+ {
36
+ unique: true
37
+ }
38
+ )
39
+ @ObjectType({ description: 'Entity for InventoryCheckItem' })
40
+ export class InventoryCheckItem {
41
+ @PrimaryGeneratedColumn('uuid')
42
+ @Field(type => ID)
43
+ readonly id: string
44
+
45
+ @ManyToOne(type => Domain)
46
+ @Field(type => Domain, { nullable: true })
47
+ domain: Domain
48
+
49
+ @RelationId((inventoryCheckItem: InventoryCheckItem) => inventoryCheckItem.domain)
50
+ domainId: string
51
+
52
+ @ManyToOne(type => Bizplace)
53
+ @Field(type => Bizplace, { nullable: true })
54
+ bizplace: Bizplace
55
+
56
+ @RelationId((inventoryCheckItem: InventoryCheckItem) => inventoryCheckItem.bizplace)
57
+ bizplaceId: string
58
+
59
+ @Column()
60
+ @Field()
61
+ name: string
62
+
63
+ @Column({ nullable: true })
64
+ @Field({ nullable: true })
65
+ countNo: number
66
+
67
+ @Column({ nullable: true })
68
+ @Field({ nullable: true })
69
+ originQty: number
70
+
71
+ @Column({ nullable: true })
72
+ @Field({ nullable: true })
73
+ inspectedQty: number
74
+
75
+ @Column({ nullable: true, type: 'float' })
76
+ @Field({ nullable: true })
77
+ originUomValue: number
78
+
79
+ @Column({ nullable: true, type: 'float' })
80
+ @Field({ nullable: true })
81
+ inspectedUomValue: number
82
+
83
+ @Column({ nullable: true })
84
+ @Field({ nullable: true })
85
+ originBatchNo: string
86
+
87
+ @Column({ nullable: true })
88
+ @Field({ nullable: true })
89
+ inspectedBatchNo: string
90
+
91
+ @ManyToOne(type => Location, { nullable: true })
92
+ @Field(type => Location, { nullable: true })
93
+ originLocation: Location
94
+
95
+ @RelationId((inventoryCheckItem: InventoryCheckItem) => inventoryCheckItem.originLocation)
96
+ originLocationId: string
97
+
98
+ @ManyToOne(type => Location, { nullable: true })
99
+ @Field(type => Location, { nullable: true })
100
+ inspectedLocation: Location
101
+
102
+ @RelationId((inventoryCheckItem: InventoryCheckItem) => inventoryCheckItem.inspectedLocation)
103
+ inspectedLocationId: string
104
+
105
+ @Column()
106
+ @Field()
107
+ status: string
108
+
109
+ @ManyToOne(type => InventoryCheck)
110
+ @Field(type => InventoryCheck, { nullable: true })
111
+ inventoryCheck: InventoryCheck
112
+
113
+ @RelationId((inventoryCheckItem: InventoryCheckItem) => inventoryCheckItem.inventoryCheck)
114
+ inventoryCheckId: string
115
+
116
+ @ManyToOne(type => Inventory, { nullable: true })
117
+ @Field(type => Inventory, { nullable: true })
118
+ inventory: Inventory
119
+
120
+ @RelationId((inventoryCheckItem: InventoryCheckItem) => inventoryCheckItem.inventory)
121
+ inventoryId: string
122
+
123
+ @ManyToOne(type => Product, { nullable: true })
124
+ @Field(type => Product, { nullable: true })
125
+ product: Product
126
+
127
+ @RelationId((inventoryCheckItem: InventoryCheckItem) => inventoryCheckItem.product)
128
+ @Field({ nullable: true })
129
+ productId: string
130
+
131
+ @ManyToOne(type => ProductDetail, { nullable: true })
132
+ @Field(type => ProductDetail, { nullable: true })
133
+ productDetail: ProductDetail
134
+
135
+ @RelationId((inventoryCheckItem: InventoryCheckItem) => inventoryCheckItem.productDetail)
136
+ productDetailId: String
137
+
138
+ @CreateDateColumn()
139
+ @Field()
140
+ createdAt: Date
141
+
142
+ @UpdateDateColumn()
143
+ @Field()
144
+ updatedAt: Date
145
+
146
+ @ManyToOne(type => User)
147
+ @Field(type => User, { nullable: true })
148
+ creator: User
149
+
150
+ @RelationId((inventoryCheckItem: InventoryCheckItem) => inventoryCheckItem.creator)
151
+ creatorId: string
152
+
153
+ @ManyToOne(type => User)
154
+ @Field(type => User, { nullable: true })
155
+ updater: User
156
+
157
+ @RelationId((inventoryCheckItem: InventoryCheckItem) => inventoryCheckItem.updater)
158
+ updaterId: string
159
+ }
@@ -70,6 +70,12 @@ export class InventoryProductGroup {
70
70
  @Field({ nullable: true })
71
71
  remainUomValueWithUom: string
72
72
 
73
+ @Field(type => Float, { nullable: true })
74
+ lockedQty: number
75
+
76
+ @Field(type => Float, { nullable: true })
77
+ unassignedQty: number
78
+
73
79
  @Field({ nullable: true })
74
80
  uom: string
75
81
 
@@ -263,110 +263,89 @@ export const InventoryUtil = {
263
263
  let queryStrings = `
264
264
  CREATE TEMP TABLE temp_inventory_product_group AS (
265
265
  SELECT * FROM (
266
- WITH oi as (
267
266
  SELECT
268
- SUM(oi.release_qty) AS release_qty,
269
- SUM(oi.release_uom_value) AS release_uom_value,
270
- oi.batch_id,
271
- oi.batch_id_ref,
272
- oi.product_id,
273
- p.name AS product_name,
274
- oi.packing_type,
275
- oi.packing_size,
276
- oi.uom
277
- FROM
278
- order_inventories oi
279
- LEFT JOIN
280
- products p
281
- ON
282
- oi.product_id = p.id
283
- WHERE
284
- (oi.status = 'PENDING' or oi.status = 'PENDING_RECEIVE' or oi.status = 'PENDING_WORKSHEET' or oi.status = 'PENDING_SPLIT')
285
- AND oi.batch_id NOTNULL
286
- AND oi.product_id NOTNULL
287
- AND oi.packing_type NOTNULL
288
- AND oi.packing_size NOTNULL
289
- AND oi.inventory_id IS NULL
290
- GROUP BY
291
- oi.batch_id,
292
- oi.batch_id_ref,
293
- oi.product_id,
294
- oi.packing_type,
295
- oi.packing_size,
296
- oi.uom,
297
- p.name
298
- )
299
- SELECT
300
- i.batch_id AS "batchId",
301
- i.batch_id_ref AS "batchIdRef",
302
- i.packing_type AS "packingType",
303
- i.packing_size AS "packingSize",
304
- i.uom AS "uom",
305
- concat(p.name, ' (', p.description, ')') AS "productName",
306
- coalesce(p.sku, '') AS "productSKU",
307
- coalesce(p.brand, '') AS "productBrand",
308
- p.id AS "productId",
309
- i.product_detail_id AS "productDetailId",
310
- SUM(COALESCE(i.qty, 0)) - GREATEST(SUM(COALESCE(i.locked_qty, 0)), 0) - MAX(COALESCE(oi.release_qty, 0)) - MAX(COALESCE(bp.bundle_product_release_qty, 0)) - GREATEST(SUM(COALESCE(pds.unassigned_qty, 0)), 0) AS "remainQty",
311
- (
312
- CASE WHEN (SUM(COALESCE(i.uom_value, 0)) - GREATEST(SUM(COALESCE(i.locked_uom_value, 0)), 0) - MAX(COALESCE(oi.release_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)) - GREATEST(SUM(COALESCE(pds.unassigned_uom_value, 0)), 0)) < 0 THEN 0
313
- ELSE SUM(COALESCE(i.uom_value, 0)) - GREATEST(SUM(COALESCE(i.locked_uom_value, 0)), 0) - MAX(COALESCE(oi.release_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)) - GREATEST(SUM(COALESCE(pds.unassigned_uom_value, 0)), 0) END
314
- ) AS "remainUomValue",
315
- (
316
- CASE WHEN (SUM(COALESCE(i.uom_value, 0)) - GREATEST(SUM(COALESCE(i.locked_uom_value, 0)), 0) - MAX(COALESCE(oi.release_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)) - GREATEST(SUM(COALESCE(pds.unassigned_uom_value, 0)), 0)) < 0 THEN concat(0, ' ', i.uom)
317
- ELSE concat(SUM(COALESCE(i.uom_value, 0)) - GREATEST(SUM(COALESCE(i.locked_uom_value, 0)), 0) - MAX(COALESCE(oi.release_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)) - GREATEST(SUM(COALESCE(pds.unassigned_uom_value, 0)), 0), ' ', i.uom) END
318
- ) AS "remainUomValueWithUom",
319
- 'SINGLE' AS "groupType"
320
- FROM
321
- inventories i
267
+ i.batch_id AS "batchId",
268
+ i.batch_id_ref AS "batchIdRef",
269
+ i.packing_type AS "packingType",
270
+ i.packing_size AS "packingSize",
271
+ i.uom AS "uom",
272
+ CONCAT(p.name, ' (', p.description, ')') AS "productName",
273
+ COALESCE(p.sku, '') AS "productSKU",
274
+ COALESCE(p.brand, '') AS "productBrand",
275
+ p.id AS "productId",
276
+ i.product_detail_id AS "productDetailId",
277
+ SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(bp.bundle_product_release_qty, 0)) - SUM(COALESCE(pds.unassigned_qty, 0)) AS "remainQty",
278
+ SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)) - SUM(COALESCE(pds.unassigned_uom_value, 0)) AS "remainUomValue",
279
+ SUM(COALESCE(i.locked_qty, 0)) AS "lockedQty",
280
+ CONCAT(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(bp.bundle_product_release_uom_value, 0)) - SUM(COALESCE(pds.unassigned_uom_value, 0)), ' ', i.uom) AS "remainUomValueWithUom",
281
+ 'SINGLE' AS "groupType",
282
+ SUM(COALESCE(pds.unassigned_qty, 0)) AS "unassignedQty"
283
+ FROM inventories i
322
284
  LEFT JOIN products p ON i.product_id = p.id
323
285
  LEFT JOIN product_detail_stocks pds ON pds.product_detail_id = i.product_detail_id
324
- LEFT JOIN oi ON i.batch_id = oi.batch_id AND p.name = oi.product_name AND i.packing_type = oi.packing_type AND i.packing_size = oi.packing_size AND i.uom = oi.uom
325
- LEFT JOIN locations l2 ON i.location_id = l2.id AND i.domain_id = l2.domain_id
326
286
  LEFT JOIN (
327
- SELECT pbs.product_id, SUM(pbs.bundle_qty * src.release_qty) AS bundle_product_release_qty, SUM(pbs.bundle_qty * src.release_uom_value) AS bundle_product_release_uom_value
328
- FROM product_bundle_settings pbs
329
- INNER JOIN json_populate_recordset(NULL::order_inventories,'${batchBundle}') src ON src.product_id = pbs.product_bundle_id
330
- GROUP BY pbs.product_id
331
- ) bp on i.product_id = bp.product_id
332
- WHERE i.domain_id = $1
333
- AND l2.type NOT IN ('${LOCATION_TYPE.QUARANTINE}', '${LOCATION_TYPE.RESERVE}', '${LOCATION_TYPE.DAMAGE}')
334
- AND i.obsolete = false
335
- AND i.transfer_qty <= 0
336
- AND i.transfer_uom_value <= 0
337
- AND case when i.expiration_date is not null and p.min_outbound_shelf_life is not null then CURRENT_DATE < i.expiration_date - p.min_outbound_shelf_life else true end
338
- ${productWhereClause}
339
- GROUP BY
340
- i.product_detail_id,
341
- i.batch_id,
342
- i.batch_id_ref,
343
- p.id,
344
- i.packing_type,
345
- i.packing_size,
346
- i.uom
347
- UNION
348
- SELECT 'BUNDLE' AS "batchId", null as "batchIdRef", packing_type, packing_size,'UNIT' AS "uom", name AS "productName", sku AS "productSKU", 'brand' AS "productBrand", id AS "productId", pbs.product_detail_id AS "productDetailId",
349
- MIN(FLOOR(pbs."availableQty")) AS "remainQty",
350
- MIN(FLOOR(pbs."availableUomValue")) AS "remainUomValue",
351
- CONCAT(MIN(FLOOR(pbs."availableUomValue")),' UNIT') AS "remainUomValueWithUom",
352
- 'BUNDLE' AS "groupType"
353
- FROM product_bundles pb
354
- INNER JOIN (
355
- SELECT pbs.product_id, pbs.product_bundle_id, min(pbs.bundle_qty),
356
- (SUM(COALESCE(i2.qty, 0)) - GREATEST(SUM(COALESCE(i2.locked_qty, 0)), 0) - MAX(COALESCE(oi.release_qty, 0))) / min(pbs.bundle_qty) AS "availableQty",
357
- (SUM(COALESCE(i2.uom_value, 0)) - GREATEST(SUM(COALESCE(i2.locked_uom_value, 0)), 0) - MAX(COALESCE(oi.release_uom_value, 0))) / min(pbs.bundle_qty) AS "availableUomValue",
358
- pbs.product_detail_id
359
- FROM product_bundle_settings pbs
360
- LEFT JOIN inventories i2 ON i2.product_id = pbs.product_id AND i2.domain_id = $1
361
- AND i2.bizplace_id IN (${bizplaceIds})
362
- AND i2.status = 'STORED'
363
- LEFT JOIN oi ON oi.product_id = i2.product_id
364
- GROUP BY pbs.product_id, pbs.product_bundle_id, pbs.product_detail_id
365
- ) pbs ON pbs.product_bundle_id = pb.id
366
- ${bundleWhereClause}
367
- GROUP BY pb.packing_type, pb.packing_size, pb.name, pb.sku, pb.id, pbs.product_detail_id
368
- )
369
- AS inv_prod_grp
287
+ SELECT
288
+ pbs.product_id,
289
+ SUM(pbs.bundle_qty * src.release_qty) AS bundle_product_release_qty,
290
+ SUM(pbs.bundle_qty * src.release_uom_value) AS bundle_product_release_uom_value
291
+ FROM product_bundle_settings pbs
292
+ INNER JOIN json_populate_recordset(NULL::order_inventories,'${batchBundle}') src ON src.product_id = pbs.product_bundle_id
293
+ GROUP BY pbs.product_id
294
+ ) bp ON i.product_id = bp.product_id
295
+ LEFT JOIN locations l2 ON i.location_id = l2.id AND i.domain_id = l2.domain_id
296
+ WHERE i.domain_id = $1
297
+ AND l2.type NOT IN ('${LOCATION_TYPE.QUARANTINE}', '${LOCATION_TYPE.RESERVE}', '${LOCATION_TYPE.DAMAGE}')
298
+ AND i.obsolete = false
299
+ AND i.transfer_qty <= 0
300
+ AND i.transfer_uom_value <= 0
301
+ AND CASE WHEN i.expiration_date IS NOT NULL AND p.min_outbound_shelf_life IS NOT NULL THEN CURRENT_DATE < i.expiration_date - p.min_outbound_shelf_life ELSE true END
302
+ ${productWhereClause}
303
+ GROUP BY
304
+ i.product_detail_id,
305
+ i.batch_id,
306
+ i.batch_id_ref,
307
+ p.id,
308
+ i.packing_type,
309
+ i.packing_size,
310
+ i.uom
311
+ UNION
312
+ SELECT
313
+ 'BUNDLE' AS "batchId",
314
+ NULL AS "batchIdRef",
315
+ pb.packing_type,
316
+ pb.packing_size,
317
+ 'UNIT' AS "uom",
318
+ pb.name AS "productName",
319
+ pb.sku AS "productSKU",
320
+ 'brand' AS "productBrand",
321
+ id AS "productId",
322
+ pbs.product_detail_id AS "productDetailId",
323
+ MIN(FLOOR(pbs."availableQty")) AS "remainQty",
324
+ MIN(FLOOR(pbs."availableUomValue")) AS "remainUomValue",
325
+ MIN(FLOOR(pbs."releaseQty")) AS "lockedQty",
326
+ CONCAT(MIN(FLOOR(pbs."availableUomValue")), ' UNIT') AS "remainUomValueWithUom",
327
+ 'BUNDLE' AS "groupType",
328
+ 0 AS "unassignedQty"
329
+ FROM product_bundles pb
330
+ INNER JOIN (
331
+ SELECT
332
+ pbs.product_id,
333
+ pbs.product_bundle_id,
334
+ MIN(pbs.bundle_qty),
335
+ (SUM(COALESCE(i2.qty, 0)) - GREATEST(SUM(COALESCE(i2.locked_qty, 0)), 0)) / MIN(pbs.bundle_qty) AS "availableQty",
336
+ (SUM(COALESCE(i2.uom_value, 0)) - GREATEST(SUM(COALESCE(i2.locked_uom_value, 0)), 0)) / MIN(pbs.bundle_qty) AS "availableUomValue",
337
+ (SUM(COALESCE(i2.locked_qty, 0))) / min(pbs.bundle_qty) AS "releaseQty",
338
+ pbs.product_detail_id
339
+ FROM product_bundle_settings pbs
340
+ LEFT JOIN inventories i2 ON i2.product_id = pbs.product_id
341
+ AND i2.domain_id = $1
342
+ AND i2.bizplace_id IN (${bizplaceIds})
343
+ AND i2.status = 'STORED'
344
+ GROUP BY pbs.product_id, pbs.product_bundle_id, pbs.product_detail_id
345
+ ) pbs ON pbs.product_bundle_id = pb.id
346
+ ${bundleWhereClause}
347
+ GROUP BY pb.packing_type, pb.packing_size, pb.name, pb.sku, pb.id, pbs.product_detail_id
348
+ ) AS inv_prod_grp
370
349
  ${whereClause}
371
350
  )
372
351
  `
@@ -819,7 +798,12 @@ async function getConditions(
819
798
  let bundleWhereClause = `
820
799
  WHERE pb.status = 'ACTIVATED'
821
800
  `
822
- let whereClause = hasRemainingQty ? ` WHERE "remainQty" > 0 ` : ` WHERE 1 = 1 `
801
+ // Find the showAllInventory filter
802
+ const showAllInventoryFilter = filters.find(filter => filter.name === 'showAllInventory')
803
+ const showAllInventory = showAllInventoryFilter ? showAllInventoryFilter.value : false
804
+
805
+ // Set the whereClause based on the showAllInventory value
806
+ let whereClause = showAllInventory ? ` WHERE 1 = 1 ` : hasRemainingQty ? ` WHERE "remainQty" > 0 ` : ` WHERE 1 = 1 `
823
807
 
824
808
  let productDetailWhereClause = ``
825
809
 
@@ -36,6 +36,10 @@ export class OrderNoGenerator {
36
36
  }${currentDate.getDate()}${currentDate.getHours()}${currentDate.getMinutes()}${currentDate.getSeconds()}${currentDate.getMilliseconds()}`
37
37
  }
38
38
 
39
+ static inventoryCheckItem() {
40
+ return uuidv4()
41
+ }
42
+
39
43
  static jobSheet(domainName) {
40
44
  const currentDate = new Date()
41
45
  return `${domainName}-${currentDate.getFullYear()}${