Skip to content

(fix) : 입금 진행 후 지출 수정 방지#67

Merged
sudhdkso merged 1 commit into
developfrom
fix/expense-lock-payment-progress
Jul 13, 2026
Merged

(fix) : 입금 진행 후 지출 수정 방지#67
sudhdkso merged 1 commit into
developfrom
fix/expense-lock-payment-progress

Conversation

@sudhdkso

@sudhdkso sudhdkso commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

#️⃣연관된 이슈

X

🔀반영 브랜치

fix/expense-lock-payment-progress -> develop

🔧변경 사항

  • 입금 확인 요청 또는 참여자 입금 완료 상태가 있으면 지출 생성/수정/삭제/이미지 수정을 차단합니다.
  • 기존 입금 확인 요청 존재 여부 조회 API가 참여자 입금 완료 상태까지 함께 반영하도록 변경했습니다.
  • 잘못된 multipart 요청은 400으로 처리해 서버 에러 알림이 발생하지 않도록 했습니다.
  • 관련 단위 테스트를 추가/수정했습니다.

💬리뷰 요구사항(선택)

X

체크:

  • 테스트 코드 포함 여부: O
  • 불필요한 로그 제거: O
  • 예외 처리 여부: O

Summary by CodeRabbit

  • 버그 수정

    • 잘못된 multipart 요청이 발생하면 경고를 기록하고, 안내 메시지와 함께 400 Bad Request 응답을 반환합니다.
    • 입금 확인 요청이 진행 중이거나 입금 완료 참가자가 있는 정산은 지출 내역의 생성·수정·삭제 및 이미지 변경이 제한됩니다.
    • 변경이 제한된 경우 명확한 오류 응답이 제공됩니다.
  • 테스트

    • multipart 오류 응답과 지출 변경 제한 시나리오에 대한 검증을 추가했습니다.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

입금 확인 요청 또는 결제 완료 참가자가 있는 정산의 지출 변경을 차단하고, multipart 요청 예외에 대한 경고 로깅 및 400 응답 처리를 추가했습니다. 관련 서비스, 저장소, 예외 처리기와 테스트가 함께 변경되었습니다.

Changes

지출 수정 잠금

