@things-factory/worksheet-base 4.1.36 → 4.1.40
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/outbound/picking-worksheet-controller.js +36 -11
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/returning-worksheet-controller.js +7 -1
- package/dist-server/controllers/outbound/returning-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/render-grn.js +26 -3
- package/dist-server/controllers/render-grn.js.map +1 -1
- package/dist-server/controllers/render-orientage-do.js +31 -0
- package/dist-server/controllers/render-orientage-do.js.map +1 -1
- package/dist-server/controllers/render-orientage-grn.js +22 -1
- package/dist-server/controllers/render-orientage-grn.js.map +1 -1
- package/dist-server/controllers/render-ro-do.js +64 -1
- package/dist-server/controllers/render-ro-do.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/assign-picking-worker.js +12 -10
- package/dist-server/graphql/resolvers/worksheet/picking/assign-picking-worker.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/picking-assignment-status-by-user.js +1 -4
- package/dist-server/graphql/resolvers/worksheet/picking/picking-assignment-status-by-user.js.map +1 -1
- package/dist-server/graphql/types/worksheet/index.js +1 -2
- package/dist-server/graphql/types/worksheet/index.js.map +1 -1
- package/package.json +17 -17
- package/server/controllers/outbound/picking-worksheet-controller.ts +44 -11
- package/server/controllers/outbound/returning-worksheet-controller.ts +7 -1
- package/server/controllers/render-grn.ts +36 -2
- package/server/controllers/render-orientage-do.ts +50 -1
- package/server/controllers/render-orientage-grn.ts +34 -2
- package/server/controllers/render-ro-do.ts +86 -2
- package/server/graphql/resolvers/worksheet/picking/assign-picking-worker.ts +14 -11
- package/server/graphql/resolvers/worksheet/picking/picking-assignment-status-by-user.ts +1 -3
- package/server/graphql/types/worksheet/index.ts +1 -2
|
@@ -468,7 +468,7 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
468
468
|
let totalInventoryItems = await this.trxMgr.getRepository(InventoryItem).count({
|
|
469
469
|
where: {
|
|
470
470
|
inventory,
|
|
471
|
-
status: Not(
|
|
471
|
+
status: Not(In([INVENTORY_STATUS.TERMINATED, INVENTORY_STATUS.PICKED]))
|
|
472
472
|
}
|
|
473
473
|
})
|
|
474
474
|
|
|
@@ -481,11 +481,14 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
481
481
|
throw new Error('Serial Number scanned is in another inventory')
|
|
482
482
|
}
|
|
483
483
|
|
|
484
|
-
if (foundSerialNumber.
|
|
485
|
-
|
|
484
|
+
if (foundSerialNumber.outboundOrderId) {
|
|
485
|
+
let releaseGood: ReleaseGood = await this.trxMgr
|
|
486
|
+
.getRepository(ReleaseGood)
|
|
487
|
+
.findOne({ where: { id: foundSerialNumber.outboundOrderId } })
|
|
488
|
+
throw new Error(`Inventory Item is already picked in ${releaseGood.name}`)
|
|
486
489
|
}
|
|
487
490
|
|
|
488
|
-
foundSerialNumber.status = INVENTORY_STATUS.
|
|
491
|
+
foundSerialNumber.status = INVENTORY_STATUS.PICKING
|
|
489
492
|
foundSerialNumber.updater = this.user
|
|
490
493
|
foundSerialNumber.outboundOrderId = releaseGood.id
|
|
491
494
|
|
|
@@ -498,7 +501,7 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
498
501
|
let inventoryItem: InventoryItem = new InventoryItem()
|
|
499
502
|
inventoryItem.name = InventoryNoGenerator.inventoryItemName()
|
|
500
503
|
inventoryItem.serialNumber = serialNumber
|
|
501
|
-
inventoryItem.status = INVENTORY_STATUS.
|
|
504
|
+
inventoryItem.status = INVENTORY_STATUS.PICKING
|
|
502
505
|
inventoryItem.outboundOrderId = releaseGood.id
|
|
503
506
|
inventoryItem.source = INVENTORY_ITEM_SOURCE.OUTBOUND
|
|
504
507
|
inventoryItem.product = product
|
|
@@ -586,7 +589,7 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
586
589
|
throw new Error('Inventory Item is not available')
|
|
587
590
|
}
|
|
588
591
|
|
|
589
|
-
foundSerialNumber.status = INVENTORY_STATUS.
|
|
592
|
+
foundSerialNumber.status = INVENTORY_STATUS.PICKING
|
|
590
593
|
foundSerialNumber.updater = this.user
|
|
591
594
|
foundSerialNumber.outboundOrderId = releaseGood.id
|
|
592
595
|
|
|
@@ -599,7 +602,7 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
599
602
|
let inventoryItem: InventoryItem = new InventoryItem()
|
|
600
603
|
inventoryItem.name = InventoryNoGenerator.inventoryItemName()
|
|
601
604
|
inventoryItem.serialNumber = serialNumber
|
|
602
|
-
inventoryItem.status = INVENTORY_STATUS.
|
|
605
|
+
inventoryItem.status = INVENTORY_STATUS.PICKING
|
|
603
606
|
inventoryItem.outboundOrderId = releaseGood.id
|
|
604
607
|
inventoryItem.product = product
|
|
605
608
|
inventoryItem.inventory = scannedPalletIdInventory
|
|
@@ -1123,6 +1126,19 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
1123
1126
|
worksheetDetail.updater = this.user
|
|
1124
1127
|
await this.trxMgr.getRepository(WorksheetDetail).save(worksheetDetail)
|
|
1125
1128
|
|
|
1129
|
+
let InventoryItems: InventoryItem = await this.trxMgr
|
|
1130
|
+
.getRepository(InventoryItem)
|
|
1131
|
+
.find({ where: { outboundOrderId: releaseGood.id } })
|
|
1132
|
+
|
|
1133
|
+
if (InventoryItems.length > 0) {
|
|
1134
|
+
InventoryItems.forEach((itm: InventoryItem) => {
|
|
1135
|
+
itm.status = INVENTORY_STATUS.PICKED
|
|
1136
|
+
itm.updater = this.user
|
|
1137
|
+
})
|
|
1138
|
+
|
|
1139
|
+
await this.trxMgr.getRepository(InventoryItem).save(InventoryItems)
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1126
1142
|
if (leftQty === 0) {
|
|
1127
1143
|
inventory.status = INVENTORY_STATUS.TERMINATED
|
|
1128
1144
|
await this.transactionInventory(inventory, releaseGood, 0, 0, INVENTORY_TRANSACTION_TYPE.TERMINATED)
|
|
@@ -1177,7 +1193,7 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
1177
1193
|
newOrderInventory.releaseQty * (targetInventory.releaseUomValue / targetInventory.releaseQty)
|
|
1178
1194
|
|
|
1179
1195
|
oldOrderInventory.releaseQty = targetInventory.pickedQty
|
|
1180
|
-
oldOrderInventory.status =
|
|
1196
|
+
oldOrderInventory.status = ORDER_INVENTORY_STATUS.PICKED
|
|
1181
1197
|
oldOrderInventory.releaseUomValue =
|
|
1182
1198
|
(targetInventory.releaseUomValue / targetInventory.releaseQty) * oldOrderInventory.releaseQty
|
|
1183
1199
|
|
|
@@ -1281,7 +1297,7 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
1281
1297
|
newOrderInventoryReleaseQty * (targetInventory.releaseUomValue / targetInventory.releaseQty)
|
|
1282
1298
|
|
|
1283
1299
|
oldOrderInventory.releaseQty = targetInventory.pickedQty
|
|
1284
|
-
oldOrderInventory.status =
|
|
1300
|
+
oldOrderInventory.status = ORDER_INVENTORY_STATUS.PICKED
|
|
1285
1301
|
oldOrderInventory.releaseUomValue =
|
|
1286
1302
|
(targetInventory.releaseUomValue / targetInventory.releaseQty) * oldOrderInventory.releaseQty
|
|
1287
1303
|
|
|
@@ -1365,8 +1381,12 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
1365
1381
|
})
|
|
1366
1382
|
|
|
1367
1383
|
let targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
1384
|
+
let releaseGood: ReleaseGood = worksheetDetail.worksheet.releaseGood
|
|
1368
1385
|
|
|
1369
|
-
if (
|
|
1386
|
+
if (
|
|
1387
|
+
targetInventory.releaseQty == targetInventory.pickedQty &&
|
|
1388
|
+
targetInventory.status == ORDER_INVENTORY_STATUS.PICKED
|
|
1389
|
+
) {
|
|
1370
1390
|
targetInventory.status = INVENTORY_STATUS.PICKING
|
|
1371
1391
|
|
|
1372
1392
|
await this.trxMgr
|
|
@@ -1383,11 +1403,24 @@ export class PickingWorksheetController extends VasWorksheetController {
|
|
|
1383
1403
|
await this.trxMgr.getRepository(Inventory).save(targetInventory.inventory)
|
|
1384
1404
|
}
|
|
1385
1405
|
|
|
1406
|
+
let InventoryItems: InventoryItem = await this.trxMgr
|
|
1407
|
+
.getRepository(InventoryItem)
|
|
1408
|
+
.find({ where: { outboundOrderId: releaseGood.id } })
|
|
1409
|
+
|
|
1386
1410
|
let removeInventoryItem: InventoryItem = await this.trxMgr
|
|
1387
1411
|
.getRepository(InventoryItem)
|
|
1388
1412
|
.findOne({ where: { id: inventoryItemId } })
|
|
1389
1413
|
|
|
1390
|
-
if (
|
|
1414
|
+
if (InventoryItems.length > 0) {
|
|
1415
|
+
InventoryItems.forEach((itm: InventoryItem) => {
|
|
1416
|
+
itm.status = INVENTORY_STATUS.PICKING
|
|
1417
|
+
itm.updater = this.user
|
|
1418
|
+
})
|
|
1419
|
+
|
|
1420
|
+
await this.trxMgr.getRepository(InventoryItem).save(InventoryItems)
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
if (removeInventoryItem.source == INVENTORY_ITEM_SOURCE.OUTBOUND) {
|
|
1391
1424
|
await this.trxMgr.getRepository(InventoryItem).delete(removeInventoryItem.id)
|
|
1392
1425
|
} else {
|
|
1393
1426
|
await this.trxMgr.getRepository(InventoryItem).update(
|
|
@@ -167,7 +167,13 @@ export class ReturningWorksheetController extends VasWorksheetController {
|
|
|
167
167
|
where: {
|
|
168
168
|
domain: this.domain,
|
|
169
169
|
name: toLocationName,
|
|
170
|
-
type: In([
|
|
170
|
+
type: In([
|
|
171
|
+
LOCATION_TYPE.SHELF,
|
|
172
|
+
LOCATION_TYPE.BUFFER,
|
|
173
|
+
LOCATION_TYPE.FLOOR,
|
|
174
|
+
LOCATION_TYPE.BIN,
|
|
175
|
+
LOCATION_TYPE.QUARANTINE
|
|
176
|
+
])
|
|
171
177
|
},
|
|
172
178
|
relations: ['warehouse']
|
|
173
179
|
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
1
2
|
import FormData from 'form-data'
|
|
2
3
|
import fetch from 'node-fetch'
|
|
3
4
|
import { getRepository, IsNull, Not } from 'typeorm'
|
|
4
|
-
|
|
5
|
+
import { InventoryItem } from '@things-factory/warehouse-base'
|
|
5
6
|
import { Attachment, STORAGE } from '@things-factory/attachment-base'
|
|
6
7
|
import { Partner } from '@things-factory/auth-base'
|
|
7
8
|
import { Bizplace, ContactPoint } from '@things-factory/biz-base'
|
|
@@ -32,6 +33,10 @@ export async function renderGRN({ grnNo, timezoneOffSet }, context: any) {
|
|
|
32
33
|
const foundGAN: ArrivalNotice = foundGRN.arrivalNotice
|
|
33
34
|
const ownRefNo = foundGAN.refNo
|
|
34
35
|
|
|
36
|
+
const foundInventoryItem: InventoryItem[] = await getRepository(InventoryItem).query(
|
|
37
|
+
`select row_number() over (partition by p.sku) as "seq",p.sku,p.brand_sku, ii.serial_number from inventory_items ii left join products p on ii.product_id = p.id where inbound_order_id = '${foundGAN.id}' group by p.sku,ii.serial_number,p.brand_sku`
|
|
38
|
+
)
|
|
39
|
+
|
|
35
40
|
// 4. find customer bizplace
|
|
36
41
|
const partnerBiz: Bizplace = foundGRN.bizplace
|
|
37
42
|
|
|
@@ -142,6 +147,31 @@ export async function renderGRN({ grnNo, timezoneOffSet }, context: any) {
|
|
|
142
147
|
cop = 'data:' + foundSignature.mimetype + ';base64,' + (await STORAGE.readFile(foundCop.path, 'base64'))
|
|
143
148
|
}
|
|
144
149
|
|
|
150
|
+
const filterInventoryItem = _.groupBy(foundInventoryItem, i => i.sku)
|
|
151
|
+
|
|
152
|
+
const tempIndexArr = []
|
|
153
|
+
|
|
154
|
+
const tempTotalQuantity = []
|
|
155
|
+
|
|
156
|
+
Object.keys(filterInventoryItem).forEach(k => {
|
|
157
|
+
const tempIndex = foundInventoryItem.findIndex(i => {
|
|
158
|
+
return i.sku == k
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
tempIndexArr.push(tempIndex)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
Object.values(filterInventoryItem).forEach(k => {
|
|
165
|
+
const tempQuantity = k.length
|
|
166
|
+
|
|
167
|
+
tempTotalQuantity.push(tempQuantity)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
tempIndexArr.forEach((t, index) => {
|
|
171
|
+
foundInventoryItem[t].totalQuantity = tempTotalQuantity[index]
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
|
|
145
175
|
const data = {
|
|
146
176
|
logo_url: logo,
|
|
147
177
|
sign_url: signature,
|
|
@@ -166,6 +196,7 @@ export async function renderGRN({ grnNo, timezoneOffSet }, context: any) {
|
|
|
166
196
|
gan_accepted_at: foundGAN.acceptedAt ? DateTimeConverter.datetime(foundGAN.acceptedAt, timezoneOffSet) : '',
|
|
167
197
|
unload_date: DateTimeConverter.date(foundWS.endedAt),
|
|
168
198
|
ref_no: ownRefNo ? `${foundGAN.name} / ${foundGAN.refNo}` : `${foundGAN.name}`,
|
|
199
|
+
ref_no_only: ownRefNo ? ` ${foundGAN.refNo}` : '',
|
|
169
200
|
ref_no1: foundGAN.refNo2 ? `${foundGAN.refNo2}` : '',
|
|
170
201
|
ref_no2: foundGAN.refNo3 ? `${foundGAN.refNo3}` : '',
|
|
171
202
|
received_date: DateTimeConverter.date(foundWS.endedAt),
|
|
@@ -188,6 +219,7 @@ export async function renderGRN({ grnNo, timezoneOffSet }, context: any) {
|
|
|
188
219
|
return {
|
|
189
220
|
list_no: idx + 1,
|
|
190
221
|
product_sku: `${item.product.sku}`,
|
|
222
|
+
product_brand_sku: `${item.product.brandSku}`,
|
|
191
223
|
product_name: `${item.product.name}(${item.product.description})`,
|
|
192
224
|
product_desc: item.product.description,
|
|
193
225
|
product_nameOnly: item.product.name,
|
|
@@ -205,10 +237,12 @@ export async function renderGRN({ grnNo, timezoneOffSet }, context: any) {
|
|
|
205
237
|
product_gross_weight: item.product.grossWeight || null,
|
|
206
238
|
unit_price: item.unitPrice || null,
|
|
207
239
|
expiry_date: unloadInvHistory.expiryDate || '',
|
|
240
|
+
manufacture_date:item.manufactureDate,
|
|
208
241
|
reusable_pallet_id: unloadInvHistory.reusablePalletId || '',
|
|
209
242
|
remark: (item.remark ? item.remark : '') + (item.issue ? ' [Issue]: ' + item.issue : '')
|
|
210
243
|
}
|
|
211
|
-
})
|
|
244
|
+
}),
|
|
245
|
+
serialNumber: foundInventoryItem
|
|
212
246
|
}
|
|
213
247
|
|
|
214
248
|
const formData = new FormData()
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
1
2
|
import FormData from 'form-data'
|
|
2
3
|
import fetch from 'node-fetch'
|
|
3
4
|
import { Equal, getRepository, In } from 'typeorm'
|
|
@@ -10,7 +11,7 @@ import { ProductDetail } from '@things-factory/product-base'
|
|
|
10
11
|
import { DeliveryOrder, ORDER_STATUS, OrderInventory, ReleaseGood } from '@things-factory/sales-base'
|
|
11
12
|
import { Domain } from '@things-factory/shell'
|
|
12
13
|
import { Inventory, Pallet } from '@things-factory/warehouse-base'
|
|
13
|
-
|
|
14
|
+
import { InventoryItem } from '@things-factory/warehouse-base'
|
|
14
15
|
import { TEMPLATE_TYPE, WORKSHEET_STATUS, WORKSHEET_TYPE } from '../constants'
|
|
15
16
|
import { Worksheet, WorksheetDetail } from '../entities'
|
|
16
17
|
|
|
@@ -35,6 +36,10 @@ export async function renderOrientageDO({ doNo }, context: any) {
|
|
|
35
36
|
]
|
|
36
37
|
}) // .. find do from deliveryOrderId
|
|
37
38
|
|
|
39
|
+
let foundInventoryItem: InventoryItem[] = await getRepository(InventoryItem).query(
|
|
40
|
+
`select row_number() over (partition by p.sku),p.sku,p.brand_sku, ii.serial_number from inventory_items ii left join products p on ii.product_id = p.id where outbound_order_id = '${foundDO.releaseGood.id}' group by p.sku,ii.serial_number,p.brand_sku`
|
|
41
|
+
)
|
|
42
|
+
|
|
38
43
|
const ownTransportFlag: Boolean = foundDO.ownCollection
|
|
39
44
|
|
|
40
45
|
let foundCP: ContactPoint = null
|
|
@@ -263,6 +268,47 @@ export async function renderOrientageDO({ doNo }, context: any) {
|
|
|
263
268
|
})
|
|
264
269
|
}
|
|
265
270
|
}, [])
|
|
271
|
+
|
|
272
|
+
let tempFoundInventoryItem:any = []
|
|
273
|
+
|
|
274
|
+
productList.forEach((product) => {
|
|
275
|
+
|
|
276
|
+
tempFoundInventoryItem = foundInventoryItem.filter((item) =>{
|
|
277
|
+
return item.sku == product.product_sku
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
tempFoundInventoryItem.concat(tempFoundInventoryItem);
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
foundInventoryItem = tempFoundInventoryItem;
|
|
284
|
+
|
|
285
|
+
const filterInventoryItem = _.groupBy(foundInventoryItem, i => i.sku)
|
|
286
|
+
|
|
287
|
+
const tempIndexArr = []
|
|
288
|
+
|
|
289
|
+
const tempTotalQuantity = []
|
|
290
|
+
|
|
291
|
+
Object.keys(filterInventoryItem).forEach(k => {
|
|
292
|
+
const tempIndex = foundInventoryItem.findIndex(i => {
|
|
293
|
+
return i.sku == k
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
tempIndexArr.push(tempIndex)
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
Object.values(filterInventoryItem).forEach(k => {
|
|
300
|
+
const tempQuantity = k.length
|
|
301
|
+
|
|
302
|
+
tempTotalQuantity.push(tempQuantity)
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
tempIndexArr.forEach((t, index) => {
|
|
306
|
+
foundInventoryItem[t].totalQuantity = tempTotalQuantity[index]
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
foundInventoryItem[0].ref_no = ownRefNo
|
|
310
|
+
|
|
311
|
+
|
|
266
312
|
|
|
267
313
|
const data = {
|
|
268
314
|
// logo_url: logo,
|
|
@@ -305,6 +351,9 @@ export async function renderOrientageDO({ doNo }, context: any) {
|
|
|
305
351
|
batch_id_ref: prod.product_batch_ref,
|
|
306
352
|
batch_id: prod.product_batch
|
|
307
353
|
}
|
|
354
|
+
}),
|
|
355
|
+
serialNumber: foundInventoryItem.map((item: any, idx) => {
|
|
356
|
+
return { ...item, delivery_to: foundDO.to }
|
|
308
357
|
})
|
|
309
358
|
} //.. make data from do
|
|
310
359
|
const formData = new FormData()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
1
2
|
import FormData from 'form-data'
|
|
2
3
|
import fetch from 'node-fetch'
|
|
3
4
|
import { getRepository, IsNull, Not } from 'typeorm'
|
|
4
|
-
|
|
5
5
|
import { Attachment, STORAGE } from '@things-factory/attachment-base'
|
|
6
6
|
import { Partner } from '@things-factory/auth-base'
|
|
7
7
|
import { Bizplace, ContactPoint } from '@things-factory/biz-base'
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
ORDER_STATUS,
|
|
15
15
|
OrderProduct
|
|
16
16
|
} from '@things-factory/sales-base'
|
|
17
|
+
import { InventoryItem } from '@things-factory/warehouse-base'
|
|
17
18
|
import { Domain } from '@things-factory/shell'
|
|
18
19
|
|
|
19
20
|
import { TEMPLATE_TYPE } from '../constants'
|
|
@@ -40,6 +41,10 @@ export async function renderOrientageGRN({ grnNo }, context: any) {
|
|
|
40
41
|
const ownRefNo2 = foundGAN.refNo2
|
|
41
42
|
const ownRefNo3 = foundGAN.refNo3
|
|
42
43
|
|
|
44
|
+
const foundInventoryItem: InventoryItem[] = await getRepository(InventoryItem).query(
|
|
45
|
+
`select row_number() over (partition by p.sku),p.sku,p.brand_sku, ii.serial_number from inventory_items ii left join products p on ii.product_id = p.id where inbound_order_id = '${foundGAN.id}' group by p.sku,ii.serial_number,p.brand_sku`
|
|
46
|
+
)
|
|
47
|
+
|
|
43
48
|
// 4. find customer bizplace
|
|
44
49
|
const partnerBiz: Bizplace = foundGRN.bizplace
|
|
45
50
|
|
|
@@ -90,6 +95,31 @@ export async function renderOrientageGRN({ grnNo }, context: any) {
|
|
|
90
95
|
logo = 'data:' + foundLogo.mimetype + ';base64,' + (await STORAGE.readFile(foundLogo.path, 'base64'))
|
|
91
96
|
}
|
|
92
97
|
|
|
98
|
+
const filterInventoryItem = _.groupBy(foundInventoryItem, i => i.sku)
|
|
99
|
+
|
|
100
|
+
const tempIndexArr = []
|
|
101
|
+
|
|
102
|
+
const tempTotalQuantity = []
|
|
103
|
+
|
|
104
|
+
Object.keys(filterInventoryItem).forEach(k => {
|
|
105
|
+
const tempIndex = foundInventoryItem.findIndex(i => {
|
|
106
|
+
return i.sku == k
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
tempIndexArr.push(tempIndex)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
Object.values(filterInventoryItem).forEach(k => {
|
|
113
|
+
const tempQuantity = k.length
|
|
114
|
+
|
|
115
|
+
tempTotalQuantity.push(tempQuantity)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
tempIndexArr.forEach((t, index) => {
|
|
119
|
+
foundInventoryItem[t].totalQuantity = tempTotalQuantity[index]
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
|
|
93
123
|
const data = {
|
|
94
124
|
logo_url: logo,
|
|
95
125
|
customer_biz: partnerBiz.name,
|
|
@@ -151,6 +181,7 @@ export async function renderOrientageGRN({ grnNo }, context: any) {
|
|
|
151
181
|
: item?.product?.volume
|
|
152
182
|
? Number((item.product.volume * item.actualPackQty).toFixed(4))
|
|
153
183
|
: 0,
|
|
184
|
+
manufacture_year: item.manufactureDate ? new Date(item.manufactureDate).getFullYear() : null,
|
|
154
185
|
manufacture_date: item.manufactureDate ? item.manufactureDate : null,
|
|
155
186
|
literage: matchedProductDetail
|
|
156
187
|
? matchedProductDetail.packingSize
|
|
@@ -161,7 +192,8 @@ export async function renderOrientageGRN({ grnNo }, context: any) {
|
|
|
161
192
|
: 0,
|
|
162
193
|
remark: item.remark || ''
|
|
163
194
|
}
|
|
164
|
-
})
|
|
195
|
+
}),
|
|
196
|
+
serialNumber: foundInventoryItem
|
|
165
197
|
}
|
|
166
198
|
|
|
167
199
|
const formData = new FormData()
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _ from 'lodash'
|
|
1
2
|
import FormData from 'form-data'
|
|
2
3
|
import fetch from 'node-fetch'
|
|
3
4
|
import { Equal, getRepository, In } from 'typeorm'
|
|
@@ -10,9 +11,10 @@ import { ProductDetail } from '@things-factory/product-base'
|
|
|
10
11
|
import { DeliveryOrder, ORDER_STATUS, OrderInventory, ReleaseGood } from '@things-factory/sales-base'
|
|
11
12
|
import { Domain } from '@things-factory/shell'
|
|
12
13
|
import { Inventory, Pallet } from '@things-factory/warehouse-base'
|
|
13
|
-
|
|
14
|
+
import { InventoryItem } from '@things-factory/warehouse-base'
|
|
14
15
|
import { TEMPLATE_TYPE, WORKSHEET_STATUS, WORKSHEET_TYPE } from '../constants'
|
|
15
16
|
import { Worksheet, WorksheetDetail } from '../entities'
|
|
17
|
+
import { DateTimeConverter } from '../utils/datetime-util'
|
|
16
18
|
|
|
17
19
|
const REPORT_API_URL = config.get('reportApiUrl', 'http://localhost:8888/rest/report/show_html')
|
|
18
20
|
|
|
@@ -48,6 +50,10 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
48
50
|
const partnerBiz: Bizplace = foundDO.bizplace //customer bizplace
|
|
49
51
|
const ownRefNo = foundRO.refNo
|
|
50
52
|
|
|
53
|
+
let foundInventoryItem: InventoryItem[] = await getRepository(InventoryItem).query(
|
|
54
|
+
`select row_number() over (partition by p.sku) as "seq",p.sku,p.brand_sku, ii.serial_number from inventory_items ii left join products p on ii.product_id = p.id where outbound_order_id = '${foundDO.releaseGood.id}' group by p.sku,ii.serial_number,p.brand_sku`
|
|
55
|
+
)
|
|
56
|
+
|
|
51
57
|
const partnerDomain: Partner = await getRepository(Partner).findOne({
|
|
52
58
|
where: { partnerDomain: partnerBiz.domain, domain },
|
|
53
59
|
relations: ['domain']
|
|
@@ -70,6 +76,11 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
70
76
|
relations: ['updater']
|
|
71
77
|
})
|
|
72
78
|
|
|
79
|
+
const foundLoadingWS: Worksheet = await getRepository(Worksheet).findOne({
|
|
80
|
+
where: { domain, releaseGood: foundRO, type: WORKSHEET_TYPE.LOADING },
|
|
81
|
+
relations: ['updater']
|
|
82
|
+
})
|
|
83
|
+
|
|
73
84
|
//find reusable pallet
|
|
74
85
|
const foundRP: Pallet[] = await getRepository(Pallet).find({
|
|
75
86
|
where: { domain, refOrderNo: foundRO.name }
|
|
@@ -211,6 +222,67 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
211
222
|
}
|
|
212
223
|
}, [])
|
|
213
224
|
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
let tempFoundInventoryItem:any = []
|
|
228
|
+
|
|
229
|
+
const sepProductList = productList.flatMap(p=>Array.from({length:p.product_qty},()=>({...p})))
|
|
230
|
+
|
|
231
|
+
sepProductList.forEach((product) => {
|
|
232
|
+
|
|
233
|
+
let temp = foundInventoryItem.filter((item) =>{
|
|
234
|
+
return item.sku == product.product_sku
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
if(temp.length>1){
|
|
238
|
+
temp.forEach(res=>{
|
|
239
|
+
console.log(res)
|
|
240
|
+
|
|
241
|
+
if(tempFoundInventoryItem.length==0){
|
|
242
|
+
tempFoundInventoryItem.push(res)
|
|
243
|
+
}else{
|
|
244
|
+
const index = tempFoundInventoryItem.findIndex(res=>res.serial_number == res.serial_number)
|
|
245
|
+
|
|
246
|
+
if(!index){
|
|
247
|
+
tempFoundInventoryItem.push(res)
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
tempFoundInventoryItem = _.uniqWith(tempFoundInventoryItem,_.isEqual)
|
|
252
|
+
})
|
|
253
|
+
}else{
|
|
254
|
+
tempFoundInventoryItem.push(Object.assign({}, ...temp))
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
foundInventoryItem = tempFoundInventoryItem;
|
|
259
|
+
|
|
260
|
+
const filterInventoryItem = _.groupBy(foundInventoryItem, i => i.sku)
|
|
261
|
+
|
|
262
|
+
const tempIndexArr = []
|
|
263
|
+
|
|
264
|
+
const tempTotalQuantity = []
|
|
265
|
+
|
|
266
|
+
Object.keys(filterInventoryItem).forEach(k => {
|
|
267
|
+
const tempIndex = foundInventoryItem.findIndex(i => {
|
|
268
|
+
return i.sku == k
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
tempIndexArr.push(tempIndex)
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
Object.values(filterInventoryItem).forEach(k => {
|
|
275
|
+
const tempQuantity = k.length
|
|
276
|
+
|
|
277
|
+
tempTotalQuantity.push(tempQuantity)
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
tempIndexArr.forEach((t, index) => {
|
|
281
|
+
foundInventoryItem[t].totalQuantity = tempTotalQuantity[index]
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
foundInventoryItem[0].ref_no = ownRefNo || ""
|
|
285
|
+
|
|
214
286
|
const data = {
|
|
215
287
|
logo_url: logo,
|
|
216
288
|
customer_biz: partnerBiz.name,
|
|
@@ -231,9 +303,16 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
231
303
|
customer_name: foundCP ? foundCP.name : null,
|
|
232
304
|
customer_delivery_address: foundCP ? foundCP.address : null,
|
|
233
305
|
customer_billing_address: foundCP ? foundCP.billingAddress : null,
|
|
306
|
+
new_billing_address: foundRO?.billingAddress || null,
|
|
234
307
|
new_delivery_address: foundRO?.deliveryAddress1 || null,
|
|
235
308
|
new_delivery_address2: foundRO?.deliveryAddress2 || null,
|
|
236
|
-
|
|
309
|
+
new_delivery_address3: foundRO?.deliveryAddress3 || null,
|
|
310
|
+
new_delivery_address4: foundRO?.deliveryAddress4 || null,
|
|
311
|
+
new_delivery_address5: foundRO?.deliveryAddress5 || null,
|
|
312
|
+
new_delivery_city: foundRO?.city || null,
|
|
313
|
+
new_delivery_state: foundRO?.state || null,
|
|
314
|
+
new_delivery_postal_code: foundRO?.postalCode || null,
|
|
315
|
+
new_delivery_country: foundRO?.country || null,
|
|
237
316
|
new_attention_to: foundRO?.attentionTo || null,
|
|
238
317
|
new_attention_company: foundRO?.attentionCompany || null,
|
|
239
318
|
new_phone_no: foundRO?.phone1 || null,
|
|
@@ -251,6 +330,8 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
251
330
|
ref_no3: foundRO.refNo3 ? `${foundRO.refNo3}` : '',
|
|
252
331
|
order_no: foundDO.name,
|
|
253
332
|
delivery_date: foundDO.deliveryDate || '',
|
|
333
|
+
complete_loading_date: DateTimeConverter.date(foundLoadingWS.endedAt),
|
|
334
|
+
ro_created_date: DateTimeConverter.date(foundRO.createdAt),
|
|
254
335
|
truck_no: foundDO.truckNo,
|
|
255
336
|
driver_name: foundDriver || '',
|
|
256
337
|
pallet_qty: foundDO.palletQty,
|
|
@@ -275,6 +356,9 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
275
356
|
inventory_remark: prod?.inventory_remark ? prod.inventory_remark : '',
|
|
276
357
|
batch_id_ref: prod.product_batch_ref
|
|
277
358
|
}
|
|
359
|
+
}),
|
|
360
|
+
serialNumber: foundInventoryItem.map((item: any, idx) => {
|
|
361
|
+
return { ...item, delivery_to: foundDO.to }
|
|
278
362
|
})
|
|
279
363
|
} //.. make data from do
|
|
280
364
|
const formData = new FormData()
|
|
@@ -7,7 +7,7 @@ import { Worksheet } from '../../../../entities'
|
|
|
7
7
|
export const assignPickingWorkerResolver = {
|
|
8
8
|
async assignPickingWorker(
|
|
9
9
|
_parentObj: void,
|
|
10
|
-
{ worksheetId, userId }: { worksheetId: string; userId: string },
|
|
10
|
+
{ worksheetId, userId }: { worksheetId: [string]; userId: string },
|
|
11
11
|
context: any
|
|
12
12
|
): Promise<void> {
|
|
13
13
|
const { tx, domain }: { tx: EntityManager; domain: Domain } = context.state
|
|
@@ -17,16 +17,19 @@ export const assignPickingWorkerResolver = {
|
|
|
17
17
|
|
|
18
18
|
if (!assignee) throw new Error('failed to find target user')
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
await Promise.all(worksheetId.map(async (worksheetId)=>{
|
|
21
|
+
const worksheet: Worksheet = await tx.getRepository(Worksheet).findOne({
|
|
22
|
+
id: worksheetId,
|
|
23
|
+
type: WORKSHEET_TYPE.PICKING
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
if (!worksheet) throw new Error('failed to find target picking worksheet')
|
|
27
|
+
if (worksheet.status !== WORKSHEET_STATUS.DEACTIVATED)
|
|
28
|
+
throw new Error(`current status of worksheet is not able to assign worker`)
|
|
29
|
+
|
|
30
|
+
worksheet.assignee = assignee
|
|
31
|
+
await tx.getRepository(Worksheet).save(worksheet)
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
if (worksheet.status !== WORKSHEET_STATUS.DEACTIVATED)
|
|
27
|
-
throw new Error(`current status of worksheet is not able to assign worker`)
|
|
28
|
-
|
|
29
|
-
worksheet.assignee = assignee
|
|
30
|
-
await tx.getRepository(Worksheet).save(worksheet)
|
|
33
|
+
}))
|
|
31
34
|
}
|
|
32
35
|
}
|
|
@@ -10,7 +10,7 @@ type AssignmentStatusByUserType = { user: User; pending?: Worksheet[]; picking?:
|
|
|
10
10
|
export const pickingAssignmentStatusByUsersResolver = {
|
|
11
11
|
async pickingAssignmentStatusByUsers(
|
|
12
12
|
_: void,
|
|
13
|
-
{
|
|
13
|
+
{ name, email }: { name?: string; email?: string },
|
|
14
14
|
context: any
|
|
15
15
|
): Promise<AssignmentStatusByUserType[]> {
|
|
16
16
|
const { domain }: { domain: Domain } = context.state
|
|
@@ -25,11 +25,9 @@ export const pickingAssignmentStatusByUsersResolver = {
|
|
|
25
25
|
|
|
26
26
|
const users: User[] = await getRepository(User).find(findOneOption)
|
|
27
27
|
|
|
28
|
-
const bizplace: Bizplace = await getRepository(Bizplace).findOne(bizplaceId)
|
|
29
28
|
const assignedPickingWorksheets: Worksheet[] = await getRepository(Worksheet).find({
|
|
30
29
|
where: {
|
|
31
30
|
domain,
|
|
32
|
-
bizplace,
|
|
33
31
|
type: WORKSHEET_TYPE.PICKING,
|
|
34
32
|
status: In([WORKSHEET_STATUS.DEACTIVATED, WORKSHEET_STATUS.EXECUTING]),
|
|
35
33
|
assignee: In(users.map((u: User) => u.id))
|
|
@@ -530,7 +530,7 @@ export const Mutation = /* GraphQL */ `
|
|
|
530
530
|
): Boolean @privilege(category: "worksheet_control", privilege: "mutation") @transaction
|
|
531
531
|
|
|
532
532
|
assignPickingWorker (
|
|
533
|
-
worksheetId: String!
|
|
533
|
+
worksheetId: [String]!
|
|
534
534
|
userId: String!
|
|
535
535
|
): Boolean @privilege(category: "worksheet_control", privilege: "mutation") @transaction
|
|
536
536
|
|
|
@@ -671,7 +671,6 @@ export const Query = /* GraphQL */ `
|
|
|
671
671
|
): [Inventory] @privilege(category: "worksheet", privilege: "query")
|
|
672
672
|
|
|
673
673
|
pickingAssignmentStatusByUsers(
|
|
674
|
-
bizplaceId: String!
|
|
675
674
|
name: String
|
|
676
675
|
email: String
|
|
677
676
|
): [PickingAssignmentStatus] @privilege(category: "worksheet", privilege: "query")
|