From e0125504af8ff6150ce5c5222d8944bc3ccf47ef Mon Sep 17 00:00:00 2001 From: "kelvin.yau" Date: Fri, 19 Dec 2025 18:15:05 +0800 Subject: [PATCH] fix fgstockinlabel --- .../jobOrder/service/JobOrderService.kt | 3 ++- .../master/entity/WarehouseRepository.kt | 2 +- .../modules/master/service/BomService.kt | 4 ++-- .../stock/service/StockInLineService.kt | 22 ++++++++++++++++--- .../FGStockInLabel/FGStockInLabel.jrxml | 6 ++--- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/ffii/fpsms/modules/jobOrder/service/JobOrderService.kt b/src/main/java/com/ffii/fpsms/modules/jobOrder/service/JobOrderService.kt index 5d8c50d..caa5af4 100644 --- a/src/main/java/com/ffii/fpsms/modules/jobOrder/service/JobOrderService.kt +++ b/src/main/java/com/ffii/fpsms/modules/jobOrder/service/JobOrderService.kt @@ -158,6 +158,7 @@ open class JobOrderService( val (sufficientCount, insufficientCount) = if (jobOrder != null) { calculateStockCounts(jobOrder, inventoriesMap) } else { + Pair(null, null) } @@ -688,7 +689,7 @@ open class JobOrderService( params["finishedGoodItemCode"] = stockInLineInfo.itemNo ?: "N/A" params["finishedGoodItemName"] = stockInLineInfo.itemName ?: "N/A" params["finishedGoodLotNo"] = stockInLineInfo.lotNo ?: "N/A" - params["productionQty"] = stockInLineInfo.acceptedQty?.toString() ?: "0" + params["FGStockInQty"] = stockInLineInfo.acceptedQty?.toString() ?: "0" params["productionDate"] = productionDate params["expiryDate"] = expiryDate params["uom"] = uomDesc diff --git a/src/main/java/com/ffii/fpsms/modules/master/entity/WarehouseRepository.kt b/src/main/java/com/ffii/fpsms/modules/master/entity/WarehouseRepository.kt index 5a90967..adfcd0e 100644 --- a/src/main/java/com/ffii/fpsms/modules/master/entity/WarehouseRepository.kt +++ b/src/main/java/com/ffii/fpsms/modules/master/entity/WarehouseRepository.kt @@ -13,5 +13,5 @@ interface WarehouseRepository : AbstractRepository { fun findByIdAndDeletedIsFalse(id: Serializable): Warehouse?; fun findByCodeAndDeletedIsFalse(code: String): Warehouse?; - + } \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/master/service/BomService.kt b/src/main/java/com/ffii/fpsms/modules/master/service/BomService.kt index a590d84..f1827bc 100644 --- a/src/main/java/com/ffii/fpsms/modules/master/service/BomService.kt +++ b/src/main/java/com/ffii/fpsms/modules/master/service/BomService.kt @@ -633,8 +633,8 @@ open class BomService( val resolver = PathMatchingResourcePatternResolver() // val excels = resolver.getResources("bomImport/*.xlsx") //val excels = resolver.getResources("file:C:/Users/Kelvin YAU/Downloads/bom/*.xlsx") - //val excels = resolver.getResources("file:C:/Users/Kelvin YAU/Downloads/bom/*.xlsx") - val excels = resolver.getResources("file:C:/Users/kw093/Downloads/bom/bom/*.xlsx") + val excels = resolver.getResources("file:C:/Users/Kelvin YAU/Downloads/bom/*.xlsx") + //val excels = resolver.getResources("file:C:/Users/kw093/Downloads/bom/bom/*.xlsx") // val excels = resolver.getResources("file:C:/Users/2Fi/Desktop/Third Wave of BOM Excel/*.xlsx") println("size: ${excels.size}") val logExcel = ClassPathResource("excelTemplate/bom_excel_issue_log.xlsx") diff --git a/src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt b/src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt index 084b968..2e124f6 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/service/StockInLineService.kt @@ -158,6 +158,14 @@ open class StockInLineService( itemNo = item.code this.stockIn = stockIn acceptedQty = request.acceptedQty + // Set demandQty based on source + if (jo != null && jo?.bom != null) { + // For job orders, demandQty comes from BOM's outputQty + this.demandQty = jo?.bom?.outputQty + } else if (pol != null) { + // For purchase orders, demandQty comes from PurchaseOrderLine's qty + this.demandQty = pol.qty + } dnNo = request.dnNo receiptDate = request.receiptDate?.atStartOfDay() ?: LocalDateTime.now() productLotNo = request.productLotNo @@ -391,12 +399,20 @@ open class StockInLineService( // TODO: check all status to prevent reverting progress due to multiple users access to the same po? // return list of stock in line, update data grid with the list stockInLine.apply { - this.productionDate = request.productionDate?.atStartOfDay() ?: this.productionDate// maybe need to change the request to LocalDateTime + this.productionDate = request.productionDate?.atStartOfDay() ?: this.productionDate this.productLotNo = request.productLotNo ?: this.productLotNo this.dnNo = request.dnNo ?: this.dnNo // this.dnDate = request.dnDate?.atStartOfDay() ?: this.dnDate - this.acceptedQty = request.acceptedQty - this.demandQty = request.acceptQty + this.acceptedQty = request.acceptQty ?: request.acceptedQty ?: this.acceptedQty + // Set demandQty based on source + if (this.jobOrder != null && this.jobOrder?.bom != null) { + // For job orders, demandQty comes from BOM's outputQty + this.demandQty = this.jobOrder?.bom?.outputQty ?: this.demandQty + } else if (this.purchaseOrderLine != null) { + // For purchase orders, demandQty comes from PurchaseOrderLine's qty + this.demandQty = this.purchaseOrderLine?.qty ?: this.demandQty + } + // Don't overwrite demandQty with acceptQty from QC form this.invoiceNo = request.invoiceNo this.receiptDate = request.receiptDate?.atStartOfDay() ?: this.receiptDate // this.status = request.status diff --git a/src/main/resources/FGStockInLabel/FGStockInLabel.jrxml b/src/main/resources/FGStockInLabel/FGStockInLabel.jrxml index 2566591..3c46650 100644 --- a/src/main/resources/FGStockInLabel/FGStockInLabel.jrxml +++ b/src/main/resources/FGStockInLabel/FGStockInLabel.jrxml @@ -14,7 +14,7 @@ - + @@ -79,7 +79,7 @@ - + @@ -144,7 +144,7 @@ -