|
|
@@ -41,6 +41,7 @@ import kotlinx.serialization.encodeToString |
|
|
import net.sf.jasperreports.engine.JasperExportManager |
|
|
import net.sf.jasperreports.engine.JasperExportManager |
|
|
import net.sf.jasperreports.engine.JasperPrint |
|
|
import net.sf.jasperreports.engine.JasperPrint |
|
|
import java.io.File |
|
|
import java.io.File |
|
|
|
|
|
import kotlin.jvm.optionals.getOrNull |
|
|
import kotlin.math.max |
|
|
import kotlin.math.max |
|
|
|
|
|
|
|
|
@Serializable |
|
|
@Serializable |
|
|
@@ -196,11 +197,13 @@ open class StockInLineService( |
|
|
|
|
|
|
|
|
@Throws(IOException::class) |
|
|
@Throws(IOException::class) |
|
|
@Transactional |
|
|
@Transactional |
|
|
fun saveQcResultWhenStockIn(request: SaveStockInLineRequest, stockInLine: StockInLine): List<QcResult>? { |
|
|
|
|
|
|
|
|
fun saveQcResultWhenStockIn(request: SaveStockInLineRequest, stockInLine: StockInLine, escLogId: Long?= 0): List<QcResult>? { |
|
|
if (!request.qcResult.isNullOrEmpty()) { |
|
|
if (!request.qcResult.isNullOrEmpty()) { |
|
|
val qcResultEntries = request.qcResult!!.map { |
|
|
val qcResultEntries = request.qcResult!!.map { |
|
|
val qcItem = qcItemsRepository.findById(it.qcItemId).orElseThrow() |
|
|
val qcItem = qcItemsRepository.findById(it.qcItemId).orElseThrow() |
|
|
val item = itemRepository.findById(stockInLine.item!!.id!!).orElseThrow() |
|
|
val item = itemRepository.findById(stockInLine.item!!.id!!).orElseThrow() |
|
|
|
|
|
val qcResult = QcResult(); |
|
|
|
|
|
|
|
|
QcResult().apply { |
|
|
QcResult().apply { |
|
|
this.qcItem = qcItem |
|
|
this.qcItem = qcItem |
|
|
this.item = item |
|
|
this.item = item |
|
|
@@ -209,6 +212,7 @@ open class StockInLineService( |
|
|
this.qcPassed = it.qcPassed |
|
|
this.qcPassed = it.qcPassed |
|
|
this.type = "qc" // default as qc for now |
|
|
this.type = "qc" // default as qc for now |
|
|
this.remarks = it.remarks |
|
|
this.remarks = it.remarks |
|
|
|
|
|
this.escalationLog = escalationLogService.find(escLogId).getOrNull() |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return qcResultRepository.saveAllAndFlush(qcResultEntries) |
|
|
return qcResultRepository.saveAllAndFlush(qcResultEntries) |
|
|
@@ -247,7 +251,6 @@ open class StockInLineService( |
|
|
val res = escalationLogService.saveEscalationLog(escReq) |
|
|
val res = escalationLogService.saveEscalationLog(escReq) |
|
|
return res.id?.let { escalationLogRepository.findById(it).orElseThrow() }; |
|
|
return res.id?.let { escalationLogRepository.findById(it).orElseThrow() }; |
|
|
}; |
|
|
}; |
|
|
// return qcResultRepository.saveAllAndFlush(qcResultEntries) |
|
|
|
|
|
} |
|
|
} |
|
|
return null |
|
|
return null |
|
|
} |
|
|
} |
|
|
@@ -367,11 +370,17 @@ open class StockInLineService( |
|
|
|
|
|
|
|
|
if (inventoryLotLines.sumOf { it.inQty ?: BigDecimal.ZERO } >= request.acceptQty?.times(ratio)) { |
|
|
if (inventoryLotLines.sumOf { it.inQty ?: BigDecimal.ZERO } >= request.acceptQty?.times(ratio)) { |
|
|
stockInLine.apply { |
|
|
stockInLine.apply { |
|
|
this.status = StockInLineStatus.COMPLETE.status |
|
|
|
|
|
|
|
|
this.status = if (request.acceptQty?.compareTo(request.acceptedQty) == 0) |
|
|
|
|
|
StockInLineStatus.COMPLETE.status else StockInLineStatus.PARTIALLY_COMPLETE.status |
|
|
// this.inventoryLotLine = savedInventoryLotLine |
|
|
// this.inventoryLotLine = savedInventoryLotLine |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else if (request.status == StockInLineStatus.PENDING.status || request.status == StockInLineStatus.ESCALATED.status) { |
|
|
} else if (request.status == StockInLineStatus.PENDING.status || request.status == StockInLineStatus.ESCALATED.status) { |
|
|
|
|
|
var escLogId : Long? = 0L; |
|
|
|
|
|
// Escalation |
|
|
|
|
|
if (request.status == StockInLineStatus.ESCALATED.status) { |
|
|
|
|
|
// |
|
|
|
|
|
} |
|
|
// QC |
|
|
// QC |
|
|
if (request.qcAccept == true) { |
|
|
if (request.qcAccept == true) { |
|
|
// Accepted |
|
|
// Accepted |
|
|
@@ -473,7 +482,7 @@ open class StockInLineService( |
|
|
stockInLine.apply { |
|
|
stockInLine.apply { |
|
|
this.status = StockInLineStatus.ESCALATED.status |
|
|
this.status = StockInLineStatus.ESCALATED.status |
|
|
} |
|
|
} |
|
|
saveEscalationLogWhenStockIn(request, stockInLine); |
|
|
|
|
|
|
|
|
escLogId = saveEscalationLogWhenStockIn(request, stockInLine)?.id; |
|
|
} else { |
|
|
} else { |
|
|
// Rejected |
|
|
// Rejected |
|
|
stockInLine.apply { |
|
|
stockInLine.apply { |
|
|
@@ -481,7 +490,8 @@ open class StockInLineService( |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
saveQcResultWhenStockIn(request, stockInLine) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
saveQcResultWhenStockIn(request, stockInLine, escLogId) |
|
|
} |
|
|
} |
|
|
val savedStockInLine = saveAndFlush(stockInLine) |
|
|
val savedStockInLine = saveAndFlush(stockInLine) |
|
|
// check if all line completed |
|
|
// check if all line completed |
|
|
|