@things-factory/operato-mms 4.3.159 → 4.3.161

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.
@@ -27,6 +27,7 @@ export const ORDER_STATUS = {
27
27
  PENDING_RECEIVE: { name: 'order_status_pending_receive', value: 'PENDING_RECEIVE' },
28
28
  PENDING_REVIEW: { name: 'order_status_pending_review', value: 'PENDING_REVIEW' },
29
29
  PENDING_APPROVAL: { name: 'order_status_pending_approval', value: 'PENDING_APPROVAL' },
30
+ PENDING_WORKSHEET: { name: 'order_status_pending_worksheet', value: 'PENDING_WORKSHEET' },
30
31
  CANCELLED: { name: 'order_status_cancelled', value: 'CANCELLED' },
31
32
  EDITING: { name: 'order_status_editing', value: 'EDITING' },
32
33
  REJECTED: { name: 'order_status_rejected', value: 'REJECTED' },
@@ -45,10 +46,12 @@ export const ORDER_STATUS = {
45
46
  INPROCESS: { name: 'order_status_in_process', value: 'INPROCESS' },
46
47
  READY_TO_PICK: { name: 'order_status_ready_to_pick', value: 'READY_TO_PICK' },
47
48
  PICKING: { name: 'order_status_picking', value: 'PICKING' },
49
+ PACKING: { name: 'order_status_packing', value: 'PACKING' },
48
50
  LOADING: { name: 'order_status_loading', value: 'LOADING' },
49
51
  READY_TO_DISPATCH: { name: 'order_status_ready_to_dispatch', value: 'READY_TO_DISPATCH' },
50
52
  READY_TO_EXECUTE: { name: 'order_status_ready_to_execute', value: 'READY_TO_EXECUTE' },
51
- READY_TO_SEND: { name: 'order_status_ready_to_send', value: 'READY_TO_SEND' }
53
+ READY_TO_SEND: { name: 'order_status_ready_to_send', value: 'READY_TO_SEND' },
54
+ OBSOLETE: { name: 'order_status_obsolete', value: 'OBSOLETE' }
52
55
  }
53
56
 
54
57
  export const ORDER_PRODUCT_STATUS = {
@@ -38,8 +38,7 @@ async function warehouseMarketplaceProduct(params, domain, user, tx) {
38
38
  "Product"."description" AS "product_description", "Product"."creator_id", "Product"."updater_id",
39
39
  "Product"."bizplace_id" AS "product_bizplace_id", 'PRODUCT' AS "type"
40
40
  FROM products "Product"
41
- WHERE 1=1
42
- AND "Product"."deleted_at" IS NULL
41
+ WHERE "Product"."deleted_at" IS NULL
43
42
  AND "Product"."bizplace_id" IN (${bizplaceIds})
44
43
  ${productQuery}
45
44
  ) d1
@@ -50,64 +49,12 @@ async function warehouseMarketplaceProduct(params, domain, user, tx) {
50
49
  "Product"."description" AS "product_description", "Product"."creator_id", "Product"."updater_id",
51
50
  "Product"."bizplace_id" AS "product_bizplace_id", 'BUNDLE' AS "type"
52
51
  FROM product_bundles "Product"
53
- WHERE 1 = 1
54
- AND "Product"."status" = 'ACTIVATED'
52
+ WHERE "Product"."status" = 'ACTIVATED'
55
53
  AND "Product"."bizplace_id" IN (${bizplaceIds})
56
54
  ${productQuery}
57
55
  ) d2
58
56
  )
59
57
  `);
60
- await tx.query(`
61
- CREATE TEMP TABLE "temp_order_inventories" ON COMMIT DROP AS (
62
- SELECT
63
- SUM(oi.release_qty) AS release_qty, SUM(oi.release_uom_value) AS release_uom_value, oi.batch_id, oi.batch_id_ref,
64
- oi.product_id, p.product_name, oi.packing_type, oi.packing_size, oi.uom
65
- FROM
66
- order_inventories oi
67
- LEFT JOIN
68
- temp_products p ON oi.product_id = p.product_id
69
- INNER JOIN
70
- domains d2 on d2.id = oi.domain_id and d2.ext_type ='warehouse'
71
- INNER JOIN
72
- fulfillment_centers fc ON fc.center_id = d2.subdomain
73
- WHERE
74
- fc.domain_id = $1
75
- AND (oi.status = 'PENDING' or oi.status = 'PENDING_RECEIVE' or oi.status = 'PENDING_WORKSHEET' or oi.status = 'PENDING_SPLIT')
76
- AND oi.batch_id NOTNULL AND oi.product_id NOTNULL AND oi.packing_type NOTNULL AND oi.packing_size NOTNULL AND oi.inventory_id IS NULL
77
- GROUP BY
78
- oi.batch_id, oi.batch_id_ref, oi.product_id, oi.packing_type,
79
- oi.packing_size, oi.uom, p.product_name
80
- );
81
- `, [domain.id]);
82
- await tx.query(`
83
- CREATE TEMP TABLE "temp_inventory" ON COMMIT DROP AS (
84
- select "i2".*, coalesce("oi".release_qty,0) + coalesce("i2".locked_qty,0) as "inventory_locked_qty" from (
85
- select "fc"."id" as "fulfillment_id", "fc"."name" as "fulfillment_name",
86
- "i2"."product_id", sum(coalesce("locked_qty",0)) as "locked_qty", sum(coalesce("qty",0)) as "inventory_qty",
87
- "i2"."domain_id", "i2"."packing_type", "i2"."packing_size", "i2"."uom"
88
- from inventories "i2"
89
- inner join warehouses "w" on "w"."id" = "i2"."warehouse_id"
90
- inner join domains "d2" on "d2"."id" = "w"."domain_id" and "d2"."ext_type" ='warehouse'
91
- inner join fulfillment_centers "fc" ON "fc"."center_id" = "d2"."subdomain"
92
- inner join (
93
- select "Product"."product_id" from (
94
- select case when "Product"."type" = 'PRODUCT' then "Product"."product_id" else "pbs"."product_id" end as "product_id"
95
- from temp_products "Product"
96
- left join product_bundles "pb" on "pb"."id" = "Product"."product_id"
97
- left join product_bundle_settings "pbs" on "pbs"."product_bundle_id" = "pb"."id"
98
- ) "Product"
99
- group by "Product"."product_id"
100
- ) "Product" on "Product"."product_id" = "i2"."product_id"
101
- where "fc"."domain_id" = $1
102
- and "i2"."status" = 'STORED'
103
- group by "i2"."domain_id", "fc"."id", "fc"."name", "i2"."product_id", "i2"."packing_type", "i2"."packing_size", "i2"."uom"
104
- ) as "i2"
105
- left join temp_order_inventories "oi" on "i2"."product_id" = "oi"."product_id"
106
- AND "i2"."packing_type" = "oi"."packing_type"
107
- AND "i2"."packing_size" = "oi"."packing_size"
108
- AND "i2"."uom" = "oi"."uom"
109
- )
110
- `, [domain.id]);
111
58
  await tx.query(`
112
59
  CREATE TEMP TABLE "temp_json_warehouse_marketplace_products" ON COMMIT DROP AS (
113
60
  select "product_id", array_to_json(array_agg(row_to_json(dt))) AS "Json_marketplaceProducts" FROM (
@@ -127,26 +74,15 @@ async function warehouseMarketplaceProduct(params, domain, user, tx) {
127
74
  await tx.query(`
128
75
  CREATE TEMP TABLE temp_json_warehouse_inventory ON COMMIT DROP AS (
129
76
  select "product_id", array_to_json(array_agg((row_to_json("dt")))) AS "Json_warehouseInventory" from(
130
- select "domain_id", "fulfillment_id", "fulfillment_name",
131
- "product_id", "inventory_locked_qty", "inventory_qty"
132
- from temp_inventory
133
- union
134
- select "bundledInv"."domain_id", "bundledInv"."fulfillment_id", "bundledInv"."fulfillment_name", "bundledInv"."product_id",
135
- max("bundledInv"."inventory_locked_qty") as "inventory_locked_qty", min("bundledInv"."inventory_qty") as "inventory_qty" from (
136
- select "Product"."product_id", fc.domain_id, "fc"."id" as "fulfillment_id", "fc"."name" as "fulfillment_name",
137
- "pbs"."bundle_qty",
138
- case when "pbs"."bundle_qty" <= 0 then 0 else floor(greatest("i2"."inventory_qty", 0)/ "pbs"."bundle_qty")- floor((greatest("i2"."inventory_qty", 0) - greatest("i2"."inventory_locked_qty",0)) / "pbs"."bundle_qty") end AS "inventory_locked_qty",
139
- case when "pbs"."bundle_qty" <= 0 then 0 else floor(greatest("i2"."inventory_qty", 0)/ "pbs"."bundle_qty") end AS "inventory_qty"
140
- from temp_products "Product"
141
- inner join product_bundle_settings pbs ON pbs.product_bundle_id = "Product"."product_id"
142
- inner join products p on p.id = pbs.product_id
143
- cross join fulfillment_centers fc
144
- inner join domains "d2" on "d2"."ext_type" ='warehouse' and "fc"."center_id" = "d2"."subdomain"
145
- left join temp_inventory i2 ON i2.product_id = pbs.product_id and "d2"."id" = "i2"."domain_id"
146
- where "fc"."domain_id" = $1
147
- order by fc.id, "Product"."product_sku", p.sku
148
- ) "bundledInv"
149
- group by "domain_id","fulfillment_id","fulfillment_name","product_id"
77
+ select wboi.domain_id, fc.id as fulfillment_id, fc.name as fulfillment_name,
78
+ coalesce(wboi.product_id, wboi.product_bundle_id) as product_id, wboi.qty - wboi.remain_qty as inventory_locked_qty, wboi.qty as inventory_qty
79
+ from warehouse_bizplace_onhand_inventories wboi
80
+ inner join domains d on d.id = wboi.domain_id
81
+ inner join fulfillment_centers fc on fc.center_id = d.subdomain
82
+ inner join bizplaces b on b.id = wboi.bizplace_id
83
+ inner join companies c on c.id = b.company_id
84
+ inner join bizplaces b2 on b2.domain_id = c.domain_id
85
+ where fc.domain_id = $1 and b2.id IN (${bizplaceIds})
150
86
  ) "dt" group by "dt"."product_id"
151
87
  )
152
88
  `, [domain.id]);
@@ -1 +1 @@
1
- {"version":3,"file":"warehouse-marketplace-products.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/interface-with-hub/warehouse-marketplace-products.ts"],"names":[],"mappings":";;;AAGA,uDAAsF;AAGzE,QAAA,oCAAoC,GAAG;IAClD,KAAK,CAAC,4BAA4B,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;QACxE,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;YAC7F,OAAO,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;SAC7D;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,KAAK,CAAA;SACZ;IACH,CAAC;CACF,CAAA;AAEM,KAAK,UAAU,2BAA2B,CAAC,MAAiB,EAAE,MAAc,EAAE,IAAU,EAAE,EAAkB;IACjH,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,cAAc,CAAC,CAAA;IAC3E,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,cAAc,CAAC,CAAA;IAEpE,MAAM,eAAe,GAAa,MAAM,IAAA,6BAAkB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACxE,MAAM,UAAU,GAAa,MAAM,IAAA,wBAAa,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAE9D,MAAM,CAAC,OAAO,GAAG,CAAC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4B,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;gCACtE,OAAO;oCACL,EAAE,EAAE,SAAS,CAAC,gCAAgC;oCAC9C,IAAI,EAAE,SAAS,CAAC,IAAI;oCACpB,GAAG,EAAE,SAAS,CAAC,GAAG;oCAClB,UAAU,EAAE,SAAS,CAAC,WAAW;iCAClC,CAAA;4BACH,CAAC,CAAC;yBACH,CAAA;oBACH,CAAC,CAAC;oBACJ,CAAC,CAAC,IAAI;gBACR,kBAAkB,EAAE,GAAG,CAAC,uBAAuB;oBAC7C,CAAC,CAAC,GAAG,CAAC,uBAAuB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;wBAC1C,OAAO;4BACL,QAAQ,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,SAAS,CAAC,gBAAgB,EAAE;4BAC5E,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,UAAU,EAAE;4BACrC,GAAG,EAAE,SAAS,CAAC,aAAa;4BAC5B,SAAS,EAAE,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;4BAC9E,SAAS,EACP,SAAS,CAAC,aAAa,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;yBAClG,CAAA;oBACH,CAAC,CAAC;oBACJ,CAAC,CAAC,IAAI;aACT,CAAA;QACH,CAAC,CAAC;QACF,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;KACtB,CAAA;AACH,CAAC;AArOD,kEAqOC"}
1
+ {"version":3,"file":"warehouse-marketplace-products.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/interface-with-hub/warehouse-marketplace-products.ts"],"names":[],"mappings":";;;AAGA,uDAAsF;AAGzE,QAAA,oCAAoC,GAAG;IAClD,KAA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EAAE,SAAS,CAAC,aAAa;4BAC5B,SAAS,EAAE,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;4BAC9E,SAAS,EACP,SAAS,CAAC,aAAa,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;yBAClG,CAAA;oBACH,CAAC,CAAC;oBACJ,CAAC,CAAC,IAAI;aACT,CAAA;QACH,CAAC,CAAC;QACF,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;KACtB,CAAA;AACH,CAAC;AA7JD,kEA6JC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/operato-mms",
3
- "version": "4.3.159",
3
+ "version": "4.3.161",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -78,12 +78,12 @@
78
78
  "@things-factory/integration-fulfillment": "^4.3.159",
79
79
  "@things-factory/integration-lmd": "^4.3.159",
80
80
  "@things-factory/lite-menu": "^4.3.159",
81
- "@things-factory/marketplace-base": "^4.3.159",
81
+ "@things-factory/marketplace-base": "^4.3.161",
82
82
  "@things-factory/more-ui": "^4.3.159",
83
83
  "@things-factory/notification": "^4.3.159",
84
84
  "@things-factory/oauth2-client": "^4.3.159",
85
85
  "@things-factory/pdf": "^4.3.159",
86
- "@things-factory/product-base": "^4.3.159",
86
+ "@things-factory/product-base": "^4.3.161",
87
87
  "@things-factory/resource-ui": "^4.3.159",
88
88
  "@things-factory/scene-data-transform": "^4.3.159",
89
89
  "@things-factory/scene-excel": "^4.3.159",
@@ -98,11 +98,11 @@
98
98
  "@things-factory/scene-visualizer": "^4.3.159",
99
99
  "@things-factory/setting-ui": "^4.3.159",
100
100
  "@things-factory/system-ui": "^4.3.159",
101
- "@things-factory/warehouse-base": "^4.3.159"
101
+ "@things-factory/warehouse-base": "^4.3.161"
102
102
  },
103
103
  "devDependencies": {
104
104
  "@things-factory/builder": "^4.3.159",
105
105
  "@types/node-fetch": "^2.5.7"
106
106
  },
107
- "gitHead": "4ef9913b22e5b7baee27d9057fb04c707f7f49ec"
107
+ "gitHead": "7fe9232a64285ebaa04382258806889c47924157"
108
108
  }
@@ -45,8 +45,7 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
45
45
  "Product"."description" AS "product_description", "Product"."creator_id", "Product"."updater_id",
46
46
  "Product"."bizplace_id" AS "product_bizplace_id", 'PRODUCT' AS "type"
47
47
  FROM products "Product"
48
- WHERE 1=1
49
- AND "Product"."deleted_at" IS NULL
48
+ WHERE "Product"."deleted_at" IS NULL
50
49
  AND "Product"."bizplace_id" IN (${bizplaceIds})
51
50
  ${productQuery}
52
51
  ) d1
