diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLine.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLine.kt index 6ce0170..443d83e 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLine.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLine.kt @@ -69,10 +69,14 @@ open class StockInLine : BaseEntity() { @JoinColumn(name = "userId") open var user: User? = null - @OneToOne + @ManyToOne @JoinColumn(name = "inventoryLotId") open var inventoryLot: InventoryLot? = null + @OneToOne + @JoinColumn(name = "inventoryLotLineId") + open var inventoryLotLine: InventoryLotLine? = null + @Column(name = "lotNo") open var lotNo: String? = null 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 4fd6e6f..adc2a40 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 @@ -251,6 +251,7 @@ open class StockInLineService( this.status = request.status this.expiryDate = stockInLine.expiryDate ?: request.expiryDate this.inventoryLot = stockInLine.inventoryLot ?: savedInventoryLot + this.inventoryLotLine = savedInventoryLotLine this.lotNo = stockInLine.lotNo ?: savedInventoryLot?.lotNo } val savedStockInLine = saveAndFlush(stockInLine) @@ -320,6 +321,7 @@ open class StockInLineService( this.acceptedQty = request.acceptedQty this.status = request.status this.inventoryLot = savedInventoryLot ?: stockInLine.inventoryLot + this.inventoryLotLine = savedInventoryLotLine this.lotNo = savedInventoryLot?.lotNo ?: stockInLine.lotNo this.expiryDate = stockInLine.expiryDate ?: request.expiryDate this.productLotNo = stockInLine.productLotNo ?: request.productLotNo diff --git a/src/main/resources/db/changelog/changes/20250620_01_derek/01_add_lot_line_id_to_stock_in_line.sql b/src/main/resources/db/changelog/changes/20250620_01_derek/01_add_lot_line_id_to_stock_in_line.sql new file mode 100644 index 0000000..15b065b --- /dev/null +++ b/src/main/resources/db/changelog/changes/20250620_01_derek/01_add_lot_line_id_to_stock_in_line.sql @@ -0,0 +1,7 @@ +-- liquibase formatted sql +-- changeset derek:add_lot_line_id_to_stock_in_line + +ALTER TABLE `stock_in_line` + ADD COLUMN `inventoryLotLineId` INT(11) NULL AFTER `inventoryLotId`, + ADD CONSTRAINT FK_STOCK_IN_LINE_ON_LOT_LINE_ID FOREIGN KEY (inventoryLotLineId) REFERENCES inventory_lot_line (id) +; \ No newline at end of file