From 8ea940cb123fd2f7b71f1ed3126a01e9d19dc387 Mon Sep 17 00:00:00 2001 From: kelvinsuen Date: Thu, 25 Sep 2025 12:58:35 +0800 Subject: [PATCH] update stock in --- .../mail/service/MailTemplateService.kt | 8 +- .../service/PurchaseOrderService.kt | 2 +- .../modules/stock/entity/EscalationLogInfo.kt | 4 +- .../modules/stock/entity/StockInRepository.kt | 1 + .../entity/projection/StockInLineInfo.kt | 2 +- .../stock/service/StockInLineService.kt | 249 +++++++----------- .../modules/stock/service/StockInService.kt | 47 ++-- .../stock/web/model/SaveStockInRequest.kt | 14 +- 8 files changed, 135 insertions(+), 192 deletions(-) diff --git a/src/main/java/com/ffii/fpsms/modules/common/mail/service/MailTemplateService.kt b/src/main/java/com/ffii/fpsms/modules/common/mail/service/MailTemplateService.kt index 3261d7a..569b4e6 100644 --- a/src/main/java/com/ffii/fpsms/modules/common/mail/service/MailTemplateService.kt +++ b/src/main/java/com/ffii/fpsms/modules/common/mail/service/MailTemplateService.kt @@ -93,7 +93,7 @@ open class MailTemplateService( val supplierEmail: String = "", val supplierName: String = "", val dnNo: String = "", - val dnDate: String = "", + val receiptDate: String = "", val poNo: String = "", val supplierId: String = "", val itemNo: String = "", @@ -115,7 +115,7 @@ open class MailTemplateService( val args = mapOf( "\${supplierName}" to supplierName, "\${dnNo}" to dnNo, - "\${dnDate}" to dnDate, + "\${receiptDate}" to receiptDate, "\${poNo}" to poNo, "\${supplierId}" to supplierId, "\${itemNo}" to itemNo, @@ -149,7 +149,7 @@ open class MailTemplateService( val supplierName = po?.supplier?.name ?: "N/A" val supplierEmail = (if((po?.supplier?.contactEmail).isNullOrEmpty()) "N/A" else po?.supplier?.contactEmail) ?: "N/A" val dnNo = stockInLine.dnNo ?: "N/A" - val dnDate = formatter.format(stockInLine.dnDate) ?: "N/A" + val receiptDate = formatter.format(stockInLine.receiptDate) ?: "N/A" val poNo = po?.code ?: "N/A" val supplierId = po?.supplier?.code ?: "N/A" // Id? val itemNo = item?.code ?: "N/A" @@ -193,7 +193,7 @@ open class MailTemplateService( supplierEmail = supplierEmail, supplierName = supplierName, dnNo = dnNo, - dnDate = dnDate, + receiptDate = receiptDate, poNo = poNo, supplierId = supplierId, itemNo = itemNo, diff --git a/src/main/java/com/ffii/fpsms/modules/purchaseOrder/service/PurchaseOrderService.kt b/src/main/java/com/ffii/fpsms/modules/purchaseOrder/service/PurchaseOrderService.kt index 0139da3..309cf79 100644 --- a/src/main/java/com/ffii/fpsms/modules/purchaseOrder/service/PurchaseOrderService.kt +++ b/src/main/java/com/ffii/fpsms/modules/purchaseOrder/service/PurchaseOrderService.kt @@ -209,7 +209,7 @@ open class PurchaseOrderService( } val mappedPoLine = pol.map { thisPol -> val inLine = stockInLine.filter { it.purchaseOrderLineId == thisPol.id } - .filter { it.dnDate != null } + .filter { it.receiptDate != null } val categoryCode = thisPol.item?.qcCategory?.code val qcItems = thisPol.item?.qcCategory?.qcItemCategory?.map { QcForPoLine( diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt index 90dc59f..05d85f5 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/EscalationLogInfo.kt @@ -25,8 +25,8 @@ interface EscalationLogInfo { @get:Value("#{target.stockInLine?.dnNo}") val dnNo: String? - @get:Value("#{target.stockInLine?.dnDate}") - val dnDate: LocalDateTime? +// @get:Value("#{target.stockInLine?.dnDate}") +// val dnDate: LocalDateTime? @get:Value("#{target.stockInLine?.item?.code} - #{target.stockInLine?.item?.name}") val item: String? diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInRepository.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInRepository.kt index 14e4038..6ed6d2d 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInRepository.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInRepository.kt @@ -7,6 +7,7 @@ import java.io.Serializable @Repository interface StockInRepository : AbstractRepository { + fun findByIdAndDeletedFalse(id: Long): StockIn? fun findByPurchaseOrderIdAndDeletedFalse(purchaseOrderId: Long): StockIn? // @Query(""" diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/projection/StockInLineInfo.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/projection/StockInLineInfo.kt index 40c6205..a45bc51 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/entity/projection/StockInLineInfo.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/projection/StockInLineInfo.kt @@ -43,7 +43,7 @@ interface StockInLineInfo { @get:Value("#{target.item?.type}") val itemType: String val dnNo: String - val dnDate: LocalDateTime? +// val dnDate: LocalDateTime? // val qcDecision: LocalDateTime? @get:Value("#{target.escalationLog.^[status.value == 'pending']?.handler?.id}") val handlerId: Long? 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 6303b59..f40f1d7 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 @@ -26,6 +26,8 @@ import com.ffii.core.utils.ZebraPrinterUtil import com.ffii.fpsms.modules.master.entity.ItemUomRespository import com.ffii.fpsms.modules.master.entity.WarehouseRepository import com.ffii.fpsms.modules.master.service.PrinterService +import com.ffii.fpsms.modules.purchaseOrder.entity.PurchaseOrder +import com.ffii.fpsms.modules.purchaseOrder.entity.PurchaseOrderLine import com.ffii.fpsms.modules.purchaseOrder.entity.PurchaseOrderRepository import com.ffii.fpsms.modules.purchaseOrder.enums.PurchaseOrderLineStatus import com.ffii.fpsms.modules.purchaseOrder.enums.PurchaseOrderStatus @@ -50,7 +52,7 @@ data class QrContent(val itemId: Long, val stockInLineId: Long) @Service open class StockInLineService( private val jdbcDao: JdbcDao, - private val purchaseOrderRepository: PurchaseOrderRepository, + private val poRepository: PurchaseOrderRepository, private val polRepository: PurchaseOrderLineRepository, private val qcItemsRepository: QcItemRepository, private val qcResultRepository: QcResultRepository, @@ -78,50 +80,74 @@ open class StockInLineService( @Transactional open fun create(request: SaveStockInLineRequest): MessageResponse { val stockInLine = StockInLine() - val item = itemRepository.findById(request.itemId).orElseThrow() - val purchaseOrderLine = request.purchaseOrderLineId?.let { polRepository.findById(it).getOrNull() } - val stockTakeLine = request.stockTakeLineId?.let { stockTakeLineRepository.findById(it).getOrNull() } - var stockIn = request.stockInId?.let { stockInRepository.findByIdAndDeletedIsFalse(it) } - ?: request.purchaseOrderId?.let { stockInRepository.findByPurchaseOrderIdAndDeletedFalse(it) } - ?: request.stockTakeId?.let { stockInRepository.findByStockTakeIdAndDeletedFalse(it) } - purchaseOrderLine?.apply { - status = PurchaseOrderLineStatus.RECEIVING - } - val pol = purchaseOrderLine?.let { polRepository.saveAndFlush(it) } + val pol = if (request.purchaseOrderLineId != null) + request.purchaseOrderLineId?.let { polRepository.findById(it).orElseThrow() } + else null + val stl = if (request.stockTakeId != null) + request.stockTakeId?.let { stockTakeLineRepository.findById(it).getOrNull() } + else null + + var stockIn = if (request.stockInId != null) request.stockInId?.let { stockInRepository.findByIdAndDeletedFalse(it) } + else if (pol != null) pol.purchaseOrder?.id?.let { stockInRepository.findByPurchaseOrderIdAndDeletedFalse(it) } + else if (request.stockTakeId != null) request.stockTakeId?.let { stockInRepository.findByStockTakeIdAndDeletedFalse(it) } + else null + if (stockIn == null) { - stockIn = stockInService.create(SaveStockInRequest(purchaseOrderId = request.purchaseOrderId)).entity as StockIn + stockIn = stockInService.create(SaveStockInRequest(purchaseOrderId = pol?.purchaseOrder?.id)).entity as StockIn +// stockIn = stockInService.create(SaveStockInRequest(purchaseOrderId = request.purchaseOrderId)).entity as StockIn +// var stockIn = stockInRepository.findByPurchaseOrderIdAndDeletedFalse(request.purchaseOrderId) + } + val item = itemRepository.findById(request.itemId).orElseThrow() + // If request contains valid POL + if (pol != null) { + val po = pol.purchaseOrder; + pol.apply { + status = PurchaseOrderLineStatus.RECEIVING + } + val savedPol = polRepository.saveAndFlush(pol) + stockInLine.apply { + this.purchaseOrderLine = savedPol + } + // update po status to receiving - val po = request.purchaseOrderId?.let { purchaseOrderRepository.findById(it).getOrNull() } if (po != null) { po.apply { status = PurchaseOrderStatus.RECEIVING } - purchaseOrderRepository.save(po) + val savedPo = poRepository.save(po) + stockInLine.apply { + this.purchaseOrder = savedPo + } } } - val allStockInLine = stockInLineRepository.findAllStockInLineInfoByStockInIdAndDeletedFalse(stockIn.id!!) - if (pol != null && pol.qty!! < request.acceptedQty) { - throw BadRequestException() + + // If request contains valid stock take id + if (stl != null) { + stockInLine.apply { + this.stockTakeLine = stl + } } + +// val allStockInLine = stockInLineRepository.findAllStockInLineInfoByStockInIdAndDeletedFalse(stockIn.id!!) +// if (pol.qty!! < request.acceptedQty) { +// throw BadRequestException() +// } stockInLine.apply { this.item = item itemNo = item.code - this.purchaseOrder = purchaseOrderLine?.purchaseOrder - this.purchaseOrderLine = purchaseOrderLine - this.stockTakeLine = stockTakeLine this.stockIn = stockIn acceptedQty = request.acceptedQty dnNo = request.dnNo - dnDate = request.dnDate?.atStartOfDay() + receiptDate = request.receiptDate?.atStartOfDay() ?: LocalDateTime.now() productLotNo = request.productLotNo status = StockInLineStatus.PENDING.status } - val savedInLine = saveAndFlush(stockInLine) - val lineInfo = stockInLineRepository.findStockInLineInfoByIdAndDeletedFalse(savedInLine.id!!) + val savedSIL = saveAndFlush(stockInLine) + val lineInfo = stockInLineRepository.findStockInLineInfoByIdAndDeletedFalse(savedSIL.id!!) return MessageResponse( - id = savedInLine.id, - code = savedInLine.itemNo, - name = savedInLine.item!!.name, + id = savedSIL.id, + code = savedSIL.itemNo, + name = savedSIL.item!!.name, type = "stock in line created: status = pending", message = "save success", errorPosition = null, @@ -274,76 +300,50 @@ open class StockInLineService( @Throws(IOException::class) @Transactional - open fun updatePurchaseOrderStatus(request: SaveStockInLineRequest) { - if (request.status == StockInLineStatus.COMPLETE.status) { - val unfinishedLines = request.purchaseOrderId?.let { polRepository - .findAllByPurchaseOrderIdAndStatusNotAndDeletedIsFalse(purchaseOrderId = it, status = PurchaseOrderLineStatus.COMPLETED) } - if (unfinishedLines != null && unfinishedLines.isEmpty()) { - val po = purchaseOrderRepository.findById(request.purchaseOrderId).orElseThrow() - po.apply { - status = PurchaseOrderStatus.COMPLETED - } - purchaseOrderRepository.saveAndFlush(po) - } else { - + open fun updatePurchaseOrderStatus(po : PurchaseOrder) { + val unfinishedPol = polRepository + .findAllByPurchaseOrderIdAndStatusNotAndDeletedIsFalse(po.id!!, + PurchaseOrderLineStatus.COMPLETED) + // If all POL is completed + if (unfinishedPol.isEmpty()) { + po.apply { + status = PurchaseOrderStatus.COMPLETED } + poRepository.saveAndFlush(po) + } else { + } } @Throws(IOException::class) @Transactional - fun updatePurchaseOrderLineStatus(request: SaveStockInLineRequest) { - println(request.status) - if (request.status == StockInLineStatus.RECEIVING.status) { - val unQcedLines = request.purchaseOrderLineId?.let { stockInLineRepository.findStockInLineInfoByPurchaseOrderLineIdAndDeletedFalse(purchaseOrderLineId = it) } - ?.filter { - it.status != StockInLineStatus.RECEIVING.status - && it.status != StockInLineStatus.RECEIVED.status - && it.status != StockInLineStatus.COMPLETE.status - && it.status != StockInLineStatus.REJECT.status - } - if (unQcedLines != null && unQcedLines.isEmpty()) { - // all stock in lines finished - // change status of purchase order line - val purchaseOrderLine = request.purchaseOrderLineId?.let { polRepository.findById(it).orElseThrow() } - if (purchaseOrderLine != null) { - purchaseOrderLine.apply { + fun updatePurchaseOrderLineStatus(pol: PurchaseOrderLine) { + val stockInLines = stockInLineRepository.findStockInLineInfoByPurchaseOrderLineIdAndDeletedFalse(pol.id!!) + val qcLines = stockInLines.filter { it.status == StockInLineStatus.PENDING.status + || it.status == StockInLineStatus.ESCALATED.status } + val receivingLines = stockInLines.filter { it.status == StockInLineStatus.RECEIVED.status + || it.status == StockInLineStatus.RECEIVING.status } + // TODO: also check the qty + if (stockInLines.isEmpty()) { // No Stock In Line + pol.apply { status = PurchaseOrderLineStatus.PENDING } + } else { + if (qcLines.isEmpty()) { // No pending QC lines + if (receivingLines.isEmpty()) { // No receiving lines + pol.apply { + status = PurchaseOrderLineStatus.COMPLETED + } + } else { // Only remain receiving lines + pol.apply { status = PurchaseOrderLineStatus.RECEIVING } - polRepository.saveAndFlush(purchaseOrderLine) } } else { - // still have unQcedLines lines - } - } - if (request.status == StockInLineStatus.COMPLETE.status || request.status == StockInLineStatus.REJECT.status) { -// val unfinishedLines = stockInLineRepository.findStockInLineInfoByPurchaseOrderLineIdAndStatusNotAndDeletedFalse(purchaseOrderLineId = request.purchaseOrderLineId, status = request.status!!) - val unfinishedLines = request.purchaseOrderLineId?.let { - stockInLineRepository.findStockInLineInfoByPurchaseOrderLineIdAndDeletedFalse( - purchaseOrderLineId = it - ) - } - ?.filter { - it.status != StockInLineStatus.COMPLETE.status - && it.status != StockInLineStatus.REJECT.status + // still have pending QC lines + pol.apply { + status = PurchaseOrderLineStatus.RECEIVING } - println("unfinishedLines") - println(unfinishedLines) - if (unfinishedLines != null && unfinishedLines.isEmpty()) { - // all stock in lines finished - // change status of purchase order line - val purchaseOrderLine = request.purchaseOrderLineId?.let { - polRepository.findById(it).orElseThrow() - } - if (purchaseOrderLine != null) { - purchaseOrderLine.apply { - status = PurchaseOrderLineStatus.COMPLETED - } - polRepository.saveAndFlush(purchaseOrderLine) - } - } else { - // still have unfinished lines } } + polRepository.saveAndFlush(pol) } @Throws(IOException::class) @Transactional @@ -370,7 +370,7 @@ open class StockInLineService( this.productionDate = request.productionDate?.atStartOfDay() ?: this.productionDate// maybe need to change the request to LocalDateTime this.productLotNo = request.productLotNo ?: this.productLotNo this.dnNo = request.dnNo ?: this.dnNo - this.dnDate = request.dnDate?.atStartOfDay() ?: this.dnDate +// this.dnDate = request.dnDate?.atStartOfDay() ?: this.dnDate this.acceptedQty = request.acceptedQty this.demandQty = request.acceptQty this.invoiceNo = request.invoiceNo @@ -433,76 +433,6 @@ open class StockInLineService( errorPosition = "request.acceptedQty", ) } - // if (request.acceptedQty.compareTo(stockInLine.acceptedQty) != 0) { - // // Partial Accept - // if (request.acceptedQty <= BigDecimal(0)) { - // return MessageResponse( - // id = null, - // code = null, - // name = null, - // type = "acceptedQty == 0", - // message = "acceptedQty cannot be 0", - // errorPosition = "request.acceptedQty", - // ) - // } - // val newStockInLine = StockInLine() - // newStockInLine.apply { - // this.item = stockInLine.item - // this.itemNo = stockInLine.itemNo - // this.purchaseOrder = stockInLine.purchaseOrderLine?.purchaseOrder - // this.purchaseOrderLine = stockInLine.purchaseOrderLine - // this.productLotNo = stockInLine.productLotNo - // this.dnNo = stockInLine.dnNo - // this.invoiceNo = stockInLine.invoiceNo - // this.remarks = stockInLine.remarks ?: request.remarks - // this.receiptDate = stockInLine.receiptDate - // this.stockIn = stockInLine.stockIn - // this.demandQty = stockInLine.demandQty - // this.acceptedQty = stockInLine.acceptedQty!!.minus(request.acceptedQty) - // this.price = stockInLine.price - // this.priceUnit = stockInLine.priceUnit - // this.inventoryLot = stockInLine.inventoryLot - // this.lotNo = stockInLine.lotNo - // this.productionDate = stockInLine.productionDate - // this.expiryDate = stockInLine.expiryDate - // this.status = StockInLineStatus.RECEIVING.status// stockInLine.status // this does update status - // this.user = stockInLine.user - // } - // saveQcResultWhenStockIn(request, stockInLine) - // var savedInventoryLot: InventoryLot? = null - // var savedInventoryLotLine: InventoryLotLine? = null // maybe remove this later - // if (request.status == StockInLineStatus.RECEIVED.status) { - // savedInventoryLot = saveInventoryLotWhenStockIn(request = request, stockInLine = stockInLine) - // } - // if (request.status == StockInLineStatus.COMPLETE.status) { - // savedInventoryLotLine = - // saveInventoryLotLineWhenStockIn(request = request, stockInLine = stockInLine) - // } - // stockInLine.apply { - // this.acceptedQty = request.acceptedQty - // this.status = StockInLineStatus.RECEIVED.status//request.status - // this.inventoryLot = savedInventoryLot ?: stockInLine.inventoryLot - // this.inventoryLotLine = savedInventoryLotLine - // this.lotNo = savedInventoryLot?.lotNo ?: stockInLine.lotNo - // } - // - // val stockInLineEntries = listOf(stockInLine, newStockInLine) - // val savedEntries = stockInLineRepository.saveAllAndFlush(stockInLineEntries) - // val ids = savedEntries.map { it.id!! } - // val lineInfoList = stockInLineRepository.findStockInLineInfoByIdInAndDeletedFalse(ids) - // // check if all line completed - // updatePurchaseOrderLineStatus(request) - // - // return MessageResponse( - // id = stockInLine.id, - // code = null, - // name = null, - // type = "Save success", - // message = "created 2 stock in line", - // errorPosition = null, - // entity = lineInfoList - // ) - // } } else if (request.qcAccept == false) { if (request.escalationLog != null) { // Escalated @@ -522,7 +452,14 @@ open class StockInLineService( } val savedStockInLine = saveAndFlush(stockInLine) // check if all line completed - updatePurchaseOrderLineStatus(request) + if (savedStockInLine.purchaseOrderLine != null) { + val pol = savedStockInLine.purchaseOrderLine + if (pol != null) { + updatePurchaseOrderLineStatus(pol) + updatePurchaseOrderStatus(pol.purchaseOrder!!) + } + } + val lineInfo = stockInLineRepository.findStockInLineInfoByIdAndDeletedFalse(savedStockInLine.id!!) return MessageResponse( diff --git a/src/main/java/com/ffii/fpsms/modules/stock/service/StockInService.kt b/src/main/java/com/ffii/fpsms/modules/stock/service/StockInService.kt index 6f25892..083e632 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/service/StockInService.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/service/StockInService.kt @@ -3,6 +3,7 @@ package com.ffii.fpsms.modules.stock.service import com.ffii.core.support.AbstractBaseEntityService import com.ffii.core.support.JdbcDao import com.ffii.fpsms.modules.master.web.models.MessageResponse +import com.ffii.fpsms.modules.purchaseOrder.entity.PurchaseOrder import com.ffii.fpsms.modules.purchaseOrder.entity.PurchaseOrderRepository import com.ffii.fpsms.modules.stock.entity.* import com.ffii.fpsms.modules.stock.web.model.SaveStockInRequest @@ -11,6 +12,9 @@ import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import java.io.IOException import kotlin.jvm.optionals.getOrNull +import java.time.LocalDate +import java.time.LocalDateTime +import java.util.* @Service open class StockInService( @@ -18,35 +22,36 @@ open class StockInService( private val stockInRepository: StockInRepository, private val purchaseOrderRepository: PurchaseOrderRepository, private val stockTakeRepository: StockTakeRepository, - ): AbstractBaseEntityService(jdbcDao, stockInRepository) { +): AbstractBaseEntityService(jdbcDao, stockInRepository) { @Throws(IOException::class) @Transactional open fun create(request: SaveStockInRequest): MessageResponse { val stockIn = StockIn() -// val purchaseOrder = if (request.purchaseOrderId != null) -// purchaseOrderRepository.findByIdAndDeletedFalse(request.purchaseOrderId).orElseThrow() -// else return MessageResponse( -// id = null, -// code = null, -// name = null, -// type = "Found Null", -// message = "request.purchaseOrderId is null", -// errorPosition = "Stock In" -// ) - val purchaseOrder = request.purchaseOrderId?.let { purchaseOrderRepository.findByIdAndDeletedFalse(request.purchaseOrderId).getOrNull() } - val stockTake = request.stockTakeId?.let { stockTakeRepository.findByIdAndDeletedIsFalse(it) } stockIn.apply { - code = request.code ?: purchaseOrder?.code - supplier = purchaseOrder?.supplier - this.purchaseOrder = purchaseOrder - this.stockTake = stockTake -// shop = purchaseOrder.shop - orderDate = purchaseOrder?.orderDate - estimatedCompleteDate = purchaseOrder?.estimatedArrivalDate?.toLocalDate() - completeDate = purchaseOrder?.completeDate status = StockInStatus.PENDING.status + orderDate = LocalDateTime.now() + code = LocalDateTime.now().toString().take(19) } + if (request.purchaseOrderId != null) { + val purchaseOrder : PurchaseOrder = purchaseOrderRepository.findByIdAndDeletedFalse(request.purchaseOrderId).orElseThrow(); + stockIn.apply { + code = purchaseOrder.code + supplier = purchaseOrder.supplier + this.purchaseOrder = purchaseOrder + // shop = purchaseOrder.shop + orderDate = purchaseOrder.orderDate + estimatedCompleteDate = purchaseOrder.estimatedArrivalDate?.toLocalDate() + completeDate = purchaseOrder.completeDate + } + } + if (request.stockTakeId != null) { + val stockTake = request.stockTakeId.let { stockTakeRepository.findByIdAndDeletedIsFalse(it) } + stockIn.apply { + this.stockTake = stockTake + } + } + val savedStockIn = saveAndFlush(stockIn) return MessageResponse( id = savedStockIn.id, diff --git a/src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveStockInRequest.kt b/src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveStockInRequest.kt index 172458b..4ba6bd4 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveStockInRequest.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/web/model/SaveStockInRequest.kt @@ -39,9 +39,12 @@ data class SaveStockInRequest( data class SaveStockInLineRequest( var id: Long? = null, + var stockInId: Long? = null, + var stockTakeId: Long? = null, + var stockTakeLineId: Long? = null, + var itemId: Long, var purchaseOrderId: Long? = null, var purchaseOrderLineId: Long? = null, - var itemId: Long, var acceptedQty: BigDecimal, var acceptQty: BigDecimal?, var acceptedWeight: BigDecimal? = null, @@ -51,18 +54,15 @@ data class SaveStockInLineRequest( var dnNo: String? = null, var invoiceNo: String? = null, var remarks: String? = null, - var dnDate: LocalDate? = null, +// var dnDate: LocalDate? = null, var receiptDate: LocalDate? = null, var productionDate: LocalDate? = null, var qcAccept: Boolean? = null, var qcResult: List? = null, var escalationLog: SaveEscalationLogRequest? = null, - var warehouseId: Long?, + var warehouseId: Long? = null, var rejectQty: BigDecimal? = null, - var inventoryLotLines: List? = null, - var stockTakeLineId: Long? = null, - var stockTakeId: Long? = null, - var stockInId: Long? = null, + var inventoryLotLines: List? = null ) data class SaveInventoryLotLineForSil (