Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/api-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
) {

/***
Expand All @@ -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()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ static Stream<Arguments> 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())
Expand All @@ -109,7 +109,12 @@ static Stream<Arguments> 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์› ์ถ”๊ฐ€"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading