fix(agent-calculate): 정산 합계 계산 경로와 회귀 테스트를 보강한다

This commit is contained in:
2026-04-10 13:51:28 +09:00
parent 83fdb3400d
commit 0b61569522
3 changed files with 190 additions and 1 deletions

View File

@@ -199,7 +199,6 @@ class AgentCalculateService(
val totalCount = totalCountLoader(startDate, endDate)
val total = totalRowsLoader(startDate, endDate)
.toMergedResponseItems()
.toResponseTotal()
val items = pagedRowsLoader(startDate, endDate)
.toMergedResponseItems()

View File

@@ -75,3 +75,30 @@ fun List<GetAgentCreatorSettlementSummaryQueryData>.toMergedResponseItems(): Lis
}
}
}
fun List<GetAgentCreatorSettlementSummaryQueryData>.toResponseTotal(): GetAgentSettlementByCreatorTotal {
return fold(
GetAgentSettlementByCreatorTotal(
count = 0,
totalCan = 0,
krw = 0,
fee = 0,
settlementAmount = 0,
tax = 0,
depositAmount = 0,
agentSettlementAmount = 0
)
) { total, row ->
val item = row.toResponseItem()
total.copy(
count = total.count + item.count,
totalCan = total.totalCan + item.totalCan,
krw = total.krw + item.krw,
fee = total.fee + item.fee,
settlementAmount = total.settlementAmount + item.settlementAmount,
tax = total.tax + item.tax,
depositAmount = total.depositAmount + item.depositAmount,
agentSettlementAmount = total.agentSettlementAmount + item.agentSettlementAmount
)
}
}