@things-factory/worksheet-base 5.0.0-alpha.5 → 5.0.0-alpha.52
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/constants/template.js +1 -0
- package/dist-server/constants/template.js.map +1 -1
- package/dist-server/controllers/ecommerce/sellercraft-controller.js +24 -10
- package/dist-server/controllers/ecommerce/sellercraft-controller.js.map +1 -1
- package/dist-server/controllers/inbound/putaway-worksheet-controller.js +22 -13
- package/dist-server/controllers/inbound/putaway-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js +309 -4
- package/dist-server/controllers/inbound/unloading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/index.js +2 -0
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/outbound/loading-worksheet-controller.js +56 -9
- package/dist-server/controllers/outbound/loading-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/packing-worksheet-controller.js +172 -7
- package/dist-server/controllers/outbound/packing-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/picking-worksheet-controller.js +500 -18
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/returning-worksheet-controller.js +11 -1
- package/dist-server/controllers/outbound/returning-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js +215 -12
- package/dist-server/controllers/outbound/sorting-worksheet-controller.js.map +1 -1
- package/dist-server/controllers/render-fm-grn.js +229 -0
- package/dist-server/controllers/render-fm-grn.js.map +1 -0
- package/dist-server/controllers/render-grn.js +77 -45
- package/dist-server/controllers/render-grn.js.map +1 -1
- package/dist-server/controllers/render-invoices.js +103 -65
- package/dist-server/controllers/render-invoices.js.map +1 -1
- package/dist-server/controllers/render-manifest.js +12 -5
- package/dist-server/controllers/render-manifest.js.map +1 -1
- package/dist-server/controllers/render-orientage-do.js.map +1 -1
- package/dist-server/controllers/render-orientage-grn.js +1 -0
- package/dist-server/controllers/render-orientage-grn.js.map +1 -1
- package/dist-server/controllers/render-po.js +147 -0
- package/dist-server/controllers/render-po.js.map +1 -0
- package/dist-server/controllers/render-ro-do.js +65 -1
- package/dist-server/controllers/render-ro-do.js.map +1 -1
- package/dist-server/controllers/worksheet-controller.js +23 -1
- package/dist-server/controllers/worksheet-controller.js.map +1 -1
- package/dist-server/entities/index.js +2 -1
- package/dist-server/entities/index.js.map +1 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js +174 -0
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js +14 -1
- package/dist-server/graphql/resolvers/worksheet/batch-picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/cancel-draft-release-order.js +17 -0
- package/dist-server/graphql/resolvers/worksheet/cancel-draft-release-order.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js +12 -4
- package/dist-server/graphql/resolvers/worksheet/cycle-count-adjustment.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/find-release-orders-by-task-no.js +30 -1
- package/dist-server/graphql/resolvers/worksheet/find-release-orders-by-task-no.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-arrival-notice-worksheet.js +27 -23
- package/dist-server/graphql/resolvers/worksheet/generate-worksheet/generate-arrival-notice-worksheet.js.map +1 -1
- 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/resolvers/worksheet/inventories-by-pallet.js +3 -0
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/loading/complete-loading.js +48 -2
- package/dist-server/graphql/resolvers/worksheet/loading/complete-loading.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/loading/loading.js +3 -10
- package/dist-server/graphql/resolvers/worksheet/loading/loading.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/loading-worksheet.js +55 -21
- package/dist-server/graphql/resolvers/worksheet/loading-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/index.js +2 -1
- package/dist-server/graphql/resolvers/worksheet/packing/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/packing/packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/packing/scan-product-packing.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/packing/undo-serial-number-packing.js +15 -0
- package/dist-server/graphql/resolvers/worksheet/packing/undo-serial-number-packing.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js +153 -132
- package/dist-server/graphql/resolvers/worksheet/packing-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/palletizing-pallets.js +2 -5
- package/dist-server/graphql/resolvers/worksheet/palletizing-pallets.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/assign-picking-worker.js +13 -10
- package/dist-server/graphql/resolvers/worksheet/picking/assign-picking-worker.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-batch-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js +14 -25
- package/dist-server/graphql/resolvers/worksheet/picking/complete-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/index.js +3 -1
- package/dist-server/graphql/resolvers/worksheet/picking/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/picking-assignment-status-by-user.js +49 -58
- package/dist-server/graphql/resolvers/worksheet/picking/picking-assignment-status-by-user.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/picking.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/picking/picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/scan-product-picking.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/picking/scan-product-picking.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/picking/seal-tote.js +15 -0
- package/dist-server/graphql/resolvers/worksheet/picking/seal-tote.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/picking/undo-serial-number-picking.js +15 -0
- package/dist-server/graphql/resolvers/worksheet/picking/undo-serial-number-picking.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js +10 -1
- package/dist-server/graphql/resolvers/worksheet/picking-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js +36 -0
- package/dist-server/graphql/resolvers/worksheet/putaway/complete-putaway.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/sorting/complete-order-sorting.js +11 -6
- package/dist-server/graphql/resolvers/worksheet/sorting/complete-order-sorting.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/sorting/scan-product-sorting.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/sorting/scan-product-sorting.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/sorting/sorting-product.js +4 -4
- package/dist-server/graphql/resolvers/worksheet/sorting/sorting-product.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/sorting-worksheet.js +6 -0
- package/dist-server/graphql/resolvers/worksheet/sorting-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloaded-inventories.js +3 -2
- package/dist-server/graphql/resolvers/worksheet/unloaded-inventories.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/complete-unloading.js +0 -21
- package/dist-server/graphql/resolvers/worksheet/unloading/complete-unloading.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/index.js +3 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/index.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading/scan-serial-number-unload.js +15 -0
- package/dist-server/graphql/resolvers/worksheet/unloading/scan-serial-number-unload.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/unloading/undo-serial-number-unload.js +15 -0
- package/dist-server/graphql/resolvers/worksheet/unloading/undo-serial-number-unload.js.map +1 -0
- package/dist-server/graphql/resolvers/worksheet/unloading/unload.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-worksheet.js +3 -1
- package/dist-server/graphql/resolvers/worksheet/unloading-worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheet.js +2 -0
- package/dist-server/graphql/resolvers/worksheet/worksheet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/worksheets.js +45 -5
- package/dist-server/graphql/resolvers/worksheet/worksheets.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/generate-batch-picking-worksheet-details-by-bulk.js +13 -8
- package/dist-server/graphql/resolvers/worksheet-detail/generate-batch-picking-worksheet-details-by-bulk.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/generate-batch-picking-worksheet-details.js +19 -4
- package/dist-server/graphql/resolvers/worksheet-detail/generate-batch-picking-worksheet-details.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/generate-pallet-id.js +24 -34
- package/dist-server/graphql/resolvers/worksheet-detail/generate-pallet-id.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/generate-picking-worksheet-details.js +12 -3
- package/dist-server/graphql/resolvers/worksheet-detail/generate-picking-worksheet-details.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-detail/generate-release-good-worksheet-details.js +10 -2
- package/dist-server/graphql/resolvers/worksheet-detail/generate-release-good-worksheet-details.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet-movement/create-worksheet-movement.js +2 -5
- package/dist-server/graphql/resolvers/worksheet-movement/create-worksheet-movement.js.map +1 -1
- package/dist-server/graphql/types/worksheet/find-release-orders-by-task-no.js +11 -0
- package/dist-server/graphql/types/worksheet/find-release-orders-by-task-no.js.map +1 -0
- package/dist-server/graphql/types/worksheet/index.js +52 -11
- package/dist-server/graphql/types/worksheet/index.js.map +1 -1
- package/dist-server/graphql/types/worksheet/loaded-worksheet-detail.js +1 -0
- package/dist-server/graphql/types/worksheet/loaded-worksheet-detail.js.map +1 -1
- package/dist-server/graphql/types/worksheet/picking-assignment-status.js +2 -2
- package/dist-server/graphql/types/worksheet/worksheet-detail-info.js +8 -3
- package/dist-server/graphql/types/worksheet/worksheet-detail-info.js.map +1 -1
- package/dist-server/graphql/types/worksheet/worksheet-info.js +3 -0
- package/dist-server/graphql/types/worksheet/worksheet-info.js.map +1 -1
- package/dist-server/graphql/types/worksheet/worksheet-patch.js +1 -0
- package/dist-server/graphql/types/worksheet/worksheet-patch.js.map +1 -1
- package/dist-server/graphql/types/worksheet/worksheet.js +1 -0
- package/dist-server/graphql/types/worksheet/worksheet.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/index.js +0 -2
- package/dist-server/graphql/types/worksheet-detail/index.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/inventory-detail.js +5 -2
- package/dist-server/graphql/types/worksheet-detail/inventory-detail.js.map +1 -1
- package/dist-server/graphql/types/worksheet-detail/worksheet-detail-patch.js +1 -1
- package/dist-server/index.js +5 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/routes.js +12 -0
- package/dist-server/routes.js.map +1 -1
- package/dist-server/utils/inventory-util.js +14 -25
- package/dist-server/utils/inventory-util.js.map +1 -1
- package/dist-server/utils/worksheet-no-generator.js +25 -28
- package/dist-server/utils/worksheet-no-generator.js.map +1 -1
- package/package.json +17 -17
- package/server/constants/template.ts +1 -0
- package/server/controllers/ecommerce/sellercraft-controller.ts +38 -10
- package/server/controllers/inbound/putaway-worksheet-controller.ts +27 -13
- package/server/controllers/inbound/unloading-worksheet-controller.ts +376 -8
- package/server/controllers/index.ts +3 -0
- package/server/controllers/outbound/loading-worksheet-controller.ts +94 -15
- package/server/controllers/outbound/packing-worksheet-controller.ts +224 -9
- package/server/controllers/outbound/picking-worksheet-controller.ts +653 -24
- package/server/controllers/outbound/returning-worksheet-controller.ts +12 -1
- package/server/controllers/outbound/sorting-worksheet-controller.ts +303 -18
- package/server/controllers/render-fm-grn.ts +266 -0
- package/server/controllers/render-grn.ts +95 -52
- package/server/controllers/render-invoices.ts +119 -72
- package/server/controllers/render-manifest.ts +12 -5
- package/server/controllers/render-orientage-do.ts +11 -11
- package/server/controllers/render-orientage-grn.ts +12 -11
- package/server/controllers/render-po.ts +170 -0
- package/server/controllers/render-ro-do.ts +93 -8
- package/server/controllers/worksheet-controller.ts +32 -3
- package/server/entities/index.ts +2 -1
- package/server/entities/warehouse-bizplace-onhand-inventory.ts +147 -0
- package/server/graphql/resolvers/worksheet/batch-picking-worksheet.ts +14 -0
- package/server/graphql/resolvers/worksheet/cancel-draft-release-order.ts +27 -0
- package/server/graphql/resolvers/worksheet/cycle-count-adjustment.ts +15 -5
- package/server/graphql/resolvers/worksheet/find-release-orders-by-task-no.ts +35 -2
- package/server/graphql/resolvers/worksheet/generate-worksheet/generate-arrival-notice-worksheet.ts +35 -25
- package/server/graphql/resolvers/worksheet/index.ts +3 -1
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +2 -0
- package/server/graphql/resolvers/worksheet/loading/complete-loading.ts +67 -8
- package/server/graphql/resolvers/worksheet/loading/loading.ts +5 -12
- package/server/graphql/resolvers/worksheet/loading-worksheet.ts +66 -13
- package/server/graphql/resolvers/worksheet/packing/index.ts +3 -1
- package/server/graphql/resolvers/worksheet/packing/packing.ts +5 -4
- package/server/graphql/resolvers/worksheet/packing/scan-product-packing.ts +9 -4
- package/server/graphql/resolvers/worksheet/packing/undo-serial-number-packing.ts +24 -0
- package/server/graphql/resolvers/worksheet/packing-worksheet.ts +167 -145
- package/server/graphql/resolvers/worksheet/palletizing-pallets.ts +2 -2
- package/server/graphql/resolvers/worksheet/picking/assign-picking-worker.ts +15 -11
- package/server/graphql/resolvers/worksheet/picking/complete-batch-picking.ts +1 -1
- package/server/graphql/resolvers/worksheet/picking/complete-picking.ts +18 -31
- package/server/graphql/resolvers/worksheet/picking/index.ts +5 -1
- package/server/graphql/resolvers/worksheet/picking/picking-assignment-status-by-user.ts +62 -61
- package/server/graphql/resolvers/worksheet/picking/picking.ts +30 -4
- package/server/graphql/resolvers/worksheet/picking/scan-product-picking.ts +7 -4
- package/server/graphql/resolvers/worksheet/picking/seal-tote.ts +25 -0
- package/server/graphql/resolvers/worksheet/picking/undo-serial-number-picking.ts +24 -0
- package/server/graphql/resolvers/worksheet/picking-worksheet.ts +13 -2
- package/server/graphql/resolvers/worksheet/putaway/complete-putaway.ts +45 -2
- package/server/graphql/resolvers/worksheet/sorting/complete-order-sorting.ts +13 -9
- package/server/graphql/resolvers/worksheet/sorting/scan-product-sorting.ts +6 -4
- package/server/graphql/resolvers/worksheet/sorting/sorting-product.ts +6 -4
- package/server/graphql/resolvers/worksheet/sorting-worksheet.ts +6 -0
- package/server/graphql/resolvers/worksheet/unloaded-inventories.ts +6 -2
- package/server/graphql/resolvers/worksheet/unloading/complete-unloading.ts +0 -25
- package/server/graphql/resolvers/worksheet/unloading/index.ts +4 -0
- package/server/graphql/resolvers/worksheet/unloading/scan-serial-number-unload.ts +26 -0
- package/server/graphql/resolvers/worksheet/unloading/undo-serial-number-unload.ts +24 -0
- package/server/graphql/resolvers/worksheet/unloading/unload.ts +3 -1
- package/server/graphql/resolvers/worksheet/unloading-worksheet.ts +3 -1
- package/server/graphql/resolvers/worksheet/worksheet.ts +2 -0
- package/server/graphql/resolvers/worksheet/worksheets.ts +64 -5
- package/server/graphql/resolvers/worksheet-detail/generate-batch-picking-worksheet-details-by-bulk.ts +30 -14
- package/server/graphql/resolvers/worksheet-detail/generate-batch-picking-worksheet-details.ts +39 -11
- package/server/graphql/resolvers/worksheet-detail/generate-pallet-id.ts +46 -49
- package/server/graphql/resolvers/worksheet-detail/generate-picking-worksheet-details.ts +15 -3
- package/server/graphql/resolvers/worksheet-detail/generate-release-good-worksheet-details.ts +18 -1
- package/server/graphql/resolvers/worksheet-movement/create-worksheet-movement.ts +2 -2
- package/server/graphql/types/worksheet/find-release-orders-by-task-no.ts +8 -0
- package/server/graphql/types/worksheet/index.ts +52 -11
- package/server/graphql/types/worksheet/loaded-worksheet-detail.ts +1 -0
- package/server/graphql/types/worksheet/picking-assignment-status.ts +2 -2
- package/server/graphql/types/worksheet/worksheet-detail-info.ts +8 -3
- package/server/graphql/types/worksheet/worksheet-info.ts +3 -0
- package/server/graphql/types/worksheet/worksheet-patch.ts +1 -0
- package/server/graphql/types/worksheet/worksheet.ts +1 -0
- package/server/graphql/types/worksheet-detail/index.ts +0 -2
- package/server/graphql/types/worksheet-detail/inventory-detail.ts +5 -2
- package/server/graphql/types/worksheet-detail/worksheet-detail-patch.ts +1 -1
- package/server/index.ts +5 -0
- package/server/routes.ts +17 -0
- package/server/utils/inventory-util.ts +15 -23
- package/server/utils/worksheet-no-generator.ts +25 -25
|
@@ -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,68 @@ 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
|
+
if (t >= 0)
|
|
282
|
+
foundInventoryItem[t].totalQuantity = tempTotalQuantity[index]
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
foundInventoryItem[0].ref_no = ownRefNo || ""
|
|
286
|
+
|
|
214
287
|
const data = {
|
|
215
288
|
logo_url: logo,
|
|
216
289
|
customer_biz: partnerBiz.name,
|
|
@@ -231,9 +304,16 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
231
304
|
customer_name: foundCP ? foundCP.name : null,
|
|
232
305
|
customer_delivery_address: foundCP ? foundCP.address : null,
|
|
233
306
|
customer_billing_address: foundCP ? foundCP.billingAddress : null,
|
|
307
|
+
new_billing_address: foundRO?.billingAddress || null,
|
|
234
308
|
new_delivery_address: foundRO?.deliveryAddress1 || null,
|
|
235
309
|
new_delivery_address2: foundRO?.deliveryAddress2 || null,
|
|
236
|
-
|
|
310
|
+
new_delivery_address3: foundRO?.deliveryAddress3 || null,
|
|
311
|
+
new_delivery_address4: foundRO?.deliveryAddress4 || null,
|
|
312
|
+
new_delivery_address5: foundRO?.deliveryAddress5 || null,
|
|
313
|
+
new_delivery_city: foundRO?.city || null,
|
|
314
|
+
new_delivery_state: foundRO?.state || null,
|
|
315
|
+
new_delivery_postal_code: foundRO?.postalCode || null,
|
|
316
|
+
new_delivery_country: foundRO?.country || null,
|
|
237
317
|
new_attention_to: foundRO?.attentionTo || null,
|
|
238
318
|
new_attention_company: foundRO?.attentionCompany || null,
|
|
239
319
|
new_phone_no: foundRO?.phone1 || null,
|
|
@@ -251,6 +331,8 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
251
331
|
ref_no3: foundRO.refNo3 ? `${foundRO.refNo3}` : '',
|
|
252
332
|
order_no: foundDO.name,
|
|
253
333
|
delivery_date: foundDO.deliveryDate || '',
|
|
334
|
+
complete_loading_date: DateTimeConverter.date(foundLoadingWS.endedAt),
|
|
335
|
+
ro_created_date: DateTimeConverter.date(foundRO.createdAt),
|
|
254
336
|
truck_no: foundDO.truckNo,
|
|
255
337
|
driver_name: foundDriver || '',
|
|
256
338
|
pallet_qty: foundDO.palletQty,
|
|
@@ -266,15 +348,18 @@ export async function renderRODO({ doNo }, context: any) {
|
|
|
266
348
|
remark: prod?.remark
|
|
267
349
|
? prod.remark
|
|
268
350
|
: prod.cross_docking
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
351
|
+
? prod.pallet === ''
|
|
352
|
+
? `${prod.palletQty} PALLET(S) [C/D]`
|
|
353
|
+
: `${prod.palletQty} PALLET(S) (${prod.pallet}) [C/D]`
|
|
354
|
+
: prod.pallet === ''
|
|
355
|
+
? `${prod.palletQty} PALLET(S)`
|
|
356
|
+
: `${prod.palletQty} PALLET(S) (${prod.pallet})`,
|
|
275
357
|
inventory_remark: prod?.inventory_remark ? prod.inventory_remark : '',
|
|
276
358
|
batch_id_ref: prod.product_batch_ref
|
|
277
359
|
}
|
|
360
|
+
}),
|
|
361
|
+
serialNumber: foundInventoryItem.map((item: any, idx) => {
|
|
362
|
+
return { ...item, delivery_to: foundDO.to }
|
|
278
363
|
})
|
|
279
364
|
} //.. make data from do
|
|
280
365
|
const formData = new FormData()
|
|
@@ -3,7 +3,7 @@ import { EntityManager, EntitySchema, Equal, FindOneOptions, In, Not } from 'typ
|
|
|
3
3
|
import { Role, User } from '@things-factory/auth-base'
|
|
4
4
|
import { Bizplace, getDomainUsers } from '@things-factory/biz-base'
|
|
5
5
|
import { sendNotification } from '@things-factory/notification'
|
|
6
|
-
import { ProductDetail } from '@things-factory/product-base'
|
|
6
|
+
import { Product, ProductDetail } from '@things-factory/product-base'
|
|
7
7
|
import {
|
|
8
8
|
ArrivalNotice,
|
|
9
9
|
DeliveryOrder,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
VasOrder
|
|
20
20
|
} from '@things-factory/sales-base'
|
|
21
21
|
import { Domain } from '@things-factory/shell'
|
|
22
|
-
import { Inventory, INVENTORY_STATUS, Pallet } from '@things-factory/warehouse-base'
|
|
22
|
+
import { Inventory, INVENTORY_STATUS, InventoryItem, Pallet } from '@things-factory/warehouse-base'
|
|
23
23
|
|
|
24
24
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../constants'
|
|
25
25
|
import { Worksheet, WorksheetDetail } from '../entities'
|
|
@@ -300,7 +300,7 @@ export class WorksheetController {
|
|
|
300
300
|
|
|
301
301
|
/**
|
|
302
302
|
* @summary find worksheet detail by passed condition
|
|
303
|
-
* @description find
|
|
303
|
+
* @description find worksheet detail based on passed condition
|
|
304
304
|
* If you want to get additional relations you need to define reltaions
|
|
305
305
|
* ex) findWorksheetDetail(condition, ['worksheet'])
|
|
306
306
|
*/
|
|
@@ -390,6 +390,19 @@ export class WorksheetController {
|
|
|
390
390
|
let refOrderType: string = await this.getRefOrderField(refOrder)
|
|
391
391
|
const bizplace: Bizplace = await this.extractBizplaceFromRefOrder(refOrder)
|
|
392
392
|
|
|
393
|
+
let existingWorksheet: Worksheet
|
|
394
|
+
try {
|
|
395
|
+
existingWorksheet = await this.findWorksheetByRefOrder(refOrder, type)
|
|
396
|
+
} catch (e) {}
|
|
397
|
+
|
|
398
|
+
if (existingWorksheet)
|
|
399
|
+
throw new Error(
|
|
400
|
+
this.ERROR_MSG.VALIDITY.CANT_PROCEED_STEP_BY(
|
|
401
|
+
`create ${type.toLocaleLowerCase()} worksheet`,
|
|
402
|
+
'existing worksheet is found'
|
|
403
|
+
)
|
|
404
|
+
)
|
|
405
|
+
|
|
393
406
|
const worksheet: Partial<Worksheet> = {
|
|
394
407
|
domain: this.domain,
|
|
395
408
|
bizplace,
|
|
@@ -941,6 +954,22 @@ export class WorksheetController {
|
|
|
941
954
|
if (duplicatedCartonCnt) throw new Error(this.ERROR_MSG.VALIDITY.DUPLICATED('Carton ID', cartonId))
|
|
942
955
|
}
|
|
943
956
|
|
|
957
|
+
/**
|
|
958
|
+
* @summary Check whether passed serial number is existing already
|
|
959
|
+
* @description It will try to count inventories which has same domain and same serial number and and not terminated one
|
|
960
|
+
* If there's positive result it will throw an error cause serial number is duplicated
|
|
961
|
+
*/
|
|
962
|
+
async checkSerialNumberDuplication(serialNumber: string, product: Product): Promise<void> {
|
|
963
|
+
const duplicatedSerialNumberCnt: number = await this.trxMgr.getRepository(InventoryItem).count({
|
|
964
|
+
domain: this.domain,
|
|
965
|
+
product,
|
|
966
|
+
serialNumber,
|
|
967
|
+
status: Not(Equal(INVENTORY_STATUS.DELETED))
|
|
968
|
+
})
|
|
969
|
+
|
|
970
|
+
if (duplicatedSerialNumberCnt) throw new Error(this.ERROR_MSG.VALIDITY.DUPLICATED('Serial Number', serialNumber))
|
|
971
|
+
}
|
|
972
|
+
|
|
944
973
|
/**
|
|
945
974
|
* @summary Check for product child qty at any scanned level
|
|
946
975
|
* @description It will check every level of product detail by comparing scanned level and GAN registered level.
|
package/server/entities/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Worksheet } from './worksheet'
|
|
2
2
|
import { WorksheetDetail } from './worksheet-detail'
|
|
3
3
|
import { WorksheetMovement } from './worksheet-movement'
|
|
4
|
+
import { WarehouseBizplaceOnhandInventory } from './warehouse-bizplace-onhand-inventory'
|
|
4
5
|
|
|
5
|
-
export const entities = [Worksheet, WorksheetDetail, WorksheetMovement]
|
|
6
|
+
export const entities = [Worksheet, WorksheetDetail, WorksheetMovement, WarehouseBizplaceOnhandInventory]
|
|
6
7
|
|
|
7
8
|
export { Worksheet, WorksheetDetail, WorksheetMovement }
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { ViewColumn, ViewEntity } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
@ViewEntity({
|
|
4
|
+
expression: `
|
|
5
|
+
select d.name as "domainName", b.name as "bizplaceName", src.* from (
|
|
6
|
+
WITH oi as (
|
|
7
|
+
select
|
|
8
|
+
oi.domain_id,
|
|
9
|
+
oi.bizplace_id,
|
|
10
|
+
SUM(oi.release_qty) AS release_qty,
|
|
11
|
+
SUM(oi.release_uom_value) AS release_uom_value,
|
|
12
|
+
oi.batch_id,
|
|
13
|
+
oi.batch_id_ref,
|
|
14
|
+
oi.product_id,
|
|
15
|
+
oi.packing_type,
|
|
16
|
+
oi.packing_size,
|
|
17
|
+
oi.uom
|
|
18
|
+
FROM
|
|
19
|
+
order_inventories oi
|
|
20
|
+
WHERE
|
|
21
|
+
(oi.status = 'PENDING' or oi.status = 'PENDING_RECEIVE' or oi.status = 'PENDING_WORKSHEET' or oi.status = 'PENDING_SPLIT')
|
|
22
|
+
AND oi.batch_id NOTNULL
|
|
23
|
+
AND oi.product_id NOTNULL
|
|
24
|
+
AND oi.packing_type NOTNULL
|
|
25
|
+
AND oi.packing_size NOTNULL
|
|
26
|
+
AND oi.inventory_id IS NULL
|
|
27
|
+
GROUP BY
|
|
28
|
+
oi.domain_id,
|
|
29
|
+
oi.bizplace_id,
|
|
30
|
+
oi.batch_id,
|
|
31
|
+
oi.batch_id_ref,
|
|
32
|
+
oi.product_id,
|
|
33
|
+
oi.packing_type,
|
|
34
|
+
oi.packing_size,
|
|
35
|
+
oi.uom
|
|
36
|
+
)
|
|
37
|
+
-- SINGLE ITEM INVENTORY QUERY
|
|
38
|
+
select
|
|
39
|
+
i.domain_id as "domainId",
|
|
40
|
+
i.bizplace_id as "bizplaceId",
|
|
41
|
+
i.packing_type as "packingType",
|
|
42
|
+
i.packing_size as "packingSize",
|
|
43
|
+
i.uom,
|
|
44
|
+
i.product_id as "productId",
|
|
45
|
+
null as "productBundleId",
|
|
46
|
+
COALESCE(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0))) AS "remainQty",
|
|
47
|
+
COALESCE(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0)), 0) AS "remainUomValue",
|
|
48
|
+
COALESCE(sum(COALESCE(i.qty, 0::double precision))) AS "qty",
|
|
49
|
+
COALESCE(sum(COALESCE(i.uom_value, 0::double precision))) AS "uomValue",
|
|
50
|
+
'SINGLE' AS "groupType"
|
|
51
|
+
FROM inventories i
|
|
52
|
+
INNER JOIN locations l2 ON i.location_id = l2.id AND i.domain_id = l2.domain_id AND l2.type NOT IN ('QUARANTINE', 'RESERVE')
|
|
53
|
+
LEFT JOIN oi ON i.batch_id = oi.batch_id AND i.product_id = oi.product_id AND i.packing_type = oi.packing_type AND i.packing_size = oi.packing_size AND i.uom = oi.uom
|
|
54
|
+
WHERE i.status = 'STORED'
|
|
55
|
+
GROUP by
|
|
56
|
+
i.domain_id,
|
|
57
|
+
i.bizplace_id,
|
|
58
|
+
i.product_id,
|
|
59
|
+
i.packing_type,
|
|
60
|
+
i.packing_size,
|
|
61
|
+
i.uom
|
|
62
|
+
union all
|
|
63
|
+
-- BUNDLE ITEM INVENTORY QUERY
|
|
64
|
+
SELECT
|
|
65
|
+
pbs.domain_id as "domainId",
|
|
66
|
+
pbs.bizplace_id as "bizplaceId",
|
|
67
|
+
pb.packing_type as "packingType",
|
|
68
|
+
pb.packing_size as "packingSize",
|
|
69
|
+
'UNIT' AS "uom",
|
|
70
|
+
null as "productId",
|
|
71
|
+
pb.id AS "productBundleId",
|
|
72
|
+
COALESCE(MIN(FLOOR(pbs."availableQty")),0) AS "remainQty",
|
|
73
|
+
COALESCE(MIN(FLOOR(pbs."availableUomValue")),0) AS "remainUomValue",
|
|
74
|
+
COALESCE(MIN(FLOOR(pbs."qty")), 0::double precision) AS "qty",
|
|
75
|
+
COALESCE(MIN(FLOOR(pbs."uomValue")), 0::double precision) AS "uomValue",
|
|
76
|
+
'BUNDLE' AS "groupType"
|
|
77
|
+
FROM product_bundles pb
|
|
78
|
+
INNER JOIN (
|
|
79
|
+
SELECT i.domain_id, i.bizplace_id, pbs.product_id, pbs.product_bundle_id, min(pbs.bundle_qty),
|
|
80
|
+
(SUM(COALESCE(i.qty, 0)) - SUM(COALESCE(i.locked_qty, 0)) - MAX(COALESCE(oi.release_qty, 0))) / min(pbs.bundle_qty) AS "availableQty",
|
|
81
|
+
(SUM(COALESCE(i.uom_value, 0)) - SUM(COALESCE(i.locked_uom_value, 0)) - MAX(COALESCE(oi.release_uom_value, 0))) / min(pbs.bundle_qty) AS "availableUomValue",
|
|
82
|
+
(sum(COALESCE(i.qty, 0::double precision))) / min(pbs.bundle_qty)::double precision AS "qty",
|
|
83
|
+
(sum(COALESCE(i.uom_value, 0::double precision))) / min(pbs.bundle_qty)::double precision AS "uomValue"
|
|
84
|
+
FROM product_bundle_settings pbs
|
|
85
|
+
LEFT JOIN inventories i ON i.product_id = pbs.product_id AND i.status = 'STORED'
|
|
86
|
+
INNER JOIN locations l ON i.location_id = l.id AND i.domain_id = l.domain_id AND l.type NOT IN ('QUARANTINE', 'RESERVE')
|
|
87
|
+
LEFT JOIN oi ON oi.product_id = i.product_id
|
|
88
|
+
GROUP by
|
|
89
|
+
i.domain_id,
|
|
90
|
+
i.bizplace_id,
|
|
91
|
+
pbs.product_id,
|
|
92
|
+
pbs.product_bundle_id
|
|
93
|
+
) pbs ON pbs.product_bundle_id = pb.id
|
|
94
|
+
GROUP BY
|
|
95
|
+
pbs.domain_id,
|
|
96
|
+
pbs.bizplace_id,
|
|
97
|
+
pb.packing_type,
|
|
98
|
+
pb.packing_size,
|
|
99
|
+
pb.name,
|
|
100
|
+
pb.sku,
|
|
101
|
+
pb.id
|
|
102
|
+
)
|
|
103
|
+
AS src
|
|
104
|
+
inner join domains d on d.id = src."domainId"
|
|
105
|
+
inner join bizplaces b on b.id = src."bizplaceId"
|
|
106
|
+
where src."remainQty" > 0
|
|
107
|
+
order by src."domainId"
|
|
108
|
+
`
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
export class WarehouseBizplaceOnhandInventory {
|
|
112
|
+
@ViewColumn()
|
|
113
|
+
domainName: string
|
|
114
|
+
|
|
115
|
+
@ViewColumn()
|
|
116
|
+
bizplaceName: string
|
|
117
|
+
|
|
118
|
+
@ViewColumn()
|
|
119
|
+
domainId: string
|
|
120
|
+
|
|
121
|
+
@ViewColumn()
|
|
122
|
+
bizplaceId: string
|
|
123
|
+
|
|
124
|
+
@ViewColumn()
|
|
125
|
+
packingType: string
|
|
126
|
+
|
|
127
|
+
@ViewColumn()
|
|
128
|
+
packingSize: number
|
|
129
|
+
|
|
130
|
+
@ViewColumn()
|
|
131
|
+
uom: string
|
|
132
|
+
|
|
133
|
+
@ViewColumn()
|
|
134
|
+
productId: string
|
|
135
|
+
|
|
136
|
+
@ViewColumn()
|
|
137
|
+
productBundleId: string
|
|
138
|
+
|
|
139
|
+
@ViewColumn()
|
|
140
|
+
remainQty: number
|
|
141
|
+
|
|
142
|
+
@ViewColumn()
|
|
143
|
+
remainUomValue: number
|
|
144
|
+
|
|
145
|
+
@ViewColumn()
|
|
146
|
+
groupType: string
|
|
147
|
+
}
|
|
@@ -3,6 +3,7 @@ import { getRepository, SelectQueryBuilder } from 'typeorm'
|
|
|
3
3
|
import { ORDER_INVENTORY_STATUS } from '@things-factory/sales-base'
|
|
4
4
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
5
5
|
import { Worksheet, WorksheetDetail } from '../../../entities'
|
|
6
|
+
import { InventoryChange } from '@things-factory/warehouse-base'
|
|
6
7
|
|
|
7
8
|
export const batchPickingWorksheetResolver = {
|
|
8
9
|
async batchPickingWorksheet(_: any, { taskNo, locationSortingRules }, context: any) {
|
|
@@ -42,6 +43,7 @@ export const batchPickingWorksheetResolver = {
|
|
|
42
43
|
.addSelect('LOC.column', 'column')
|
|
43
44
|
.addSelect('LOC.shelf', 'shelf')
|
|
44
45
|
.addSelect('BIN_LOC.name', 'binLocationName')
|
|
46
|
+
.addSelect('WSD.status', 'status')
|
|
45
47
|
.leftJoin('WSD.targetInventory', 'T_INV')
|
|
46
48
|
.leftJoin('T_INV.inventory', 'INV')
|
|
47
49
|
.leftJoin('T_INV.product', 'PROD')
|
|
@@ -70,6 +72,7 @@ export const batchPickingWorksheetResolver = {
|
|
|
70
72
|
.addGroupBy('LOC.column')
|
|
71
73
|
.addGroupBy('LOC.row')
|
|
72
74
|
.addGroupBy('LOC.shelf')
|
|
75
|
+
.addGroupBy('WSD.status')
|
|
73
76
|
|
|
74
77
|
if (locationSortingRules?.length > 0) {
|
|
75
78
|
locationSortingRules.forEach((rule: { name: string; desc: boolean }) => {
|
|
@@ -86,6 +89,15 @@ export const batchPickingWorksheetResolver = {
|
|
|
86
89
|
partnerDomainId: worksheet.bizplace?.domain.id
|
|
87
90
|
},
|
|
88
91
|
worksheetDetailInfos: items.map(async (item: any) => {
|
|
92
|
+
const inventoryChangesCount: number = await getRepository(InventoryChange).count({
|
|
93
|
+
where: {
|
|
94
|
+
inventory: item.inventoryId,
|
|
95
|
+
status: 'PENDING',
|
|
96
|
+
transactionType: 'MISSING'
|
|
97
|
+
},
|
|
98
|
+
relations: ['inventory', 'product']
|
|
99
|
+
})
|
|
100
|
+
|
|
89
101
|
return {
|
|
90
102
|
palletId: item?.palletId,
|
|
91
103
|
cartonId: item?.cartonId,
|
|
@@ -98,6 +110,8 @@ export const batchPickingWorksheetResolver = {
|
|
|
98
110
|
},
|
|
99
111
|
qty: item?.qty,
|
|
100
112
|
releaseQty: item.releaseQty,
|
|
113
|
+
hasMissingInventoryChanges: inventoryChangesCount > 0 ? true : false,
|
|
114
|
+
status: item.status,
|
|
101
115
|
pickedQty: item.pickedQty,
|
|
102
116
|
packingType: item?.packingType,
|
|
103
117
|
packingSize: item?.packingSize,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { User } from '@things-factory/auth-base'
|
|
4
|
+
import {
|
|
5
|
+
ORDER_STATUS,
|
|
6
|
+
DraftReleaseGood
|
|
7
|
+
} from '@things-factory/sales-base'
|
|
8
|
+
import { Domain } from '@things-factory/shell'
|
|
9
|
+
|
|
10
|
+
export const cancelDraftReleaseOrder = {
|
|
11
|
+
async cancelDraftReleaseOrder(_: any, { name }, context: any) {
|
|
12
|
+
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
13
|
+
|
|
14
|
+
const foundDRO: DraftReleaseGood = await tx.getRepository(DraftReleaseGood).findOne({
|
|
15
|
+
where: { domain, name }
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
if (foundDRO) {
|
|
19
|
+
await tx.getRepository(DraftReleaseGood).save({
|
|
20
|
+
...foundDRO,
|
|
21
|
+
status: ORDER_STATUS.CANCELLED,
|
|
22
|
+
updater: user
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -56,7 +56,9 @@ export async function cycleCountAdjustment(
|
|
|
56
56
|
'targetInventory.inventory.product.productDetails',
|
|
57
57
|
'targetInventory.inventory.product.productDetails.childProductDetail',
|
|
58
58
|
'targetInventory.inventory.bizplace',
|
|
59
|
+
'targetInventory.inventory.domain',
|
|
59
60
|
'targetInventory.inventory.bizplace.domain',
|
|
61
|
+
'targetInventory.inventory.warehouse',
|
|
60
62
|
'targetInventory.inventory.location',
|
|
61
63
|
'targetInventory.inspectedLocation',
|
|
62
64
|
'targetInventory.inspectedLocation.warehouse'
|
|
@@ -67,11 +69,12 @@ export async function cycleCountAdjustment(
|
|
|
67
69
|
const targetInventory: OrderInventory = worksheetDetail.targetInventory
|
|
68
70
|
let inventory: Inventory = targetInventory.inventory
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
let transactQty: number = targetInventory.inspectedQty - inventory.qty
|
|
73
|
+
let transactUomValue: number = targetInventory.inspectedUomValue - inventory.uomValue
|
|
72
74
|
|
|
73
75
|
const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({
|
|
74
|
-
where: { domain: inventory.bizplace.domain, status: SellercraftStatus.ACTIVE }
|
|
76
|
+
where: { domain: inventory.bizplace.domain, status: SellercraftStatus.ACTIVE },
|
|
77
|
+
relations: ['domain']
|
|
75
78
|
})
|
|
76
79
|
|
|
77
80
|
if (targetInventory.status === ORDER_INVENTORY_STATUS.MISSING) {
|
|
@@ -137,16 +140,23 @@ export async function cycleCountAdjustment(
|
|
|
137
140
|
|
|
138
141
|
if (targetInventory.inspectedBatchNo !== inventory.batchId) {
|
|
139
142
|
// generate TERMINATED, ADJUSTMENT history
|
|
143
|
+
const { qty, uomValue }: { qty: number; uomValue: number } = inventory
|
|
140
144
|
inventory.status = INVENTORY_STATUS.TERMINATED
|
|
145
|
+
inventory.qty = 0
|
|
146
|
+
inventory.uomValue = 0
|
|
147
|
+
|
|
141
148
|
await generateInventoryHistory(
|
|
142
149
|
inventory,
|
|
143
150
|
cycleCount,
|
|
144
151
|
INVENTORY_TRANSACTION_TYPE.CC_ADJUSTMENT,
|
|
145
|
-
-
|
|
146
|
-
-
|
|
152
|
+
-qty,
|
|
153
|
+
-uomValue,
|
|
147
154
|
user,
|
|
148
155
|
tx
|
|
149
156
|
)
|
|
157
|
+
|
|
158
|
+
transactQty = targetInventory.inspectedQty
|
|
159
|
+
transactUomValue = targetInventory.inspectedUomValue
|
|
150
160
|
}
|
|
151
161
|
|
|
152
162
|
inventory.batchId = targetInventory.inspectedBatchNo
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { EntityManager, SelectQueryBuilder } from 'typeorm'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
ORDER_STATUS,
|
|
4
|
+
ORDER_STATUS, ORDER_INVENTORY_STATUS,
|
|
5
5
|
OrderInventory as OrderInventoryEntity,
|
|
6
6
|
ReleaseGood as ReleaseGoodEntity
|
|
7
7
|
} from '@things-factory/sales-base'
|
|
8
8
|
import { Domain } from '@things-factory/shell'
|
|
9
|
+
import { Location } from '@things-factory/warehouse-base'
|
|
9
10
|
|
|
10
11
|
import { WORKSHEET_STATUS, WORKSHEET_TYPE } from '../../../constants'
|
|
11
12
|
import { Worksheet as WorksheetEntity, WorksheetDetail as WorksheetDetailEntity } from '../../../entities'
|
|
@@ -16,6 +17,38 @@ export const findReleaseOrdersByTaskNoResolver = {
|
|
|
16
17
|
let task = await tx.getRepository(WorksheetEntity).findOne({
|
|
17
18
|
where: { taskNo, status: WORKSHEET_STATUS.EXECUTING, type: WORKSHEET_TYPE.SORTING }
|
|
18
19
|
})
|
|
20
|
+
|
|
21
|
+
// Find Task based on Bin
|
|
22
|
+
if (!task) {
|
|
23
|
+
const binLocation: Location = await tx.getRepository(Location).findOne({
|
|
24
|
+
where: { domain, name: taskNo }
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const qb: SelectQueryBuilder<OrderInventoryEntity> = tx.getRepository(OrderInventoryEntity).createQueryBuilder('orderInventory')
|
|
28
|
+
|
|
29
|
+
qb.innerJoinAndSelect('orderInventory.releaseGood', 'releaseGood')
|
|
30
|
+
.innerJoinAndSelect('worksheets', 'ws', `orderInventory.ref_worksheet_id = ws.id AND ws.type = 'BATCH_PICKING'`)
|
|
31
|
+
.innerJoinAndSelect('worksheets', 'ws2', `ws2.task_no = ws.task_no AND ws2.type = 'SORTING'`)
|
|
32
|
+
.innerJoinAndSelect('releaseGood.bizplace', 'bizplace')
|
|
33
|
+
.innerJoinAndSelect('bizplace.domain', 'domain')
|
|
34
|
+
.where('orderInventory.domain_id = :domainId', { domainId: domain.id })
|
|
35
|
+
.andWhere('orderInventory.status IN (:...orderInventoryStatus)', {
|
|
36
|
+
orderInventoryStatus: [ORDER_INVENTORY_STATUS.SORTING]
|
|
37
|
+
})
|
|
38
|
+
.andWhere('orderInventory.bin_location_id = :locationId', { locationId: binLocation.id })
|
|
39
|
+
.andWhere('releaseGood.status = :status', { status: ORDER_STATUS.SORTING })
|
|
40
|
+
|
|
41
|
+
const orderInventoryByBin = await qb.getRawOne()
|
|
42
|
+
if (orderInventoryByBin?.releaseGood_id) {
|
|
43
|
+
taskNo = orderInventoryByBin.ws_task_no
|
|
44
|
+
task = await tx.getRepository(WorksheetEntity).findOne({
|
|
45
|
+
where: { taskNo, status: WORKSHEET_STATUS.EXECUTING, type: WORKSHEET_TYPE.SORTING }
|
|
46
|
+
})
|
|
47
|
+
} else {
|
|
48
|
+
throw new Error(`Bin do not have any batch picking order.`)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
19
52
|
if (!task) throw new Error('Unable to find task no.')
|
|
20
53
|
|
|
21
54
|
const qb: SelectQueryBuilder<WorksheetEntity> = tx
|
|
@@ -38,6 +71,6 @@ export const findReleaseOrdersByTaskNoResolver = {
|
|
|
38
71
|
.addGroupBy('rg.status')
|
|
39
72
|
|
|
40
73
|
const releaseGoods: ReleaseGoodEntity[] = await qb.getRawMany()
|
|
41
|
-
return releaseGoods
|
|
74
|
+
return { releaseGoods, taskNo }
|
|
42
75
|
}
|
|
43
76
|
}
|
package/server/graphql/resolvers/worksheet/generate-worksheet/generate-arrival-notice-worksheet.ts
CHANGED
|
@@ -8,34 +8,44 @@ import { Worksheet } from '../../../../entities'
|
|
|
8
8
|
export const generateArrivalNoticeWorksheetResolver = {
|
|
9
9
|
async generateArrivalNoticeWorksheet(_: any, { arrivalNoticeNo, bufferLocation }, context: any) {
|
|
10
10
|
const { tx, domain, user }: { tx: EntityManager; domain: Domain; user: User } = context.state
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const releaseGoodNo: string = arrivalNotice.releaseGood.name
|
|
29
|
-
const pickingWSCtrl: PickingWorksheetController = new PickingWorksheetController(tx, domain, user)
|
|
30
|
-
await pickingWSCtrl.generatePickingWorksheet(releaseGoodNo)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const vasWorksheet: Worksheet = await tx.getRepository(Worksheet).findOne({
|
|
34
|
-
where: { domain: domain, arrivalNotice }
|
|
11
|
+
return await generateArrivalNoticeWorksheet(tx, domain, user, arrivalNoticeNo, bufferLocation)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function generateArrivalNoticeWorksheet(
|
|
16
|
+
tx: EntityManager,
|
|
17
|
+
domain: Domain,
|
|
18
|
+
user: User,
|
|
19
|
+
arrivalNoticeNo: string,
|
|
20
|
+
bufferLocation: { id: string }
|
|
21
|
+
) {
|
|
22
|
+
let unloadingWorksheet = await generateUnloadingWorksheet(tx, domain, user, arrivalNoticeNo, bufferLocation)
|
|
23
|
+
|
|
24
|
+
if (!unloadingWorksheet.arrivalNotice?.id) {
|
|
25
|
+
unloadingWorksheet = await tx.getRepository(Worksheet).findOne({
|
|
26
|
+
where: unloadingWorksheet,
|
|
27
|
+
relations: ['arrivalNotice']
|
|
35
28
|
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let arrivalNotice: ArrivalNotice = unloadingWorksheet.arrivalNotice
|
|
32
|
+
const crossDocking: boolean = unloadingWorksheet.arrivalNotice.crossDocking
|
|
36
33
|
|
|
37
|
-
|
|
34
|
+
if (crossDocking) {
|
|
35
|
+
arrivalNotice = await tx
|
|
36
|
+
.getRepository(ArrivalNotice)
|
|
37
|
+
.findOne({ where: { domain: domain, name: arrivalNoticeNo }, relations: ['releaseGood'] })
|
|
38
|
+
|
|
39
|
+
const releaseGoodNo: string = arrivalNotice.releaseGood.name
|
|
40
|
+
const pickingWSCtrl: PickingWorksheetController = new PickingWorksheetController(tx, domain, user)
|
|
41
|
+
await pickingWSCtrl.generatePickingWorksheet(releaseGoodNo)
|
|
38
42
|
}
|
|
43
|
+
|
|
44
|
+
const vasWorksheet: Worksheet = await tx.getRepository(Worksheet).findOne({
|
|
45
|
+
where: { domain: domain, arrivalNotice }
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
return { unloadingWorksheet, vasWorksheet }
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
async function generateUnloadingWorksheet(
|
|
@@ -22,6 +22,7 @@ import { Mutations as PackingMutations } from './packing'
|
|
|
22
22
|
import { packingWorksheetResolver } from './packing-worksheet'
|
|
23
23
|
import { palletizingPallets } from './palletizing-pallets'
|
|
24
24
|
import { pendingCancellationReleaseOrder } from './pending-cancellation-release-order'
|
|
25
|
+
import { cancelDraftReleaseOrder } from './cancel-draft-release-order'
|
|
25
26
|
import { Mutations as PickingMutations } from './picking'
|
|
26
27
|
import { pickingWorksheetResolver } from './picking-worksheet'
|
|
27
28
|
import { myPickingAssignmentStatusResolver } from './picking/my-picking-assignment-status'
|
|
@@ -132,5 +133,6 @@ export const Mutation = {
|
|
|
132
133
|
...crossDockPickingResolver,
|
|
133
134
|
...unpackingResolver,
|
|
134
135
|
...palletizingPallets,
|
|
135
|
-
...fetchSellercraftAirwayBillResolver
|
|
136
|
+
...fetchSellercraftAirwayBillResolver,
|
|
137
|
+
...cancelDraftReleaseOrder
|
|
136
138
|
}
|
|
@@ -78,6 +78,8 @@ export const inventoriesByPalletResolver = {
|
|
|
78
78
|
locationSortingRules.forEach((rule: { name: string; desc: boolean }) => {
|
|
79
79
|
qb.addOrderBy(`location.${rule.name}`, rule.desc ? 'DESC' : 'ASC')
|
|
80
80
|
})
|
|
81
|
+
} else {
|
|
82
|
+
qb.addOrderBy('location.name', 'DESC')
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
if (productFilters && productFilters.length > 0) {
|