@things-factory/warehouse-base 4.3.637 → 4.3.638

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.
@@ -1,4 +1,10 @@
1
- import { Field, Float, ID, Int, ObjectType } from 'type-graphql'
1
+ import {
2
+ Field,
3
+ Float,
4
+ ID,
5
+ Int,
6
+ ObjectType
7
+ } from 'type-graphql'
2
8
  import {
3
9
  Column,
4
10
  CreateDateColumn,
@@ -13,8 +19,14 @@ import {
13
19
 
14
20
  import { User } from '@things-factory/auth-base'
15
21
  import { Bizplace } from '@things-factory/biz-base'
16
- import { Product, ProductDetail } from '@things-factory/product-base'
17
- import { Domain, ScalarDate } from '@things-factory/shell'
22
+ import {
23
+ Product,
24
+ ProductDetail
25
+ } from '@things-factory/product-base'
26
+ import {
27
+ Domain,
28
+ ScalarDate
29
+ } from '@things-factory/shell'
18
30
 
19
31
  import { InventoryChange } from '../inventory-change/inventory-change'
20
32
  import { InventoryItem } from '../inventory-item/inventory-item'
@@ -152,130 +164,26 @@ export class Inventory {
152
164
  @Field({ nullable: true })
153
165
  uom: string
154
166
 
155
- @Column({
156
- nullable: true,
157
- type: 'decimal',
158
- scale: 3,
159
- transformer: {
160
- to: (value: string | null) => value,
161
- from: (value: string | null) => {
162
- if (value === null || value === undefined) return null
163
- const parsed = parseFloat(value)
164
- return isNaN(parsed) ? null : parsed
165
- }
166
- }
167
- })
168
- @Field(type => Float, { nullable: true })
167
+ @Column('float', { nullable: true })
168
+ @Field({ nullable: true })
169
169
  uomValue: number
170
170
 
171
- @Column({
172
- nullable: true,
173
- type: 'decimal',
174
- scale: 3,
175
- transformer: {
176
- to: (value: string | null) => value,
177
- from: (value: string | null) => {
178
- if (value === null || value === undefined) return null
179
- const parsed = parseFloat(value)
180
- return isNaN(parsed) ? null : parsed
181
- }
182
- }
183
- })
184
- @Field(type => Float, { nullable: true })
171
+ @Column('float', { nullable: true })
172
+ @Field({ nullable: true })
185
173
  lockedUomValue: number
186
174
 
187
- @Column({
188
- nullable: true,
189
- type: 'decimal',
190
- scale: 3,
191
- transformer: {
192
- to: (value: string | null) => value,
193
- from: (value: string | null) => {
194
- if (value === null || value === undefined) return null
195
- const parsed = parseFloat(value)
196
- return isNaN(parsed) ? null : parsed
197
- }
198
- }
199
- })
200
- @Field(type => Float, { nullable: true })
175
+ @Column('float')
176
+ @Field({ nullable: true })
177
+ qty: number
178
+
179
+ @Column('float', { nullable: true })
180
+ @Field({ nullable: true })
201
181
  lockedQty: number
202
182
 
203
183
  @Column('float', { nullable: true })
204
- @Field(type => Float, { nullable: true })
184
+ @Field({ nullable: true })
205
185
  unitCost: number
206
186
 
207
- @Column({
208
- nullable: true,
209
- type: 'decimal',
210
- scale: 3,
211
- transformer: {
212
- to: (value: string | null) => value,
213
- from: (value: string | null) => {
214
- if (value === null || value === undefined) return null
215
- const parsed = parseFloat(value)
216
- return isNaN(parsed) ? null : parsed
217
- }
218
- }
219
- })
220
- @Field(type => Float, { nullable: true })
221
- qty: number
222
-
223
- @Column('float', { default: 0 })
224
- @Field(type => Float)
225
- transferQty: number
226
-
227
- @Column('float', { default: 0 })
228
- @Field(type => Float)
229
- transferUomValue: number
230
-
231
- @Field(type => Float, { nullable: true })
232
- nonLoadedQty: number
233
-
234
- @Field(type => Float, { nullable: true })
235
- nonLoadedUomValue: number
236
-
237
- @Field(type => Float, { nullable: true })
238
- remainUomValue?: number
239
-
240
- @Field(type => Float, { nullable: true })
241
- putawayQty: number
242
-
243
- @Field(type => Float, { nullable: true })
244
- availableQty: number
245
-
246
- @Field(type => Float, { nullable: true })
247
- releaseQty: number
248
-
249
- @Field(type => Float, { nullable: true })
250
- quarantineQty: number
251
-
252
- @Field(type => Float, { nullable: true })
253
- reserveQty: number
254
-
255
- @Field(type => Float, { nullable: true })
256
- draftQty: number
257
-
258
- @Field(type => Float, { nullable: true })
259
- warehouseQty: number
260
-
261
- @Field(type => Float, { nullable: true })
262
- obsoleteQty: number
263
-
264
- @Field(type => Float, { nullable: true })
265
- minQty: number
266
-
267
- @Field(type => Float, { nullable: true })
268
- pickingShelfQty: number
269
-
270
- @Field(type => Float, { nullable: true })
271
- storageQty: number
272
-
273
- @Field(type => Float, { nullable: true })
274
- insufficientQty: number
275
-
276
- @Field(type => Float, { nullable: true })
277
- damageQty: number
278
-
279
187
  @Column({ nullable: true })
280
188
  @Field({ nullable: true })
281
189
  adjustmentCode: string
@@ -304,6 +212,14 @@ export class Inventory {
304
212
  @Field({ nullable: true })
305
213
  remark: string
306
214
 
215
+ @Column('float', { default: 0 })
216
+ @Field()
217
+ transferQty: number
218
+
219
+ @Column('float', { default: 0 })
220
+ @Field()
221
+ transferUomValue: number
222
+
307
223
  @Column({ nullable: true })
308
224
  @Field({ nullable: true })
309
225
  lockInventory: boolean
@@ -345,15 +261,18 @@ export class Inventory {
345
261
  @Field({ nullable: true })
346
262
  productBrand: string
347
263
 
348
- @Field({ nullable: true })
349
- isInventoryDecimal: boolean
350
-
351
264
  @Field(type => Float, { nullable: true })
352
265
  averageUnitCost: number
353
266
 
354
- @Field(type => Float, { nullable: true })
267
+ @Field(type => Int, { nullable: true })
355
268
  remainQty: number
356
269
 
270
+ @Field(type => Int, { nullable: true })
271
+ nonLoadedQty: number
272
+
273
+ @Field(type => Float, { nullable: true })
274
+ nonLoadedUomValue: number
275
+
357
276
  @Field({ nullable: true })
358
277
  initialInboundAt: string
359
278
 
@@ -386,6 +305,9 @@ export class Inventory {
386
305
  @Field({ nullable: true })
387
306
  remainUomValueWithUom?: string
388
307
 
308
+ @Field({ nullable: true })
309
+ remainUomValue?: number
310
+
389
311
  @Field({ nullable: true })
390
312
  changeCount?: number
391
313
 
@@ -398,6 +320,45 @@ export class Inventory {
398
320
  @Field({ nullable: true })
399
321
  inventoryItemCount: number
400
322
 
323
+ @Field({ nullable: true })
324
+ putawayQty: number
325
+
326
+ @Field({ nullable: true })
327
+ availableQty: number
328
+
329
+ @Field({ nullable: true })
330
+ releaseQty: number
331
+
332
+ @Field({ nullable: true })
333
+ quarantineQty: number
334
+
335
+ @Field({ nullable: true })
336
+ reserveQty: number
337
+
338
+ @Field({ nullable: true })
339
+ draftQty: number
340
+
341
+ @Field({ nullable: true })
342
+ warehouseQty: number
343
+
344
+ @Field({ nullable: true })
345
+ obsoleteQty: number
346
+
347
+ @Field({ nullable: true })
348
+ minQty: number
349
+
350
+ @Field({ nullable: true })
351
+ pickingShelfQty: number
352
+
353
+ @Field({ nullable: true })
354
+ storageQty: number
355
+
356
+ @Field({ nullable: true })
357
+ insufficientQty: number
358
+
359
+ @Field({ nullable: true })
360
+ damageQty: number
361
+
401
362
  @Field({ nullable: true })
402
363
  condition: string
403
364
 
@@ -269,8 +269,8 @@ export class InventoryHistoryQuery {
269
269
  SELECT prd.sku as sku, prd.name AS product_name, prd.description AS product_description, prd.type as product_type, prd.aux_value_1 AS product_aux_value_1, trim(invh.batch_id) as batch_id, invh.product_id,
270
270
  invh.packing_type, invh.bizplace_id, invh.domain_id,
271
271
  invh.ref_order_id, invh.order_no, invh.order_ref_no, invh.transaction_type, invh.status, invh.created_at,
272
- TRUNC(CAST(invh.qty AS NUMERIC), 3) as qty, TRUNC(CAST(invh.opening_qty AS NUMERIC), 3) as opening_qty,
273
- invh.uom, TRUNC(CAST(COALESCE(invh.uom_value, 0) AS NUMERIC), 3) as uom_value, TRUNC(CAST(COALESCE(invh.opening_uom_value, 0) AS NUMERIC), 3) as opening_uom_value
272
+ invh.qty, invh.opening_qty,
273
+ invh.uom, COALESCE(invh.uom_value, 0) as uom_value, COALESCE(invh.opening_uom_value, 0) as opening_uom_value
274
274
  FROM reduced_inventory_histories invh
275
275
  INNER JOIN temp_products prd ON prd.id = invh.product_id::uuid
276
276
  WHERE
@@ -288,10 +288,10 @@ export class InventoryHistoryQuery {
288
288
  create temp table temp_inv_history as (
289
289
  SELECT src.sku, src.product_name, src.product_description, src.product_type, src.product_aux_value_1, src.batch_id, src.product_id, src.packing_type, src.uom,
290
290
  src.bizplace_id, src.domain_id,
291
- TRUNC(CAST(SUM(COALESCE(src.qty,0)) AS NUMERIC), 3) AS qty,
292
- TRUNC(CAST(SUM(COALESCE(src.opening_qty,0)) AS NUMERIC), 3) AS opening_qty,
293
- TRUNC(CAST(SUM(COALESCE(src.uom_value,0)) AS NUMERIC), 3) AS uom_value,
294
- TRUNC(CAST(SUM(COALESCE(src.opening_uom_value,0)) AS NUMERIC), 3) AS opening_uom_value,
291
+ SUM(COALESCE(src.qty,0)) AS qty,
292
+ SUM(COALESCE(src.opening_qty,0)) AS opening_qty,
293
+ SUM(COALESCE(src.uom_value,0)) AS uom_value,
294
+ SUM(COALESCE(src.opening_uom_value,0)) AS opening_uom_value,
295
295
  'Opening Balance' AS order_name,
296
296
  '-' AS ref_no,
297
297
  '-' as transaction_type,
@@ -304,7 +304,7 @@ export class InventoryHistoryQuery {
304
304
  src.bizplace_id, src.domain_id
305
305
  UNION ALL
306
306
  SELECT sku, product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
307
- domain_id, TRUNC(CAST(sum(qty) AS NUMERIC), 3) as qty, TRUNC(CAST(sum(opening_qty) AS NUMERIC), 3) as opening_qty, TRUNC(CAST(sum(uom_value) AS NUMERIC), 3) as uom_value, TRUNC(CAST(sum(opening_uom_value) AS NUMERIC), 3) as opening_uom_value,
307
+ domain_id, sum(qty) as qty, sum(opening_qty) as opening_qty, sum(uom_value) as uom_value, sum(opening_uom_value) as opening_uom_value,
308
308
  order_name, ref_no, '-' as transaction_type ,1 AS rn, MIN(created_at) - $2::interval as created_at, (MIN(created_at) - $2::interval)::DATE as created_date
309
309
  FROM (
310
310
  SELECT invh.sku, invh.product_name, invh.product_description, invh.product_type, invh.product_aux_value_1, invh.batch_id, invh.product_id, invh.packing_type, invh.bizplace_id,
@@ -327,7 +327,7 @@ export class InventoryHistoryQuery {
327
327
  domain_id, order_name, ref_no, rn
328
328
  UNION ALL
329
329
  SELECT sku, product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
330
- domain_id, TRUNC(CAST(sum(qty) AS NUMERIC), 3) as qty, TRUNC(CAST(sum(opening_qty) AS NUMERIC), 3) as opening_qty, TRUNC(CAST(sum(uom_value) AS NUMERIC), 3) as uom_value, TRUNC(CAST(sum(opening_uom_value) AS NUMERIC), 3) as opening_uom_value,
330
+ domain_id, sum(qty) as qty, sum(opening_qty) as opening_qty, sum(uom_value) as uom_value, sum(opening_uom_value) as opening_uom_value,
331
331
  CASE
332
332
  WHEN transaction_type IN ('PICKING', 'CANCEL_ORDER') THEN order_no
333
333
  ELSE order_name
@@ -364,7 +364,7 @@ export class InventoryHistoryQuery {
364
364
  domain_id, inv_movement.transaction_type,inv_movement.order_no,order_name, ref_no, rn, created_at
365
365
  UNION ALL
366
366
  SELECT sku, product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
367
- domain_id, TRUNC(CAST(sum(-opening_qty) AS NUMERIC), 3) as qty, TRUNC(CAST(sum(opening_qty) AS NUMERIC), 3) as opening_qty, TRUNC(CAST(sum(-opening_uom_value) AS NUMERIC), 3) as uom_value, TRUNC(CAST(sum(opening_uom_value) AS NUMERIC), 3) as opening_uom_value,
367
+ domain_id, sum(-opening_qty) as qty, sum(opening_qty) as opening_qty, sum(-opening_uom_value) as uom_value, sum(opening_uom_value) as opening_uom_value,
368
368
  order_name, ref_no, transaction_type,1 AS rn, created_at - $2::interval as created_at, created_at::date as created_date
369
369
  FROM (
370
370
  SELECT invh.sku, invh.product_name, invh.product_description, invh.product_type, invh.product_aux_value_1, invh.batch_id, invh.product_id, invh.packing_type, invh.uom, invh.bizplace_id,
@@ -413,11 +413,11 @@ export class InventoryHistoryQuery {
413
413
  domain_id, sum(qty) as qty, sum(opening_qty) as opening_qty, sum(uom_value) as uom_value, sum(opening_uom_value) as opening_uom_value, order_name, ref_no, transaction_type, created_at::date
414
414
  from(
415
415
  select sku, product_name, product_description, product_type, product_aux_value_1, batch_id, product_id, packing_type, uom, bizplace_id,
416
- domain_id, qty, opening_qty, TRUNC(CAST(uom_value AS NUMERIC), 3) as uom_value, opening_uom_value, order_name, ref_no, transaction_type,created_at::date
416
+ domain_id, qty, opening_qty, round(uom_value::decimal,2) as uom_value, opening_uom_value, order_name, ref_no, transaction_type,created_at::date
417
417
  from temp_inv_history invh where
418
418
  exists (
419
419
  select 1 from (
420
- select sku, batch_id, product_name, packing_type, TRUNC(CAST(sum(qty) AS NUMERIC), 3) as totalQty, count(*) as totalRow from temp_inv_history ih2
420
+ select sku, batch_id, product_name, packing_type, sum(qty) as totalQty, count(*) as totalRow from temp_inv_history ih2
421
421
  group by sku, batch_id, product_name, packing_type
422
422
  ) src
423
423
  where src.sku = invh.sku and src.batch_id = invh.batch_id and src.product_name = invh.product_name and src.packing_type = invh.packing_type
@@ -1168,10 +1168,7 @@ export class InventoryHistoryQuery {
1168
1168
  await tx.query(
1169
1169
  `
1170
1170
  create temp table tmp_src on commit drop as (
1171
- select domain_id, pallet_id, carton_id, seq,
1172
- TRUNC(qty::numeric,3) as qty,
1173
- TRUNC(uom_value::numeric,3) as uom_value,
1174
- packing_type, batch_id, batch_id_ref, created_at, status, unit_cost,
1171
+ select domain_id, pallet_id, carton_id, seq, qty, uom_value, packing_type, batch_id, batch_id_ref, created_at, status, unit_cost,
1175
1172
  product_id::uuid as product_id, bizplace_id::uuid as bizplace_id, location_id::uuid as location_id
1176
1173
  from reduced_inventory_histories rih
1177
1174
  where domain_id = $1 and created_at < $2::timestamp + $3::INTERVAL + '1 day'::INTERVAL
@@ -1183,10 +1180,7 @@ export class InventoryHistoryQuery {
1183
1180
  await tx.query(
1184
1181
  `
1185
1182
  CREATE TEMP TABLE tmp_src_group on commit drop AS (
1186
- select ih.domain_id, ih.pallet_id,
1187
- TRUNC(sum(ih.qty)::numeric,3) as qty,
1188
- TRUNC(sum(ih.uom_value)::numeric,3) as uom_value,
1189
- max(ih.seq) as last_seq, max(ih.created_at) as created_at,
1183
+ select ih.domain_id, ih.pallet_id, sum(ih.qty) as qty, sum(ih.uom_value) as uom_value, max(ih.seq) as last_seq, max(ih.created_at) as created_at,
1190
1184
  min(ih.created_at) as initial_inbound_at
1191
1185
  from tmp_src ih
1192
1186
  group by ih.domain_id, ih.pallet_id
@@ -1224,9 +1218,8 @@ export class InventoryHistoryQuery {
1224
1218
  const result: any = await tx.query(
1225
1219
  `
1226
1220
  select
1227
- rih.domain_id, rih.pallet_id as "palletId", rih.carton_id as "cartonId",
1228
- TRUNC(rih.qty::numeric,3) as "remainQty",
1229
- TRUNC(rih.uom_value::numeric,3) as "uomValue", rih.uom, rih.last_seq, rih.created_at,
1221
+ rih.domain_id, rih.pallet_id as "palletId", rih.carton_id as "cartonId", rih.qty as "remainQty",
1222
+ TRUNC(rih.uom_value::numeric,2) as "uomValue", rih.uom, rih.last_seq, rih.created_at,
1230
1223
  rih.initial_inbound_at as "initialInboundAt", rih.unit_cost as "unitCost",
1231
1224
  case when rih.reusable_pallet_id is not null then concat(rih.batch_id, ' (', plt.name, ')') else rih.batch_id end as "batchId",
1232
1225
  rih.batch_id_ref as "batchIdRef", rih.product_id, rih.packing_type as "packingType", rih.bizplace_id, rih.location_id,
@@ -1245,7 +1238,7 @@ export class InventoryHistoryQuery {
1245
1238
  when (rih.expiration_date - (prd.outbound_alert || ' days')::INTERVAL) < now() then 'Risky'
1246
1239
  else 'Normal' end as expiry,
1247
1240
  i.adjustment_note as "adjustmentNote",
1248
- TRUNC(coalesce((
1241
+ coalesce((
1249
1242
  select sum(oi1.release_qty) as nonLoadedQty from order_inventories oi1
1250
1243
  inner join release_goods rg1 on rg1.id = oi1.release_good_id
1251
1244
  where rg1.status in ('PICKING', 'LOADING')
@@ -1253,7 +1246,7 @@ export class InventoryHistoryQuery {
1253
1246
  and oi1.status in ('PICKED', 'LOADING')
1254
1247
  and rg1.domain_id = '${domain.id}'
1255
1248
  group by oi1.inventory_id
1256
- ),0)::numeric,3) as "nonLoadedQty",
1249
+ ),0) as "nonLoadedQty",
1257
1250
  TRUNC(coalesce((
1258
1251
  select sum(oi1.release_uom_value) as nonLoadedUomValue from order_inventories oi1
1259
1252
  inner join release_goods rg1 on rg1.id = oi1.release_good_id
@@ -1262,9 +1255,9 @@ export class InventoryHistoryQuery {
1262
1255
  and oi1.status in ('PICKED', 'LOADING')
1263
1256
  and rg1.domain_id = '${domain.id}'
1264
1257
  group by oi1.inventory_id
1265
- ),0)::numeric,3) as "nonLoadedUomValue",
1266
- TRUNC(i.transfer_qty::numeric,3) as "transferQty",
1267
- TRUNC(i.transfer_uom_value::numeric,3) as "transferUomValue"
1258
+ ),0)::numeric,2) as "nonLoadedUomValue",
1259
+ i.transfer_qty as "transferQty",
1260
+ i.transfer_uom_value as "transferUomValue"
1268
1261
  from tmp_data rih
1269
1262
  left join pallets plt on plt.id = rih.reusable_pallet_id
1270
1263
  inner join products prd on prd.id = rih.product_id
@@ -1670,14 +1663,14 @@ async function massageInventorySummary(tx: EntityManager, params: ListParam, biz
1670
1663
  `
1671
1664
  create temp table temp_inventory_summary ON COMMIT DROP as (
1672
1665
  select src.*,
1673
- TRUNC(CAST(opening_qty + adjustment_qty + total_in_qty + total_out_qty + missing_qty AS NUMERIC), 3) as closing_qty
1666
+ opening_qty + adjustment_qty + total_in_qty + total_out_qty + missing_qty as closing_qty
1674
1667
  from (
1675
1668
  select prd.sku AS product_sku, prd.name as product_name, prd.description as product_description, prd.type AS product_type, ih.packing_type, ih.packing_size,
1676
- TRUNC(CAST(sum(case when ih.created_at >= $1 and ih.transaction_type = 'ADJUSTMENT' then ih.qty else 0 end) AS NUMERIC), 3) as adjustment_qty,
1677
- TRUNC(CAST(sum(case when ih.created_at < $1 then qty else 0 end) AS NUMERIC), 3) as opening_qty,
1678
- TRUNC(CAST(sum(case when ih.status = 'MISSING' then -ih.opening_qty else 0 end) AS NUMERIC), 3) as missing_qty,
1679
- TRUNC(CAST(sum(case when ih.created_at >= $1 then case when ih.qty > 0 and ih.transaction_type <> 'ADJUSTMENT' and ih.transaction_type <> 'RELOCATE' then ih.qty else 0 end else 0 end) AS NUMERIC), 3) as total_in_qty,
1680
- TRUNC(CAST(sum(case when ih.created_at >= $1 then case when ih.qty < 0 and ih.transaction_type <> 'ADJUSTMENT' and ih.transaction_type <> 'RELOCATE' then ih.qty else 0 end else 0 end) AS NUMERIC), 3) as total_out_qty,
1669
+ sum(case when ih.created_at >= $1 and ih.transaction_type = 'ADJUSTMENT' then ih.qty else 0 end) as adjustment_qty,
1670
+ sum(case when ih.created_at < $1 then qty else 0 end) as opening_qty,
1671
+ sum(case when ih.status = 'MISSING' then -ih.opening_qty else 0 end) as missing_qty,
1672
+ sum(case when ih.created_at >= $1 then case when ih.qty > 0 and ih.transaction_type <> 'ADJUSTMENT' and ih.transaction_type <> 'RELOCATE' then ih.qty else 0 end else 0 end) as total_in_qty,
1673
+ sum(case when ih.created_at >= $1 then case when ih.qty < 0 and ih.transaction_type <> 'ADJUSTMENT' and ih.transaction_type <> 'RELOCATE' then ih.qty else 0 end else 0 end) as total_out_qty,
1681
1674
  ih.product_id
1682
1675
  from temp_inv_history ih
1683
1676
  inner join temp_products prd on prd.id = ih.product_id
@@ -194,7 +194,7 @@ export async function generateInventoryHistory(
194
194
  transactionType,
195
195
  qty,
196
196
  openingQty: 0,
197
- uomValue: Math.trunc(uomValue * 1000) / 1000,
197
+ uomValue,
198
198
  openingUomValue: 0,
199
199
  seq: 0
200
200
  }
@@ -208,6 +208,7 @@ export async function generateInventoryHistory(
208
208
  palletId: inventory.palletId,
209
209
  refOrderId: refOrder.id
210
210
  })
211
+
211
212
  if (findSameOrderHistory.length > 0) {
212
213
  let prevTotalQty = 0
213
214
  let prevTotalUomValue = 0
@@ -231,10 +232,10 @@ export async function generateInventoryHistory(
231
232
  transactionType,
232
233
  qty,
233
234
  openingQty: () =>
234
- `TRUNC((select opening_qty::numeric from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1) + (select qty::numeric from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1), 3)`,
235
- uomValue: Math.trunc(uomValue * 1000) / 1000,
235
+ `(select opening_qty from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1) + (select qty from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1)`,
236
+ uomValue,
236
237
  openingUomValue: () =>
237
- `TRUNC((select opening_uom_value::numeric from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1) + (select uom_value::numeric from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1), 3)`,
238
+ `(select opening_uom_value from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1) + (select uom_value from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1)`,
238
239
  seq: () =>
239
240
  `(select seq from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1) + 1`
240
241
  }