@things-factory/worksheet-base 4.3.81 → 4.3.86

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.
@@ -393,7 +393,7 @@ export class WorksheetController {
393
393
  let existingWorksheet: Worksheet
394
394
  try {
395
395
  existingWorksheet = await this.findWorksheetByRefOrder(refOrder, type)
396
- } catch (e) {}
396
+ } catch (e) { }
397
397
 
398
398
  if (existingWorksheet)
399
399
  throw new Error(
@@ -1054,6 +1054,48 @@ export class WorksheetController {
1054
1054
  return childQty
1055
1055
  }
1056
1056
 
1057
+ public async getDirectQty(
1058
+ productDetail: ProductDetail,
1059
+ productBarcode: string,
1060
+ qty: number
1061
+ ): Promise<any> {
1062
+ try {
1063
+ console.time('getDirectQty')
1064
+ let results = await this.trxMgr.query(`
1065
+ WITH RECURSIVE cte as (
1066
+ select * from (
1067
+ select pd.product_id as "productId", id, pd.packing_size as "packingSize",
1068
+ pd.packing_type as "packingType", pd.uom as "uom", (pd.uom_value * $2::float) as "uomValue", $2::float as "qty", pd.gtin
1069
+ from product_details pd
1070
+ where pd.id = $1
1071
+ ) as dt
1072
+ union all
1073
+ select pd.product_id as "productId", pd.id, pd.packing_size as "packingSize",
1074
+ pd.packing_type as "packingType", pd.uom,
1075
+ dt1.qty * pd.packing_size * pd.uom_value as "uomValue", dt1.qty * pd.packing_size as "qty", pd.gtin
1076
+ from product_details pd
1077
+ inner join cte dt1 on dt1.id = pd.child_product_detail_id
1078
+ where pd.deleted_at is null
1079
+ )
1080
+ select * from cte where gtin = $3
1081
+ `, [
1082
+ productDetail.id,
1083
+ qty,
1084
+ productBarcode
1085
+ ])
1086
+
1087
+ if (results.length <= 0)
1088
+ throw new Error(this.ERROR_MSG.FIND.NO_RESULT(productBarcode))
1089
+
1090
+ console.timeEnd('getDirectQty')
1091
+ return results[0]
1092
+ } catch (error) {
1093
+ throw error
1094
+ }
1095
+ }
1096
+
1097
+
1098
+
1057
1099
  /**
1058
1100
  * @summary Check for product child qty at any scanned level
1059
1101
  * @description It will check every level of product detail by comparing scanned level and GAN registered level.
@@ -16,6 +16,11 @@ import { Worksheet } from './worksheet'
16
16
  'ix_worksheet-detail_1',
17
17
  (worksheetDetail: WorksheetDetail) => [worksheetDetail.targetInventory]
18
18
  )
19
+ @Index(
20
+ 'ix_worksheet-detail_2',
21
+ (worksheetDetail: WorksheetDetail) => [worksheetDetail.id],
22
+ { unique: true }
23
+ )
19
24
  export class WorksheetDetail {
20
25
  @PrimaryGeneratedColumn('uuid')
21
26
  id: string
@@ -3,6 +3,9 @@ import { Domain } from '@things-factory/shell'
3
3
  import { EntityManager } from 'typeorm'
4
4
  import { PickingWorksheetController } from '../../../../controllers'
5
5
 
6
+ import { pickingWorksheet } from '../picking-worksheet'
7
+
8
+
6
9
  export const scanProductPickingResolver = {
7
10
  async scanProductPicking(
8
11
  _: any,
@@ -10,10 +13,9 @@ export const scanProductPickingResolver = {
10
13
  context: any
11
14
  ) {
12
15
  const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
13
- await scanProductPicking(
14
- tx,
15
- domain,
16
- user,
16
+
17
+ const worksheetController: PickingWorksheetController = new PickingWorksheetController(tx, domain, user)
18
+ let ws = await worksheetController.scanProductPicking(
17
19
  worksheetDetailName,
18
20
  worksheetType,
19
21
  productBarcode,
@@ -23,31 +25,9 @@ export const scanProductPickingResolver = {
23
25
  toteNo,
24
26
  pickingQty
25
27
  )
26
- }
27
- }
28
28
 
29
- export async function scanProductPicking(
30
- tx: EntityManager,
31
- domain: Domain,
32
- user: User,
33
- worksheetDetailName: string,
34
- worksheetType: string,
35
- productBarcode: string,
36
- cartonId: string,
37
- binLocation?: string,
38
- serialNumber?: string,
39
- toteNo?: string,
40
- pickingQty?: number
41
- ) {
42
- const worksheetController: PickingWorksheetController = new PickingWorksheetController(tx, domain, user)
43
- await worksheetController.scanProductPicking(
44
- worksheetDetailName,
45
- worksheetType,
46
- productBarcode,
47
- cartonId,
48
- binLocation,
49
- serialNumber,
50
- toteNo,
51
- pickingQty
52
- )
29
+
30
+ // return await pickingWorksheet(domain, releaseGoodNo, locationSortingRule, tx)
31
+
32
+ }
53
33
  }