@things-factory/worksheet-base 4.3.494 → 4.3.499

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 (61) hide show
  1. package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js +68 -29
  2. package/dist-server/controllers/inspect/cycle-count-worksheet-controller.js.map +1 -1
  3. package/dist-server/controllers/render-invoices.js +5 -2
  4. package/dist-server/controllers/render-invoices.js.map +1 -1
  5. package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js +30 -6
  6. package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js.map +1 -1
  7. package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet-for-carton.js +17 -1
  8. package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet-for-carton.js.map +1 -1
  9. package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet-for-pallet.js +18 -2
  10. package/dist-server/graphql/resolvers/worksheet/cycle-count-worksheet-for-pallet.js.map +1 -1
  11. package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-cycle-count-worksheet.js +4 -4
  12. package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-cycle-count-worksheet.js.map +1 -1
  13. package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-release-good-worksheet.js +1 -0
  14. package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-release-good-worksheet.js.map +1 -1
  15. package/dist-server/graphql/resolvers/worksheet/inspecting/add-extra-inventory.js +4 -4
  16. package/dist-server/graphql/resolvers/worksheet/inspecting/add-extra-inventory.js.map +1 -1
  17. package/dist-server/graphql/resolvers/worksheet/inspecting/inspecting-carton.js +4 -4
  18. package/dist-server/graphql/resolvers/worksheet/inspecting/inspecting-carton.js.map +1 -1
  19. package/dist-server/graphql/resolvers/worksheet/inspecting/inspecting-pallet.js +4 -4
  20. package/dist-server/graphql/resolvers/worksheet/inspecting/inspecting-pallet.js.map +1 -1
  21. package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js +1 -0
  22. package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
  23. package/dist-server/graphql/resolvers/worksheet/not-tally-target-inventories.js +15 -1
  24. package/dist-server/graphql/resolvers/worksheet/not-tally-target-inventories.js.map +1 -1
  25. package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js +7 -1
  26. package/dist-server/graphql/resolvers/worksheet/picking/activate-picking.js.map +1 -1
  27. package/dist-server/graphql/resolvers/worksheet/picking/bulk-activate-picking.js +7 -1
  28. package/dist-server/graphql/resolvers/worksheet/picking/bulk-activate-picking.js.map +1 -1
  29. package/dist-server/graphql/resolvers/worksheet/worksheet-with-pagination.js +15 -1
  30. package/dist-server/graphql/resolvers/worksheet/worksheet-with-pagination.js.map +1 -1
  31. package/dist-server/graphql/resolvers/worksheet/worksheets.js +8 -0
  32. package/dist-server/graphql/resolvers/worksheet/worksheets.js.map +1 -1
  33. package/dist-server/graphql/types/worksheet/index.js +9 -3
  34. package/dist-server/graphql/types/worksheet/index.js.map +1 -1
  35. package/dist-server/graphql/types/worksheet/location-filter.js +13 -0
  36. package/dist-server/graphql/types/worksheet/location-filter.js.map +1 -0
  37. package/dist-server/graphql/types/worksheet/worksheet-detail-info.js +1 -0
  38. package/dist-server/graphql/types/worksheet/worksheet-detail-info.js.map +1 -1
  39. package/dist-server/utils/lmd-util.js +21 -26
  40. package/dist-server/utils/lmd-util.js.map +1 -1
  41. package/package.json +6 -6
  42. package/server/controllers/inspect/cycle-count-worksheet-controller.ts +98 -33
  43. package/server/controllers/render-invoices.ts +7 -2
  44. package/server/graphql/resolvers/worksheet/cycle-count-adjustment.ts +39 -33
  45. package/server/graphql/resolvers/worksheet/cycle-count-worksheet-for-carton.ts +20 -5
  46. package/server/graphql/resolvers/worksheet/cycle-count-worksheet-for-pallet.ts +27 -5
  47. package/server/graphql/resolvers/worksheet/generate-worksheet/generate-cycle-count-worksheet.ts +7 -4
  48. package/server/graphql/resolvers/worksheet/generate-worksheet/generate-release-good-worksheet.ts +1 -0
  49. package/server/graphql/resolvers/worksheet/inspecting/add-extra-inventory.ts +8 -4
  50. package/server/graphql/resolvers/worksheet/inspecting/inspecting-carton.ts +7 -4
  51. package/server/graphql/resolvers/worksheet/inspecting/inspecting-pallet.ts +5 -4
  52. package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +1 -0
  53. package/server/graphql/resolvers/worksheet/not-tally-target-inventories.ts +22 -1
  54. package/server/graphql/resolvers/worksheet/picking/activate-picking.ts +7 -1
  55. package/server/graphql/resolvers/worksheet/picking/bulk-activate-picking.ts +7 -1
  56. package/server/graphql/resolvers/worksheet/worksheet-with-pagination.ts +26 -1
  57. package/server/graphql/resolvers/worksheet/worksheets.ts +12 -1
  58. package/server/graphql/types/worksheet/index.ts +9 -3
  59. package/server/graphql/types/worksheet/location-filter.ts +10 -0
  60. package/server/graphql/types/worksheet/worksheet-detail-info.ts +1 -0
  61. package/server/utils/lmd-util.ts +30 -28
