@things-factory/worksheet-base 3.7.6 → 3.7.7

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 (31) hide show
  1. package/dist-server/constants/template.js +1 -0
  2. package/dist-server/constants/template.js.map +1 -1
  3. package/dist-server/controllers/index.js +1 -0
  4. package/dist-server/controllers/index.js.map +1 -1
  5. package/dist-server/controllers/outbound/picking-worksheet-controller.js +111 -120
  6. package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
  7. package/dist-server/controllers/render-manifest.js +64 -0
  8. package/dist-server/controllers/render-manifest.js.map +1 -0
  9. package/dist-server/graphql/resolvers/worksheet/loading-worksheet.js +9 -13
  10. package/dist-server/graphql/resolvers/worksheet/loading-worksheet.js.map +1 -1
  11. package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +10 -14
  12. package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
  13. package/dist-server/graphql/resolvers/worksheet/picking/picking.js +4 -4
  14. package/dist-server/graphql/resolvers/worksheet/picking/picking.js.map +1 -1
  15. package/dist-server/graphql/resolvers/worksheet/picking/scan-product-picking.js +4 -4
  16. package/dist-server/graphql/resolvers/worksheet/picking/scan-product-picking.js.map +1 -1
  17. package/dist-server/graphql/types/worksheet/index.js +2 -0
  18. package/dist-server/graphql/types/worksheet/index.js.map +1 -1
  19. package/dist-server/routes.js +4 -0
  20. package/dist-server/routes.js.map +1 -1
  21. package/package.json +8 -8
  22. package/server/constants/template.ts +1 -0
  23. package/server/controllers/index.ts +1 -0
  24. package/server/controllers/outbound/picking-worksheet-controller.ts +142 -149
  25. package/server/controllers/render-manifest.ts +68 -0
  26. package/server/graphql/resolvers/worksheet/loading-worksheet.ts +12 -15
  27. package/server/graphql/resolvers/worksheet/packing-worksheet.ts +11 -14
  28. package/server/graphql/resolvers/worksheet/picking/picking.ts +5 -4
  29. package/server/graphql/resolvers/worksheet/picking/scan-product-picking.ts +7 -4
  30. package/server/graphql/types/worksheet/index.ts +3 -1
  31. package/server/routes.ts +5 -0
@@ -0,0 +1,68 @@
1
+ import FormData from 'form-data'
2
+ import fetch from 'node-fetch'
3
+ import { getRepository } from 'typeorm'
4
+
5
+ import { Attachment, STORAGE } from '@things-factory/attachment-base'
6
+ import { config } from '@things-factory/env'
7
+ import { Manifest, ReleaseGood } from '@things-factory/sales-base'
8
+ import { Domain } from '@things-factory/shell'
9
+
10
+ import { TEMPLATE_TYPE } from '../constants'
11
+ import { DateTimeConverter } from '../utils/datetime-util'
12
+
13
+ const REPORT_API_URL = config.get('reportApiUrl', 'http://localhost:8888/rest/report/show_html')
14
+
15
+ export async function renderManifest({ manifestNo }, context: any) {
16
+ // 1. find domain
17
+ const domain: Domain = await getRepository(Domain).findOne({
18
+ where: { id: context.state.domain.id }
19
+ })
20
+
21
+ // 2. find manifest
22
+ const manifest: Manifest = await getRepository(Manifest).findOne({
23
+ where: { domain, name: manifestNo },
24
+ relations: ['domain']
25
+ })
26
+
27
+ // find release good
28
+ const releaseGoods: ReleaseGood[] = await getRepository(ReleaseGood).find({
29
+ where: { domain, manifest }
30
+ })
31
+
32
+ // 7. find grn template based on category
33
+ const foundTemplate: Attachment = await getRepository(Attachment).findOne({
34
+ where: { domain, category: TEMPLATE_TYPE.MANIFEST_TEMPLATE }
35
+ })
36
+
37
+ const template = await STORAGE.readFile(foundTemplate.path, 'utf-8')
38
+
39
+ const data = {
40
+ shipping_provider: manifest?.shippingProvider,
41
+ manifest_no: manifest?.name,
42
+ manifest_date: DateTimeConverter.date(manifest?.createdAt).toString(),
43
+ total_list: releaseGoods?.length || 0,
44
+ product_list: releaseGoods.map((item, idx) => {
45
+ return {
46
+ list_no: idx + 1,
47
+ order_no: item?.refNo,
48
+ tracking_no: item?.trackingNo,
49
+ phone: item?.phone1,
50
+ delivery_date: DateTimeConverter.date(manifest?.dispatchedAt).toString(),
51
+ attention_to: item?.attentionTo,
52
+ delivery_address: item?.deliveryAddress1,
53
+ postal_code_city: `${item?.postalCode}, ${item?.city}`
54
+ }
55
+ })
56
+ }
57
+
58
+ const formData = new FormData()
59
+ formData.append('template', template)
60
+ formData.append('jsonString', JSON.stringify(data))
61
+
62
+ const response = await fetch(REPORT_API_URL, {
63
+ method: 'POST',
64
+ body: formData
65
+ })
66
+
67
+ return await response.text()
68
+ }
@@ -1,6 +1,6 @@
1
- import { Equal, getRepository, In, Not } from 'typeorm'
1
+ import { Equal, getRepository, In, Not, SelectQueryBuilder } from 'typeorm'
2
2
 