@@ -57,73 +56,13 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
57
56
  "Product"."description" AS "product_description", "Product"."creator_id", "Product"."updater_id",
58
57
  "Product"."bizplace_id" AS "product_bizplace_id", 'BUNDLE' AS "type"
59
58
  FROM product_bundles "Product"
60
- WHERE 1 = 1
61
- AND "Product"."status" = 'ACTIVATED'
59
+ WHERE "Product"."status" = 'ACTIVATED'
62
60
  AND "Product"."bizplace_id" IN (${bizplaceIds})
63
61
  ${productQuery}
64
62
  ) d2
65
63
  )
66
64
  `)
67
65
 
68
- await tx.query(
69
- `
70
- CREATE TEMP TABLE "temp_order_inventories" ON COMMIT DROP AS (
71
- SELECT
72
- SUM(oi.release_qty) AS release_qty, SUM(oi.release_uom_value) AS release_uom_value, oi.batch_id, oi.batch_id_ref,
73
- oi.product_id, p.product_name, oi.packing_type, oi.packing_size, oi.uom
74
- FROM
75
- order_inventories oi
76
- LEFT JOIN
77
- temp_products p ON oi.product_id = p.product_id
78
- INNER JOIN
79
- domains d2 on d2.id = oi.domain_id and d2.ext_type ='warehouse'
80
- INNER JOIN
81
- fulfillment_centers fc ON fc.center_id = d2.subdomain
82
- WHERE
83
- fc.domain_id = $1
84
- AND (oi.status = 'PENDING' or oi.status = 'PENDING_RECEIVE' or oi.status = 'PENDING_WORKSHEET' or oi.status = 'PENDING_SPLIT')
85
- AND oi.batch_id NOTNULL AND oi.product_id NOTNULL AND oi.packing_type NOTNULL AND oi.packing_size NOTNULL AND oi.inventory_id IS NULL
86
- GROUP BY
87
- oi.batch_id, oi.batch_id_ref, oi.product_id, oi.packing_type,
88
- oi.packing_size, oi.uom, p.product_name
89
- );
90
- `,
91
- [domain.id]
92
- )
93
-
94
- await tx.query(
95
- `
96
- CREATE TEMP TABLE "temp_inventory" ON COMMIT DROP AS (
97
- select "i2".*, coalesce("oi".release_qty,0) + coalesce("i2".locked_qty,0) as "inventory_locked_qty" from (
98
- select "fc"."id" as "fulfillment_id", "fc"."name" as "fulfillment_name",
99
- "i2"."product_id", sum(coalesce("locked_qty",0)) as "locked_qty", sum(coalesce("qty",0)) as "inventory_qty",
100
- "i2"."domain_id", "i2"."packing_type", "i2"."packing_size", "i2"."uom"
101
- from inventories "i2"
102
- inner join warehouses "w" on "w"."id" = "i2"."warehouse_id"
103
- inner join domains "d2" on "d2"."id" = "w"."domain_id" and "d2"."ext_type" ='warehouse'
104
- inner join fulfillment_centers "fc" ON "fc"."center_id" = "d2"."subdomain"
105
- inner join (
106
- select "Product"."product_id" from (
107
- select case when "Product"."type" = 'PRODUCT' then "Product"."product_id" else "pbs"."product_id" end as "product_id"
108
- from temp_products "Product"
109
- left join product_bundles "pb" on "pb"."id" = "Product"."product_id"
110
- left join product_bundle_settings "pbs" on "pbs"."product_bundle_id" = "pb"."id"
111
- ) "Product"
112
- group by "Product"."product_id"
113
- ) "Product" on "Product"."product_id" = "i2"."product_id"
114
- where "fc"."domain_id" = $1
115
- and "i2"."status" = 'STORED'
116
- group by "i2"."domain_id", "fc"."id", "fc"."name", "i2"."product_id", "i2"."packing_type", "i2"."packing_size", "i2"."uom"
117
- ) as "i2"
118
- left join temp_order_inventories "oi" on "i2"."product_id" = "oi"."product_id"
119
- AND "i2"."packing_type" = "oi"."packing_type"
120
- AND "i2"."packing_size" = "oi"."packing_size"
121
- AND "i2"."uom" = "oi"."uom"
122
- )
123
- `,
124
- [domain.id]
125
- )
126
-
127
66
  await tx.query(`
