@things-factory/worksheet-base 4.3.46 → 4.3.47
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 +223 -191
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js +2 -2
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheet.js +5 -1
- package/dist-server/graphql/resolvers/worksheet/worksheet.js.map +1 -1
- package/package.json +17 -17
- package/server/controllers/ecommerce/sellercraft-controller.ts +274 -223
- package/server/controllers/inbound/unloading-worksheet-controller.ts +2 -2
- package/server/graphql/resolvers/worksheet/worksheet.ts +5 -1
|
@@ -15,283 +15,334 @@ import { WorksheetController } from '../worksheet-controller'
|
|
|
15
15
|
|
|
16
16
|
export class SellercraftController extends WorksheetController {
|
|
17
17
|
async packOrder(sellercraft: Sellercraft, releaseGood: ReleaseGood): Promise<ReleaseGood> {
|
|
18
|
-
|
|
19
|
-
let
|
|
18
|
+
let sellercraftSetting: any = sellercraft.sellercraftSetting
|
|
19
|
+
let disablePackOrder: boolean =
|
|
20
|
+
sellercraftSetting?.disablePackOrder && sellercraftSetting?.disablePackOrder == 1 ? true : false
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
const
|
|
22
|
+
if (!disablePackOrder) {
|
|
23
|
+
const orderProducts: OrderProduct[] = releaseGood.orderProducts
|
|
24
|
+
let sellercraftOPs: any[] = []
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
sellercraftOPs = orderProducts.map(orderProduct => {
|
|
27
|
+
const product: Product = orderProduct.product
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
sku: product.sku,
|
|
31
|
+
releaseQty: orderProduct.releaseQty,
|
|
32
|
+
uom: 'EA'
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const orderInformation: any = {
|
|
37
|
+
accountId: sellercraft.accountId,
|
|
38
|
+
orderId: releaseGood.refNo2,
|
|
39
|
+
sellercraftOPs
|
|
28
40
|
}
|
|
29
|
-
|
|
41
|
+
const packageId: string = await SellercraftAPI.packMarketplaceOrder(sellercraft, {
|
|
42
|
+
...orderInformation,
|
|
43
|
+
context: { state: { domain: this?.domain, user: this?.user } }
|
|
44
|
+
})
|
|
30
45
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
orderId: releaseGood.refNo2,
|
|
34
|
-
sellercraftOPs
|
|
46
|
+
releaseGood.packageId = packageId
|
|
47
|
+
releaseGood.updater = this.user
|
|
35
48
|
}
|
|
36
|
-
const packageId: string = await SellercraftAPI.packMarketplaceOrder(sellercraft, {
|
|
37
|
-
...orderInformation,
|
|
38
|
-
context: { state: { domain: this?.domain, user: this?.user } }
|
|
39
|
-
})
|
|
40
49
|
|
|
41
|
-
releaseGood.packageId = packageId
|
|
42
|
-
releaseGood.updater = this.user
|
|
43
50
|
return releaseGood
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
async registerProductInbound(sellercraft: Sellercraft, arrivalNotice: ArrivalNotice): Promise<void> {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
productDetail => productDetail.packingType === unloadedPackingType
|
|
54
|
+
let sellercraftSetting: any = sellercraft.sellercraftSetting
|
|
55
|
+
let disableRegisterInbound: boolean =
|
|
56
|
+
sellercraftSetting?.disableRegisterInbound && sellercraftSetting?.disableRegisterInbound == 1 ? true : false
|
|
57
|
+
|
|
58
|
+
if (!disableRegisterInbound) {
|
|
59
|
+
const orderProducts: OrderProduct[] = arrivalNotice.orderProducts
|
|
60
|
+
const purchaseOrder: PurchaseOrder = arrivalNotice.purchaseOrder
|
|
61
|
+
const sellercraftOPs: any[] = await Promise.all(
|
|
62
|
+
orderProducts.map(async (orderProduct: OrderProduct) => {
|
|
63
|
+
const product: Product = orderProduct.product
|
|
64
|
+
const productDetails: ProductDetail[] = product.productDetails
|
|
65
|
+
const unloadedPackingType: string = orderProduct.packingType
|
|
66
|
+
const defaultProductDetail: ProductDetail = product.productDetails.find(
|
|
67
|
+
productDetail => productDetail.isDefault
|
|
62
68
|
)
|
|
63
69
|
|
|
64
|
-
packingSize =
|
|
65
|
-
|
|
70
|
+
let packingSize: number = 1
|
|
71
|
+
if (unloadedPackingType !== defaultProductDetail.packingType) {
|
|
72
|
+
const unmatchingProductDetail: ProductDetail = product.productDetails.find(
|
|
73
|
+
productDetail => productDetail.packingType === unloadedPackingType
|
|
74
|
+
)
|
|
66
75
|
|
|
67
|
-
|
|
68
|
-
sku: product.sku,
|
|
69
|
-
purchaseOrderQty: orderProduct.packQty * packingSize,
|
|
70
|
-
receivedQty: orderProduct.actualPackQty * packingSize,
|
|
71
|
-
uom: 'EA',
|
|
72
|
-
batchId: orderProduct.batchId,
|
|
73
|
-
productName: product.name,
|
|
74
|
-
gtin: defaultProductDetail.gtin,
|
|
75
|
-
forceCreateProduct: true,
|
|
76
|
-
expiryTime: 0,
|
|
77
|
-
weight: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
78
|
-
packageDimension: {
|
|
79
|
-
length: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
80
|
-
width: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
81
|
-
height: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
76
|
+
packingSize = await this.getChildPackingSize(productDetails, defaultProductDetail, unmatchingProductDetail)
|
|
82
77
|
}
|
|
83
|
-
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
sku: product.sku,
|
|
81
|
+
purchaseOrderQty: orderProduct.packQty * packingSize,
|
|
82
|
+
receivedQty: orderProduct.actualPackQty * packingSize,
|
|
83
|
+
uom: 'EA',
|
|
84
|
+
batchId: orderProduct.batchId,
|
|
85
|
+
productName: product.name,
|
|
86
|
+
gtin: defaultProductDetail.gtin,
|
|
87
|
+
forceCreateProduct: true,
|
|
88
|
+
expiryTime: 0,
|
|
89
|
+
weight: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
90
|
+
packageDimension: {
|
|
91
|
+
length: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
92
|
+
width: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
93
|
+
height: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
const inboundOrder: any = {
|
|
100
|
+
accountId: sellercraft.accountId,
|
|
101
|
+
inboundId: arrivalNotice.name,
|
|
102
|
+
inboundTime: Math.floor(new Date(arrivalNotice.updatedAt).getTime() / 1000),
|
|
103
|
+
inboundType: purchaseOrder ? 'purchase_order' : 'blind_receive',
|
|
104
|
+
purchaseOrderId: purchaseOrder ? purchaseOrder.name : '',
|
|
105
|
+
sellercraftOPs
|
|
106
|
+
}
|
|
107
|
+
await SellercraftAPI.addInboundOrder(sellercraft, {
|
|
108
|
+
...inboundOrder,
|
|
109
|
+
context: { state: { domain: this?.domain, user: this?.user } }
|
|
84
110
|
})
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
const inboundOrder: any = {
|
|
88
|
-
accountId: sellercraft.accountId,
|
|
89
|
-
inboundId: arrivalNotice.name,
|
|
90
|
-
inboundTime: Math.floor(new Date(arrivalNotice.updatedAt).getTime() / 1000),
|
|
91
|
-
inboundType: purchaseOrder ? 'purchase_order' : 'blind_receive',
|
|
92
|
-
purchaseOrderId: purchaseOrder ? purchaseOrder.name : '',
|
|
93
|
-
sellercraftOPs
|
|
94
111
|
}
|
|
95
|
-
await SellercraftAPI.addInboundOrder(sellercraft, {
|
|
96
|
-
...inboundOrder,
|
|
97
|
-
context: { state: { domain: this?.domain, user: this?.user } }
|
|
98
|
-
})
|
|
99
112
|
}
|
|
100
113
|
|
|
101
114
|
async registerProductReturn(sellercraft: Sellercraft, returnOrder: ReturnOrder): Promise<void> {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
productDetail => productDetail.packingType === unloadedPackingType
|
|
115
|
+
let sellercraftSetting: any = sellercraft.sellercraftSetting
|
|
116
|
+
let disableRegisterReturn: boolean =
|
|
117
|
+
sellercraftSetting?.disableRegisterReturn && sellercraftSetting?.disableRegisterReturn == 1 ? true : false
|
|
118
|
+
|
|
119
|
+
if (!disableRegisterReturn) {
|
|
120
|
+
const orderInventories: OrderInventory[] = returnOrder.orderInventories
|
|
121
|
+
const sellercraftOPs: any[] = await Promise.all(
|
|
122
|
+
orderInventories.map(async (orderInventory: OrderInventory) => {
|
|
123
|
+
const product: Product = orderInventory.product
|
|
124
|
+
const productDetails: ProductDetail[] = product.productDetails
|
|
125
|
+
const unloadedPackingType: string = orderInventory.packingType
|
|
126
|
+
const defaultProductDetail: ProductDetail = product.productDetails.find(
|
|
127
|
+
productDetail => productDetail.isDefault
|
|
116
128
|
)
|
|
117
129
|
|
|
118
|
-
packingSize =
|
|
119
|
-
|
|
130
|
+
let packingSize: number = 1
|
|
131
|
+
if (unloadedPackingType !== defaultProductDetail.packingType) {
|
|
132
|
+
const unmatchingProductDetail: ProductDetail = product.productDetails.find(
|
|
133
|
+
productDetail => productDetail.packingType === unloadedPackingType
|
|
134
|
+
)
|
|
120
135
|
|
|
121
|
-
|
|
122
|
-
sku: product.sku,
|
|
123
|
-
productName: product.name,
|
|
124
|
-
gtin: defaultProductDetail.gtin,
|
|
125
|
-
purchaseOrderQty: orderInventory.returnQty * packingSize,
|
|
126
|
-
receivedQty: orderInventory.returnQty * packingSize,
|
|
127
|
-
uom: 'EA',
|
|
128
|
-
batchId: orderInventory.batchId,
|
|
129
|
-
forceCreateProduct: true,
|
|
130
|
-
expiryTime: 0,
|
|
131
|
-
weight: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
132
|
-
packageDimension: {
|
|
133
|
-
length: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
134
|
-
width: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
135
|
-
height: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
136
|
+
packingSize = await this.getChildPackingSize(productDetails, defaultProductDetail, unmatchingProductDetail)
|
|
136
137
|
}
|
|
137
|
-
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
sku: product.sku,
|
|
141
|
+
productName: product.name,
|
|
142
|
+
gtin: defaultProductDetail.gtin,
|
|
143
|
+
purchaseOrderQty: orderInventory.returnQty * packingSize,
|
|
144
|
+
receivedQty: orderInventory.returnQty * packingSize,
|
|
145
|
+
uom: 'EA',
|
|
146
|
+
batchId: orderInventory.batchId,
|
|
147
|
+
forceCreateProduct: true,
|
|
148
|
+
expiryTime: 0,
|
|
149
|
+
weight: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
150
|
+
packageDimension: {
|
|
151
|
+
length: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
152
|
+
width: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
153
|
+
height: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
const returnInbound: any = {
|
|
160
|
+
accountId: sellercraft.accountId,
|
|
161
|
+
inboundId: returnOrder.name,
|
|
162
|
+
inboundTime: Math.floor(new Date(returnOrder.updatedAt).getTime() / 1000),
|
|
163
|
+
purchaseOrderId: '',
|
|
164
|
+
inboundType: 'sales_return',
|
|
165
|
+
sellercraftOPs
|
|
166
|
+
}
|
|
167
|
+
await SellercraftAPI.addInboundOrder(sellercraft, {
|
|
168
|
+
...returnInbound,
|
|
169
|
+
context: { state: { domain: this?.domain, user: this?.user } }
|
|
138
170
|
})
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
const returnInbound: any = {
|
|
142
|
-
accountId: sellercraft.accountId,
|
|
143
|
-
inboundId: returnOrder.name,
|
|
144
|
-
inboundTime: Math.floor(new Date(returnOrder.updatedAt).getTime() / 1000),
|
|
145
|
-
purchaseOrderId: '',
|
|
146
|
-
inboundType: 'sales_return',
|
|
147
|
-
sellercraftOPs
|
|
148
171
|
}
|
|
149
|
-
await SellercraftAPI.addInboundOrder(sellercraft, {
|
|
150
|
-
...returnInbound,
|
|
151
|
-
context: { state: { domain: this?.domain, user: this?.user } }
|
|
152
|
-
})
|
|
153
172
|
}
|
|
154
173
|
|
|
155
174
|
async updateSellercraftStock(sellercraft: Sellercraft, inventory: Inventory): Promise<void> {
|
|
156
|
-
|
|
157
|
-
let
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
.
|
|
165
|
-
.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
175
|
+
let sellercraftSetting: any = sellercraft.sellercraftSetting
|
|
176
|
+
let disableUpdateStock: boolean =
|
|
177
|
+
sellercraftSetting?.disableUpdateStock && sellercraftSetting?.disableUpdateStock == 1 ? true : false
|
|
178
|
+
|
|
179
|
+
if (!disableUpdateStock) {
|
|
180
|
+
const bizplace: Bizplace = await this.trxMgr.getRepository(Bizplace).findOne({ domain: sellercraft.domain })
|
|
181
|
+
let product: Product = inventory.product
|
|
182
|
+
const productDetails: ProductDetail[] = product.productDetails
|
|
183
|
+
let qb = await this.trxMgr.getRepository(Inventory).createQueryBuilder('inv')
|
|
184
|
+
qb.leftJoinAndSelect('inv.location', 'loc')
|
|
185
|
+
.andWhere('"inv"."domain_id" = :domainId')
|
|
186
|
+
.andWhere('"inv"."bizplace_id" = :bizplaceId')
|
|
187
|
+
.andWhere('"inv"."product_id" = :productId')
|
|
188
|
+
.andWhere('"inv"."status" = :status')
|
|
189
|
+
.andWhere('"loc"."type" NOT IN (:...locationTypes)')
|
|
190
|
+
.setParameters({
|
|
191
|
+
domainId: this.domain.id,
|
|
192
|
+
bizplaceId: bizplace.id,
|
|
193
|
+
productId: product.id,
|
|
194
|
+
status: INVENTORY_STATUS.STORED,
|
|
195
|
+
locationTypes: [LOCATION_TYPE.QUARANTINE, LOCATION_TYPE.RESERVE]
|
|
196
|
+
})
|
|
173
197
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
198
|
+
let inventories: Inventory[] = await qb.getMany()
|
|
199
|
+
let inventoryTotalQty: number = 0
|
|
200
|
+
let inventoryTotalLockedQty: number = 0
|
|
177
201
|
|
|
178
|
-
|
|
202
|
+
let defaultProductDetail: ProductDetail = product.productDetails.find(productDetail => productDetail.isDefault)
|
|
179
203
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
204
|
+
if (inventories?.length > 0) {
|
|
205
|
+
const sellercraftInvs: any[] = await Promise.all(
|
|
206
|
+
inventories.map(async (inventory: Inventory) => {
|
|
207
|
+
const inventoryPackingType: string = inventory.packingType
|
|
184
208
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
209
|
+
let packingSize: number = 1
|
|
210
|
+
if (inventoryPackingType !== defaultProductDetail.packingType) {
|
|
211
|
+
const unmatchingProductDetail: ProductDetail = product.productDetails.find(
|
|
212
|
+
productDetail => productDetail.packingType === inventoryPackingType
|
|
213
|
+
)
|
|
190
214
|
|
|
191
|
-
|
|
192
|
-
|
|
215
|
+
packingSize = await this.getChildPackingSize(
|
|
216
|
+
productDetails,
|
|
217
|
+
defaultProductDetail,
|
|
218
|
+
unmatchingProductDetail
|
|
219
|
+
)
|
|
220
|
+
}
|
|
193
221
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
222
|
+
return { totalQty: inventory.qty * packingSize, totalLockedQty: inventory.lockedQty * packingSize }
|
|
223
|
+
})
|
|
224
|
+
)
|
|
197
225
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
226
|
+
inventoryTotalQty = sellercraftInvs.reduce((total, currentValue) => {
|
|
227
|
+
total += currentValue.totalQty
|
|
228
|
+
return total
|
|
229
|
+
}, 0)
|
|
202
230
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
231
|
+
inventoryTotalQty = sellercraftInvs.reduce((total, currentValue) => {
|
|
232
|
+
total += currentValue.totalLockedQty
|
|
233
|
+
return total
|
|
234
|
+
}, 0)
|
|
235
|
+
}
|
|
208
236
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
237
|
+
const sellercraftInv: any[] = [
|
|
238
|
+
{
|
|
239
|
+
sku: product.sku,
|
|
240
|
+
gtin: defaultProductDetail.gtin,
|
|
241
|
+
stock: {
|
|
242
|
+
quantity_total: inventoryTotalQty,
|
|
243
|
+
quantity_reserved: inventoryTotalLockedQty,
|
|
244
|
+
unit_of_measure: 'EA'
|
|
245
|
+
},
|
|
246
|
+
package_weight_gm: defaultProductDetail.nettWeight < 1 ? 1 : defaultProductDetail.nettWeight,
|
|
247
|
+
package_dimensions: {
|
|
248
|
+
length_mm: defaultProductDetail.depth < 1 ? 1 : defaultProductDetail.depth,
|
|
249
|
+
width_mm: defaultProductDetail.width < 1 ? 1 : defaultProductDetail.width,
|
|
250
|
+
height_mm: defaultProductDetail.height < 1 ? 1 : defaultProductDetail.height
|
|
251
|
+
}
|
|
223
252
|
}
|
|
224
|
-
|
|
225
|
-
]
|
|
253
|
+
]
|
|
226
254
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
255
|
+
await SellercraftAPI.updateProduct(sellercraft, {
|
|
256
|
+
context: { state: { domain: this?.domain, user: this?.user } },
|
|
257
|
+
accountId: sellercraft.accountId,
|
|
258
|
+
sellercraftInv
|
|
259
|
+
})
|
|
260
|
+
}
|
|
232
261
|
}
|
|
233
262
|
|
|
234
263
|
async initiateOrderShipment(sellercraft: Sellercraft, releaseGood: ReleaseGood): Promise<ReleaseGood> {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
264
|
+
let sellercraftSetting: any = sellercraft.sellercraftSetting
|
|
265
|
+
let disableInitiateOrderShipment: boolean =
|
|
266
|
+
sellercraftSetting?.disableInitiateOrderShipment && sellercraftSetting?.disableInitiateOrderShipment == 1
|
|
267
|
+
? true
|
|
268
|
+
: false
|
|
269
|
+
|
|
270
|
+
if (!disableInitiateOrderShipment) {
|
|
271
|
+
if (!releaseGood?.packageId) throw new Error('Order package id is not found')
|
|
272
|
+
|
|
273
|
+
const orderInformation: any = {
|
|
274
|
+
accountId: sellercraft.accountId,
|
|
275
|
+
orderId: releaseGood.refNo2,
|
|
276
|
+
packageId: releaseGood.packageId
|
|
277
|
+
}
|
|
242
278
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
279
|
+
const { handOverType, pickupTime, pickupAddress, dropoffAddress } = await SellercraftAPI.initiateOrderShipment(
|
|
280
|
+
sellercraft,
|
|
281
|
+
{ ...orderInformation, context: { state: { domain: this?.domain, user: this?.user } } }
|
|
282
|
+
)
|
|
247
283
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
284
|
+
releaseGood.handoverType = handOverType
|
|
285
|
+
if (pickupAddress) {
|
|
286
|
+
releaseGood.pickupAddress = pickupAddress
|
|
287
|
+
releaseGood.pickupTime = new Date(pickupTime * 1000)
|
|
288
|
+
}
|
|
289
|
+
if (dropoffAddress) releaseGood.dropoffAddress = dropoffAddress
|
|
290
|
+
releaseGood.updater = this.user
|
|
291
|
+
return await this.trxMgr.getRepository(ReleaseGood).save(releaseGood)
|
|
252
292
|
}
|
|
253
|
-
if (dropoffAddress) releaseGood.dropoffAddress = dropoffAddress
|
|
254
|
-
releaseGood.updater = this.user
|
|
255
|
-
return await this.trxMgr.getRepository(ReleaseGood).save(releaseGood)
|
|
256
293
|
}
|
|
257
294
|
|
|
258
295
|
async initiateOrderDocument(sellercraft: Sellercraft, releaseGood: ReleaseGood): Promise<void> {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
296
|
+
let sellercraftSetting: any = sellercraft.sellercraftSetting
|
|
297
|
+
let disableInitiateOrderDocument: boolean =
|
|
298
|
+
sellercraftSetting?.disableInitiateOrderDocument && sellercraftSetting?.disableInitiateOrderDocument == 1
|
|
299
|
+
? true
|
|
300
|
+
: false
|
|
301
|
+
|
|
302
|
+
if (!disableInitiateOrderDocument) {
|
|
303
|
+
const orderInformation: any = {
|
|
304
|
+
accountId: sellercraft.accountId,
|
|
305
|
+
orderId: releaseGood.refNo2,
|
|
306
|
+
packageId: releaseGood.packageId
|
|
307
|
+
}
|
|
308
|
+
await SellercraftAPI.initiateOrderDocument(sellercraft, {
|
|
309
|
+
...orderInformation,
|
|
310
|
+
context: { state: { domain: this?.domain, user: this?.user } }
|
|
311
|
+
})
|
|
263
312
|
}
|
|
264
|
-
await SellercraftAPI.initiateOrderDocument(sellercraft, {
|
|
265
|
-
...orderInformation,
|
|
266
|
-
context: { state: { domain: this?.domain, user: this?.user } }
|
|
267
|
-
})
|
|
268
313
|
}
|
|
269
314
|
|
|
270
315
|
async fetchOrderDocument(sellercraft: Sellercraft, releaseGood: ReleaseGood): Promise<ReleaseGood> {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
316
|
+
let sellercraftSetting: any = sellercraft.sellercraftSetting
|
|
317
|
+
let disableFetchOrderDocument: boolean =
|
|
318
|
+
sellercraftSetting?.disableFetchOrderDocument && sellercraftSetting?.disableFetchOrderDocument == 1 ? true : false
|
|
319
|
+
|
|
320
|
+
if (!disableFetchOrderDocument) {
|
|
321
|
+
const orderInformation: any = {
|
|
322
|
+
accountId: sellercraft.accountId,
|
|
323
|
+
orderId: releaseGood.refNo2,
|
|
324
|
+
packageId: releaseGood.packageId
|
|
325
|
+
}
|
|
326
|
+
const { documents, trackingNo, transporter }: { documents: any[]; trackingNo: string; transporter: string } =
|
|
327
|
+
await SellercraftAPI.fetchOrderDocument(sellercraft, {
|
|
328
|
+
...orderInformation,
|
|
329
|
+
context: { state: { domain: this?.domain, user: this?.user } }
|
|
330
|
+
})
|
|
281
331
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
332
|
+
if (documents?.length) {
|
|
333
|
+
documents.map(document => {
|
|
334
|
+
if (document.type === 'invoice') {
|
|
335
|
+
releaseGood.invoice = document.download_url
|
|
336
|
+
} else if (document.type === 'airway_bill') {
|
|
337
|
+
releaseGood.airwayBill = document.download_url
|
|
338
|
+
}
|
|
339
|
+
})
|
|
290
340
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
341
|
+
releaseGood.trackingNo = trackingNo
|
|
342
|
+
releaseGood.transporter = transporter
|
|
343
|
+
releaseGood.updater = this.user
|
|
344
|
+
releaseGood = await this.trxMgr.getRepository(ReleaseGood).save(releaseGood)
|
|
345
|
+
}
|
|
295
346
|
}
|
|
296
347
|
|
|
297
348
|
return releaseGood
|
|
@@ -396,7 +396,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
396
396
|
foundInventory = await this.trxMgr.getRepository(Inventory).save(newInventory)
|
|
397
397
|
} else {
|
|
398
398
|
const updatedQty: number = foundInventory.qty + qty
|
|
399
|
-
foundInventory.expirationDate = new Date(foundInventory.expirationDate)
|
|
399
|
+
foundInventory.expirationDate = foundInventory.expirationDate ? new Date(foundInventory.expirationDate) : null
|
|
400
400
|
foundInventory.qty = updatedQty
|
|
401
401
|
foundInventory.uomValue +=
|
|
402
402
|
Math.round(
|
|
@@ -613,7 +613,7 @@ export class UnloadingWorksheetController extends VasWorksheetController {
|
|
|
613
613
|
await this.trxMgr.getRepository(Inventory).save(newInventory)
|
|
614
614
|
} else {
|
|
615
615
|
const updatedQty: number = foundInventory.qty + qty
|
|
616
|
-
foundInventory.expirationDate = new Date(foundInventory.expirationDate)
|
|
616
|
+
foundInventory.expirationDate = foundInventory.expirationDate ? new Date(foundInventory.expirationDate) : null
|
|
617
617
|
foundInventory.qty = updatedQty
|
|
618
618
|
foundInventory.uomValue +=
|
|
619
619
|
Math.round(
|
|
@@ -121,7 +121,11 @@ export const worksheetResolver = {
|
|
|
121
121
|
let inventory: Inventory = wsd.targetInventory.inventory
|
|
122
122
|
|
|
123
123
|
let foundUnloadedHistory: InventoryHistory = await getRepository(InventoryHistory).findOne({
|
|
124
|
-
where:
|
|
124
|
+
where: [
|
|
125
|
+
{ inventory, refOrderId: worksheet.arrivalNotice.id, status: INVENTORY_STATUS.UNLOADED },
|
|
126
|
+
{ inventory, refOrderId: worksheet.arrivalNotice.id, status: INVENTORY_STATUS.PARTIALLY_UNLOADED },
|
|
127
|
+
{ inventory, refOrderId: worksheet.arrivalNotice.id, status: INVENTORY_STATUS.CHECKED }
|
|
128
|
+
],
|
|
125
129
|
relations: ['location', 'product']
|
|
126
130
|
})
|
|
127
131
|
|