Skip to content

[FIX] 구매 서비스 예정일 계산 로직 수정#3

Merged
taemin3 merged 1 commit into
mainfrom
SPM-460
Nov 8, 2025
Merged

[FIX] 구매 서비스 예정일 계산 로직 수정#3
taemin3 merged 1 commit into
mainfrom
SPM-460

Conversation

@taemin3
Copy link
Copy Markdown
Contributor

@taemin3 taemin3 commented Nov 8, 2025

📝 Summary

  • 구매 서비스 예정일 계산 로직 수정

🙏 Question & PR point

📬 Reference

Summary by CodeRabbit

  • 새로운 기능
    • 표준 수량을 고려한 예상 배송일 계산 로직이 추가되었습니다.
    • 실제 주문 수량과 표준 수량의 비율을 기반으로 더 정확한 리드타임을 동적으로 계산합니다.
    • 이를 통해 구매 주문의 배송 예상일 정확도가 향상되었습니다.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 8, 2025

개요

주문 항목에 표준 수량 필드를 추가하고, (수량/표준수량) × 리드타임 공식을 통해 예상 납기일을 계산하는 로직을 구현했습니다. DTO, 엔티티, 서비스 계층에 걸쳐 변경이 적용되었습니다.

변경 사항

변경 항목 요약
엔티티 및 DTO 계층
src/main/java/com/sampoom/purchase/api/purchase/entity/PurchaseOrderItem.java,
src/main/java/com/sampoom/purchase/api/purchase/dto/PurchaseOrderItemDto.java
standardQuantity 필드 추가 및 Lombok을 통한 자동 getter 생성. DTO에는 calculateExpectedDate(LocalDate orderDate) 메서드 추가로 예상 납기일 계산 지원.
서비스 계층
src/main/java/com/sampoom/purchase/api/purchase/service/PurchaseService.java
주문 생성 시 각 항목에 standardQuantity 설정. (수량/표준수량) × 리드타임 공식으로 계산된 리드타임을 최댓값으로 적용하여 expectedDeliveryAt 결정. 표준수량 또는 리드타임이 불완전하면 기존 리드타임 사용.

시퀀스 다이어그램

sequenceDiagram
    actor User
    participant Service as PurchaseService
    participant Item as PurchaseOrderItem
    participant DTO as PurchaseOrderItemDto
    
    User->>Service: 주문 생성 요청
    Service->>Service: standardQuantity 포함 아이템 생성
    Service->>Item: (quantity / standardQuantity) × leadTimeDays 계산
    Service->>Service: 최댓값으로 expectedDeliveryAt 결정
    Item->>DTO: 엔티티에서 DTO로 변환
    DTO->>DTO: calculateExpectedDate() 호출<br/>(필요시 납기일 재계산)
    DTO->>User: 변환된 주문 정보 반환
Loading

예상 코드 리뷰 소요 시간

🎯 2 (Simple) | ⏱️ ~10분

  • 표준수량 필드 추가는 반복적이고 일관된 패턴
  • 계산 로직(leadTimeDays 공식)의 null 및 0 값 처리 검증 필요
  • 세 개 파일에 걸친 변경이지만 응집도 높음

시 (詩)

🐰 표준을 정하고 수량을 재니,
납기는 이제 계산으로 맺히고,
리드타임 곱하기 그 몫이라니,
정확한 날짜 손에 들어오네요!
예상은 이제 혼란 없이 ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경 사항의 주요 목적을 명확하게 반영하고 있습니다. 구매 서비스의 예정일 계산 로직 수정이라는 핵심 변화를 간결하게 설명합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 SPM-460

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 and usage tips.

Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (2)
src/main/java/com/sampoom/purchase/api/purchase/service/PurchaseService.java (1)

118-126: DTO와 서비스 간 계산 로직 중복

이 메서드의 계산 로직이 PurchaseOrderItemDto.calculateExpectedDate (lines 43-52)와 중복됩니다. 다만 이 서비스 메서드가 null 처리를 더 안전하게 수행하고 있습니다.

코드 중복을 줄이기 위해 다음 중 하나를 고려해보세요:

  • DTO 메서드를 제거하고 서비스 로직만 유지
  • 또는 공통 유틸리티로 추출하여 두 곳에서 재사용
src/main/java/com/sampoom/purchase/api/purchase/dto/PurchaseOrderItemDto.java (1)

37-52: 미사용 DTO 메서드 제거 검토 필요

검증 결과, calculateExpectedDate 메서드는 코드베이스 내 어디서도 호출되지 않습니다. 동시에 PurchaseService.calculateItemLeadTime (lines 118-126)과 동일한 계산 공식 (quantity/standardQuantity) * leadTimeDays를 중복 구현하고 있습니다.

  • 이 메서드가 향후 외부 API나 클라이언트 용도로 필요한 경우 유지
  • 그렇지 않으면 미사용 메서드로 제거 검토
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1e325af and ac8c22f.

📒 Files selected for processing (3)
  • src/main/java/com/sampoom/purchase/api/purchase/dto/PurchaseOrderItemDto.java (3 hunks)
  • src/main/java/com/sampoom/purchase/api/purchase/entity/PurchaseOrderItem.java (1 hunks)
  • src/main/java/com/sampoom/purchase/api/purchase/service/PurchaseService.java (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (java-kotlin)
🔇 Additional comments (7)
src/main/java/com/sampoom/purchase/api/purchase/entity/PurchaseOrderItem.java (1)

22-22: LGTM!

새로운 standardQuantity 필드 추가가 적절하며, 예정일 계산 로직 개선을 위한 기반이 잘 마련되었습니다.

src/main/java/com/sampoom/purchase/api/purchase/dto/PurchaseOrderItemDto.java (2)

21-21: LGTM!

DTO에 standardQuantity 필드가 적절히 추가되었습니다.


25-35: LGTM!

from() 메서드에서 standardQuantity 매핑이 정확합니다.

src/main/java/com/sampoom/purchase/api/purchase/service/PurchaseService.java (4)

47-52: LGTM!

최대 계산된 리드타임을 구하는 로직이 정확합니다. 각 아이템의 계산된 리드타임 중 최댓값을 선택하는 방식은 전체 주문의 예정일을 결정하는 데 적합합니다.


54-55: LGTM!

예정일 계산 로직이 새로운 리드타임 계산 방식을 올바르게 반영하고 있습니다.


75-86: LGTM!

주문 아이템 생성 시 standardQuantity 필드가 적절히 설정되고 있습니다.


118-126: LGTM! null 처리가 안전합니다.

calculateItemLeadTime 메서드가 모든 필수 필드(quantity, standardQuantity, leadTimeDays)에 대해 적절히 null 체크를 수행하고 있으며, 계산 공식이 정확합니다. Math.ceil을 사용하여 부분 일수를 올림 처리하는 것도 적절합니다.

Copy link
Copy Markdown

@vivivim vivivim left a comment

Choose a reason for hiding this comment

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

좋군요

@taemin3 taemin3 merged commit 6861d57 into main Nov 8, 2025
8 checks passed
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.

2 participants