|
|
@@ -1250,7 +1250,7 @@ open class StockTakeRecordService( |
|
|
return toRemove.size |
|
|
return toRemove.size |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
open fun listStockTakeRoundCards(yearMonth: String?): StockTakeRoundCardsRes { |
|
|
|
|
|
|
|
|
open fun listStockTakeRoundCards(yearMonth: String?, view: String? = null): StockTakeRoundCardsRes { |
|
|
val all = stockTakeRepository.findAll().filter { !it.deleted } |
|
|
val all = stockTakeRepository.findAll().filter { !it.deleted } |
|
|
if (all.isEmpty()) { |
|
|
if (all.isEmpty()) { |
|
|
val thisMonth = java.time.YearMonth.now().toString() |
|
|
val thisMonth = java.time.YearMonth.now().toString() |
|
|
@@ -1285,13 +1285,19 @@ open class StockTakeRecordService( |
|
|
val completedYearMonths = ( |
|
|
val completedYearMonths = ( |
|
|
cards.filter { !it.open }.map { it.yearMonth } + thisMonth |
|
|
cards.filter { !it.open }.map { it.yearMonth } + thisMonth |
|
|
).distinct().filter { it <= thisMonth }.sortedDescending() |
|
|
).distinct().filter { it <= thisMonth }.sortedDescending() |
|
|
val rounds = if (hasOpenRounds) { |
|
|
|
|
|
|
|
|
val openRoundsSorted = run { |
|
|
val openCards = cards.filter { it.open } |
|
|
val openCards = cards.filter { it.open } |
|
|
val thisMonthOpen = openCards.filter { it.yearMonth == thisMonth } |
|
|
val thisMonthOpen = openCards.filter { it.yearMonth == thisMonth } |
|
|
thisMonthOpen + openCards.filter { it.yearMonth != thisMonth } |
|
|
thisMonthOpen + openCards.filter { it.yearMonth != thisMonth } |
|
|
} else { |
|
|
|
|
|
val ym = yearMonth?.trim()?.takeIf { it.matches(Regex("\\d{4}-\\d{2}")) } ?: thisMonth |
|
|
|
|
|
cards.filter { !it.open && it.yearMonth == ym } |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
val historyYm = yearMonth?.trim()?.takeIf { it.matches(Regex("\\d{4}-\\d{2}")) } ?: thisMonth |
|
|
|
|
|
val historyRounds = cards.filter { !it.open && it.yearMonth == historyYm } |
|
|
|
|
|
val viewNorm = view?.trim()?.lowercase().orEmpty() |
|
|
|
|
|
val rounds = when (viewNorm) { |
|
|
|
|
|
"open" -> openRoundsSorted |
|
|
|
|
|
"history" -> historyRounds |
|
|
|
|
|
// 舊行為:有進行中只回 open,否則回該月歷史(PickerCardList 等相容) |
|
|
|
|
|
else -> if (hasOpenRounds) openRoundsSorted else historyRounds |
|
|
} |
|
|
} |
|
|
return StockTakeRoundCardsRes( |
|
|
return StockTakeRoundCardsRes( |
|
|
hasOpenRounds = hasOpenRounds, |
|
|
hasOpenRounds = hasOpenRounds, |
|
|
|