@things-factory/warehouse-base 4.3.636 → 4.3.637

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,10 +1,4 @@
1
- import {
2
- Field,
3
- Float,
4
- ID,
5
- Int,
6
- ObjectType
7
- } from 'type-graphql'
1
+ import { Field, Float, ID, Int, ObjectType } from 'type-graphql'
8
2
  import {
9
3
  Column,
10
4
  CreateDateColumn,
@@ -19,14 +13,8 @@ import {
19
13
 
20
14
  import { User } from '@things-factory/auth-base'
21
15
  import { Bizplace } from '@things-factory/biz-base'
22
- import {
23
- Product,
24
- ProductDetail
25
- } from '@things-factory/product-base'
26
- import {
27
- Domain,
28
- ScalarDate
29
- } from '@things-factory/shell'
16
+ import { Product, ProductDetail } from '@things-factory/product-base'
17
+ import { Domain, ScalarDate } from '@things-factory/shell'
30
18
 
31
19
  import { InventoryChange } from '../inventory-change/inventory-change'
32
20
  import { InventoryItem } from '../inventory-item/inventory-item'
@@ -164,26 +152,130 @@ export class Inventory {
164
152
  @Field({ nullable: true })
165
153
  uom: string
166
154
 
167
- @Column('float', { nullable: true })
168
- @Field({ nullable: true })
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 })
169
169
  uomValue: number
170
170
 
171
- @Column('float', { nullable: true })
172
- @Field({ nullable: true })
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 })
173
185
  lockedUomValue: number
174
186
 
175
- @Column('float')
176
- @Field({ nullable: true })
177
- qty: number
178
-
179
- @Column('float', { nullable: true })
180
- @Field({ nullable: true })
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 })
181
201
  lockedQty: number
182
202
 
183
203
  @Column('float', { nullable: true })
184
- @Field({ nullable: true })
204
+ @Field(type => Float, { nullable: true })
185
205
  unitCost: number
186
206
 
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
+
187
279
  @Column({ nullable: true })
188
280
  @Field({ nullable: true })
189
281
  adjustmentCode: string
