|
|
|
@@ -53,6 +53,8 @@ import com.ffii.fpsms.modules.stock.entity.StockLedgerRepository |
|
|
|
import com.ffii.fpsms.modules.stock.entity.InventoryRepository |
|
|
|
import org.springframework.http.HttpStatus |
|
|
|
import org.springframework.web.server.ResponseStatusException |
|
|
|
import kotlin.text.toDouble |
|
|
|
|
|
|
|
@Serializable |
|
|
|
data class QrContent(val itemId: Long, val stockInLineId: Long) |
|
|
|
|
|
|
|
@@ -606,7 +608,7 @@ open class StockInLineService( |
|
|
|
field["poCode"] = info.poCode ?: "N/A" |
|
|
|
field["itemType"] = info.itemType ?: "N/A" |
|
|
|
field["acceptedQty"] = "%.2f".format(acceptedQty) |
|
|
|
field["uom"] = info.uom?.udfudesc.toString() ?: "N/A" |
|
|
|
field["uom"] = stockItemUom?.uom?.udfudesc ?: info.uom?.udfudesc?.toString() ?: "N/A" |
|
|
|
field["productionDate"] = info.productionDate?.format(DateTimeFormatter.ISO_LOCAL_DATE) ?: "" |
|
|
|
field["expiryDate"] = info.expiryDate?.format(DateTimeFormatter.ISO_LOCAL_DATE) ?: "" |
|
|
|
field["lotNo"] = info.lotNo ?: "N/A" |
|
|
|
@@ -740,12 +742,11 @@ open class StockInLineService( |
|
|
|
) |
|
|
|
} |
|
|
|
@Transactional |
|
|
|
private fun createStockLedgerForStockIn(stockInLine: StockInLine) { |
|
|
|
val item = stockInLine.item ?: return |
|
|
|
val inventory = inventoryRepository.findByItemId(item.id!!).orElse(null) ?: return |
|
|
|
|
|
|
|
val inQty = stockInLine.acceptedQty?.toDouble() ?: 0.0 |
|
|
|
|
|
|
|
private fun createStockLedgerForStockIn(stockInLine: StockInLine) { |
|
|
|
val item = stockInLine.item ?: return |
|
|
|
val inventory = inventoryRepository.findFirstByItemIdAndDeletedIsFalseOrderByIdAsc(item.id!!) ?: return |
|
|
|
val inQty = stockInLine.acceptedQty?.toDouble() ?: 0.0 |
|
|
|
|
|
|
|
// ✅ 修复:查询最新的 stock_ledger 记录,基于前一笔 balance 计算 |
|
|
|
val latestLedger = stockLedgerRepository.findLatestByItemId(item.id!!).firstOrNull() |
|
|
|
|