Bladeren bron

make the stock take qty can be edit before 完成

production
Fai Luk 4 uur geleden
bovenliggende
commit
41d5df10a5
4 gewijzigde bestanden met toevoegingen van 65 en 2 verwijderingen
  1. +4
    -0
      src/main/java/com/ffii/fpsms/modules/stock/entity/StockTakeRecord.kt
  2. +51
    -1
      src/main/java/com/ffii/fpsms/modules/stock/service/StockTakeRecordService.kt
  3. +5
    -1
      src/main/java/com/ffii/fpsms/modules/stock/web/model/StockTakeRecordReponse.kt
  4. +5
    -0
      src/main/resources/db/changelog/changes/20261001_picker_revise_count/01_add_picker_revise_count.sql

+ 4
- 0
src/main/java/com/ffii/fpsms/modules/stock/entity/StockTakeRecord.kt Bestand weergeven

@@ -81,6 +81,10 @@ open class StockTakeRecord : BaseEntity<Long>() {
@Column(name = "lastSelect")
open var lastSelect: Int? = null

/** How many times the picker has changed an already saved first count. Max 2. */
@Column(name = "pickerReviseCount", nullable = false)
open var pickerReviseCount: Int? = 0

@Column(name = "approverTime")
open var approverTime: LocalDateTime? = null
@Column(name = "date", nullable = false)


+ 51
- 1
src/main/java/com/ffii/fpsms/modules/stock/service/StockTakeRecordService.kt Bestand weergeven

@@ -1200,6 +1200,7 @@ open class StockTakeRecordService(
stockTakerName = rec.stockTakerName,
stockTakeEndTime = rec.stockTakeEndTime,
approverTime = rec.approverTime,
pickerReviseCount = rec.pickerReviseCount ?: 0,
)
}

@@ -1296,6 +1297,7 @@ open class StockTakeRecordService(
stockTakerName = stockTakeRecord?.stockTakerName,
stockTakeEndTime = stockTakeRecord?.stockTakeEndTime,
approverTime = stockTakeRecord?.approverTime,
pickerReviseCount = stockTakeRecord?.pickerReviseCount ?: 0,
)
}

@@ -1342,12 +1344,59 @@ open class StockTakeRecordService(
.subtract(inventoryLotLine.outQty ?: BigDecimal.ZERO)
//.subtract(inventoryLotLine.holdQty ?: BigDecimal.ZERO)

if (request.reviseFirstQty && request.stockTakeRecordId == null) {
throw IllegalArgumentException("Stock take record ID is required")
}

// 3. 新建、更新預建記錄之第一次盤點、或第二次盤點
val stockTakeRecord: StockTakeRecord = if (request.stockTakeRecordId != null) {
val existingRecord = stockTakeRecordRepository.findByIdAndDeletedIsFalse(request.stockTakeRecordId)
?: throw IllegalArgumentException("Stock take record not found: ${request.stockTakeRecordId}")

val headerStatus = stockTake.status
val headerStillOpen = headerStatus == StockTakeStatus.PENDING ||
headerStatus == StockTakeStatus.STOCKTAKING ||
headerStatus == StockTakeStatus.APPROVING
val revisingOpenPass = existingRecord.pickerFirstStockTakeQty != null &&
existingRecord.pickerSecondStockTakeQty == null &&
existingRecord.approverStockTakeQty == null &&
existingRecord.status.equals("pass", ignoreCase = true) &&
headerStillOpen
when {
// 已盤點的列在區域「已完成」前可改第一次數量。列狀態已完成、或區域已完成,不能改。
request.reviseFirstQty || revisingOpenPass -> {
if (!headerStillOpen) {
throw IllegalArgumentException("Cannot change counted qty after the section is completed")
}
if (!existingRecord.status.equals("pass", ignoreCase = true)) {
throw IllegalArgumentException("Only counted records can be changed")
}
if (existingRecord.pickerFirstStockTakeQty == null) {
throw IllegalArgumentException("No first count to change")
}
if (existingRecord.pickerSecondStockTakeQty != null || existingRecord.approverStockTakeQty != null) {
throw IllegalArgumentException("Cannot change the first count after a later count exists")
}
val reviseCount = existingRecord.pickerReviseCount ?: 0
if (reviseCount >= 2) {
throw IllegalArgumentException("This count can only be changed 2 times")
}
val varianceQty = availableQty - request.qty - request.badQty
existingRecord.apply {
this.pickerFirstStockTakeQty = request.qty
this.pickerFirstBadQty = request.badQty
this.bookQty = availableQty
this.varianceQty = varianceQty
this.stockTakerId = stockTakerId
this.stockTakerName = user?.name
this.status = "pass"
this.pickerSecondStockTakeQty = null
this.pickerSecondBadQty = null
this.stockTakeEndTime = null
this.pickerReviseCount = reviseCount + 1
}
existingRecord
}
existingRecord.pickerFirstStockTakeQty == null -> {
val isCompled = inventoryLotLine.inQty == inventoryLotLine.outQty
val varianceQty = availableQty - request.qty - request.badQty
@@ -1367,7 +1416,8 @@ open class StockTakeRecordService(
}
existingRecord
}
existingRecord.pickerSecondStockTakeQty == null -> {
existingRecord.pickerSecondStockTakeQty == null &&
existingRecord.status.equals("notMatch", ignoreCase = true) -> {
val varianceQty = availableQty - request.qty - request.badQty
existingRecord.apply {
this.stockTakeRoundId = this.stockTakeRoundId ?: (stockTake.stockTakeRoundId ?: stockTake.id)


+ 5
- 1
src/main/java/com/ffii/fpsms/modules/stock/web/model/StockTakeRecordReponse.kt Bestand weergeven

@@ -80,6 +80,8 @@ data class InventoryLotDetailResponse(
val lastSelect: Int? = null,
/** Stock UoM short label (e.g. 包), shown beside the count input. */
val uomShortDesc: String? = null,
/** Times the picker has changed this saved first count. */
val pickerReviseCount: Int? = 0,
)
data class InventoryLotLineListRequest(
val warehouseCode: String
@@ -90,7 +92,9 @@ data class SaveStockTakeRecordRequest(
val qty: BigDecimal, // QTY(第一次或第二次,后端判断)
val badQty: BigDecimal,
// val stockTakerName: String,
val remark: String? = null
val remark: String? = null,
/** true = 區域仍在盤點中時,覆寫已盤點的第一次數量;不寫入第二次盤點 */
val reviseFirstQty: Boolean = false,
)

/**


+ 5
- 0
src/main/resources/db/changelog/changes/20261001_picker_revise_count/01_add_picker_revise_count.sql Bestand weergeven

@@ -0,0 +1,5 @@
-- liquibase formatted sql
-- changeset fpsms:20261001-picker-revise-count

ALTER TABLE `fpsmsdb`.`stocktakerecord`
ADD COLUMN `pickerReviseCount` INT NOT NULL DEFAULT 0 AFTER `lastSelect`;

Laden…
Annuleren
Opslaan