Skip to content

refactor: 입고 및 입고 품목에서 무게나 박스에 관련된 부분 삭제#150

Merged
JoonKyoLee merged 5 commits intomainfrom
refactor/remove-weight-in-receipt
Nov 30, 2025
Merged

refactor: 입고 및 입고 품목에서 무게나 박스에 관련된 부분 삭제#150
JoonKyoLee merged 5 commits intomainfrom
refactor/remove-weight-in-receipt

Conversation

@JoonKyoLee
Copy link
Contributor

@JoonKyoLee JoonKyoLee commented Nov 30, 2025

✨ 작업 내용

  • 입고 및 입고 품목에서 무게나 박스에 관련된 부분 삭제

📝 적용 범위

  • /receipt

📌 참고 사항

Summary by CodeRabbit

릴리스 노트

  • 리팩토링

    • 영수증 및 영수증 항목의 보조 지표(상자 수, 측정 무게, 오차율 등)를 제거하여 데이터 모델과 업데이트 흐름을 단순화했습니다.
    • 영수증/항목 업데이트는 이제 상태, 활성화 여부 및 항목의 수량·단가·메모만 처리합니다.
  • 테스트

    • 테스트 데이터와 기대 응답을 간소화하여 제거된 필드를 반영했습니다.

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

@JoonKyoLee JoonKyoLee self-assigned this Nov 30, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 30, 2025

둘러보기

이 PR은 Receipt 및 ReceiptItem 도메인에서 박스 수량 및 무게 관련 필드를 제거하고, 관련 DTO와 서비스 호출 시그니처를 단순화하며 테스트들을 이에 맞게 조정합니다. 제거된 필드: totalBoxCount, totalWeightG, boxCount, measuredWeight, errorRate; 관련 계산/재계산 로직도 삭제되었습니다.

변경 사항

Cohort / File(s) 변경 요약
도메인 — Receipt
src/main/java/com/almang/inventory/receipt/domain/Receipt.java
totalBoxCount, totalWeightG 필드 및 JPA 매핑 제거. update(...) 시그니처에서 총계 관련 파라미터 제거(이제 update(ReceiptStatus, Boolean)만 유지). updateTotalBoxCount 제거.
도메인 — ReceiptItem
src/main/java/com/almang/inventory/receipt/domain/ReceiptItem.java
boxCount, measuredWeight, errorRate 필드 제거. calculateErrorRate() 및 관련 계산/할당 로직 제거. update(...) 시그니처에서 boxCount/measuredWeight 파라미터 제거(이제 update(actualQuantity, unitPrice, note) 형태).
요청 DTOs
src/main/java/com/almang/inventory/receipt/dto/request/UpdateReceiptItemRequest.java, src/main/java/com/almang/inventory/receipt/dto/request/UpdateReceiptRequest.java
각각 레코드에서 제거된 필드(boxCount, measuredWeight, totalBoxCount, totalWeightG) 삭제하여 생성자/필드 축소. 불필요한 BigDecimal import 제거.
응답 DTOs
src/main/java/com/almang/inventory/receipt/dto/response/ReceiptItemResponse.java, src/main/java/com/almang/inventory/receipt/dto/response/ReceiptResponse.java
응답 레코드에서 boxCount, measuredWeight, errorRate, totalBoxCount, totalWeightG 제거. from(...) 팩토리 메서드 인자 조정.
서비스 레이어
src/main/java/com/almang/inventory/receipt/service/ReceiptService.java
Receipt/ReceiptItem 생성·업데이트 경로에서 총계/박스/무게 초기화 제거. receipt.update(...)receiptItem.update(...) 호출부 시그니처 업데이트. calculateTotalBoxCount 헬퍼 및 총계 재계산 로직 삭제.
테스트
src/test/java/com/almang/inventory/receipt/controller/ReceiptControllerTest.java, src/test/java/com/almang/inventory/receipt/service/ReceiptServiceTest.java
DTO/응답 생성자 호출과 빌더 초기화에서 제거된 필드 삭제. 관련 어설션 제거 및 테스트 데이터 구조 간소화. 일부 import 정리(List 등).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • 주의할 파일/영역:
    • ReceiptService.java: 모든 호출부가 새 시그니처로 일관되게 변경되었는지(생성, 업데이트, 삭제 흐름 포함) 확인하세요.
    • 도메인 엔티티의 JPA 매핑 제거가 DB 스키마/마이그레이션과 충돌 없는지(남아있는 쿼리/JPQL에서 참조 여부) 점검하세요.
    • 테스트 케이스에서 제거된 필드에 대한 잔존 참조(직접적인 생성자/어설션뿐 아니라 json 매칭 등)가 없는지 전체 검색하세요.
    • 외부(컨트롤러/클라이언트) API 계약이 변경되었으므로 API 문서나 클라이언트 호출부가 동기화되어야 합니다.