3
- import { ORDER_INVENTORY_STATUS, OrderInventory, ReleaseGood } from '@things-factory/sales-base'
3
+ import { ORDER_STATUS, ORDER_INVENTORY_STATUS, OrderInventory, ReleaseGood } from '@things-factory/sales-base'
4
4
  import { Domain } from '@things-factory/shell'
5
5
  import { Inventory, Location } from '@things-factory/warehouse-base'
6
6
 
@@ -22,19 +22,16 @@ export const loadingWorksheetResolver = {
22
22
  where: { domain, name: releaseGoodNo }
23
23
  })
24
24
 
25
- const orderInventoryByBin: OrderInventory = await getRepository(OrderInventory).findOne({
26
- where: {
27
- domain, binLocation, status: In([ORDER_INVENTORY_STATUS.LOADING, ORDER_INVENTORY_STATUS.LOADED])
28
- },
29
- order: {
30
- createdAt: 'ASC'
31
- },
32
- relations: [
33
- 'releaseGood',
34
- 'releaseGood.bizplace',
35
- 'releaseGood.bizplace.domain'
36
- ]
37
- })
25
+ const qb: SelectQueryBuilder<OrderInventory> = getRepository(OrderInventory).createQueryBuilder('orderInventory')
26
+ qb.innerJoinAndSelect('orderInventory.releaseGood', 'releaseGood')
27
+ .innerJoinAndSelect('releaseGood.bizplace', 'bizplace')
28
+ .innerJoinAndSelect('bizplace.domain', 'domain')
29
+ .where('orderInventory.domain_id = :domainId', { domainId: domain.id })
30
+ .andWhere('orderInventory.status IN (:...orderInventoryStatus)', { orderInventoryStatus: [ORDER_INVENTORY_STATUS.LOADING, ORDER_INVENTORY_STATUS.LOADED] })
31
+ .andWhere('orderInventory.bin_location_id = :locationId', { locationId: binLocation.id })
32
+ .andWhere('releaseGood.status = :status', { status: ORDER_STATUS.LOADING })
33
+
34
+ const orderInventoryByBin = await qb.getOne()
38
35
 
