@things-factory/operato-wms 4.3.632 → 4.3.634

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.
Files changed (46) hide show
  1. package/client/pages/inbound/inbound-worksheet.js +5 -0
  2. package/client/pages/inbound/unload-product.js +2 -1
  3. package/client/pages/inventory/inventory-by-product.js +11 -0
  4. package/client/pages/inventory/onhand-inventory.js +51 -32
  5. package/client/pages/order/arrival-notice/arrival-notice-list.js +26 -3
  6. package/client/pages/order/draft-release-good/draft-release-good-list.js +26 -0
  7. package/client/pages/order/release-order/b2b/b2b-order-list.js +29 -1
  8. package/client/pages/order/release-order/b2b/b2b-order-requests.js +26 -0
  9. package/client/pages/order/release-order/b2c/b2c-order-requests.js +27 -0
  10. package/client/pages/outbound/loading-product.js +0 -4
  11. package/client/pages/outbound/loading-v2/loading.js +4 -16
  12. package/client/pages/outbound/loading-v2/release-good-info.js +3 -4
  13. package/client/pages/outbound/merged-outbound-worksheet.js +7 -0
  14. package/client/pages/outbound/picking-v2/picking-execution-base.js +16 -1
  15. package/client/pages/outbound/picking-v2/picking.js +32 -26
  16. package/client/pages/outbound/picking-v2/worksheet-info.js +7 -1
  17. package/client/pages/outbound/single-outbound-worksheet.js +27 -6
  18. package/client/pages/outbound/worksheet-picking.js +3 -4
  19. package/client/pages/outbound/zone-worksheet.js +7 -0
  20. package/client/util/apply-params-to-field.js +40 -0
  21. package/client/util/index.js +1 -0
  22. package/dist-server/graphql/resolvers/outbound/get-loading-task.js +3 -1
  23. package/dist-server/graphql/resolvers/outbound/get-loading-task.js.map +1 -1
  24. package/dist-server/graphql/resolvers/outbound/loading-worksheet-v2.js +7 -5
  25. package/dist-server/graphql/resolvers/outbound/loading-worksheet-v2.js.map +1 -1
  26. package/dist-server/graphql/resolvers/reports/index.js +2 -1
  27. package/dist-server/graphql/resolvers/reports/index.js.map +1 -1
  28. package/dist-server/graphql/resolvers/reports/pg-udf-query.js +68 -0
  29. package/dist-server/graphql/resolvers/reports/pg-udf-query.js.map +1 -0
  30. package/dist-server/graphql/resolvers/zone-worksheet/zone-picking.js +7 -2
  31. package/dist-server/graphql/resolvers/zone-worksheet/zone-picking.js.map +1 -1
  32. package/dist-server/graphql/resolvers/zone-worksheet/zone-worksheet.js.map +1 -1
  33. package/dist-server/graphql/types/reports/index.js +4 -1
  34. package/dist-server/graphql/types/reports/index.js.map +1 -1
  35. package/dist-server/graphql/types/reports/pg-udf-query-list.js +13 -0
  36. package/dist-server/graphql/types/reports/pg-udf-query-list.js.map +1 -0
  37. package/package.json +4 -4
  38. package/server/graphql/resolvers/outbound/get-loading-task.ts +8 -19
  39. package/server/graphql/resolvers/outbound/loading-worksheet-v2.ts +11 -9
  40. package/server/graphql/resolvers/reports/index.ts +3 -1
  41. package/server/graphql/resolvers/reports/pg-udf-query.ts +77 -0
  42. package/server/graphql/resolvers/zone-worksheet/zone-picking.ts +13 -2
  43. package/server/graphql/resolvers/zone-worksheet/zone-worksheet.ts +1 -2
  44. package/server/graphql/types/reports/index.ts +4 -1
  45. package/server/graphql/types/reports/pg-udf-query-list.ts +7 -0
  46. package/config.development.js +0 -105
@@ -1,14 +1,13 @@
1
- import { EntityManager, getRepository, Not, Equal } from 'typeorm'
1
+ import { EntityManager } from 'typeorm'
2
2
 
3
3
  import { Domain } from '@things-factory/shell'
4
4
  import { ReleaseGood, ORDER_INVENTORY_STATUS, ORDER_STATUS } from '@things-factory/sales-base'
