@things-factory/worksheet-base 4.3.39 → 4.3.42
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.
- package/dist-server/controllers/ecommerce/sellercraft-controller.js +2 -2
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +6 -17
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/render-orientage-do.js +20 -6
- package/dist-server/controllers/render-orientage-do.js.map +1 -1
- package/dist-server/controllers/render-ro-do.js +5 -5
- package/dist-server/controllers/render-ro-do.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/fetch-delivery-order-ro.js +169 -0
- package/dist-server/graphql/resolvers/worksheet/fetch-delivery-order-ro.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/index.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/index.js.map +1 -1
- package/dist-server/graphql/types/worksheet/delivery-order-ro.js +18 -0
- package/dist-server/graphql/types/worksheet/delivery-order-ro.js.map +1 -0
- package/dist-server/graphql/types/worksheet/index.js +7 -1
- package/dist-server/graphql/types/worksheet/index.js.map +1 -1
- package/package.json +15 -15
- package/server/controllers/ecommerce/sellercraft-controller.ts +2 -2
- package/server/controllers/outbound/picking-worksheet-controller.ts +7 -17
- package/server/controllers/render-orientage-do.ts +32 -17
- package/server/controllers/render-ro-do.ts +5 -5
- package/server/graphql/resolvers/worksheet/fetch-delivery-order-ro.ts +193 -0
- package/server/graphql/resolvers/worksheet/index.ts +3 -1
- package/server/graphql/types/worksheet/delivery-order-ro.ts +15 -0
- package/server/graphql/types/worksheet/index.ts +9 -2
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
2
|
+
import FormData from 'form-data'
|
|
3
|
+
import fetch from 'node-fetch'
|
|
4
|
+
import { Equal, getRepository, In } from 'typeorm'
|
|
5
|
+
|
|
6
|
+
import { Partner } from '@things-factory/auth-base'
|
|
7
|
+
import { Bizplace, ContactPoint } from '@things-factory/biz-base'
|
|
8
|
+
import { DeliveryOrder, ORDER_STATUS, OrderInventory, ReleaseGood } from '@things-factory/sales-base'
|
|
9
|
+
import { Domain } from '@things-factory/shell'
|
|
10
|
+
import { Inventory, Pallet } from '@things-factory/warehouse-base'
|
|
11
|
+
import { InventoryItem } from '@things-factory/warehouse-base'
|
|
12
|
+
import { TEMPLATE_TYPE, WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
13
|
+
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
14
|
+
import { DateTimeConverter } from '../../../utils'
|
|
15
|
+
|
|
16
|
+
export const fetchDeliveryOrderROResolver = {
|
|
17
|
+
async fetchDeliveryOrderRO(_: any, { name }, context: any) {
|
|
18
|
+
const domain: Domain = await getRepository(Domain).findOne({
|
|
19
|
+
where: { id: context.state.domain.id }
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const foundDO: DeliveryOrder = await getRepository(DeliveryOrder).findOne({
|
|
23
|
+
where: { domain, name },
|
|
24
|
+
relations: [
|
|
25
|
+
'domain',
|
|
26
|
+
'bizplace',
|
|
27
|
+
'bizplace.company',
|
|
28
|
+
'bizplace.domain',
|
|
29
|
+
'transportDriver',
|
|
30
|
+
'transportVehicle',
|
|
31
|
+
'releaseGood',
|
|
32
|
+
'creator',
|
|
33
|
+
'updater'
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const ownTransportFlag: Boolean = foundDO.ownCollection
|
|
38
|
+
|
|
39
|
+
let foundCP: ContactPoint = null
|
|
40
|
+
if (foundDO?.contactPointRefId) {
|
|
41
|
+
foundCP = await getRepository(ContactPoint).findOne({
|
|
42
|
+
where: { domain, id: foundDO.contactPointRefId }
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const foundRO: ReleaseGood = foundDO.releaseGood
|
|
47
|
+
const partnerBiz: Bizplace = foundDO.bizplace //customer bizplace
|
|
48
|
+
const ownRefNo = foundRO.refNo
|
|
49
|
+
|
|
50
|
+
//find list of loaded inventory
|
|
51
|
+
const targetInventories: OrderInventory[] = await getRepository(OrderInventory).find({
|
|
52
|
+
where: { domain, deliveryOrder: foundDO },
|
|
53
|
+
relations: ['inventory']
|
|
54
|
+
})
|
|
55
|
+
const orderInvIds: string[] = targetInventories.map((oi: any) => oi.id)
|
|
56
|
+
|
|
57
|
+
const foundWSD: WorksheetDetail[] = await getRepository(WorksheetDetail).find({
|
|
58
|
+
where: {
|
|
59
|
+
domain,
|
|
60
|
+
targetInventory: In(orderInvIds),
|
|
61
|
+
type: WORKSHEET_TYPE.LOADING,
|
|
62
|
+
status: Equal(WORKSHEET_STATUS.DONE)
|
|
63
|
+
},
|
|
64
|
+
relations: [
|
|
65
|
+
'targetInventory',
|
|
66
|
+
'targetInventory.inventory',
|
|
67
|
+
'targetInventory.inventory.location',
|
|
68
|
+
'targetInventory.inventory.product',
|
|
69
|
+
'targetInventory.inventory.product.productDetails',
|
|
70
|
+
'targetInventory.inventory.reusablePallet',
|
|
71
|
+
'updater'
|
|
72
|
+
]
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
let foundDriver: any = null
|
|
76
|
+
if (foundDO.status !== ORDER_STATUS.READY_TO_DISPATCH) {
|
|
77
|
+
if (foundDO?.ownCollection && foundDO?.otherDriver) {
|
|
78
|
+
foundDriver = foundDO.otherDriver
|
|
79
|
+
} else {
|
|
80
|
+
foundDriver = foundDO.transportDriver.name
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let productList: any[] = []
|
|
85
|
+
productList = foundWSD
|
|
86
|
+
.map((wsd: WorksheetDetail) => {
|
|
87
|
+
const targetInventory: OrderInventory = wsd.targetInventory
|
|
88
|
+
const inventory: Inventory = targetInventory.inventory
|
|
89
|
+
const productDetails: any[] = inventory.product.productDetails
|
|
90
|
+
const matchedProductDetail: any = productDetails.find(
|
|
91
|
+
productDetail => productDetail.packingType === inventory.packingType
|
|
92
|
+
)
|
|
93
|
+
return {
|
|
94
|
+
product_name: `${inventory.product.name} (${inventory.product.description})`,
|
|
95
|
+
product_desc: `${inventory.product?.description || ''}`,
|
|
96
|
+
product_nameOnly: `${inventory.product.name}`,
|
|
97
|
+
product_sku: `${inventory.product.sku}`,
|
|
98
|
+
product_type: inventory.packingType,
|
|
99
|
+
product_size: matchedProductDetail ? matchedProductDetail.packingSize : inventory.packingSize,
|
|
100
|
+
product_batch: inventory.batchId,
|
|
101
|
+
product_batch_ref: inventory.batchIdRef,
|
|
102
|
+
product_qty: targetInventory.releaseQty,
|
|
103
|
+
product_weight: targetInventory.releaseWeight,
|
|
104
|
+
product_gross_weight: inventory.product.grossWeight,
|
|
105
|
+
product_uom_value: targetInventory.releaseUomValue,
|
|
106
|
+
product_uom: inventory.uom,
|
|
107
|
+
remark: targetInventory.remark,
|
|
108
|
+
inventory_remark: inventory.remark,
|
|
109
|
+
cross_docking: targetInventory.crossDocking,
|
|
110
|
+
pallet: inventory?.reusablePallet && inventory?.reusablePallet?.name ? inventory.reusablePallet.name : ''
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
.reduce((newItem, item) => {
|
|
114
|
+
var foundItem = newItem.find(
|
|
115
|
+
newItem =>
|
|
116
|
+
newItem.product_name === item.product_name &&
|
|
117
|
+
newItem.product_batch === item.product_batch &&
|
|
118
|
+
newItem.product_batch_ref === item.product_batch_ref &&
|
|
119
|
+
newItem.cross_docking === item.cross_docking &&
|
|
120
|
+
newItem.pallet === item.pallet
|
|
121
|
+
)
|
|
122
|
+
if (!foundItem) {
|
|
123
|
+
foundItem = {
|
|
124
|
+
product_sku: item.product_sku,
|
|
125
|
+
product_name: item.product_name,
|
|
126
|
+
product_type: item.product_type,
|
|
127
|
+
product_size: item.product_size,
|
|
128
|
+
product_batch: item.product_batch,
|
|
129
|
+
product_batch_ref: item.product_batch_ref,
|
|
130
|
+
product_qty: item.product_qty,
|
|
131
|
+
product_weight: item.product_weight,
|
|
132
|
+
product_gross_weight: item.product_gross_weight,
|
|
133
|
+
product_uom_value: item.product_uom_value,
|
|
134
|
+
product_uom: item.product_uom,
|
|
135
|
+
product_desc: item.product_desc,
|
|
136
|
+
product_nameOnly: item.product_nameOnly,
|
|
137
|
+
remark: item.remark,
|
|
138
|
+
inventory_remark: item.inventory_remark,
|
|
139
|
+
palletQty: 1,
|
|
140
|
+
cross_docking: item.cross_docking,
|
|
141
|
+
pallet: item.pallet
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
newItem.push(foundItem)
|
|
145
|
+
return newItem
|
|
146
|
+
} else {
|
|
147
|
+
return newItem.map(ni => {
|
|
148
|
+
if (
|
|
149
|
+
ni.product_name === item.product_name &&
|
|
150
|
+
ni.product_batch === item.product_batch &&
|
|
151
|
+
ni.product_batch_ref === item.product_batch_ref &&
|
|
152
|
+
ni.cross_docking === item.cross_docking &&
|
|
153
|
+
ni.pallet === item.pallet
|
|
154
|
+
) {
|
|
155
|
+
return {
|
|
156
|
+
...ni,
|
|
157
|
+
palletQty: ni.palletQty + 1,
|
|
158
|
+
product_qty: ni.product_qty + item.product_qty,
|
|
159
|
+
product_weight: ni.product_weight + item.product_weight,
|
|
160
|
+
product_uom_value: ni.product_uom_value + item.product_uom_value
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
return ni
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
}, [])
|
|
168
|
+
|
|
169
|
+
const data = {
|
|
170
|
+
roNo: foundRO.name,
|
|
171
|
+
doNo: foundDO.name,
|
|
172
|
+
roRef: foundRO.refNo,
|
|
173
|
+
roRef2: foundRO.refNo2,
|
|
174
|
+
roRef3: foundRO.refNo3,
|
|
175
|
+
companyDomain: foundDO.bizplace.name,
|
|
176
|
+
recipientBiz: foundRO.attentionTo || '',
|
|
177
|
+
doDate: DateTimeConverter.date(foundDO.createdAt),
|
|
178
|
+
productList: productList.map((prod: any, idx) => {
|
|
179
|
+
return {
|
|
180
|
+
batchNo: prod.product_batch,
|
|
181
|
+
sku: prod.product_sku,
|
|
182
|
+
name: prod.product_name,
|
|
183
|
+
type: prod.product_type,
|
|
184
|
+
loadedQty: prod.product_qty,
|
|
185
|
+
uom: prod.product_uom,
|
|
186
|
+
uomValue: `${Math.round(prod.product_uom_value * 100) / 100}`
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return data
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -8,6 +8,7 @@ import { cycleCountAdjustmentResolver } from './cycle-count-adjustment'
|
|
|
8
8
|
import { cycleCountWorksheetResolver } from './cycle-count-worksheet'
|
|
9
9
|
import { deleteWorksheet } from './delete-worksheet'
|
|
10
10
|
import { deliveryOrderByWorksheetResolver } from './delivery-order-by-worksheet'
|
|
11
|
+
import { fetchDeliveryOrderROResolver } from './fetch-delivery-order-ro'
|
|
11
12
|
import { fetchSellercraftAirwayBillResolver } from './fetch-sellercraft-airway-bill'
|
|
12
13
|
import { findReleaseOrdersByTaskNoResolver } from './find-release-orders-by-task-no'
|
|
13
14
|
import { Mutations as GenerateWorksheetMutations } from './generate-worksheet'
|
|
@@ -98,7 +99,8 @@ export const Query = {
|
|
|
98
99
|
...myPickingAssignmentStatusResolver,
|
|
99
100
|
...recommendPutawayLocationResolver,
|
|
100
101
|
...sortingWorksheetResolver,
|
|
101
|
-
...findReleaseOrdersByTaskNoResolver
|
|
102
|
+
...findReleaseOrdersByTaskNoResolver,
|
|
103
|
+
...fetchDeliveryOrderROResolver
|
|
102
104
|
}
|
|
103
105
|
|
|
104
106
|
export const Mutation = {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { gql } from 'apollo-server-koa'
|
|
2
|
+
|
|
3
|
+
export const DeliveryOrderRO = gql`
|
|
4
|
+
type DeliveryOrderRO {
|
|
5
|
+
roNo: String
|
|
6
|
+
doNo: String
|
|
7
|
+
roRef: String
|
|
8
|
+
roRef2: String
|
|
9
|
+
roRef3: String
|
|
10
|
+
companyDomain: String
|
|
11
|
+
recipientBiz: String
|
|
12
|
+
doDate: String
|
|
13
|
+
productList:[Product]
|
|
14
|
+
}
|
|
15
|
+
`
|
|
@@ -23,6 +23,8 @@ import { WorksheetInfo } from './worksheet-info'
|
|
|
23
23
|
import { WorksheetList } from './worksheet-list'
|
|
24
24
|
import { WorksheetPatch } from './worksheet-patch'
|
|
25
25
|
import { WorksheetWithPagination } from './worksheet-with-pagination'
|
|
26
|
+
import { DeliveryOrderRO } from './delivery-order-ro'
|
|
27
|
+
|
|
26
28
|
|
|
27
29
|
export const Mutation = /* GraphQL */ `
|
|
28
30
|
createWorksheet (
|
|
@@ -627,6 +629,10 @@ export const Query = /* GraphQL */ `
|
|
|
627
629
|
name: String!
|
|
628
630
|
): GoodsDeliveryNote @privilege(category: "worksheet", privilege: "query")
|
|
629
631
|
|
|
632
|
+
fetchDeliveryOrderRO (
|
|
633
|
+
name: String!
|
|
634
|
+
): DeliveryOrderRO @privilege(category: "worksheet", privilege: "query")
|
|
635
|
+
|
|
630
636
|
batchPickingWorksheet (
|
|
631
637
|
taskNo: String!, locationSortingRules: [Sorting]
|
|
632
638
|
): ExecutingWorksheet @privilege(category: "worksheet", privilege: "query")
|
|
@@ -707,7 +713,7 @@ export const Query = /* GraphQL */ `
|
|
|
707
713
|
findReleaseOrdersByTaskNo(taskNo: String!): FindReleaseOrdersByTaskNo @privilege(category: "worksheet", privilege: "query") @transaction
|
|
708
714
|
`
|
|
709
715
|
|
|
710
|
-
export const Types = /* GraphQL */
|
|
716
|
+
export const Types = /* GraphQL */[
|
|
711
717
|
Worksheet,
|
|
712
718
|
AirwayBill,
|
|
713
719
|
NewWorksheet,
|
|
@@ -732,5 +738,6 @@ export const Types = /* GraphQL */ [
|
|
|
732
738
|
WorksheetWithPagination,
|
|
733
739
|
PickingAssignmentStatus,
|
|
734
740
|
MyPickingAssignmentStatus,
|
|
735
|
-
FindReleaseOrdersByTaskNo
|
|
741
|
+
FindReleaseOrdersByTaskNo,
|
|
742
|
+
DeliveryOrderRO
|
|
736
743
|
]
|