추천 참조: JPA 필드 제거 시점의 마이그레이션 가이드(예: Flyway/DDL 변경), Java record/DTO 변경 관련 호환성 문서.

Possibly related PRs

제안 라벨

enhancement

📦 박스는 떠나가고, 숫자는 가벼워져,
코드가 한숨 돌리듯 숨을 쉬네.
복잡함을 덜고 길을 닦았으니,
작지만 깔끔한 변화에 박수를! 👏✨

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 PR 제목이 주요 변경사항을 명확하게 요약합니다. 입고 및 입고 품목에서 무게와 박스 관련 부분 삭제라는 핵심 변경사항이 잘 드러나 있습니다.
Description check ✅ Passed PR 설명이 템플릿의 모든 필수 섹션(작업 내용, 적용 범위, 참고 사항)을 포함하고 있으며, 이슈 #142와의 연결성을 명확히 하고 있습니다.
Linked Issues check ✅ Passed PR의 모든 변경사항이 이슈 #142의 목표인 '입고에서 박스나 무게를 계산하지 않도록 수정'을 완전히 충족합니다. Receipt, ReceiptItem 도메인 및 관련 DTO, 서비스, 테스트가 일관되게 수정되었습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 이슈 #142의 범위 내에 있으며, 무게와 박스 관련 필드 및 로직 제거에만 집중되어 있습니다. 범위 외의 변경사항은 없습니다.
✨ 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 refactor/remove-weight-in-receipt

📜 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 a8bbb4e and 6662bb3.

📒 Files selected for processing (7)
  • src/main/java/com/almang/inventory/receipt/domain/Receipt.java (1 hunks)
  • src/main/java/com/almang/inventory/receipt/domain/ReceiptItem.java (0 hunks)
  • src/main/java/com/almang/inventory/receipt/dto/request/UpdateReceiptItemRequest.java (0 hunks)
  • src/main/java/com/almang/inventory/receipt/dto/request/UpdateReceiptRequest.java (0 hunks)
  • src/main/java/com/almang/inventory/receipt/dto/response/ReceiptResponse.java (0 hunks)
  • src/main/java/com/almang/inventory/receipt/service/ReceiptService.java (1 hunks)
  • src/test/java/com/almang/inventory/receipt/service/ReceiptServiceTest.java (6 hunks)
💤 Files with no reviewable changes (4)
  • src/main/java/com/almang/inventory/receipt/dto/request/UpdateReceiptItemRequest.java
  • src/main/java/com/almang/inventory/receipt/dto/response/ReceiptResponse.java
  • src/main/java/com/almang/inventory/receipt/dto/request/UpdateReceiptRequest.java
  • src/main/java/com/almang/inventory/receipt/domain/ReceiptItem.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/almang/inventory/receipt/domain/Receipt.java
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-20T10:43:47.502Z
Learnt from: JoonKyoLee
Repo: almang2/inventory-server PR: 33
File: src/main/java/com/almang/inventory/product/domain/Product.java:62-66
Timestamp: 2025-11-20T10:43:47.502Z
Learning: In the almang2/inventory-server repository, Product entity update methods (e.g., updateVendor in src/main/java/com/almang/inventory/product/domain/Product.java) do not require null checks on vendor parameters because ProductService validates vendor existence via findVendorByIdAndValidateAccess before calling update methods, and the vendor field has nullable=false constraint ensuring this.vendor is never null for persisted entities.

Applied to files:

  • src/test/java/com/almang/inventory/receipt/service/ReceiptServiceTest.java
📚 Learning: 2025-11-22T18:12:13.172Z
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.172Z
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/service/ReceiptServiceTest.java
  • src/main/java/com/almang/inventory/receipt/service/ReceiptService.java
🔇 Additional comments (6)
src/test/java/com/almang/inventory/receipt/service/ReceiptServiceTest.java (3)

39-39: 정적 임포트 추가로 코드 가독성이 개선되었습니다! 👍

List.of() 사용을 위한 정적 임포트 추가로 테스트 코드가 더 깔끔해졌습니다.


730-730: 정적 임포트를 일관되게 적용했습니다.

