diff --git a/docs/api-spec.md b/docs/api-spec.md index eecd6f9..5186737 100644 --- a/docs/api-spec.md +++ b/docs/api-spec.md @@ -328,11 +328,18 @@ T-14 정산 리포트의 교육비 안내 블록. `invoices.report_id = reportId "canceledCount": 0, "deductionAmount": 0, "calculatedAmount": 360000, - "amount": 360000 + "amount": 360000, + "recognizedCount": 8, + "bankCode": "004", + "bankName": "국민은행", + "accountLast4": "1492", + "accountHolder": "한서윤" } ``` - 키 이름 · 순서는 노션 명세와 같다. `settlementSessionCnt` · `paymentTiming` · `unitPrice` · `calculatedAmount` · `amount`는 청구 컬럼 값이다. +- `recognizedCount`: '인정 회차 × 회당 단가' 줄의 회차. 정산 없이 만든 선불 첫 청구(FIRST)는 null이고, 이때 프론트는 `settlementSessionCnt`를 보여 준다. +- 입금 계좌(`bankCode` · `bankName` · `accountLast4` · `accountHolder`)는 청구 시점 스냅샷이라 이후 과외 계좌를 바꿔도 이 청구는 그대로다. `bankCode`는 금융결제원 3자리, 목록에 없는 '기타' 은행이면 null이고 `bankName`에 직접 입력한 이름이 온다. 짧은 이름('국민') · 로고는 프론트가 `bankCode`로 찾는다. 전체 계좌번호는 내려주지 않는다(화면은 `****` + 끝 4자리). - `canceledCount`: 청구 스냅샷 휴강 내역(`canceledLessons`) 개수. `deductionAmount` · `billedCycleStartDate`는 공통 '금액 이름' 참고. - 예: 후불 회차 부족(인정 5 · 정산 8 · 단가 45,000 · 자동 계산 225,000) → `deductionAmount` 135,000. 단가 버림(수업료 100,000 · 3회 → 단가 33,333)은 3 × 33,333 < 100,000이어도 0. diff --git a/src/main/java/com/sudam/domain/invoice/dto/response/ReportInvoiceResponse.java b/src/main/java/com/sudam/domain/invoice/dto/response/ReportInvoiceResponse.java index 7ae5805..5090438 100644 --- a/src/main/java/com/sudam/domain/invoice/dto/response/ReportInvoiceResponse.java +++ b/src/main/java/com/sudam/domain/invoice/dto/response/ReportInvoiceResponse.java @@ -20,6 +20,11 @@ * @param deductionAmount 정산 회차 × 단가에서 자동 계산 금액이 모자란 만큼. 최소 0 * @param calculatedAmount 자동 계산 금액. 교육비를 수정해도 바뀌지 않는다 * @param amount 최종 금액 (교육비 수정 반영) + * @param recognizedCount 인정 회차 ('인정 회차 × 회당 단가' 줄). 정산 없이 만든 청구(FIRST)는 null + * @param bankCode 입금 계좌 은행 코드 (청구 시점 스냅샷). 목록에 없는 '기타' 은행은 null + * @param bankName 입금 계좌 은행 이름 (청구 시점 스냅샷) + * @param accountLast4 입금 계좌 끝 4자리. 화면은 마스킹해 보여 주므로 전체 계좌번호는 내려주지 않는다 + * @param accountHolder 예금주 (청구 시점 스냅샷) */ public record ReportInvoiceResponse( @Schema(description = "청구 ID", example = "301") @@ -48,7 +53,22 @@ public record ReportInvoiceResponse( Integer calculatedAmount, @Schema(description = "최종 금액(원). 교육비 수정 반영", example = "375000") - Integer amount + Integer amount, + + @Schema(description = "인정 회차. 정산 없이 만든 선불 첫 청구(FIRST)는 null", example = "8", nullable = true) + Integer recognizedCount, + + @Schema(description = "금융결제원 은행 코드 3자리. 목록에 없는 '기타' 은행은 null", example = "004", nullable = true) + String bankCode, + + @Schema(description = "은행 이름", example = "국민은행") + String bankName, + + @Schema(description = "계좌번호 끝 4자리", example = "1492") + String accountLast4, + + @Schema(description = "예금주", example = "한서윤") + String accountHolder ) { /*** @@ -69,7 +89,12 @@ public static ReportInvoiceResponse of(Invoice invoice) { snapshot != null ? snapshot.canceledLessons().size() : 0, Math.max(0, fullAmount - invoice.getCalculatedAmount()), invoice.getCalculatedAmount(), - invoice.getAmount() + invoice.getAmount(), + invoice.getRecognizedCount(), + invoice.getBankCode(), + invoice.getBankName(), + invoice.getAccountLast4(), + invoice.getAccountHolder() ); } } diff --git a/src/test/java/com/sudam/domain/invoice/controller/InvoiceAdjustmentControllerTest.java b/src/test/java/com/sudam/domain/invoice/controller/InvoiceAdjustmentControllerTest.java index fbbd2e6..7793dae 100644 --- a/src/test/java/com/sudam/domain/invoice/controller/InvoiceAdjustmentControllerTest.java +++ b/src/test/java/com/sudam/domain/invoice/controller/InvoiceAdjustmentControllerTest.java @@ -86,12 +86,12 @@ static Stream invalidBodies() { } @Test - @DisplayName("교육비 수정은 200 · INVOICE200_3과 교육비 안내 9개 필드를 돌려준다") + @DisplayName("교육비 수정은 200 · INVOICE200_3과 교육비 안내 14개 필드를 돌려준다") void 수정_성공() throws Exception { // given given(reportInvoiceService.adjustAmount(eq(TEACHER_ID), eq(301L), any(AdjustInvoiceAmountRequest.class))) .willReturn(new ReportInvoiceResponse(301L, PaymentTiming.PREPAID, 8, LocalDate.of(2026, 9, 14), - 45_000, 0, 0, 360_000, 375_000)); + 45_000, 0, 0, 360_000, 375_000, 8, "004", "국민은행", "1492", "한서윤")); // when & then mockMvc.perform(post(URL).with(teacher()) @@ -109,7 +109,12 @@ static Stream invalidBodies() { .andExpect(jsonPath("$.result.canceledCount").value(0)) .andExpect(jsonPath("$.result.deductionAmount").value(0)) .andExpect(jsonPath("$.result.calculatedAmount").value(360_000)) - .andExpect(jsonPath("$.result.amount").value(375_000)); + .andExpect(jsonPath("$.result.amount").value(375_000)) + .andExpect(jsonPath("$.result.recognizedCount").value(8)) + .andExpect(jsonPath("$.result.bankCode").value("004")) + .andExpect(jsonPath("$.result.bankName").value("국민은행")) + .andExpect(jsonPath("$.result.accountLast4").value("1492")) + .andExpect(jsonPath("$.result.accountHolder").value("한서윤")); verify(reportInvoiceService).adjustAmount(TEACHER_ID, 301L, new AdjustInvoiceAmountRequest(375_000, "교재비 15,000원 추가")); diff --git a/src/test/java/com/sudam/domain/invoice/controller/ReportInvoiceControllerTest.java b/src/test/java/com/sudam/domain/invoice/controller/ReportInvoiceControllerTest.java index b962d09..694deb0 100644 --- a/src/test/java/com/sudam/domain/invoice/controller/ReportInvoiceControllerTest.java +++ b/src/test/java/com/sudam/domain/invoice/controller/ReportInvoiceControllerTest.java @@ -48,7 +48,7 @@ class ReportInvoiceControllerTest { // given given(reportInvoiceService.getReportInvoice(TEACHER_ID, 21L)) .willReturn(new ReportInvoiceResponse(301L, PaymentTiming.POSTPAID, 8, null, - 45_000, 2, 135_000, 225_000, 225_000)); + 45_000, 2, 135_000, 225_000, 225_000, 5, "004", "국민은행", "1492", "한서윤")); // when & then mockMvc.perform(get("/api/v1/reports/21/invoice").with(teacher())) @@ -59,7 +59,13 @@ class ReportInvoiceControllerTest { .andExpect(jsonPath("$.result.invoiceId").value(301)) .andExpect(jsonPath("$.result.billedCycleStartDate").doesNotExist()) .andExpect(jsonPath("$.result.canceledCount").value(2)) - .andExpect(jsonPath("$.result.deductionAmount").value(135_000)); + .andExpect(jsonPath("$.result.deductionAmount").value(135_000)) + .andExpect(jsonPath("$.result.recognizedCount").value(5)) + .andExpect(jsonPath("$.result.bankCode").value("004")) + .andExpect(jsonPath("$.result.bankName").value("국민은행")) + .andExpect(jsonPath("$.result.accountLast4").value("1492")) + .andExpect(jsonPath("$.result.accountHolder").value("한서윤")) + .andExpect(jsonPath("$.result.accountNumber").doesNotExist()); } @Test diff --git a/src/test/java/com/sudam/domain/invoice/dto/response/ReportInvoiceResponseTest.java b/src/test/java/com/sudam/domain/invoice/dto/response/ReportInvoiceResponseTest.java index bb24d9b..f16c8ac 100644 --- a/src/test/java/com/sudam/domain/invoice/dto/response/ReportInvoiceResponseTest.java +++ b/src/test/java/com/sudam/domain/invoice/dto/response/ReportInvoiceResponseTest.java @@ -109,6 +109,66 @@ class ReportInvoiceResponseTest { assertThat(response.deductionAmount()).isZero(); } + @Test + @DisplayName("입금 계좌는 청구 스냅샷의 은행 코드 · 은행 이름 · 끝 4자리 · 예금주를 그대로 쓰고 인정 회차도 함께 담는다") + void 입금_계좌와_인정_회차() { + // given + TutoringPolicy policy = policy(PaymentTiming.POSTPAID, 360_000, 8); + Invoice invoice = issue(policy, InvoiceKind.FINAL, 225_000, + InvoiceSnapshot.of(policy, 5, SEP_14, List.of())); + + // when + ReportInvoiceResponse response = ReportInvoiceResponse.of(invoice); + + // then + assertThat(response.recognizedCount()).isEqualTo(5); + assertThat(response.bankCode()).isEqualTo("004"); + assertThat(response.bankName()).isEqualTo("국민"); + assertThat(response.accountLast4()).isEqualTo("1492"); + assertThat(response.accountHolder()).isEqualTo("한서윤"); + } + + @Test + @DisplayName("정산 없이 만든 선불 첫 청구(FIRST)는 인정 회차가 null이다") + void 선불_첫_청구_인정_회차() { + // given + TutoringPolicy policy = policy(PaymentTiming.PREPAID, 360_000, 8); + Invoice invoice = issue(policy, InvoiceKind.FIRST, 360_000, + InvoiceSnapshot.of(policy, null, null, null)); + + // when + ReportInvoiceResponse response = ReportInvoiceResponse.of(invoice); + + // then + assertThat(response.recognizedCount()).isNull(); + } + + @Test + @DisplayName("목록에 없는 '기타' 은행 계좌면 은행 코드는 null이고 직접 입력한 은행 이름이 담긴다") + void 기타_은행() { + // given + TutoringPolicy policy = TutoringPolicy.builder() + .effectiveCycleNo(1) + .settlementSessionCnt(8) + .paymentTiming(PaymentTiming.PREPAID) + .tuitionFee(360_000) + .bankCode(null) + .bankName("증권사 CMA") + .accountNumber("5555-6666-7777") + .accountHolder("한서윤") + .build(); + Invoice invoice = issue(policy, InvoiceKind.NEXT, 360_000, + InvoiceSnapshot.of(policy, 8, SEP_14, List.of())); + + // when + ReportInvoiceResponse response = ReportInvoiceResponse.of(invoice); + + // then + assertThat(response.bankCode()).isNull(); + assertThat(response.bankName()).isEqualTo("증권사 CMA"); + assertThat(response.accountLast4()).isEqualTo("7777"); + } + private static TutoringPolicy policy(PaymentTiming timing, int tuitionFee, int settlementSessionCnt) { return TutoringPolicy.builder() .effectiveCycleNo(1)