From c50f165949d7687fdb09c9b63b62da49860b808b Mon Sep 17 00:00:00 2001 From: "cyril.tsui" Date: Fri, 11 Apr 2025 16:38:53 +0800 Subject: [PATCH] add stock in --- .../ffii/fpsms/modules/master/entity/Shop.kt | 63 ++++++++++++++++++ .../modules/master/entity/ShopRepository.kt | 8 +++ .../fpsms/modules/master/entity/Warehouse.kt | 32 ++++++++++ .../master/entity/WarehouseRepository.kt | 8 +++ .../fpsms/modules/stock/entity/Inventory.kt | 15 +++++ .../modules/stock/entity/InventoryLotNo.kt | 25 ++++++++ .../stock/entity/InventoryLotNoRepository.kt | 8 +++ .../fpsms/modules/stock/entity/M18DataLog.kt | 33 ++++++++++ .../stock/entity/M18DataLogRepository.kt | 8 +++ .../fpsms/modules/stock/entity/StockIn.kt | 50 +++++++++++++++ .../fpsms/modules/stock/entity/StockInLine.kt | 64 +++++++++++++++++++ .../stock/entity/StockInLineRepository.kt | 8 +++ .../modules/stock/entity/StockInRepository.kt | 8 +++ .../stock/entity/enum/StockInLineStatus.kt | 10 +++ .../stock/entity/enum/StockInStatus.kt | 7 ++ .../20250409_01_cyril/01_master_data.sql | 43 +++++++++++++ .../20250409_01_cyril/02_m18_data_log.sql | 18 ++++++ .../changes/20250409_01_cyril/03_stock_in.sql | 55 ++++++++++++++++ .../20250409_01_cyril/04_inventory.sql | 25 ++++++++ 19 files changed, 488 insertions(+) create mode 100644 src/main/java/com/ffii/fpsms/modules/master/entity/Shop.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/master/entity/ShopRepository.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/master/entity/Warehouse.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/master/entity/WarehouseRepository.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotNo.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotNoRepository.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/stock/entity/M18DataLog.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/stock/entity/M18DataLogRepository.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/stock/entity/StockIn.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLine.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLineRepository.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/stock/entity/StockInRepository.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/stock/entity/enum/StockInLineStatus.kt create mode 100644 src/main/java/com/ffii/fpsms/modules/stock/entity/enum/StockInStatus.kt create mode 100644 src/main/resources/db/changelog/changes/20250409_01_cyril/01_master_data.sql create mode 100644 src/main/resources/db/changelog/changes/20250409_01_cyril/02_m18_data_log.sql create mode 100644 src/main/resources/db/changelog/changes/20250409_01_cyril/03_stock_in.sql create mode 100644 src/main/resources/db/changelog/changes/20250409_01_cyril/04_inventory.sql diff --git a/src/main/java/com/ffii/fpsms/modules/master/entity/Shop.kt b/src/main/java/com/ffii/fpsms/modules/master/entity/Shop.kt new file mode 100644 index 0000000..3d58278 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/master/entity/Shop.kt @@ -0,0 +1,63 @@ +package com.ffii.fpsms.modules.master.entity + +import com.ffii.core.entity.BaseEntity +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.Table +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Size + +@Entity +@Table(name = "shop") +open class Shop : BaseEntity() { + + @Size(max = 30) + @NotNull + @Column(name = "code", nullable = false, length = 30) + open var code: String? = null + + @Size(max = 30) + @NotNull + @Column(name = "name", nullable = false, length = 30) + open var name: String? = null + + @Size(max = 30) + @Column(name = "brNo", length = 30) + open var brNo: String? = null + + @Size(max = 30) + @Column(name = "contactNo", length = 30) + open var contactNo: String? = null + + @Size(max = 30) + @Column(name = "contactEmail", length = 30) + open var contactEmail: String? = null + + @Size(max = 30) + @Column(name = "contactName", length = 30) + open var contactName: String? = null + + @Size(max = 30) + @Column(name = "addr1", length = 30) + open var addr1: String? = null + + @Size(max = 30) + @Column(name = "addr2", length = 30) + open var addr2: String? = null + + @Size(max = 30) + @Column(name = "addr3", length = 30) + open var addr3: String? = null + + @Size(max = 30) + @Column(name = "addr4", length = 30) + open var addr4: String? = null + + @Size(max = 30) + @Column(name = "district", length = 30) + open var district: String? = null + + @Size(max = 10) + @Column(name = "type", length = 10) + open var type: String? = null +} \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/master/entity/ShopRepository.kt b/src/main/java/com/ffii/fpsms/modules/master/entity/ShopRepository.kt new file mode 100644 index 0000000..edf5784 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/master/entity/ShopRepository.kt @@ -0,0 +1,8 @@ +package com.ffii.fpsms.modules.master.entity + +import com.ffii.core.support.AbstractRepository +import org.springframework.stereotype.Repository + +@Repository +interface ShopRepository : AbstractRepository { +} \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/master/entity/Warehouse.kt b/src/main/java/com/ffii/fpsms/modules/master/entity/Warehouse.kt new file mode 100644 index 0000000..87feb19 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/master/entity/Warehouse.kt @@ -0,0 +1,32 @@ +package com.ffii.fpsms.modules.master.entity + +import com.ffii.core.entity.BaseEntity +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.Table +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Size +import java.math.BigDecimal + +@Entity +@Table(name = "warehouse") +open class Warehouse : BaseEntity() { + @Size(max = 30) + @NotNull + @Column(name = "code", nullable = false, length = 30) + open var code: String? = null + + @Size(max = 30) + @NotNull + @Column(name = "name", nullable = false, length = 30) + open var name: String? = null + + @Size(max = 30) + @NotNull + @Column(name = "description", nullable = false, length = 30) + open var description: String? = null + + @NotNull + @Column(name = "capacity", nullable = false, precision = 14, scale = 2) + open var capacity: BigDecimal? = null +} \ No newline at end of file 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 new file mode 100644 index 0000000..e020040 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/master/entity/WarehouseRepository.kt @@ -0,0 +1,8 @@ +package com.ffii.fpsms.modules.master.entity + +import com.ffii.core.support.AbstractRepository +import org.springframework.stereotype.Repository + +@Repository +interface WarehouseRepository : AbstractRepository { +} \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/Inventory.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/Inventory.kt index 33b85fd..c8f1fd9 100644 --- a/src/main/java/com/ffii/fpsms/modules/stock/entity/Inventory.kt +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/Inventory.kt @@ -2,8 +2,11 @@ package com.ffii.fpsms.modules.stock.entity import com.ffii.core.entity.BaseEntity import com.ffii.fpsms.modules.master.entity.Items +import com.ffii.fpsms.modules.master.entity.Warehouse import jakarta.persistence.* import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Size +import java.math.BigDecimal import java.time.LocalDate @Entity @@ -36,4 +39,16 @@ open class Inventory: BaseEntity(){ // @NotNull @Column(name = "status") open var status: String? = null + + @NotNull + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "warehouseId", nullable = false) + open var warehouse: Warehouse? = null + + @Column(name = "price", precision = 14, scale = 2) + open var price: BigDecimal? = null + + @Size(max = 5) + @Column(name = "priceUnit", length = 5) + open var priceUnit: String? = null } \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotNo.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotNo.kt new file mode 100644 index 0000000..2b225c9 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotNo.kt @@ -0,0 +1,25 @@ +package com.ffii.fpsms.modules.stock.entity + +import com.ffii.core.entity.BaseEntity +import jakarta.persistence.* +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Size +import org.hibernate.annotations.JdbcTypeCode +import org.hibernate.type.SqlTypes + +@Entity +@Table(name = "inventory_lot_no") +open class InventoryLotNo : BaseEntity() { + @NotNull + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "inventoryId", nullable = false) + open var inventory: Inventory? = null + + @Size(max = 30) + @Column(name = "lotNo", length = 30) + open var lotNo: String? = null + + @JdbcTypeCode(SqlTypes.JSON) + @Column(name = "qrCodeJson") + open var qrCodeJson: MutableMap? = null +} \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotNoRepository.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotNoRepository.kt new file mode 100644 index 0000000..208f277 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/InventoryLotNoRepository.kt @@ -0,0 +1,8 @@ +package com.ffii.fpsms.modules.stock.entity + +import com.ffii.core.support.AbstractRepository +import org.springframework.stereotype.Repository + +@Repository +interface InventoryLotNoRepository : AbstractRepository { +} \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/M18DataLog.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/M18DataLog.kt new file mode 100644 index 0000000..2b15e02 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/M18DataLog.kt @@ -0,0 +1,33 @@ +package com.ffii.fpsms.modules.stock.entity + +import com.ffii.core.entity.BaseEntity +import jakarta.persistence.Column +import jakarta.persistence.Entity +import jakarta.persistence.Table +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Size +import org.hibernate.annotations.JdbcTypeCode +import org.hibernate.type.SqlTypes + +@Entity +@Table(name = "m18_data_log") +open class M18DataLog : BaseEntity() { + @Size(max = 10) + @NotNull + @Column(name = "refType", nullable = false, length = 10) + open var refType: String? = null + + @NotNull + @Column(name = "m18Key", nullable = false) + open var m18Key: Int? = null + + @NotNull + @JdbcTypeCode(SqlTypes.JSON) + @Column(name = "dataLog", nullable = false) + open var dataLog: MutableMap? = null + + @Size(max = 5) + @NotNull + @Column(name = "status", nullable = false, length = 5) + open var status: String? = null +} \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/M18DataLogRepository.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/M18DataLogRepository.kt new file mode 100644 index 0000000..bbad2b7 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/M18DataLogRepository.kt @@ -0,0 +1,8 @@ +package com.ffii.fpsms.modules.stock.entity + +import com.ffii.core.support.AbstractRepository +import org.springframework.stereotype.Repository + +@Repository +interface M18DataLogRepository : AbstractRepository { +} \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/StockIn.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/StockIn.kt new file mode 100644 index 0000000..5e7013e --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/StockIn.kt @@ -0,0 +1,50 @@ +package com.ffii.fpsms.modules.stock.entity + +import com.ffii.core.entity.BaseEntity +import com.ffii.fpsms.modules.master.entity.Shop +import com.ffii.fpsms.modules.stock.entity.enum.StockInStatus +import jakarta.persistence.* +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Size +import java.time.Instant +import java.time.LocalDate +import java.time.LocalDateTime + +@Entity +@Table(name = "stock_in") +open class StockIn : BaseEntity() { + @Size(max = 30) + @NotNull + @Column(name = "code", nullable = false, length = 30) + open var code: String? = null + + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "supplierId") + open var supplier: Shop? = null + + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "shopId") + open var shop: Shop? = null + + @Column(name = "refId") + open var refId: Int? = null + + @Size(max = 5) + @Column(name = "refType", length = 5) + open var refType: String? = null + + @Column(name = "orderDate") + open var orderDate: LocalDateTime? = null + + @Column(name = "estimatedCompleteDate") + open var estimatedCompleteDate: LocalDate? = null + + @Column(name = "completeDate") + open var completeDate: LocalDateTime? = null + + @Size(max = 10) + @NotNull + @Column(name = "status", nullable = false, length = 10) + @Enumerated(EnumType.STRING) + open var status: StockInStatus? = null +} \ No newline at end of file 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 new file mode 100644 index 0000000..56bcf54 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLine.kt @@ -0,0 +1,64 @@ +package com.ffii.fpsms.modules.stock.entity + +import com.ffii.core.entity.BaseEntity +import com.ffii.fpsms.modules.master.entity.Items +import com.ffii.fpsms.modules.stock.entity.enum.StockInLineStatus +import com.ffii.fpsms.modules.user.entity.User +import jakarta.persistence.* +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Size +import java.math.BigDecimal +import java.time.Instant + +@Entity +@Table(name = "stock_in_line") +open class StockInLine : BaseEntity() { + @NotNull + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "itemId", nullable = false) + open var item: Items? = null + + @Size(max = 20) + @NotNull + @Column(name = "itemNo", nullable = false, length = 20) + open var itemNo: String? = null + + @NotNull + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "stockInId", nullable = false) + open var stockIn: StockIn? = null + + @Column(name = "demandQty", precision = 14, scale = 2) + open var demandQty: BigDecimal? = null + + @Column(name = "acceptedQty", precision = 14, scale = 2) + open var acceptedQty: BigDecimal? = null + + @Column(name = "price", precision = 14, scale = 2) + open var price: BigDecimal? = null + + @Size(max = 5) + @Column(name = "priceUnit", length = 5) + open var priceUnit: String? = null + + @Column(name = "productDate") + open var productDate: Instant? = null + + @Column(name = "shelfLifeDate") + open var shelfLifeDate: Instant? = null + + @Size(max = 10) + @NotNull + @Column(name = "status", nullable = false, length = 10) + @Enumerated(EnumType.STRING) + open var status: StockInLineStatus? = null + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "userId") + open var user: User? = null + + @NotNull + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "m18DataLogId", nullable = false) + open var m18DataLog: M18DataLog? = null +} \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLineRepository.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLineRepository.kt new file mode 100644 index 0000000..1ceb9d4 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInLineRepository.kt @@ -0,0 +1,8 @@ +package com.ffii.fpsms.modules.stock.entity + +import com.ffii.core.support.AbstractRepository +import org.springframework.stereotype.Repository + +@Repository +interface StockInLineRepository : AbstractRepository { +} \ No newline at end of file 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 new file mode 100644 index 0000000..7f33738 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/StockInRepository.kt @@ -0,0 +1,8 @@ +package com.ffii.fpsms.modules.stock.entity + +import com.ffii.core.support.AbstractRepository +import org.springframework.stereotype.Repository + +@Repository +interface StockInRepository : AbstractRepository { +} \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/enum/StockInLineStatus.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/enum/StockInLineStatus.kt new file mode 100644 index 0000000..88dc1c0 --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/enum/StockInLineStatus.kt @@ -0,0 +1,10 @@ +package com.ffii.fpsms.modules.stock.entity.enum + +enum class StockInLineStatus(val status: String) { + PENDING("pending"), + QC1("qc1"), + QC2("qc2"), + QC3("qc3"), + RECEIVING("receiving"), + COMPLETED("completed") +} \ No newline at end of file diff --git a/src/main/java/com/ffii/fpsms/modules/stock/entity/enum/StockInStatus.kt b/src/main/java/com/ffii/fpsms/modules/stock/entity/enum/StockInStatus.kt new file mode 100644 index 0000000..bf2a66d --- /dev/null +++ b/src/main/java/com/ffii/fpsms/modules/stock/entity/enum/StockInStatus.kt @@ -0,0 +1,7 @@ +package com.ffii.fpsms.modules.stock.entity.enum + +enum class StockInStatus(val status: String) { + PENDING("pending"), + RECEIVING("receiving"), + COMPLETED("completed") +} \ No newline at end of file diff --git a/src/main/resources/db/changelog/changes/20250409_01_cyril/01_master_data.sql b/src/main/resources/db/changelog/changes/20250409_01_cyril/01_master_data.sql new file mode 100644 index 0000000..f83e2d5 --- /dev/null +++ b/src/main/resources/db/changelog/changes/20250409_01_cyril/01_master_data.sql @@ -0,0 +1,43 @@ +--liquibase formatted sql + +--changeset cyril:master data for shop and warehouse +CREATE TABLE `shop` +( + `id` INT NOT NULL AUTO_INCREMENT, + `created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `createdBy` VARCHAR(30) NULL DEFAULT NULL, + `version` INT NOT NULL DEFAULT '0', + `modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modifiedBy` VARCHAR(30) NULL DEFAULT NULL, + `deleted` TINYINT(1) NOT NULL DEFAULT '0', + `code` VARCHAR(30) NOT NULL, + `name` VARCHAR(30) NOT NULL, + `brNo` VARCHAR(30) NULL, + `contactNo` VARCHAR(30) NULL, + `contactEmail` VARCHAR(30) NULL, + `contactName` VARCHAR(30) NULL, + `addr1` VARCHAR(30) NULL, + `addr2` VARCHAR(30) NULL, + `addr3` VARCHAR(30) NULL, + `addr4` VARCHAR(30) NULL, + `district` VARCHAR(30) NULL, + `type` VARCHAR(10) NULL, + `m18Id` INT NOT NULL, + CONSTRAINT pk_shop PRIMARY KEY (id) +); + +CREATE TABLE `warehouse` +( + `id` INT NOT NULL AUTO_INCREMENT, + `created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `createdBy` VARCHAR(30) NULL DEFAULT NULL, + `version` INT NOT NULL DEFAULT '0', + `modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modifiedBy` VARCHAR(30) NULL DEFAULT NULL, + `deleted` TINYINT(1) NOT NULL DEFAULT '0', + `code` VARCHAR(30) NOT NULL, + `name` VARCHAR(30) NOT NULL, + `description` VARCHAR(30) NOT NULL, + `capacity` DECIMAL(14, 2) NOT NULL, + CONSTRAINT pk_warehouse PRIMARY KEY (id) +); \ No newline at end of file diff --git a/src/main/resources/db/changelog/changes/20250409_01_cyril/02_m18_data_log.sql b/src/main/resources/db/changelog/changes/20250409_01_cyril/02_m18_data_log.sql new file mode 100644 index 0000000..f1b30b8 --- /dev/null +++ b/src/main/resources/db/changelog/changes/20250409_01_cyril/02_m18_data_log.sql @@ -0,0 +1,18 @@ +--liquibase formatted sql + +--changeset cyril:m18 data log +CREATE TABLE `m18_data_log` +( + `id` INT NOT NULL AUTO_INCREMENT, + `created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `createdBy` VARCHAR(30) NULL DEFAULT NULL, + `version` INT NOT NULL DEFAULT '0', + `modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modifiedBy` VARCHAR(30) NULL DEFAULT NULL, + `deleted` TINYINT(1) NOT NULL DEFAULT '0', + `refType` VARCHAR(10) NOT NULL, + `m18Key` INT NOT NULL, + `dataLog` JSON NOT NULL, + `status` VARCHAR(5) NOT NULL, + CONSTRAINT pk_m18_data_log PRIMARY KEY (id) +); \ No newline at end of file diff --git a/src/main/resources/db/changelog/changes/20250409_01_cyril/03_stock_in.sql b/src/main/resources/db/changelog/changes/20250409_01_cyril/03_stock_in.sql new file mode 100644 index 0000000..a8f01ff --- /dev/null +++ b/src/main/resources/db/changelog/changes/20250409_01_cyril/03_stock_in.sql @@ -0,0 +1,55 @@ +--liquibase formatted sql + +--changeset cyril:stock in +CREATE TABLE `stock_in` +( + `id` INT NOT NULL AUTO_INCREMENT, + `created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `createdBy` VARCHAR(30) NULL DEFAULT NULL, + `version` INT NOT NULL DEFAULT '0', + `modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modifiedBy` VARCHAR(30) NULL DEFAULT NULL, + `deleted` TINYINT(1) NOT NULL DEFAULT '0', + `code` VARCHAR(30) NOT NULL, + `supplierId` INT NULL, + `shopId` INT NULL, + `refId` INT NULL, + `refType` VARCHAR(5) NULL, + `orderDate` DATETIME NULL, + `estimatedCompleteDate` DATETIME NULL, + `completeDate` DATETIME NULL, + `status` VARCHAR(10) NOT NULL DEFAULT 'pending', + `m18DataLogId` INT NOT NULL, + CONSTRAINT pk_stock_in PRIMARY KEY (id), + CONSTRAINT FK_STOCK_IN_ON_SUPPLIERID FOREIGN KEY (supplierId) REFERENCES shop (id), + CONSTRAINT FK_STOCK_IN_ON_SHOPID FOREIGN KEY (shopId) REFERENCES shop (id), + CONSTRAINT FK_STOCK_IN_ON_M18DATALOGID FOREIGN KEY (m18DataLogId) REFERENCES m18_data_log (id) +); + +CREATE TABLE `stock_in_line` +( + `id` INT NOT NULL AUTO_INCREMENT, + `created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `createdBy` VARCHAR(30) NULL DEFAULT NULL, + `version` INT NOT NULL DEFAULT '0', + `modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modifiedBy` VARCHAR(30) NULL DEFAULT NULL, + `deleted` TINYINT(1) NOT NULL DEFAULT '0', + `itemId` INT NOT NULL, + `itemNo` VARCHAR(20) NOT NULL, + `stockInId` INT NOT NULL, + `demandQty` DECIMAL(14, 2) NULL, + `acceptedQty` DECIMAL(14, 2) NULL, + `price` DECIMAL(14, 2) NULL, + `priceUnit` VARCHAR(5) NULL, + `productDate` DATETIME NULL, + `shelfLifeDate` DATETIME NULL, + `status` VARCHAR(10) NOT NULL DEFAULT 'pending', + `userId` INT NULL, + `m18DataLogId` INT NOT NULL, + CONSTRAINT pk_stock_in_line PRIMARY KEY (id), + CONSTRAINT FK_STOCK_IN_LINE_ON_ITEMID FOREIGN KEY (itemId) REFERENCES items (id), + CONSTRAINT FK_STOCK_IN_LINE_ON_STOCKINID FOREIGN KEY (stockInId) REFERENCES stock_in (id), + CONSTRAINT FK_STOCK_IN_LINE_ON_USERID FOREIGN KEY (userId) REFERENCES user (id), + CONSTRAINT FK_STOCK_IN_LINE_ON_M18DATALOGID FOREIGN KEY (m18DataLogId) REFERENCES m18_data_log (id) +); \ No newline at end of file diff --git a/src/main/resources/db/changelog/changes/20250409_01_cyril/04_inventory.sql b/src/main/resources/db/changelog/changes/20250409_01_cyril/04_inventory.sql new file mode 100644 index 0000000..e5b1bdd --- /dev/null +++ b/src/main/resources/db/changelog/changes/20250409_01_cyril/04_inventory.sql @@ -0,0 +1,25 @@ +--liquibase formatted sql + +--changeset cyril:inventory +ALTER TABLE `inventory` + ADD COLUMN `price` DECIMAL(14, 2) NULL AFTER `qty`, + ADD COLUMN `priceUnit` VARCHAR(5) NULL AFTER `price`, + ADD COLUMN `warehouseId` INT NOT NULL AFTER `stockInLineId`, + ADD CONSTRAINT FK_INVENTORY_STOCKINLINEID FOREIGN KEY (stockInLineId) REFERENCES stock_in_line (id), + ADD CONSTRAINT FK_INVENTORY_WAREHOUSEID FOREIGN KEY (warehouseId) REFERENCES warehouse (id); + +CREATE TABLE `inventory_lot_no` +( + `id` INT NOT NULL AUTO_INCREMENT, + `created` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `createdBy` VARCHAR(30) NULL DEFAULT NULL, + `version` INT NOT NULL DEFAULT '0', + `modified` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modifiedBy` VARCHAR(30) NULL DEFAULT NULL, + `deleted` TINYINT(1) NOT NULL DEFAULT '0', + `inventoryId` INT NOT NULL, + `lotNo` VARCHAR(30) NULL, + `qrCodeJson` JSON NULL, + CONSTRAINT pk_inventory_lot_no PRIMARY KEY (id), + CONSTRAINT FK_INVENTORY_LOT_NO_INVENTORYID FOREIGN KEY (inventoryId) REFERENCES inventory (id) +); \ No newline at end of file