Layer / File(s) Summary
입금 상태 존재 여부 판별
src/main/java/com/dnd/moddo/event/application/impl/*, src/main/java/com/dnd/moddo/event/infrastructure/MemberRepository.java, src/test/java/com/dnd/moddo/domain/paymentRequest/service/*
정산의 입금 확인 요청 또는 결제 완료 참가자 존재 여부를 확인하도록 조회 로직과 테스트를 확장했습니다.
지출 변경 잠금 적용
src/main/java/com/dnd/moddo/event/application/command/CommandExpenseService.java, src/main/java/com/dnd/moddo/event/domain/expense/exception/ExpenseModificationLockedException.java, src/test/java/com/dnd/moddo/domain/expense/service/CommandExpenseServiceTest.java
지출 생성·수정·이미지 URL 변경·삭제 전에 잠금 상태를 검증하고, 잠금 시 403 예외를 발생시키도록 변경했습니다.

Multipart 예외 처리

Layer / File(s) Summary
Multipart 오류 응답 처리
src/main/java/com/dnd/moddo/common/exception/GlobalExceptionHandler.java, src/main/java/com/dnd/moddo/common/logging/LoggingUtils.java, src/test/java/com/dnd/moddo/common/exception/GlobalExceptionHandlerTest.java
MultipartException을 경고 로깅하고 "잘못된 multipart 요청입니다." 메시지와 400 Bad Request를 반환하도록 추가했습니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant CommandExpenseService
  participant PaymentRequestReader
  participant MemberReader
  Client->>CommandExpenseService: 지출 변경 요청
  CommandExpenseService->>PaymentRequestReader: 정산 잠금 여부 확인
  PaymentRequestReader->>MemberReader: 결제 완료 참가자 확인
  MemberReader-->>PaymentRequestReader: 존재 여부 반환
  PaymentRequestReader-->>CommandExpenseService: 입금 요청 또는 완료 참가자 여부
  CommandExpenseService-->>Client: 잠금 예외 또는 변경 결과
Loading

Possibly related PRs

Poem

당근처럼 단단히 잠긴 지출 문
토끼가 multipart 오류도 살펴보네
로그는 살짝, 응답은 정확히
입금이 끝나면 수정은 멈추고
깡충! 테스트도 모두 통과하네 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 입금 진행 후 지출 생성·수정·삭제 차단이라는 핵심 변경을 잘 요약합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/expense-lock-payment-progress

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

📝 테스트 커버리지 리포트입니다!

File Coverage [97.17%] 🍏
CommandExpenseService.java 100% 🍏
PaymentRequestReader.java 97.32% 🍏
MemberReader.java 89.09% 🍏
Total Project Coverage 72.14%

@sudhdkso sudhdkso merged commit c4224e1 into develop Jul 13, 2026
2 of 3 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/main/java/com/dnd/moddo/event/domain/expense/exception/ExpenseModificationLockedException.java (1)

8-10: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

예외 메시지가 모든 동작(생성/수정/삭제/이미지변경)에 대해 "수정할 수 없습니다"로 고정됨.

이 예외는 CommandExpenseServicecreateExpenses, update, updateImgUrl, delete 4곳에서 모두 던져지지만 메시지는 항상 "수정"으로 고정되어 있어, 실제로는 생성이나 삭제를 시도했는데도 "수정할 수 없다"는 메시지가 노출됩니다. 클라이언트/사용자가 오류 원인을 파악하기 어려울 수 있습니다.

♻️ 동작명을 파라미터로 받는 개선 예시
 public class ExpenseModificationLockedException extends ModdoException {
-	public ExpenseModificationLockedException(Long settlementId) {
-		super(HttpStatus.FORBIDDEN, "입금 확인 요청 또는 입금 완료 상태가 있어 지출내역을 수정할 수 없습니다. (Settlement ID: " + settlementId + ")");
-	}
+	public ExpenseModificationLockedException(Long settlementId, String action) {
+		super(HttpStatus.FORBIDDEN,
+			"입금 확인 요청 또는 입금 완료 상태가 있어 지출내역을 " + action + "할 수 없습니다. (Settlement ID: " + settlementId + ")");
+	}
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/dnd/moddo/event/domain/expense/exception/ExpenseModificationLockedException.java`
around lines 8 - 10, Update ExpenseModificationLockedException to accept the
attempted expense operation as a parameter and build its message with that
operation instead of hardcoding “수정”. Modify CommandExpenseService call sites in
createExpenses, update, updateImgUrl, and delete to pass the corresponding
operation name, preserving the existing settlementId and forbidden status.
src/test/java/com/dnd/moddo/domain/expense/service/CommandExpenseServiceTest.java (1)

301-321: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

createExpenses/updateImgUrl 경로의 잠금 실패 테스트가 없음.

update(141-164)와 delete(214-236)에는 existsBySettlementId=true일 때 ExpenseModificationLockedException이 발생하는 테스트가 추가되었지만, 동일하게 validateExpenseModifiable이 적용된 createExpensesupdateImgUrl에는 잠금 실패 시나리오 테스트가 보이지 않습니다. 이 PR의 핵심 변경사항(4개 진입점 모두 잠금)에 대한 테스트 커버리지가 일관되지 않습니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/com/dnd/moddo/domain/expense/service/CommandExpenseServiceTest.java`
around lines 301 - 321, Extend CommandExpenseServiceTest to cover
locked-settlement failures for both createExpenses and updateImgUrl. Stub
paymentRequestReader.existsBySettlementId(groupId) to return true, assert
ExpenseModificationLockedException is thrown, and verify expense creation/image
update is not invoked; retain the existing successful-path tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@src/main/java/com/dnd/moddo/event/domain/expense/exception/ExpenseModificationLockedException.java`:
- Around line 8-10: Update ExpenseModificationLockedException to accept the
attempted expense operation as a parameter and build its message with that
operation instead of hardcoding “수정”. Modify CommandExpenseService call sites in
createExpenses, update, updateImgUrl, and delete to pass the corresponding
operation name, preserving the existing settlementId and forbidden status.

In
`@src/test/java/com/dnd/moddo/domain/expense/service/CommandExpenseServiceTest.java`:
- Around line 301-321: Extend CommandExpenseServiceTest to cover
locked-settlement failures for both createExpenses and updateImgUrl. Stub
paymentRequestReader.existsBySettlementId(groupId) to return true, assert
ExpenseModificationLockedException is thrown, and verify expense creation/image
update is not invoked; retain the existing successful-path tests.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c3323cd6-0198-41e4-b51d-eba8da1006df

📥 Commits

Reviewing files that changed from the base of the PR and between 1ccc8e5 and bab6739.

📒 Files selected for processing (11)
  • src/main/java/com/dnd/moddo/common/exception/GlobalExceptionHandler.java
  • src/main/java/com/dnd/moddo/common/logging/LoggingUtils.java
  • src/main/java/com/dnd/moddo/event/application/command/CommandExpenseService.java
  • src/main/java/com/dnd/moddo/event/application/impl/MemberReader.java
  • src/main/java/com/dnd/moddo/event/application/impl/PaymentRequestReader.java
  • src/main/java/com/dnd/moddo/event/domain/expense/exception/ExpenseModificationLockedException.java
  • src/main/java/com/dnd/moddo/event/infrastructure/MemberRepository.java
  • src/test/java/com/dnd/moddo/common/exception/GlobalExceptionHandlerTest.java
  • src/test/java/com/dnd/moddo/domain/expense/service/CommandExpenseServiceTest.java
  • src/test/java/com/dnd/moddo/domain/paymentRequest/service/QueryPaymentRequestServiceTest.java
  • src/test/java/com/dnd/moddo/domain/paymentRequest/service/implementation/PaymentRequestReaderTest.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant