feat(api): DeductionService + PaymentService 차감 통합 + DeductionController (도메인 P0-2-c)
P0-2 공제/차감 도메인 마무리. ga-batch 정산 step 통합은 도메인 P0 마무리에서.
DeductionService (신규):
- CRUD: list/detail/create/update/cancel
- create는 (agent_id, settle_month, deduction_type) 유니크 중복 검증
- cancel은 status를 CANCELLED로 전이
- 정산용: sumPendingByAgent, selectPendingByMonth, markAsApplied(batch)
PaymentService 확장:
- applyDeductions(paymentId, settleMonth) — 단건:
1. PENDING 차감 조회
2. payment_deduction_detail INSERT
3. agent_deduction.status → APPLIED 일괄 전이
4. payment.deduction_amount UPDATE
5. net_amount 재계산 (newNet = currentNet - deductionTotal)
- applyDeductionsForMonth(settleMonth) — 월 일괄
net_amount 공식 갱신:
- 세금 적용(calculateTaxes): amount - incomeTax - localTax + vat
- 차감 적용(applyDeductions): currentNet - deductionTotal
- 최종: amount - incomeTax - localTax + vat - deduction
Mapper 추가 (ga-core):
- AgentDeductionMapper: selectPendingByAgent, updateStatusBatch, countByAgentMonthType
- PaymentMapper: updateDeduction
DeductionController + PaymentController 엔드포인트 추가:
- /api/deductions CRUD (5종)
- /api/payments/{id}/apply-deductions
- /api/payments/apply-deductions?settleMonth=YYYYMM
This commit is contained in:
@@ -25,4 +25,17 @@ public interface AgentDeductionMapper {
|
||||
|
||||
/** 정산월 전체 PENDING 목록 (배치용) */
|
||||
List<AgentDeductionVO> selectPendingByMonth(@Param("settleMonth") String settleMonth);
|
||||
|
||||
/** 설계사의 PENDING 목록 (단건 차감 적용용) */
|
||||
List<AgentDeductionVO> selectPendingByAgent(@Param("agentId") Long agentId,
|
||||
@Param("settleMonth") String settleMonth);
|
||||
|
||||
/** 일괄 상태 전이 */
|
||||
int updateStatusBatch(@Param("deductionIds") List<Long> deductionIds,
|
||||
@Param("status") String status);
|
||||
|
||||
/** 중복 검증 */
|
||||
int countByAgentMonthType(@Param("agentId") Long agentId,
|
||||
@Param("settleMonth") String settleMonth,
|
||||
@Param("deductionType") String deductionType);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@ public interface PaymentMapper {
|
||||
@Param("netAmount") BigDecimal netAmount);
|
||||
int updateTaxesBatch(@Param("list") List<PaymentVO> list);
|
||||
|
||||
int updateDeduction(@Param("paymentId") Long paymentId,
|
||||
@Param("deductionAmount") BigDecimal deductionAmount,
|
||||
@Param("netAmount") BigDecimal netAmount);
|
||||
|
||||
List<PaymentVO> selectPendingByMonthAndBank(@Param("settleMonth") String settleMonth,
|
||||
@Param("bankCode") String bankCode);
|
||||
List<PaymentVO> selectBySettleMonth(@Param("settleMonth") String settleMonth);
|
||||
|
||||
Reference in New Issue
Block a user