128
67
  CREATE TEMP TABLE "temp_json_warehouse_marketplace_products" ON COMMIT DROP AS (
129
68
  select "product_id", array_to_json(array_agg(row_to_json(dt))) AS "Json_marketplaceProducts" FROM (
@@ -145,26 +84,15 @@ export async function warehouseMarketplaceProduct(params: ListParam, domain: Dom
145
84
  `
146
85
  CREATE TEMP TABLE temp_json_warehouse_inventory ON COMMIT DROP AS (
147
86
  select "product_id", array_to_json(array_agg((row_to_json("dt")))) AS "Json_warehouseInventory" from(
148
- select "domain_id", "fulfillment_id", "fulfillment_name",
149
- "product_id", "inventory_locked_qty", "inventory_qty"
150
- from temp_inventory
151
- union
152
- select "bundledInv"."domain_id", "bundledInv"."fulfillment_id", "bundledInv"."fulfillment_name", "bundledInv"."product_id",
153
- max("bundledInv"."inventory_locked_qty") as "inventory_locked_qty", min("bundledInv"."inventory_qty") as "inventory_qty" from (
154
- select "Product"."product_id", fc.domain_id, "fc"."id" as "fulfillment_id", "fc"."name" as "fulfillment_name",
155
- "pbs"."bundle_qty",
156
- case when "pbs"."bundle_qty" <= 0 then 0 else floor(greatest("i2"."inventory_qty", 0)/ "pbs"."bundle_qty")- floor((greatest("i2"."inventory_qty", 0) - greatest("i2"."inventory_locked_qty",0)) / "pbs"."bundle_qty") end AS "inventory_locked_qty",
157
- case when "pbs"."bundle_qty" <= 0 then 0 else floor(greatest("i2"."inventory_qty", 0)/ "pbs"."bundle_qty") end AS "inventory_qty"
158
- from temp_products "Product"
159
- inner join product_bundle_settings pbs ON pbs.product_bundle_id = "Product"."product_id"
160
- inner join products p on p.id = pbs.product_id
161
- cross join fulfillment_centers fc
162
- inner join domains "d2" on "d2"."ext_type" ='warehouse' and "fc"."center_id" = "d2"."subdomain"
163
- left join temp_inventory i2 ON i2.product_id = pbs.product_id and "d2"."id" = "i2"."domain_id"
164
- where "fc"."domain_id" = $1
165
- order by fc.id, "Product"."product_sku", p.sku
166
- ) "bundledInv"
167
- group by "domain_id","fulfillment_id","fulfillment_name","product_id"
87
+ select wboi.domain_id, fc.id as fulfillment_id, fc.name as fulfillment_name,
88
+ coalesce(wboi.product_id, wboi.product_bundle_id) as product_id, wboi.qty - wboi.remain_qty as inventory_locked_qty, wboi.qty as inventory_qty
89
+ from warehouse_bizplace_onhand_inventories wboi
90
+ inner join domains d on d.id = wboi.domain_id
91
+ inner join fulfillment_centers fc on fc.center_id = d.subdomain
92
+ inner join bizplaces b on b.id = wboi.bizplace_id
93
+ inner join companies c on c.id = b.company_id
94
+ inner join bizplaces b2 on b2.domain_id = c.domain_id
95
+ where fc.domain_id = $1 and b2.id IN (${bizplaceIds})
168
96
  ) "dt" group by "dt"."product_id"
169
97
  )
170
98
  `,