39
36
  if (orderInventoryByBin?.releaseGood) {
40
37
  releaseGoodNo = orderInventoryByBin.releaseGood.name
@@ -1,4 +1,4 @@
1
- import { EntityManager, In } from 'typeorm'
1
+ import { EntityManager, In, SelectQueryBuilder } from 'typeorm'
2
2
 
3
3
  import { User } from '@things-factory/auth-base'
4
4
  import { Sellercraft, SellercraftStatus } from '@things-factory/integration-sellercraft'
@@ -11,6 +11,7 @@ import { WORKSHEET_TYPE } from '../../../constants'
11
11
  import { SellercraftController } from '../../../controllers'
12
12
  import { Worksheet, WorksheetDetail } from '../../../entities'
13
13
  import { fetchExecutingWorksheet } from '../../../utils'
14
+ import { ORDER_STATUS } from '@things-factory/sales-base'
14
15
 
15
16
  export const packingWorksheetResolver = {
16
17
  async packingWorksheet(_: any, { releaseGoodNo }, context: any) {
@@ -29,20 +30,16 @@ export const packingWorksheetResolver = {
29
30
  where: { domain, name: releaseGoodNo }
30
31
  })
31
32
 
32
- const orderInventoryByBin: OrderInventory = await tx.getRepository(OrderInventory).findOne({
33
- where: {
34
- domain, binLocation, status: In([ORDER_INVENTORY_STATUS.PACKING, ORDER_INVENTORY_STATUS.PACKED])
35
- },
36
- order: {
37
- createdAt: 'ASC'
38
- },
39
- relations: [
40
- 'releaseGood',
41
- 'releaseGood.bizplace',
42
- 'releaseGood.bizplace.domain'
43
- ]
44
- })
33
+ const qb: SelectQueryBuilder<OrderInventory> = tx.getRepository(OrderInventory).createQueryBuilder('orderInventory')
34
+ qb.innerJoinAndSelect('orderInventory.releaseGood', 'releaseGood')
35
+ .innerJoinAndSelect('releaseGood.bizplace', 'bizplace')
36
+ .innerJoinAndSelect('bizplace.domain', 'domain')
37
+ .where('orderInventory.domain_id = :domainId', { domainId: domain.id })
38
+ .andWhere('orderInventory.status IN (:...orderInventoryStatus)', { orderInventoryStatus: [ORDER_INVENTORY_STATUS.PACKING, ORDER_INVENTORY_STATUS.PACKED] })
39
+ .andWhere('orderInventory.bin_location_id = :locationId', { locationId: binLocation.id })
40
+ .andWhere('releaseGood.status = :status', { status: ORDER_STATUS.PACKING })
45
41
 
42
+ const orderInventoryByBin = await qb.getOne()
46
43
  if (orderInventoryByBin?.releaseGood) {
47
44
  releaseGoodNo = orderInventoryByBin.releaseGood.name
48
45
  releaseGood = orderInventoryByBin.releaseGood
@@ -4,9 +4,9 @@ import { EntityManager } from 'typeorm'
4
4
  import { PickingWorksheetController } from '../../../../controllers'
5
5
 
6
6
  export const pickingResolver = {
7
- async picking(_: any, { worksheetDetailName, worksheetType, palletId, locationName, releaseQty, binLocation }, context: any) {
7
+ async picking(_: any, { worksheetDetailName, worksheetType, palletId, locationName, releaseQty, binLocation, serialNumber }, context: any) {
8
8
  const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
9
- await picking(tx, domain, user, worksheetDetailName, worksheetType, palletId, locationName, releaseQty, binLocation)
9
+ await picking(tx, domain, user, worksheetDetailName, worksheetType, palletId, locationName, releaseQty, binLocation, serialNumber)
10
10
  }
11
11
  }
12
12
 
@@ -19,8 +19,9 @@ export async function picking(
19
19
  palletId: string,
20
20
  locationName: string,
21
21
  releaseQty: number,
22
- binLocation?: string
22
+ binLocation?: string,
23
+ serialNumber?: string
23
24
  ) {
24
25
  const worksheetController: PickingWorksheetController = new PickingWorksheetController(tx, domain, user)
25
- await worksheetController.picking(worksheetDetailName, worksheetType, palletId, locationName, releaseQty, binLocation)
26
+ await worksheetController.picking(worksheetDetailName, worksheetType, palletId, locationName, releaseQty, binLocation, serialNumber)
26
27
  }
@@ -6,7 +6,7 @@ import { PickingWorksheetController } from '../../../../controllers'
6
6
  export const scanProductPickingResolver = {
7
7
  async scanProductPicking(
8
8
  _: any,
9
- { worksheetDetailName, worksheetType, productBarcode, cartonId, binLocation },
9
+ { worksheetDetailName, worksheetType, productBarcode, cartonId, binLocation, serialNumber },
10
10
  context: any
11
11
  ) {
12
12
  const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
@@ -18,7 +18,8 @@ export const scanProductPickingResolver = {
18
18
  worksheetType,
19
19
  productBarcode,
20
20
  cartonId,
21
- binLocation
21
+ binLocation,
22
+ serialNumber
22
23
  )
23
24
  }
24
25
  }
@@ -31,7 +32,8 @@ export async function scanProductPicking(
31
32
  worksheetType: string,
32
33
  productBarcode: string,
33
34
  cartonId: string,
34
- binLocation?: string
35
+ binLocation?: string,
36
+ serialNumber?: string
35
37
  ) {
36
38
  const worksheetController: PickingWorksheetController = new PickingWorksheetController(tx, domain, user)
37
39
  await worksheetController.scanProductPicking(
@@ -39,6 +41,7 @@ export async function scanProductPicking(
39
41
  worksheetType,
40
42
  productBarcode,
41
43
  cartonId,
42
- binLocation
44
+ binLocation,
45
+ serialNumber
43
46
  )
44
47
  }
@@ -291,6 +291,7 @@ export const Mutation = /* GraphQL */ `
291
291
  locationName: String!
292
292
  releaseQty: Int!
293
293
  binLocation: String
294
+ serialNumber: String
294
295
  ): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
295
296
 
296
297
  scanProductPicking (
@@ -299,6 +300,7 @@ export const Mutation = /* GraphQL */ `
299
300
  productBarcode: String!
300
301
  cartonId: String!
301
302
  binLocation: String
303
+ serialNumber: String
302
304
  ): Boolean @privilege(category: "worksheet_execute", privilege: "mutation") @transaction
303
305
 
304
306
  sortingProduct (
@@ -666,7 +668,7 @@ export const Query = /* GraphQL */ `
666
668
  findReleaseOrdersByTaskNo(taskNo: String!): [ReleaseGood] @privilege(category: "worksheet", privilege: "query") @transaction
667
669
  `
668
670
 
669
- export const Types = /* GraphQL */ [
671
+ export const Types = /* GraphQL */[
670
672
  Worksheet,
671
673
  AirwayBill,
672
674
  NewWorksheet,
package/server/routes.ts CHANGED
@@ -2,6 +2,7 @@ import { renderElcclGRN } from './controllers/render-elccl-grn'
2
2
  import { renderGRN } from './controllers/render-grn'
3
3
  import { renderJobSheet } from './controllers/render-job-sheet'
4
4
  import { renderKimedaGRN } from './controllers/render-kimeda-grn'
5
+ import { renderManifest } from './controllers/render-manifest'
5
6
  import { renderManualDO } from './controllers/render-manual-do'
6
7
  import { renderOrientageDO } from './controllers/render-orientage-do'
7
8
  import { renderOrientageGRN } from './controllers/render-orientage-grn'
@@ -44,4 +45,8 @@ process.on('bootstrap-module-domain-private-route' as any, (app, routes) => {
44
45
  routes.get('/view_job_sheet/:ganNo/:timezoneOffSet', async (context, next) => {
45
46
  context.body = await renderJobSheet(context.params, context)
46
47
  })
48
+
49
+ routes.get('/view_manifest/:manifestNo', async (context, next) => {
50
+ context.body = await renderManifest(context.params, context)
51
+ })
47
52
  })