@@ -212,14 +304,6 @@ export class Inventory {
212
304
  @Field({ nullable: true })
213
305
  remark: string
214
306
 
215
- @Column('float', { default: 0 })
216
- @Field()
217
- transferQty: number
218
-
219
- @Column('float', { default: 0 })
220
- @Field()
221
- transferUomValue: number
222
-
223
307
  @Column({ nullable: true })
224
308
  @Field({ nullable: true })
225
309
  lockInventory: boolean
@@ -261,17 +345,14 @@ export class Inventory {
261
345
  @Field({ nullable: true })
262
346
  productBrand: string
263
347
 
348
+ @Field({ nullable: true })
349
+ isInventoryDecimal: boolean
350
+
264
351
  @Field(type => Float, { nullable: true })
265
352
  averageUnitCost: number
266
353
 
267
- @Field(type => Int, { nullable: true })
268
- remainQty: number
269
-
270
- @Field(type => Int, { nullable: true })
271
- nonLoadedQty: number
272
-
273
354
  @Field(type => Float, { nullable: true })
274
- nonLoadedUomValue: number
355
+ remainQty: number
275
356
 
276
357
  @Field({ nullable: true })
277
358
  initialInboundAt: string
@@ -305,9 +386,6 @@ export class Inventory {
305
386
  @Field({ nullable: true })
306
387
  remainUomValueWithUom?: string
307
388
 
308
- @Field({ nullable: true })
309
- remainUomValue?: number
310
-
311
389
  @Field({ nullable: true })
312
390
  changeCount?: number
313
391
 
@@ -320,45 +398,6 @@ export class Inventory {
320
398
  @Field({ nullable: true })
321
399
  inventoryItemCount: number
322
400
 
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
-
362
401
  @Field({ nullable: true })
363
402
  condition: string
364
403
 
@@ -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
- 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
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
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
- 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,
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,
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, sum(qty) as qty, sum(opening_qty) as opening_qty, sum(uom_value) as uom_value, sum(opening_uom_value) as opening_uom_value,
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,
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, sum(qty) as qty, sum(opening_qty) as opening_qty, sum(uom_value) as uom_value, sum(opening_uom_value) as opening_uom_value,
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,
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, 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,
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,
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, round(uom_value::decimal,2) as uom_value, opening_uom_value, order_name, ref_no, transaction_type,created_at::date
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
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, sum(qty) as totalQty, count(*) as totalRow from temp_inv_history ih2
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
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,7 +1168,10 @@ 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, qty, uom_value, packing_type, batch_id, batch_id_ref, created_at, status, unit_cost,
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,
1172
1175
  product_id::uuid as product_id, bizplace_id::uuid as bizplace_id, location_id::uuid as location_id
1173
1176
  from reduced_inventory_histories rih
1174
1177
  where domain_id = $1 and created_at < $2::timestamp + $3::INTERVAL + '1 day'::INTERVAL
@@ -1180,7 +1183,10 @@ export class InventoryHistoryQuery {
1180
1183
  await tx.query(
1181
1184
  `
1182
1185
  CREATE TEMP TABLE tmp_src_group on commit drop AS (
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,
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,
1184
1190
  min(ih.created_at) as initial_inbound_at
1185
1191
  from tmp_src ih
1186
1192
  group by ih.domain_id, ih.pallet_id
@@ -1218,8 +1224,9 @@ export class InventoryHistoryQuery {
1218
1224
  const result: any = await tx.query(
1219
1225
  `
1220
1226
  select
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,
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,
1223
1230
  rih.initial_inbound_at as "initialInboundAt", rih.unit_cost as "unitCost",
1224
1231
  case when rih.reusable_pallet_id is not null then concat(rih.batch_id, ' (', plt.name, ')') else rih.batch_id end as "batchId",
1225
1232
  rih.batch_id_ref as "batchIdRef", rih.product_id, rih.packing_type as "packingType", rih.bizplace_id, rih.location_id,
@@ -1238,7 +1245,7 @@ export class InventoryHistoryQuery {
1238
1245
  when (rih.expiration_date - (prd.outbound_alert || ' days')::INTERVAL) < now() then 'Risky'
1239
1246
  else 'Normal' end as expiry,
1240
1247
  i.adjustment_note as "adjustmentNote",
1241
- coalesce((
1248
+ TRUNC(coalesce((
1242
1249
  select sum(oi1.release_qty) as nonLoadedQty from order_inventories oi1
1243
1250
  inner join release_goods rg1 on rg1.id = oi1.release_good_id
1244
1251
  where rg1.status in ('PICKING', 'LOADING')
@@ -1246,7 +1253,7 @@ export class InventoryHistoryQuery {
1246
1253
  and oi1.status in ('PICKED', 'LOADING')
1247
1254
  and rg1.domain_id = '${domain.id}'
1248
1255
  group by oi1.inventory_id
1249
- ),0) as "nonLoadedQty",
1256
+ ),0)::numeric,3) as "nonLoadedQty",
1250
1257
  TRUNC(coalesce((
1251
1258
  select sum(oi1.release_uom_value) as nonLoadedUomValue from order_inventories oi1
1252
1259
  inner join release_goods rg1 on rg1.id = oi1.release_good_id
@@ -1255,9 +1262,9 @@ export class InventoryHistoryQuery {
1255
1262
  and oi1.status in ('PICKED', 'LOADING')
1256
1263
  and rg1.domain_id = '${domain.id}'
1257
1264
  group by oi1.inventory_id
1258
- ),0)::numeric,2) as "nonLoadedUomValue",
1259
- i.transfer_qty as "transferQty",
1260
- i.transfer_uom_value as "transferUomValue"
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"
1261
1268
  from tmp_data rih
1262
1269
  left join pallets plt on plt.id = rih.reusable_pallet_id
1263
1270
  inner join products prd on prd.id = rih.product_id
@@ -1663,14 +1670,14 @@ async function massageInventorySummary(tx: EntityManager, params: ListParam, biz
1663
1670
  `
1664
1671
  create temp table temp_inventory_summary ON COMMIT DROP as (
1665
1672
  select src.*,
1666
- opening_qty + adjustment_qty + total_in_qty + total_out_qty + missing_qty as closing_qty
1673
+ TRUNC(CAST(opening_qty + adjustment_qty + total_in_qty + total_out_qty + missing_qty AS NUMERIC), 3) as closing_qty
1667
1674
  from (
1668
1675
  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,
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,
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,
1674
1681
  ih.product_id
1675
1682
  from temp_inv_history ih
1676
1683
  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,
197
+ uomValue: Math.trunc(uomValue * 1000) / 1000,
198
198
  openingUomValue: 0,
199
199
  seq: 0
200
200
  }
@@ -208,7 +208,6 @@ export async function generateInventoryHistory(
208
208
  palletId: inventory.palletId,
209
209
  refOrderId: refOrder.id
210
210
  })
211
-
212
211
  if (findSameOrderHistory.length > 0) {
213
212
  let prevTotalQty = 0
214
213
  let prevTotalUomValue = 0
@@ -232,10 +231,10 @@ export async function generateInventoryHistory(
232
231
  transactionType,
233
232
  qty,
234
233
  openingQty: () =>
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,
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,
237
236
  openingUomValue: () =>
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)`,
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)`,
239
238
  seq: () =>
240
239
  `(select seq from inventory_histories where pallet_id = '${inventory.palletId}' and domain_id = '${domain.id}' order by seq desc limit 1) + 1`
241
240
  }