@things-factory/sales-base 4.3.700 → 4.3.701

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.
@@ -78,8 +78,6 @@ export const InventoryUtil = {
78
78
  }
79
79
  }
80
80
 
81
- // optional override for outbound shelf life (from ContactPoint deliverTo)
82
- const releaseShelfLifeOverrideFilter = filters.find(f => f.name === 'releaseShelfLifeOverride')
83
81
  let queryStrings = `
84
82
  CREATE TEMP TABLE temp_inventory_product_group ON COMMIT DROP AS (
85
83
  SELECT * FROM (
@@ -165,19 +163,7 @@ export const InventoryUtil = {
165
163
  ) bp on i.product_id = bp.product_id
166
164
  WHERE i.bizplace_id IN (${bizplaceIds})
167
165
  AND i.lock_inventory is not true
168
- AND case
169
- when i.expiration_date is not null
170
- then CURRENT_DATE < i.expiration_date - (
171
- case
172
- when $2::integer is not null and $2::integer > 0
173
- then $2::integer
174
- when p.min_outbound_shelf_life is not null
175
- then p.min_outbound_shelf_life
176
- else 0
177
- end
178
- )
179
- else true
180
- end
166
+ 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
181
167
  ${productDetailWhereClause}
182
168
  ${
183
169
  productFilter
@@ -266,10 +252,7 @@ export const InventoryUtil = {
266
252
  )
267
253
  `
268
254
 
269
- await trxMgr.query(queryStrings, [
270
- domain.id,
271
- releaseShelfLifeOverrideFilter ? releaseShelfLifeOverrideFilter.value : null
272
- ])
255
+ await trxMgr.query(queryStrings, [domain.id])
273
256
 
274
257
  const [{ total }]: any = await trxMgr.query(`select count(*) as total from temp_inventory_product_group`)
275
258
  let items: any[] = []
@@ -312,7 +295,6 @@ export const InventoryUtil = {
312
295
  let cycleCountFilter = filters.find(filter => filter.name == 'cycleCount')?.value
313
296
 
314
297
  const _groupType = filters.find(res => res.name == 'groupType')
315
- const releaseShelfLifeOverrideFilter = filters.find(filter => filter.name === 'releaseShelfLifeOverride')
316
298
  let queryStrings = `
317
299
  CREATE TEMP TABLE temp_inventory_product_group AS (
318
300
  SELECT * FROM (
@@ -353,7 +335,7 @@ export const InventoryUtil = {
353
335
  AND i.transfer_qty <= 0
354
336
  AND i.transfer_uom_value <= 0
355
337
  AND i.lock_inventory is not true
356
- AND CASE WHEN i.expiration_date IS NOT NULL AND COALESCE($2::integer, p.min_outbound_shelf_life) IS NOT NULL THEN CURRENT_DATE < i.expiration_date - COALESCE($2::integer, p.min_outbound_shelf_life) ELSE true END
338
+ 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
357
339
  ${
358
340
  cycleCountFilter
359
341
  ? `AND i.id NOT IN (
@@ -443,10 +425,7 @@ export const InventoryUtil = {
443
425
  })
444
426
  }
445
427
 
446
- await trxMgr.query(queryStrings, [
447
- domain.id,
448
- releaseShelfLifeOverrideFilter ? releaseShelfLifeOverrideFilter.value : null
449
- ])
428
+ await trxMgr.query(queryStrings, [domain.id])
450
429
 
451
430
  const [{ total }]: any = await trxMgr.query(
452
431
  `select count(*) as total from temp_inventory_product_group ${filterGroupTypeQuery ? filterGroupTypeQuery : ''}`
@@ -894,8 +873,7 @@ export const InventoryUtil = {
894
873
  recall: boolean = null,
895
874
  cartonId?: string,
896
875
  expirationDate?: Date,
897
- warehouseName?: string,
898
- outboundShelfLifeOverride?: number
876
+ warehouseName?: string
899
877
  ): Promise<OrderInventory[]> {
900
878
  let strictProduct = 'false'
901
879
 
@@ -940,15 +918,14 @@ export const InventoryUtil = {
940
918
  .andWhere('"iv"."transfer_uom_value" <= 0')
941
919
  .andWhere('"iv"."product_id" = :productId')
942
920
  .andWhere(
943
- 'case when "iv"."expiration_date" is not null then CURRENT_DATE < "iv"."expiration_date" - (case when :outboundShelfLifeOverride::integer is not null and :outboundShelfLifeOverride::integer > 0 then :outboundShelfLifeOverride::integer when "p"."min_outbound_shelf_life" is not null then "p"."min_outbound_shelf_life" else 0 end) else true end'
921
+ 'case when "iv"."expiration_date" is not null and "p"."min_outbound_shelf_life" is not null then CURRENT_DATE < "iv"."expiration_date" - "p"."min_outbound_shelf_life" else true end'
944
922
  )
945
923
  .setParameters({
946
924
  domainId: domain.id,
947
925
  bizplaceId: customerBizplace.id,
948
926
  productId: product.id,
949
927
  status: INVENTORY_STATUS.STORED,
950
- locationTypes,
951
- outboundShelfLifeOverride: outboundShelfLifeOverride ?? null
928
+ locationTypes
952
929
  })
953
930
 
954
931
  if (batchId) {