java.util.List.of() 대신 List.of()를 사용하여 코드가 더 간결해졌습니다. 테스트 전반에 걸쳐 일관되게 적용되었네요.

Also applies to: 751-751, 783-783, 850-850


1152-1152: 코드 포맷팅이 간결해졌습니다.

짧은 파라미터 리스트를 한 줄로 표현하여 가독성이 개선되었습니다.

src/main/java/com/almang/inventory/receipt/service/ReceiptService.java (3)

128-128: 입고 업데이트 로직이 깔끔하게 단순화되었습니다! 🎯

박스와 무게 관련 파라미터를 제거하여 receipt.update()가 상태와 활성화 여부만 처리하도록 개선되었습니다. 도메인 모델의 단순화가 서비스 레이어에 제대로 반영되었네요.


208-210: 입고 품목 업데이트가 핵심 정보에 집중하도록 개선되었습니다.

receiptItem.update()에서 박스 수량과 측정 무게 파라미터를 제거하여, 실제 수량, 단가, 비고만 업데이트하도록 단순화했습니다. 두 메서드(updateReceiptItem, updateReceiptItems)에서 일관되게 적용되었네요.

참고: 리팩토링 후에도 actualQuantity를 통해 여전히 정확한 입고 수량 추적이 가능합니다.

Also applies to: 348-350


243-262: 엔티티 생성 로직이 간결하고 명확합니다.

toReceiptEntity()toReceiptItemEntity() 빌더에서 박스/무게 관련 필드를 완전히 제거하여, 입고 데이터 모델이 심플해졌습니다. 불필요한 초기화 코드가 사라져 유지보수가 쉬워졌네요.


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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/test/java/com/almang/inventory/receipt/service/ReceiptServiceTest.java (1)

687-688: 사용하지 않는 변수 제거 필요

newTotalWeight 변수가 선언되었지만 사용되지 않습니다. 무게 관련 로직 제거 과정에서 남은 잔여 코드로 보입니다. 테스트 코드의 명확성을 위해 제거해 주세요.

