-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Portfolio의 LocalDate 모킹 * feat: StockDividend 필드에 isDeleted 컬럼 추가 * feat: DividendDates 임베디드 클래스 추가 * feat: StockDividendParser 추가 * feat: 생성자 압축 * refactor: 객체지향적으로 변경 * refactor: Stock 필드에 LocalDateTimeService 추가 * refactor: StockParser 추가 및 분리 * style: 코드 정리 * fix: HashTable 변경 * style: equals 재정의 * refactor: 불필요한 메서드 인수 제거 * Refactor: file.delete 개선 * style: 코드 정리 * style: sonarLint에 따른 코드 정리 * fix: 테스트 실패 해결 * style:: 코드 정리 * test: 테스트 해결 * style: 코드 정리 * [feat] �배당금 엔티티에 필드 추가 및 포트폴리오 필드 추가 (#451) * feat: Portfolio의 LocalDate 모킹 * feat: StockDividend 필드에 isDeleted 컬럼 추가
- Loading branch information
1 parent
4ff3f23
commit 6e06a15
Showing
113 changed files
with
816 additions
and
612 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
src/main/java/codesquad/fineants/domain/common/money/Bank.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
src/main/java/codesquad/fineants/domain/dividend/domain/entity/DividendDates.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package codesquad.fineants.domain.dividend.domain.entity; | ||
|
||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import org.apache.logging.log4j.util.Strings; | ||
|
||
import codesquad.fineants.domain.dividend.domain.calculator.ExDividendDateCalculator; | ||
import codesquad.fineants.domain.dividend.domain.reader.HolidayFileReader; | ||
import codesquad.fineants.domain.kis.repository.HolidayRepository; | ||
import codesquad.fineants.domain.purchasehistory.domain.entity.PurchaseHistory; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Embeddable | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@EqualsAndHashCode(of = "recordDate") | ||
public class DividendDates { | ||
@Column(name = "record_date", nullable = false) | ||
private LocalDate recordDate; | ||
@Column(name = "ex_dividend_date", nullable = false) | ||
private LocalDate exDividendDate; | ||
@Column(name = "payment_date") | ||
private LocalDate paymentDate; | ||
|
||
private static final ExDividendDateCalculator EX_DIVIDEND_DATE_CALCULATOR = new ExDividendDateCalculator( | ||
new HolidayRepository(new HolidayFileReader())); | ||
|
||
public static DividendDates withRecordDateOnly(LocalDate recordDate) { | ||
LocalDate exDividendDate = EX_DIVIDEND_DATE_CALCULATOR.calculate(recordDate); | ||
return new DividendDates(recordDate, exDividendDate, null); | ||
} | ||
|
||
public static DividendDates withPaymentDate(LocalDate recordDate, LocalDate paymentDate) { | ||
LocalDate exDividendDate = EX_DIVIDEND_DATE_CALCULATOR.calculate(recordDate); | ||
return new DividendDates(recordDate, exDividendDate, paymentDate); | ||
} | ||
|
||
public static DividendDates of(LocalDate recordDate, LocalDate exDividendDate, LocalDate paymentDate) { | ||
return new DividendDates(recordDate, exDividendDate, paymentDate); | ||
} | ||
|
||
public boolean canReceiveDividendOn(LocalDate purchaseDate) { | ||
if (paymentDate == null) { | ||
return false; | ||
} | ||
return purchaseDate.isBefore(exDividendDate); | ||
} | ||
|
||
public Integer getPaymentDateMonth() { | ||
return paymentDate.getMonthValue(); | ||
} | ||
|
||
public boolean isCurrentYearRecordDate(LocalDate localDate) { | ||
return localDate.getYear() == recordDate.getYear(); | ||
} | ||
|
||
public boolean isLastYearPaymentDate(LocalDate lastYearLocalDate) { | ||
if (paymentDate == null) { | ||
return false; | ||
} | ||
return lastYearLocalDate.getYear() == paymentDate.getYear(); | ||
} | ||
|
||
public Integer getQuarterWithRecordDate() { | ||
return recordDate.getMonthValue() / 4 + 1; | ||
} | ||
|
||
public boolean isCurrentYearPaymentDate(LocalDate today) { | ||
if (paymentDate == null) { | ||
return false; | ||
} | ||
return today.getYear() == paymentDate.getYear(); | ||
} | ||
|
||
public boolean equalRecordDate(LocalDate recordDate) { | ||
return this.recordDate.equals(recordDate); | ||
} | ||
|
||
public boolean hasPaymentDate() { | ||
return paymentDate != null; | ||
} | ||
|
||
public String parse() { | ||
return String.format("%s:%s:%s", recordDate, exDividendDate, paymentDate); | ||
} | ||
|
||
public boolean isPaymentInCurrentYear(LocalDate localDate) { | ||
if (paymentDate == null) { | ||
return false; | ||
} | ||
return localDate.getYear() == paymentDate.getYear(); | ||
} | ||
|
||
public boolean hasInRangeForRecordDate(LocalDate from, LocalDate to) { | ||
return recordDate.isAfter(from) && recordDate.isBefore(to); | ||
} | ||
|
||
public boolean equalPaymentDate(LocalDate paymentDate) { | ||
if (this.paymentDate == null) { | ||
return false; | ||
} | ||
return this.paymentDate.equals(paymentDate); | ||
} | ||
|
||
public String basicIsoForRecordDate() { | ||
return basicIso(recordDate); | ||
} | ||
|
||
public String basicIsoForPaymentDate() { | ||
return basicIso(paymentDate); | ||
} | ||
|
||
private String basicIso(LocalDate localDate) { | ||
if (localDate == null) { | ||
return Strings.EMPTY; | ||
} | ||
return localDate.format(DateTimeFormatter.BASIC_ISO_DATE); | ||
} | ||
|
||
public boolean isSatisfiedBy(PurchaseHistory history) { | ||
return history.isSatisfiedDividend(exDividendDate); | ||
} | ||
|
||
public boolean isPurchaseDateBeforeExDividendDate(PurchaseHistory history) { | ||
return history.isPurchaseDateBeforeExDividendDate(exDividendDate.atStartOfDay()); | ||
} | ||
} |
Oops, something went wrong.