5
5
  import { Worksheet, WorksheetDetail, WORKSHEET_TYPE, WORKSHEET_STATUS } from '@things-factory/worksheet-base'
6
- import { User } from '@things-factory/auth-base'
7
6
  import { Setting } from '@things-factory/setting-base'
8
7
 
9
8
  export const loadingWorksheetv2 = {
10
9
  async loadingWorksheetv2(_: any, { orderNo, filter = null }, context: any) {
11
- const { domain, tx, user }: { domain: Domain; tx: EntityManager; user: User } = context.state
10
+ const { domain, tx }: { domain: Domain; tx: EntityManager } = context.state
12
11
 
13
12
  if (process.env.NODE_ENV == 'development') {
14
13
  console.time('loadingWorksheetv2')
@@ -72,12 +71,11 @@ export const loadingWorksheetv2 = {
72
71
 
73
72
  //if order is zone picked, or (not zone picked and disableQc = false), filter by sortedQty
74
73
  if (filter === 'loading') {
75
- const shouldFilterBySortedQty =
76
- releaseGood.status !== ORDER_STATUS.LOADING ||
77
- (releaseGood.status === ORDER_STATUS.LOADING && !disableQc);
74
+ const shouldFilterBySortedQty =
75
+ releaseGood.status !== ORDER_STATUS.LOADING || (releaseGood.status === ORDER_STATUS.LOADING && !disableQc)
78
76
 
79
77
  if (shouldFilterBySortedQty) {
80
- qb.andWhere('targetInventory.sortedQty > 0');
78
+ qb.andWhere('targetInventory.sortedQty > 0')
81
79
  }
82
80
  }
83
81
 
@@ -106,7 +104,8 @@ async function mapdata(worksheet, worksheetDetails, releaseGood, disableQC) {
106
104
  attentionCompany: releaseGood?.attentionCompany,
107
105
  refNo: releaseGood?.refNo,
108
106
  refNo2: releaseGood?.refNo2,
109
- refNo3: releaseGood?.refNo3
107
+ refNo3: releaseGood?.refNo3,
108
+ remark: releaseGood?.remark
110
109
  }
111
110
  }
112
111
  const worksheetDetailInfos = worksheetDetails.map(wsd => ({
@@ -115,7 +114,10 @@ async function mapdata(worksheet, worksheetDetails, releaseGood, disableQC) {
115
114
  batchId: wsd.targetInventory.batchId || '-',
116
115
  releaseQty: wsd.targetInventory.releaseQty,
117
116
  pickedQty: wsd.targetInventory.pickedQty,
118
- sortedQty: (releaseGood.status == ORDER_STATUS.LOADING && disableQC) ? wsd.targetInventory.pickedQty : wsd.targetInventory.sortedQty,
117
+ sortedQty:
118
+ releaseGood.status == ORDER_STATUS.LOADING && disableQC
119
+ ? wsd.targetInventory.pickedQty
120
+ : wsd.targetInventory.sortedQty,
119
121
  loadedQty: wsd.targetInventory.loadedQty,
120
122
  status: wsd.status,
121
123
  packingType: wsd.targetInventory.packingType,
@@ -15,6 +15,7 @@ import {
15
15
  orderVasReport,
16
16
  vasReport
17
17
  } from './vas-report'
18
+ import { pgUdfQuery } from './pg-udf-query'
18
19
 
19
20
  export const Query = {
20
21
  ...inboundSerialNumberReport,
@@ -31,5 +32,6 @@ export const Query = {
31
32
  ...analysisPickingPackingReport,
32
33
  ...cycleCountReport,
33
34
  ...nonLoadedOrderInventoriesReport,
34
- ...manifestReport
35
+ ...manifestReport,
36
+ ...pgUdfQuery
35
37
  }
@@ -0,0 +1,77 @@
1
+ import { EntityManager } from 'typeorm'
2
+ import { Domain, ListParam } from '@things-factory/shell'
3
+
4
+ export const pgUdfQuery = {
5
+ async pgUdfQuery(_: any, params: ListParam, context: any) {
6
+ const { domain, tx }: { domain: Domain, tx: EntityManager } = context.state
7
+ let udfName = params.filters.find(param => param.name === 'udf')
8
+
9
+ try {
10
+ if (!udfName?.value) {
11
+ throw new Error('UDF name is required')
12
+ }
13
+
14
+ // Remove the udf filter and convert remaining filters to an object
15
+ const parameters = params.filters
16
+ .filter(f => f.name !== 'udf')
17
+ .map(filter => ({
18
+ [filter.name]: filter.value
19
+ }));
20
+
21
+ return { items: JSON.stringify(await callPostgresFunction(udfName.value, tx, parameters)) }
22
+ } catch (error) {
23
+ throw error
24
+ }
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Calls a PostgreSQL user-defined function through TypeORM
30
+ *
31
+ * @param functionName - Name of the PostgreSQL UDF to call
32
+ * @param entityManager - EntityManager instance
33
+ * @param parameters - Array of parameters or string to pass to the function
34
+ * @returns Promise with the function result
35
+ */
36
+ async function callPostgresFunction(
37
+ functionName: string,
38
+ entityManager: EntityManager,
39
+ parameters: any[] | string
40
+ ) {
41
+ try {
42
+ const exists = await entityManager.query(`
43
+ SELECT EXISTS (
44
+ SELECT 1 FROM pg_proc p
45
+ JOIN pg_namespace n ON p.pronamespace = n.oid
46
+ WHERE p.proname = $1
47
+ AND n.nspname = 'public'
48
+ )`, [functionName])
49
+
50
+ if (!exists[0].exists) {
51
+ throw new Error(`PostgreSQL function '${functionName}' does not exist in the database.`)
52
+ }
53
+
54
+ let query: string, params: any[]
55
+
56
+ if (typeof parameters === 'string') {
57
+ // Pass string parameter directly
58
+ query = `SELECT * FROM ${functionName}($1)`
59
+ params = [parameters]
60
+ } else {
61
+ // Handle array of parameters
62
+ const paramPlaceholders = parameters.map((_, index) => `$${index + 1}`).join(', ')
63
+ query = `SELECT * FROM ${functionName}(${paramPlaceholders})`
64
+ params = parameters.map(param => Object.values(param)).flat()
65
+ }
66
+
67
+ // Execute the query with the provided parameters
68
+ const result = await entityManager.query(query, params)
69
+
70
+ // PostgreSQL functions typically return rows, so we handle both single and multiple results
71
+ return Array.isArray(result) && result.length === 1
72
+ ? result[0]
73
+ : result
74
+ } catch (error) {
75
+ throw new Error(`Error calling PostgreSQL function '${functionName}': ${error.message}`)
76
+ }
77
+ }
@@ -63,10 +63,15 @@ export const zonePicking = {
63
63
  .innerJoinAndSelect('oi.inventory', 'i', 'i.id = oi.inventory_id')
64
64
  .where('oi.id IN(:...oiIds)', { oiIds: oiIds })
65
65
  .andWhere('i.carton_id = :cartonId', { cartonId: cartonId })
66
+ .andWhere('oi.status = :status', { status: ORDER_INVENTORY_STATUS.PROCESSING })
66
67
  .orderBy('oi.created_at')
67
68
  .getMany()
68
69
 
69
- if (!targetInventories) throw new Error('Invalid carton id')
70
+ if (!targetInventories || targetInventories.length === 0) {
71
+ throw new Error(
72
+ `No inventory found for carton ID: ${cartonId}. Please verify the carton ID and worksheet details.`
73
+ )
74
+ }
70
75
 
71
76
  //fetch product, product detail
72
77
  const productDetail: ProductDetail = await tx
@@ -79,6 +84,10 @@ export const zonePicking = {
79
84
  .andWhere('pb.gtin = :productBarcode', { productBarcode: productBarcode })
80
85
  .getOne()
81
86
 
87
+ if (!productDetail) {
88
+ throw new Error(`Product not found with barcode: ${productBarcode}.`)
89
+ }
90
+
82
91
  const product = productDetail.product
83
92
  let pickedQty: number = pickingQty ? pickingQty : 1
84
93
 
@@ -110,7 +119,9 @@ export const zonePicking = {
110
119
  wsController.ERROR_MSG.VALIDITY.CANT_PROCEED_STEP_BY('picking', `quantity can't exceed limitation`)
111
120
  )
112
121
 
113
- let productOrderInventory = targetInventories.filter(oi => oi.productId === product.id && oi.productDetailId === productDetail.id)
122
+ let productOrderInventory = targetInventories.filter(
123
+ oi => oi.productId === product.id && oi.productDetailId === productDetail.id
124
+ )
114
125
 
115
126
  //update all oi
116
127
  for (const oi of productOrderInventory) {
@@ -90,8 +90,7 @@ export const zonePickingWorksheet = {
90
90
  //item assigned to obsolete inventories will not be displayed during picking
91
91
  if (filter) {
92
92
  qb.andWhere('rg.status != :orderStatus', { orderStatus: ORDER_STATUS.OBSOLETE })
93
- qb.andWhere('oi.status != :terminateStatus',{ terminateStatus: ORDER_INVENTORY_STATUS.TERMINATED }
94
- )
93
+ qb.andWhere('oi.status != :terminateStatus', { terminateStatus: ORDER_INVENTORY_STATUS.TERMINATED })
95
94
  }
96
95
 
97
96
  if (filter && filter == 'PICKING') {
@@ -26,6 +26,7 @@ import { ShortageReportList } from './shortage-report-list'
26
26
  import { ShortageReport } from './shortage-report-type'
27
27
  import { OrderVasReport, VasReport } from './vas-report'
28
28
  import { OrderVasReportList, VasReportList } from './vas-report-list'
29
+ import { PgUdfQueryList } from './pg-udf-query-list'
29
30
 
30
31
  export const Query = `
31
32
  inboundSerialNumberReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): InboundSerialNumberReportList @transaction
@@ -43,6 +44,7 @@ export const Query = `
43
44
  cycleCountReport(filters: [Filter], pagination: Pagination, sortings: [Sorting], name: String!): CycleCountReportList @transaction
44
45
  nonLoadedOrderInventories(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): NonLoadedOrderInventoryReportList @transaction
45
46
  manifestReport(filters: [Filter!], pagination: Pagination, sortings: [Sorting!]): ManifestReportList @transaction
47
+ pgUdfQuery(filters: [Filter!]): PgUdfQueryList @transaction
46
48
  `
47
49
 
48
50
  export const Types = [
@@ -75,5 +77,6 @@ export const Types = [
75
77
  NonLoadedOrderInventoryReport,
76
78
  NonLoadedOrderInventoryReportList,
77
79
  ManifestReport,
78
- ManifestReportList
80
+ ManifestReportList,
81
+ PgUdfQueryList
79
82
  ]
@@ -0,0 +1,7 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ export const PgUdfQueryList = gql`
4
+ type PgUdfQueryList {
5
+ items: String
6
+ }
7
+ `
@@ -1,105 +0,0 @@
1
- module.exports = {
2
- domainType: 'warehouse',
3
- domainExtType: 'warehouse',
4
- useVirtualHostBasedDomain: false,
5
- fallbackRoute: '/',
6
- subdomainOffset: 2,
7
- port: 1100,
8
- inspect: '9430',
9
- ormconfig: {
10
- name: 'default',
11
- type: 'postgres',
12
- database: 'dev',
13
- username: 'postgres',
14
- password: 'hatio',
15
- host: '192.168.0.161',
16
- port: 15432,
17
- synchronize: false,
18
- logging: true
19
- },
20
- // ormconfig: {
21
- // name: 'default',
22
- // type: 'postgres',
23
- // database: 'postgres',
24
- // username: 'postgres',
25
- // password: 'abcd1234',
26
- // host: 'operatov3.cluster-cijhm4n1hbst.ap-southeast-1.rds.amazonaws.com',
27
- // port: 55432,
28
- // synchronize: false,
29
- // logging: true
30
- // },
31
- sellercraftIntegrationConfig: {
32
- apiKey: 'Et0KqtLvA6e92bDvOywy9eCCud4hpAal8akpqI90'
33
- },
34
- SECRET: '0xD58F835B69D207A76CC5F84a70a1D0d4C79dfC95',
35
- password: {
36
- lowerCase: true,
37
- upperCase: false,
38
- digit: false,
39
- specialCharacter: false,
40
- allowRepeat: true,
41
- useTightPattern: false,
42
- useLoosePattern: true,
43
- tightCharacterLength: 4,
44
- looseCharacterLength: 4,
45
- history: 2
46
- },
47
- // storage: {
48
- // type: 's3',
49
- // accessKeyId: 'AKIAUQEOPWEJCDH6AR5H',
50
- // secretAccessKey: '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',
51
- // bucketName: 'opa-one',
52
- // region: 'ap-southeast-1'
53
- // },
54
- uploads: 'uploads',
55
- attachmentsPath: 'attachments',
56
- logger: {
57
- file: {
58
- filename: 'logs/application-%DATE%.log',
59
- datePattern: 'YYYY-MM-DD-HH',
60
- zippedArchive: true,
61
- maxSize: '200m',
62
- maxFiles: '1m',
63
- level: 'info'
64
- }
65
- },
66
- email: {
67
- host: 'smtp.office365.com',
68
- port: 587,
69
- secure: false, // true for 465, false for other ports
70
- auth: {
71
- user: 'no-reply@hatiolab.com', // generated ethereal user
72
- pass: 'h@ti0LAB1008' // generated ethereal password
73
- },
74
- secureConnection: false,
75
- tls: {
76
- ciphers: 'SSLv3'
77
- }
78
- },
79
- sender: 'no-reply@hatiolab.com',
80
- notification: {
81
- // fcm: {
82
- // serviceAccount: {
83
- // project_id: 'operato',
84
- // private_key:
85
- // '-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDYNOfyNjPMSeG9\nzU1qs0cpVK5cVfadcUaw5g+hkQZMOMlAA7uqW2eX4vkayj7MzbYUayH+sei8044Q\nJIyl6f26dNX1VT3UgTmSmCS0v48EBEZHCgusrUGFjduLRN6OS6uvrXW1xKA18k9q\nai1C2EHCXF2AE4PTvf239RC1UIOnVePcMtT7rMTdHRO4s8OKVuSDbzIt8k1cV3Zt\nES0YsJlkELqBisYpV//2/ZSILTt39J9JzrVef03X9kkoo9p+YnNyy6tWsfQPfgJO\nybiRGBNxiyJ/E2pxRo/WqU0go9OzYJlGaSUrUx09heNiRD1b0MAOmyPDJz/6AaTk\nkU/A+kLzAgMBAAECggEADQ5s2gtR53VSujk1V/Xe8e0Di99DwaWUj5w6YhcK7/wX\nPdQRN4Fw6RLeLjL7xeG/rCNSwzm6hKSrQJL5zLnWW7XbMdyQRk6jdmnVAEv3zACi\nFH9+eFK3e+Q214XfgWz/v4p/FZdRLCYni5VBNHcwyWxLLS/V1ynzB3KM1sDiTRmI\npcT7+uTtwrKgJq64sXtFE2pYrFxDdCiyqzkhv/2ed4YIowAjpKBbbcCDKeVxVkoz\nC1P4PAzs9EeUuKSWYrWaUjN17lq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Config: {
89
- // apiKey: 'AIzaSyDdTM2BTLHSt2LNS0G5QB8G0i4KBXFiG7U',
90
- // projectId: 'operato',
91
- // messagingSenderId: 79537064975,
92
- // appId: '1:79537064975:web:32f53119e9c8c6ee2a277a'
93
- // },
94
- // serverKey:
95
- // 'AAAAEoTHTA8:APA91bGwt-4HT82Dfwf_VwbQaKT0_qHd0Y3tuW41udjWz5Lz0Ko0mEMD6WbHHSILvQpa6yuoGGKCMsrU7VW2qWRrUm3CYpyG9oSwshNm1tIhljAnOuUfwHCoawbVLwf9qlWpHt4dwCoc'
96
- // },
97
- // vapidKey: {
98
- // subject: 'mailto:heartyoh@hatiolab.com',
99
- // publicKey: 'BAkVkITsCXBIsYL1yeaBmx5_dn57we-ZXMjirPPHzC2dan82cdEnAio_53PQ-1_w3ykWCBPrrFAWQ_d9N4cFF0o',
100
- // privateKey: '4pmlt3Wk019u7nqU3Q_oGZE6LbUDjjf8DpmAcn9-iss'
101
- // }
102
- },
103
- // reportApiUrl: 'localhost:8888/rest/report/show_html'
104
- reportApiUrl: 'http://192.168.0.153:8888/rest/report/show_html'
105
- }