-        BigDecimal newTotalWeight = BigDecimal.valueOf(123.456);
-
         UpdateReceiptRequest request = new UpdateReceiptRequest(
🧹 Nitpick comments (1)
src/main/java/com/almang/inventory/receipt/domain/Receipt.java (1)

14-14: 사용하지 않는 import 발견

org.springframework.security.core.parameters.P는 현재 파일에서 사용되지 않는 것으로 보입니다. 리팩토링 과정에서 남은 잔여물로 추정됩니다. 코드 정리 차원에서 제거를 권장합니다.

-import org.springframework.security.core.parameters.P;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7bf9399 and a8bbb4e.

📒 Files selected for processing (9)
  • src/main/java/com/almang/inventory/receipt/domain/Receipt.java (1 hunks)
  • src/main/java/com/almang/inventory/receipt/domain/ReceiptItem.java (0 hunks)
  • src/main/java/com/almang/inventory/receipt/dto/request/UpdateReceiptItemRequest.java (0 hunks)
  • src/main/java/com/almang/inventory/receipt/dto/request/UpdateReceiptRequest.java (0 hunks)
  • src/main/java/com/almang/inventory/receipt/dto/response/ReceiptItemResponse.java (0 hunks)
  • src/main/java/com/almang/inventory/receipt/dto/response/ReceiptResponse.java (0 hunks)
  • src/main/java/com/almang/inventory/receipt/service/ReceiptService.java (1 hunks)
  • src/test/java/com/almang/inventory/receipt/controller/ReceiptControllerTest.java (1 hunks)
  • src/test/java/com/almang/inventory/receipt/service/ReceiptServiceTest.java (6 hunks)
💤 Files with no reviewable changes (5)
  • src/main/java/com/almang/inventory/receipt/dto/request/UpdateReceiptRequest.java
  • src/main/java/com/almang/inventory/receipt/dto/request/UpdateReceiptItemRequest.java
  • src/main/java/com/almang/inventory/receipt/domain/ReceiptItem.java
  • src/main/java/com/almang/inventory/receipt/dto/response/ReceiptResponse.java
  • src/main/java/com/almang/inventory/receipt/dto/response/ReceiptItemResponse.java
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-20T10:43:47.502Z
Learnt from: JoonKyoLee
Repo: almang2/inventory-server PR: 33
File: src/main/java/com/almang/inventory/product/domain/Product.java:62-66
Timestamp: 2025-11-20T10:43:47.502Z
Learning: In the almang2/inventory-server repository, Product entity update methods (e.g., updateVendor in src/main/java/com/almang/inventory/product/domain/Product.java) do not require null checks on vendor parameters because ProductService validates vendor existence via findVendorByIdAndValidateAccess before calling update methods, and the vendor field has nullable=false constraint ensuring this.vendor is never null for persisted entities.

Applied to files:

  • src/test/java/com/almang/inventory/receipt/service/ReceiptServiceTest.java
📚 Learning: 2025-11-22T18:12:13.172Z
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.172Z
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/service/ReceiptServiceTest.java
  • src/main/java/com/almang/inventory/receipt/domain/Receipt.java
  • src/test/java/com/almang/inventory/receipt/controller/ReceiptControllerTest.java
  • src/main/java/com/almang/inventory/receipt/service/ReceiptService.java
🔇 Additional comments (9)
src/main/java/com/almang/inventory/receipt/domain/Receipt.java (1)

56-65: 리팩토링 목표에 부합하는 깔끔한 변경입니다 👍

update 메서드에서 totalBoxCounttotalWeightG 관련 파라미터가 제거되어 PR 목표(입고에서 박스/무게 계산 제거)에 잘 부합합니다. null 체크 패턴도 기존 엔티티 패턴과 일관성을 유지하고 있습니다.

src/test/java/com/almang/inventory/receipt/service/ReceiptServiceTest.java (2)

39-39: import 정리 및 일관성 개선 LGTM

java.util.List import 추가 후 List.of() 형태로 통일한 것은 코드 가독성 향상에 좋습니다. 테스트 케이스들이 새로운 DTO 시그니처에 맞게 잘 업데이트되었습니다.

Also applies to: 732-732, 753-753, 785-785, 852-852


1154-1154: UpdateReceiptItemRequest 생성자 호출 확인

간소화된 DTO 시그니처에 맞게 테스트가 잘 업데이트되었습니다. boxCountmeasuredWeight 파라미터가 제거된 새로운 생성자 형태를 올바르게 사용하고 있습니다.

src/test/java/com/almang/inventory/receipt/controller/ReceiptControllerTest.java (2)

402-410: DTO 시그니처 변경에 따른 테스트 업데이트 확인

ReceiptItemResponse 생성자가 박스/무게 관련 필드 제거에 맞게 올바르게 업데이트되었습니다. 테스트 데이터 구성이 새로운 API 응답 형태와 일치합니다.


65-109: 컨트롤러 테스트 커버리지 유지 확인 👍

성공 케이스와 에러 케이스 모두에 대한 테스트가 잘 유지되고 있습니다. Mock 응답 객체들이 간소화된 DTO 구조에 맞게 적절히 업데이트되었으며, JSON 경로 검증도 새로운 응답 형태에 맞습니다.

Also applies to: 183-226, 300-343, 399-451, 487-550, 740-771, 830-874

src/main/java/com/almang/inventory/receipt/service/ReceiptService.java (4)

119-138: 입고 수정 로직 간소화 완료

receipt.update() 호출이 statusactivated만 전달하도록 단순화되었습니다. 무게/박스 재계산 로직이 제거되어 코드 복잡도가 감소했습니다. PR 목표에 부합하는 깔끔한 리팩토링입니다.


195-217: 입고 아이템 수정 메서드 개선

receiptItem.update() 호출에서 boxCountmeasuredWeight 파라미터가 제거되었습니다. 이에 따라 총 박스 수 재계산 로직도 불필요해져 전체적인 코드 흐름이 단순해졌습니다.


246-265: 엔티티 생성 메서드 정리 완료

toReceiptEntitytoReceiptItemEntity 메서드에서 무게/박스 관련 필드 초기화가 제거되었습니다. 빌더 패턴 사용이 깔끔하며, 필수 필드만 설정하는 명확한 구조입니다.


343-355: updateReceiptItems 헬퍼 메서드 간소화

반복문 내 receiptItem.update() 호출이 새로운 시그니처에 맞게 업데이트되었습니다. 이전에 존재하던 총 박스 수 재계산 로직이 제거되어 메서드의 책임이 명확해졌습니다.

@JoonKyoLee JoonKyoLee merged commit a732986 into main Nov 30, 2025
1 check passed
@JoonKyoLee JoonKyoLee deleted the refactor/remove-weight-in-receipt branch December 2, 2025 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] 입고 관련 부분 리팩토링 진행

1 participant