Skip to content

feat: 입고 아이템 수정 기능 구현#92

Merged
JoonKyoLee merged 6 commits intomainfrom
feat/update-receipt-item
Nov 24, 2025
Merged

feat: 입고 아이템 수정 기능 구현#92
JoonKyoLee merged 6 commits intomainfrom
feat/update-receipt-item

Conversation

@JoonKyoLee
Copy link
Contributor

@JoonKyoLee JoonKyoLee commented Nov 24, 2025

✨ 작업 내용

  • 입고 아이템 수정 기능 추가

📝 적용 범위

  • /receipt

📌 참고 사항

Summary by CodeRabbit

  • 새로운 기능

    • 입고 아이템 수정 API 추가 — 항목 정보(박스 수, 측정 중량, 예상/실제 수량, 단가, 메모) 업데이트 가능
    • 입고 아이템 응답에 단가(unitPrice) 필드 추가
    • 성공 응답 메시지 항목에 입고 아이템 수정 성공 메시지 추가
  • 테스트

    • 입고 아이템 수정 관련 테스트 추가(성공 및 다양한 실패 시나리오 포함)

✏️ Tip: You can customize this high-level summary in your review settings.

@JoonKyoLee JoonKyoLee self-assigned this Nov 24, 2025
@JoonKyoLee JoonKyoLee added the enhancement New feature or request label Nov 24, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 24, 2025

Walkthrough

입고 아이템 수정 기능이 추가되었습니다: SuccessMessage에 상수 추가, PATCH 엔드포인트와 요청 DTO 도입, ReceiptItemResponse에 unitPrice 필드 확장, ReceiptService에 트랜잭션 업데이트 로직 추가, 관련 단위/통합 테스트 보강이 포함됩니다.

Changes

Cohort / File(s) Change Summary
성공 메시지 정의
src/main/java/com/almang/inventory/global/api/SuccessMessage.java
UPDATE_RECEIPT_ITEM_SUCCESS("입고 아이템 수정 성공") 열거형 상수 추가
컨트롤러 엔드포인트
src/main/java/com/almang/inventory/receipt/controller/ReceiptController.java
PATCH /api/v1/receipt/receipt/{receiptItemId} 엔드포인트 추가 (요청: UpdateReceiptItemRequest, 인증 필요, 서비스 위임, 성공 응답: UPDATE_RECEIPT_ITEM_SUCCESS)
응답 DTO 확장
src/main/java/com/almang/inventory/receipt/dto/response/ReceiptItemResponse.java
Integer unitPrice 컴포넌트 추가 및 from(ReceiptItem) 팩토리에서 unitPrice 채움
비즈니스 로직
src/main/java/com/almang/inventory/receipt/service/ReceiptService.java
updateReceiptItem(Long, UpdateReceiptItemRequest, Long) 트랜잭션 메서드 추가: 사용자/점포 인증, receipt 접근 검증, ReceiptItem 조회 및 필드(boxCount, measuredWeight, expectedQuantity, actualQuantity, unitPrice, note) 업데이트, Receipt의 totalBoxCount 재계산, 응답 반환
컨트롤러 테스트
src/test/java/com/almang/inventory/receipt/controller/ReceiptControllerTest.java
ReceiptItemResponse 생성자 시그니처 변경 반영, 테스트 데이터/응답 검증 조정, 입고 아이템 수정 성공/실패 케이스 추가
서비스 테스트
src/test/java/com/almang/inventory/receipt/service/ReceiptServiceTest.java
ReceiptItemRepository 주입 추가 및 업데이트 관련 성공/실패 경로(unitPrice 포함) 테스트 추가

Sequence Diagram(s)

sequenceDiagram
    participant Client as 클라이언트
    participant Controller as ReceiptController
    participant Service as ReceiptService
    participant Repo as Repository(s)
    rect rgb(220,240,255)
    Client->>Controller: PATCH /api/v1/receipt/receipt/{receiptItemId}\nUpdateReceiptItemRequest + Auth
    Controller->>Service: updateReceiptItem(id, req, userId)
    end
    rect rgb(235,255,230)
    Service->>Repo: findUserById(userId)\nfindReceiptById(req.receiptId)\nfindReceiptItemById(receiptItemId)
    Repo-->>Service: entities
    Service->>Service: 검증: 사용자/점포/소유권
    Service->>Service: update fields\nrecalculate totalBoxCount
    Service->>Repo: save/update entities
    Repo-->>Service: saved entities
    end
    Service-->>Controller: ReceiptItemResponse
    Controller-->>Client: 200 OK { ApiResponse<ReceiptItemResponse>, message: UPDATE_RECEIPT_ITEM_SUCCESS }
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20분

  • 주의 검토 포인트:
    • ReceiptService.updateReceiptItem(): 사용자·점포 유도 및 소유권 검증 체인이 누락 없이 구현되었는지(경계 조건 포함) 확인하세요.
    • amount/금액 관련 필드 재계산: unitPrice 변경 시 amount(총액)가 자동 갱신되는지 확인하고 필요하면 명시적 업데이트를 추가하세요.
    • totalBoxCount 재계산이 모든 ReceiptItem의 boxCount 합으로 정확히 반영되는지(동시성/트랜잭션 경합 고려) 검증하세요.
    • API 응답 호환성: ReceiptItemResponse에 unitPrice가 추가되어 프론트엔드 영향이 있는지 확인하세요.
    • 테스트: 음수/0/큰값 등 경계값 케이스 추가를 권장합니다.