@@ -7,7 +7,7 @@ import { Product } from 'puppeteer'
7
7
  export const inspectingCartonResolver = {
8
8
  async inspectingCarton(
9
9
  _: any,
10
- { productDetailId, cartonId, batchId, locationId, inspectedBatchNo, inspectedQty, inspectedUomValue },
10
+ { productDetailId, cartonId, batchId, locationId, inspectedBatchNo, inspectedQty, inspectedUomValue, inspectedExpirationDate },
11
11
  context: any
12
12
  ) {
13
13
  const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
@@ -21,7 +21,8 @@ export const inspectingCartonResolver = {
21
21
  locationId,
22
22
  inspectedBatchNo,
23
23
  inspectedQty,
24
- inspectedUomValue
24
+ inspectedUomValue,
25
+ inspectedExpirationDate
25
26
  )
26
27
  }
27
28
  }
@@ -36,7 +37,8 @@ export async function executeInspectionCarton(
36
37
  locationId: string,
37
38
  inspectedBatchNo: string,
38
39
  inspectedQty: number,
39
- inspectedUomValue: number
40
+ inspectedUomValue: number,
41
+ inspectedExpirationDate: Date
40
42
  ) {
41
43
  const worksheetController: CycleCountWorksheetController = new CycleCountWorksheetController(tx, domain, user)
42
44
  await worksheetController.inspectingCarton(
@@ -46,6 +48,7 @@ export async function executeInspectionCarton(
46
48
  locationId,
47
49
  inspectedBatchNo,
48
50
  inspectedQty,
49
- inspectedUomValue
51
+ inspectedUomValue,
52
+ inspectedExpirationDate
50
53
  )
51
54
  }
@@ -4,9 +4,9 @@ import { EntityManager } from 'typeorm'
4
4
  import { CycleCountWorksheetController } from '../../../../controllers'
5
5
 
6
6
  export const inspectingPalletResolver = {
7
- async inspectingPallet(_: any, { worksheetDetailName, inspectedBatchNo, inspectedQty, inspectedUomValue }, context: any) {
7
+ async inspectingPallet(_: any, { worksheetDetailName, inspectedBatchNo, inspectedQty, inspectedUomValue, inspectedExpirationDate}, context: any) {
8
8
  const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
9
- await executeInspectionPallet(tx, domain, user, worksheetDetailName, inspectedBatchNo, inspectedQty, inspectedUomValue)
9
+ await executeInspectionPallet(tx, domain, user, worksheetDetailName, inspectedBatchNo, inspectedQty, inspectedUomValue, inspectedExpirationDate)
10
10
  }
11
11
  }
12
12
 
@@ -17,8 +17,9 @@ export async function executeInspectionPallet(
17
17
  worksheetDetailName: string,
18
18
  inspectedBatchNo: string,
19
19
  inspectedQty: number,
20
- inspectedUomValue: number
20
+ inspectedUomValue: number,
21
+ inspectedExpirationDate: Date
21
22
  ) {
22
23
  const worksheetController: CycleCountWorksheetController = new CycleCountWorksheetController(tx, domain, user)
23
- await worksheetController.inspectingPallet(worksheetDetailName, inspectedBatchNo, inspectedQty, inspectedUomValue)
24
+ await worksheetController.inspectingPallet(worksheetDetailName, inspectedBatchNo, inspectedQty, inspectedUomValue, inspectedExpirationDate)
24
25
  }
@@ -43,6 +43,7 @@ export const inventoriesByPalletResolver = {
43
43
  .andWhere('iv.qty > 0')
44
44
  .andWhere('iv.transfer_qty <= 0')
45
45
  .andWhere('iv.transfer_uom_value <= 0')
46
+ .andWhere('iv.lock_inventory != true')
46
47
  .andWhere(
47
48
  `location.type ${recallFilters?.value === true ? '' : 'NOT'} IN ('${LOCATION_TYPE.QUARANTINE}', '${
48
49
  LOCATION_TYPE.RESERVE
@@ -33,6 +33,27 @@ export const notTallyTargetInventoriesResolver = {
33
33
  .andWhere('WSD.status = :status', { status: INVENTORY_CHECK_ITEM_STATUS.NOT_TALLY })
34
34
  .getMany()
35
35
 
36
- return worksheetDetails.map((wsd: WorksheetDetail) => wsd.targetInventoryCheckItem)
36
+ let targetInventoryCheckItem = worksheetDetails.map((wsd: WorksheetDetail) => {
37
+ let orgExpDate = wsd.targetInventoryCheckItem.originExpirationDate ? formatDate(wsd.targetInventoryCheckItem.originExpirationDate) : null
38
+ let insExpDate = wsd.targetInventoryCheckItem.inspectedExpirationDate? formatDate(wsd.targetInventoryCheckItem.inspectedExpirationDate) : null
39
+ return {
40
+ ...wsd.targetInventoryCheckItem,
41
+ systemExpiryDate: orgExpDate,
42
+ inspectedExpiryDate: insExpDate
43
+ }
44
+ })
45
+
46
+ return targetInventoryCheckItem
37
47
  }
38
48
  }
49
+
50
+ function formatDate(date) {
51
+ const getDate = new Date(date)
52
+ let formatDate = {
53
+ year: getDate.getFullYear(),
54
+ month: String(getDate.getMonth() + 1).padStart(2, '0'),
55
+ day: String(getDate.getDate()).padStart(2, '0')
56
+ }
57
+
58
+ return `${formatDate.day}-${formatDate.month}-${formatDate.year}`
59
+ }
@@ -34,7 +34,13 @@ export async function activatePicking(
34
34
 
35
35
  const marketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
36
36
  where: { orderNo: releaseGood.refNo, domain: companyDomain },
37
- relations: ['marketplaceStore']
37
+ relations: [
38
+ 'marketplaceStore',
39
+ 'marketplaceStore.marketplaceDistributors',
40
+ 'marketplaceOrderItems',
41
+ 'marketplaceOrderItems.marketplaceOrderShippingItems',
42
+ 'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping'
43
+ ]
38
44
  })
39
45
 
40
46
  switch (orderSource) {
@@ -35,7 +35,13 @@ export async function activateBulkPicking(
35
35
 
36
36
  const marketplaceOrder: MarketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
37
37
  where: { orderNo: releaseGood.refNo, domain: companyDomain },
38
- relations: ['marketplaceStore']
38
+ relations: [
39
+ 'marketplaceStore',
40
+ 'marketplaceStore.marketplaceDistributors',
41
+ 'marketplaceOrderItems',
42
+ 'marketplaceOrderItems.marketplaceOrderShippingItems',
43
+ 'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping'
44
+ ]
39
45
  })
40
46
 
41
47
  switch (orderSource) {
@@ -35,7 +35,21 @@ export const worksheetWithPaginationResolver = {
35
35
  findManyOptions.take = limit
36
36
  }
37
37
 
38
- const [worksheetDetails, total] = await getRepository(WorksheetDetail).findAndCount(findManyOptions)
38
+ let [worksheetDetails, total] = await getRepository(WorksheetDetail).findAndCount(findManyOptions)
39
+
40
+ worksheetDetails = worksheetDetails.map(wd => {
41
+ let orgExpDate = wd.targetInventoryCheckItem.originExpirationDate ? formatDate(wd.targetInventoryCheckItem.originExpirationDate) : null
42
+ let insExpDate = wd.targetInventoryCheckItem.inspectedExpirationDate? formatDate(wd.targetInventoryCheckItem.inspectedExpirationDate) : null
43
+
44
+ return {
45
+ ...wd,
46
+ targetInventoryCheckItem: {
47
+ ...wd.targetInventoryCheckItem,
48
+ systemExpiryDate: orgExpDate,
49
+ inspectedExpiryDate: insExpDate
50
+ }
51
+ }
52
+ })
39
53
 
40
54
  return {
41
55
  worksheet,
@@ -44,3 +58,14 @@ export const worksheetWithPaginationResolver = {
44
58
  }
45
59
  }
46
60
  }
61
+
62
+ function formatDate(date) {
63
+ const getDate = new Date(date)
64
+ let formatDate = {
65
+ year: getDate.getFullYear(),
66
+ month: String(getDate.getMonth() + 1).padStart(2, '0'),
67
+ day: String(getDate.getDate()).padStart(2, '0')
68
+ }
69
+
70
+ return `${formatDate.day}-${formatDate.month}-${formatDate.year}`
71
+ }
@@ -552,7 +552,7 @@ export const worksheetsResolver = {
552
552
  sort.name != 'releaseRefNo' &&
553
553
  sort.name != 'returnOrderNo' &&
554
554
  sort.name != 'inventoryCheckStatus' &&
555
- sort.name != 'executionDate'
555
+ sort.name != 'executionDate'
556
556
  ) {
557
557
  return {
558
558
  ...acc,
@@ -619,6 +619,17 @@ export const worksheetsResolver = {
619
619
  }
620
620
  }
621
621
 
622
+ if (params.sortings.some(e => e.name === 'updatedAt')) {
623
+ // overwrite the worksheet status sorting since inventory check status is needed
624
+ sort = {
625
+ 'ws.updatedAt': params.sortings[
626
+ params.sortings.findIndex(item => item.name == 'updatedAt')
627
+ ].desc
628
+ ? 'DESC'
629
+ : 'ASC'
630
+ }
631
+ }
632
+
622
633
  qb.orderBy(sort)
623
634
 
624
635
  let [items, total] = await qb.getManyAndCount()
@@ -28,6 +28,7 @@ import { WorksheetInfo } from './worksheet-info'
28
28
  import { WorksheetList } from './worksheet-list'
29
29
  import { WorksheetPatch } from './worksheet-patch'
30
30
  import { WorksheetWithPagination } from './worksheet-with-pagination'
31
+ import { LocationFilter } from './location-filter'
31
32
 
32
33
  export const Mutation = /* GraphQL */ `
33
34
  createWorksheet (
@@ -100,6 +101,7 @@ export const Mutation = /* GraphQL */ `
100
101
  limit: Int
101
102
  selectedLocation: [String]
102
103
  cycleCountNo: String
104
+ lockInventory: Boolean
103
105
  ): CycleCountWorksheet @privilege(category: "worksheet_control", privilege: "mutation") @transaction
104
106
 
105
107
  generateCycleCountWorksheetCarton (
@@ -461,6 +463,7 @@ export const Mutation = /* GraphQL */ `
461
463
  inspectedBatchNo: String!
462
464
  inspectedQty: Int!
463
465
  inspectedUomValue: Float!
466
+ inspectedExpirationDate: Date
464
467
  ): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
465
468
 
466
469
  inspectingCarton (
@@ -471,6 +474,7 @@ export const Mutation = /* GraphQL */ `
471
474
  inspectedBatchNo: String!
472
475
  inspectedQty: Int!
473
476
  inspectedUomValue: Float!
477
+ inspectedExpirationDate: Date
474
478
  ): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
475
479
 
476
480
  undoInspection (
@@ -525,6 +529,7 @@ export const Mutation = /* GraphQL */ `
525
529
  inspectedQty: Int!
526
530
  inspectedUomValue: Float!
527
531
  countNo: Int!
532
+ inspectedExpirationDate: Date
528
533
  ): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
529
534
 
530
535
 
@@ -784,11 +789,11 @@ export const Query = /* GraphQL */ `
784
789
  ): ExecutingWorksheet @privilege(category: "worksheet", privilege: "query")
785
790
 
786
791
  cycleCountWorksheetForPallet (
787
- inventoryCheckNo: String!, locationSortingRules: [Sorting], locationName: String, cartonId: String, palletId: String, inventoryCheckItemStatus: String
792
+ inventoryCheckNo: String!, locationSortingRules: [Sorting], locationName: String, cartonId: String, palletId: String, inventoryCheckItemStatus: String, locationFilter : LocationFilter
788
793
  ): ExecutingWorksheet @privilege(category: "worksheet", privilege: "query")
789
794
 
790
795
  cycleCountWorksheetForCarton (
791
- inventoryCheckNo: String!, locationSortingRules: [Sorting], locationName: String, cartonId: String, palletId: String, inventoryCheckItemStatus: String
796
+ inventoryCheckNo: String!, locationSortingRules: [Sorting], locationName: String, cartonId: String, palletId: String, inventoryCheckItemStatus: String, locationFilter : LocationFilter
792
797
  ): ExecutingWorksheet @privilege(category: "worksheet", privilege: "query")
793
798
 
794
799
  vasCandidates (
@@ -886,5 +891,6 @@ export const Types = /* GraphQL */ [
886
891
  FindReleaseOrdersByTaskNo,
887
892
  DeliveryOrderRO,
888
893
  GenerateBatchPickInfo,
889
- MultipleReleaseGoodWorksheet
894
+ MultipleReleaseGoodWorksheet,
895
+ LocationFilter
890
896
  ]
@@ -0,0 +1,10 @@
1
+ import { gql } from 'apollo-server-koa'
2
+
3
+ export const LocationFilter = gql`
4
+ input LocationFilter {
5
+ zone: String
6
+ row: String
7
+ column: String
8
+ shelf: String
9
+ }
10
+ `
@@ -35,6 +35,7 @@ export const WorksheetDetailInfo = gql`
35
35
  inspectedBatchNo: String
36
36
  inspectedQty: Int
37
37
  inspectedUomValue: Float
38
+ inspectedExpirationDate: String
38
39
  inspectedLocation: Location
39
40
  operationGuide: String
40
41
  set: Int
@@ -3,6 +3,7 @@ import 'jspdf'
3
3
  import fetch from 'node-fetch'
4
4
  import { Brackets, getRepository, SelectQueryBuilder, ILike } from 'typeorm'
5
5
  import { v4 as uuidv4 } from 'uuid'
6
+ import {Domain} from '@things-factory/shell'
6
7
 
7
8
  import { InvokeCommand, LambdaClient, LogType } from '@aws-sdk/client-lambda'
8
9
  import { Attachment, uploadAwb, uploadInvoice } from '@things-factory/attachment-base'
@@ -20,6 +21,7 @@ import {
20
21
  getAccessTokenCityLink
21
22
  } from '@things-factory/integration-lmd'
22
23
  import { createReleaseGoodLog, OrderPackage, ReleaseGood } from '@things-factory/sales-base'
24
+ import {MarketplaceOrder, MarketplaceStore} from '@things-factory/marketplace-base'
23
25
  import { Lambda } from './lambda/lambda-const'
24
26
 
25
27
  import { EcommerceController } from '../index'
@@ -411,34 +413,34 @@ export async function processAwbAndTrackingNo(orderPackages, tx, domain, user, m
411
413
 
412
414
  // update tracking no to mms then to Magento
413
415
  // comment temporarily to validate db lock
414
- // const companyDomain: Domain = releaseGood.bizplace.company.domain
415
- // if (!marketplaceOrder) {
416
- // marketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
417
- // where: { orderNo: releaseGood.refNo, domain: companyDomain },
418
- // relations: [
419
- // 'marketplaceStore',
420
- // 'marketplaceStore.marketplaceDistributors',
421
- // 'marketplaceOrderItems',
422
- // 'marketplaceOrderItems.marketplaceOrderShippingItems',
423
- // 'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping'
424
- // ]
425
- // })
426
- // }
427
-
428
- // if (marketplaceOrder) {
429
- // const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
430
- // const marketplaceStore: MarketplaceStore = marketplaceOrder.marketplaceStore
431
-
432
- // if (marketplaceStore?.isAutoUpdateShipment) {
433
- // await ecommerceCtrl.createOrderShip(
434
- // releaseGood,
435
- // marketplaceStore,
436
- // marketplaceOrder,
437
- // companyDomain,
438
- // tracking_no
439
- // )
440
- // }
441
- // }
416
+ const companyDomain: Domain = releaseGood.bizplace.company.domain
417
+ if (!marketplaceOrder) {
418
+ marketplaceOrder = await tx.getRepository(MarketplaceOrder).findOne({
419
+ where: { orderNo: releaseGood.refNo, domain: companyDomain },
420
+ relations: [
421
+ 'marketplaceStore',
422
+ 'marketplaceStore.marketplaceDistributors',
423
+ 'marketplaceOrderItems',
424
+ 'marketplaceOrderItems.marketplaceOrderShippingItems',
425
+ 'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping'
426
+ ]
427
+ })
428
+ }
429
+
430
+ if (marketplaceOrder) {
431
+ const ecommerceCtrl: EcommerceController = new EcommerceController(tx, domain, user)
432
+ const marketplaceStore: MarketplaceStore = marketplaceOrder.marketplaceStore
433
+
434
+ if (marketplaceStore?.isAutoUpdateShipment) {
435
+ await ecommerceCtrl.createOrderShip(
436
+ releaseGood,
437
+ marketplaceStore,
438
+ marketplaceOrder,
439
+ companyDomain,
440
+ tracking_no
441
+ )
442
+ }
443
+ }
442
444
  }
443
445
  } catch (e) {
444
446
  let releaseGoodId = orderPackage.releaseGood.id