@things-factory/worksheet-base 4.3.824 → 4.3.827
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 +53 -84
- package/dist-server/controllers/outbound/picking-worksheet-controller.js.map +1 -1
- package/dist-server/entities/warehouse-bizplace-onhand-inventory.js +2 -2
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js +1 -1
- package/dist-server/graphql/resolvers/worksheet/confirm-cancellation-release-order.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js +1 -1
- package/dist-server/graphql/resolvers/worksheet/inventories-by-pallet.js.map +1 -1
- package/dist-server/graphql/resolvers/worksheet/recommend-putaway-location.js +94 -4
- package/dist-server/graphql/resolvers/worksheet/recommend-putaway-location.js.map +1 -1
- package/package.json +4 -4
- package/server/controllers/outbound/picking-worksheet-controller.ts +77 -94
- package/server/entities/warehouse-bizplace-onhand-inventory.ts +2 -2
- package/server/graphql/resolvers/worksheet/confirm-cancellation-release-order.ts +1 -1
- package/server/graphql/resolvers/worksheet/inventories-by-pallet.ts +1 -1
- package/server/graphql/resolvers/worksheet/recommend-putaway-location.ts +110 -4
|
@@ -865,8 +865,6 @@ class PickingWorksheetController extends vas_worksheet_controller_1.VasWorksheet
|
|
|
865
865
|
if (toteNo) {
|
|
866
866
|
await this.toteScanning(toteNo, targetProduct, targetInventory, pickedQty, releaseGood, bizplace);
|
|
867
867
|
}
|
|
868
|
-
// temporarily override with separate logic to handle transaction to speed up function
|
|
869
|
-
// await this.updatePickingTransaction(releaseGood, targetInventory, worksheetDetail, inventory, pickedQty)
|
|
870
868
|
const releaseQty = targetInventory.releaseQty;
|
|
871
869
|
targetInventory.pickedQty = ((targetInventory === null || targetInventory === void 0 ? void 0 : targetInventory.pickedQty) || 0) + pickedQty;
|
|
872
870
|
let updateOiObj = {
|
|
@@ -891,62 +889,55 @@ class PickingWorksheetController extends vas_worksheet_controller_1.VasWorksheet
|
|
|
891
889
|
.andWhere(`picked_qty + :pickedQty <= release_qty`, { pickedQty })
|
|
892
890
|
.execute();
|
|
893
891
|
if (oiUpdateResult.affected > 0 && targetInventory.pickedQty == releaseQty) {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
await tx.getRepository(warehouse_base_1.InventoryItem).save(inventoryItems);
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
catch (error) {
|
|
947
|
-
throw error;
|
|
948
|
-
}
|
|
949
|
-
});
|
|
892
|
+
//update worksheet details only when line item picking complete
|
|
893
|
+
await this.trxMgr
|
|
894
|
+
.getRepository(entities_1.WorksheetDetail)
|
|
895
|
+
.createQueryBuilder()
|
|
896
|
+
.update(entities_1.WorksheetDetail)
|
|
897
|
+
.set({
|
|
898
|
+
status: constants_1.WORKSHEET_STATUS.DONE,
|
|
899
|
+
updater: this.user,
|
|
900
|
+
updatedAt: new Date()
|
|
901
|
+
})
|
|
902
|
+
.where('id = :id', { id: worksheetDetailInfos.worksheetDetailId })
|
|
903
|
+
.execute();
|
|
904
|
+
let releaseUomValue = Math.trunc((pickedUomValue / pickedQty) * releaseQty * 1000) / 1000;
|
|
905
|
+
let updateInvObj = {
|
|
906
|
+
qty: () => `"qty" - :deductQty::numeric`,
|
|
907
|
+
lockedQty: () => `GREATEST("locked_qty" - :deductQty::numeric, 0)`,
|
|
908
|
+
uomValue: () => `"uom_value" - :deductUomValue::numeric`,
|
|
909
|
+
lockedUomValue: () => `GREATEST("locked_uom_value" - :deductUomValue::numeric, 0)`,
|
|
910
|
+
status: () => `case when "qty" - :deductQty::numeric <= 0 then '${warehouse_base_1.INVENTORY_STATUS.TERMINATED}' else status end`,
|
|
911
|
+
updater: this.user,
|
|
912
|
+
updatedAt: new Date()
|
|
913
|
+
};
|
|
914
|
+
const invUpdateResult = await this.trxMgr
|
|
915
|
+
.getRepository(warehouse_base_1.Inventory)
|
|
916
|
+
.createQueryBuilder()
|
|
917
|
+
.update(warehouse_base_1.Inventory)
|
|
918
|
+
.set(updateInvObj)
|
|
919
|
+
.setParameter('deductQty', releaseQty)
|
|
920
|
+
.setParameter('deductUomValue', releaseUomValue)
|
|
921
|
+
.where('id = :id AND qty >= :deductQty', {
|
|
922
|
+
id: worksheetDetailInfos.inventoryId,
|
|
923
|
+
deductQty: releaseQty
|
|
924
|
+
})
|
|
925
|
+
.returning(['qty'])
|
|
926
|
+
.execute();
|
|
927
|
+
if (invUpdateResult.affected === 0) {
|
|
928
|
+
throw new Error(`Insufficient inventory quantity to complete picking`);
|
|
929
|
+
}
|
|
930
|
+
await (0, warehouse_base_1.generateInventoryHistory)(inventory, releaseGood, warehouse_base_1.INVENTORY_TRANSACTION_TYPE.PICKING, -releaseQty, -releaseUomValue, this.user, this.trxMgr);
|
|
931
|
+
let inventoryItems = await this.trxMgr
|
|
932
|
+
.getRepository(warehouse_base_1.InventoryItem)
|
|
933
|
+
.find({ where: { outboundOrderId: worksheetDetailInfos.releaseGoodId } });
|
|
934
|
+
if (inventoryItems.length > 0) {
|
|
935
|
+
inventoryItems.forEach((itm) => {
|
|
936
|
+
itm.status = warehouse_base_1.INVENTORY_STATUS.PICKED;
|
|
937
|
+
itm.updater = this.user;
|
|
938
|
+
});
|
|
939
|
+
await this.trxMgr.getRepository(warehouse_base_1.InventoryItem).save(inventoryItems);
|
|
940
|
+
}
|
|
950
941
|
}
|
|
951
942
|
let worksheetDetail = await this.trxMgr
|
|
952
943
|
.getRepository(entities_1.WorksheetDetail)
|
|
@@ -1993,7 +1984,7 @@ class PickingWorksheetController extends vas_worksheet_controller_1.VasWorksheet
|
|
|
1993
1984
|
}
|
|
1994
1985
|
}
|
|
1995
1986
|
async assignInventoriesForUnassignedOrder(worksheet, tx) {
|
|
1996
|
-
var _a;
|
|
1987
|
+
var _a, _b, _c;
|
|
1997
1988
|
const releaseGood = worksheet.releaseGood;
|
|
1998
1989
|
const orderProducts = releaseGood.orderProducts;
|
|
1999
1990
|
let finalOrderInventories = [];
|
|
@@ -2045,18 +2036,7 @@ class PickingWorksheetController extends vas_worksheet_controller_1.VasWorksheet
|
|
|
2045
2036
|
if (lockResult.affected === 0) {
|
|
2046
2037
|
throw new Error(`Insufficient inventory for picking assignment`);
|
|
2047
2038
|
}
|
|
2048
|
-
await transaction
|
|
2049
|
-
.getRepository(warehouse_base_1.ProductDetailStock)
|
|
2050
|
-
.createQueryBuilder()
|
|
2051
|
-
.update(warehouse_base_1.ProductDetailStock)
|
|
2052
|
-
.set({
|
|
2053
|
-
unassignedQty: () => `GREATEST("unassigned_qty" - :oiReleaseQty::numeric, 0)`,
|
|
2054
|
-
unassignedUomValue: () => `GREATEST("unassigned_uom_value" - :oiReleaseUomValue::numeric, 0)`
|
|
2055
|
-
})
|
|
2056
|
-
.setParameter('oiReleaseQty', oi.releaseQty)
|
|
2057
|
-
.setParameter('oiReleaseUomValue', oi.releaseUomValue)
|
|
2058
|
-
.where({ productDetail: oi.productDetail.id })
|
|
2059
|
-
.execute();
|
|
2039
|
+
await (0, warehouse_base_1.upsertProductDetailStockUnassigned)(transaction, (_b = oi.productDetail) === null || _b === void 0 ? void 0 : _b.id, this.domain.id, (_c = releaseGood.bizplace) === null || _c === void 0 ? void 0 : _c.id, -oi.releaseQty, -oi.releaseUomValue);
|
|
2060
2040
|
const worksheetDetail = Object.assign(new entities_1.WorksheetDetail(), {
|
|
2061
2041
|
domain: this.domain,
|
|
2062
2042
|
bizplace: { id: releaseGood.bizplace.id },
|
|
@@ -2076,7 +2056,7 @@ class PickingWorksheetController extends vas_worksheet_controller_1.VasWorksheet
|
|
|
2076
2056
|
return newWorksheetDetails;
|
|
2077
2057
|
}
|
|
2078
2058
|
async assignInventoriesForUnassignedMergedOrder(worksheet) {
|
|
2079
|
-
var _a, _b, _c;
|
|
2059
|
+
var _a, _b, _c, _d, _e;
|
|
2080
2060
|
//const releaseGood = worksheet.releaseGood
|
|
2081
2061
|
const orderProducts = worksheet.worksheetDetails
|
|
2082
2062
|
.filter(itm => itm.targetProduct.releaseGood.assignedInventory == false)
|
|
@@ -2134,18 +2114,7 @@ class PickingWorksheetController extends vas_worksheet_controller_1.VasWorksheet
|
|
|
2134
2114
|
throw new Error(`Insufficient inventory for picking assignment`);
|
|
2135
2115
|
}
|
|
2136
2116
|
// update product detail stock deduct unassigned qty and unassigned uom value
|
|
2137
|
-
await this.trxMgr
|
|
2138
|
-
.getRepository(warehouse_base_1.ProductDetailStock)
|
|
2139
|
-
.createQueryBuilder()
|
|
2140
|
-
.update(warehouse_base_1.ProductDetailStock)
|
|
2141
|
-
.set({
|
|
2142
|
-
unassignedQty: () => `GREATEST("unassigned_qty" - :deductQty::numeric, 0)`,
|
|
2143
|
-
unassignedUomValue: () => `GREATEST("unassigned_uom_value" - :deductUomValue::numeric, 0)`
|
|
2144
|
-
})
|
|
2145
|
-
.setParameter('deductQty', allocatedQty)
|
|
2146
|
-
.setParameter('deductUomValue', allocatedUomValue)
|
|
2147
|
-
.where({ productDetail: orderProducts[i].productDetail.id })
|
|
2148
|
-
.execute();
|
|
2117
|
+
await (0, warehouse_base_1.upsertProductDetailStockUnassigned)(this.trxMgr, (_d = orderProducts[i].productDetail) === null || _d === void 0 ? void 0 : _d.id, this.domain.id, ((_e = orderProducts[i].bizplace) === null || _e === void 0 ? void 0 : _e.id) || orderProducts[i].bizplaceId, -allocatedQty, -allocatedUomValue);
|
|
2149
2118
|
// update order product status to ASSIGNED
|
|
2150
2119
|
await this.trxMgr
|
|
2151
2120
|
.getRepository(sales_base_1.OrderProduct)
|