Possibly related PRs

  • #71 — 비슷한 패턴으로 UPDATE_*_ITEM_SUCCESS 상수를 추가하고 아이템 업데이트 엔드포인트를 구현한 PR (enum/패턴 중복 가능성).
  • #82 — Receipt/ReceiptItem 도메인과 DTO·컨트롤러·서비스를 확장한 PR으로 동일 파일군에 연관성 높음.
  • #89 — 입고(Receipt) 업데이트 흐름을 다루는 PR로, 컨트롤러·서비스 수정 영역이 겹칩니다.

Poem

📦 입고의 수정이 도착했네,
PATCH 한 줄로 값이 바뀌고,
unitPrice가 새 자리를 찾고,
검증은 견고히, 테스트는 증명하네,
작은 변경, 큰 안심 — 잘했어요! 🎉

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly summarizes the main feature being implemented: adding the receipt item update functionality, directly matching the primary change across all modified files.
Description check ✅ Passed The description follows the repository template with all required sections (작업 내용, 적용 범위, 참고 사항) completed and clearly identifies the scope as /receipt endpoint with issue reference.
Linked Issues check ✅ Passed The pull request fully implements the objective from issue #80: the receipt item update functionality is comprehensively implemented across controller, service, DTO, and test layers with proper validation and error handling.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the receipt item update feature—controller endpoint, service logic, DTOs, success message, and comprehensive test coverage—with no extraneous modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/update-receipt-item

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e939b9f and d4d36f0.

📒 Files selected for processing (1)
  • src/test/java/com/almang/inventory/receipt/controller/ReceiptControllerTest.java (13 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-22T18:12:13.161Z
Learnt from: JoonKyoLee
Repo: almang2/inventory-server PR: 66
File: src/main/java/com/almang/inventory/order/domain/OrderItem.java:41-53
Timestamp: 2025-11-22T18:12:13.161Z
Learning: In the almang2/inventory-server repository, OrderItem entity update methods (updateQuantity, updatePrice in src/main/java/com/almang/inventory/order/domain/OrderItem.java) do not require null checks because OrderService will validate parameters before calling these update methods, following the same pattern as Product entity updates.
<!--

Applied to files:

  • src/test/java/com/almang/inventory/receipt/controller/ReceiptControllerTest.java
🧬 Code graph analysis (1)
src/test/java/com/almang/inventory/receipt/controller/ReceiptControllerTest.java (1)
src/test/java/com/almang/inventory/receipt/service/ReceiptServiceTest.java (4)
  • Test (641-739)
  • Test (982-1024)
  • Test (821-895)
  • receiptService (816-816)
🔇 Additional comments (3)
src/test/java/com/almang/inventory/receipt/controller/ReceiptControllerTest.java (3)

66-79: LGTM! ReceiptItemResponse 생성자 호출 일관되게 업데이트됨

새로 추가된 unitPrice 필드를 위해 null 인자를 추가한 것이 모든 테스트에서 일관되게 적용되었습니다. 기존 테스트들과의 호환성을 유지하면서 잘 처리되었습니다.

Also applies to: 189-201, 311-323, 413-427, 789-801


874-925: LGTM! 성공 케이스 테스트 잘 작성됨

입고 아이템 수정 성공 시나리오가 명확하게 구현되었습니다. 요청 데이터 생성, 모킹, 그리고 응답 검증까지 체계적으로 작성되어 있고, 금액 계산(10 * 1500 = 15000)도 정확합니다.


927-1085: LGTM! 예외 처리 테스트 완벽하게 커버됨

5가지 예외 시나리오가 빠짐없이 테스트되었습니다:

  • 사용자 미존재
  • 입고 미존재
  • 입고 접근 권한 부족
  • 아이템 미존재
  • 다른 상점 아이템 접근 거부

각 테스트는 적절한 HTTP 상태 코드와 에러 메시지를 검증하고 있으며, 서비스 레이어의 예외 처리와 일관성 있게 구성되었습니다. 👍


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

@JoonKyoLee JoonKyoLee force-pushed the feat/update-receipt-item branch from e939b9f to d4d36f0 Compare November 24, 2025 08:48
@JoonKyoLee JoonKyoLee merged commit 2d74e9c into main Nov 24, 2025
1 check passed
@JoonKyoLee JoonKyoLee deleted the feat/update-receipt-item branch November 25, 2025 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 입고 아이템 수정 기능 구현

1 participant