Skip to content

Commit

Permalink
feat : upgrade to java 21 (#403)
Browse files Browse the repository at this point in the history
* feat : upgrade to java 21

* format
  • Loading branch information
rajadilipkolli authored Aug 31, 2024
1 parent a8419c3 commit df007e6
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 22 deletions.
23 changes: 23 additions & 0 deletions init.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
initscript {
repositories {
maven { url "https://plugins.gradle.org/m2" }
}
dependencies { classpath("org.openrewrite:plugin:6.21.1") }
}
rootProject {
plugins.apply(org.openrewrite.gradle.RewritePlugin)
dependencies {
rewrite("org.openrewrite.recipe:rewrite-spring:5.18.0")
}
rewrite {
activeRecipe("org.openrewrite.java.spring.boot3.SpringBoot3BestPractices")
exportDatatables = true
}
afterEvaluate {
if (repositories.isEmpty()) {
repositories {
mavenCentral()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ default MFSchemeDTO updateMFScheme(MFSchemeEntity mfSchemeEntity, @MappingTarget
String date = null;
String nav = null;
if (!mfSchemeEntity.getMfSchemeNavEntities().isEmpty()) {
LocalDate localDate = mfSchemeEntity.getMfSchemeNavEntities().get(0).getNavDate();
nav = String.valueOf(mfSchemeEntity.getMfSchemeNavEntities().get(0).getNav());
LocalDate localDate =
mfSchemeEntity.getMfSchemeNavEntities().getFirst().getNavDate();
nav = String.valueOf(
mfSchemeEntity.getMfSchemeNavEntities().getFirst().getNav());
if (null != localDate) {
date = localDate.toString();
}
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/com/learning/mfscreener/service/FIFOUnitsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,32 +189,32 @@ void findTaxFromTransactionsAndProcess(List<UserTransactionDTO> userTransactionD
Double tax = userTransactionDTOS.get(1).amount();
buy(
dt,
BigDecimal.valueOf(userTransactionDTOS.get(0).units()),
BigDecimal.valueOf(userTransactionDTOS.get(0).nav()),
BigDecimal.valueOf(userTransactionDTOS.getFirst().units()),
BigDecimal.valueOf(userTransactionDTOS.getFirst().nav()),
BigDecimal.valueOf(tax));
} else if (userTransactionDTOS.get(0).type().compareTo(TransactionType.STT_TAX) == 0) {
} else if (userTransactionDTOS.getFirst().type().compareTo(TransactionType.STT_TAX) == 0) {
// sell
Double tax = userTransactionDTOS.get(0).amount();
Double tax = userTransactionDTOS.getFirst().amount();
sell(
dt,
BigDecimal.valueOf(userTransactionDTOS.get(1).units()),
BigDecimal.valueOf(userTransactionDTOS.get(1).nav()),
BigDecimal.valueOf(tax));
}
} else if (userTransactionDTOS.size() == 1) {
if (userTransactionDTOS.get(0).type().compareTo(TransactionType.REDEMPTION) == 0
|| userTransactionDTOS.get(0).type().compareTo(TransactionType.SWITCH_OUT) == 0) {
if (userTransactionDTOS.getFirst().type().compareTo(TransactionType.REDEMPTION) == 0
|| userTransactionDTOS.getFirst().type().compareTo(TransactionType.SWITCH_OUT) == 0) {
sell(
dt,
BigDecimal.valueOf(userTransactionDTOS.get(0).units()),
BigDecimal.valueOf(userTransactionDTOS.get(0).nav()),
BigDecimal.valueOf(userTransactionDTOS.getFirst().units()),
BigDecimal.valueOf(userTransactionDTOS.getFirst().nav()),
BigDecimal.ZERO);
} else if (userTransactionDTOS.get(0).type().compareTo(TransactionType.PURCHASE) == 0
|| userTransactionDTOS.get(0).type().compareTo(TransactionType.SWITCH_IN) == 0) {
} else if (userTransactionDTOS.getFirst().type().compareTo(TransactionType.PURCHASE) == 0
|| userTransactionDTOS.getFirst().type().compareTo(TransactionType.SWITCH_IN) == 0) {
buy(
dt,
BigDecimal.valueOf(userTransactionDTOS.get(0).units()),
BigDecimal.valueOf(userTransactionDTOS.get(0).nav()),
BigDecimal.valueOf(userTransactionDTOS.getFirst().units()),
BigDecimal.valueOf(userTransactionDTOS.getFirst().nav()),
BigDecimal.ZERO);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public BigDecimal getNavByISINOnDate(String isin, LocalDate inputDate) {
List<Long> schemeIdByISINList = schemeService.getSchemeIdByISIN(isin);
BigDecimal nav = BigDecimal.ZERO;
if (!schemeIdByISINList.isEmpty()) {
Long schemeCode = schemeIdByISINList.get(0);
Long schemeCode = schemeIdByISINList.getFirst();
if (schemeCode < 143000) {
try {
MFSchemeDTO navByDateWithRetry = getNavByDateWithRetry(schemeCode, inputDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ List<Transaction> buildTransactionList(
// XIRR cant be calculated when there are only 2 transactions and both has same date.
if (currentBalance != 0.0
&& !(transactionList.size() == 1
&& transactionList.get(0).getWhen().equals(asOfDate))) {
&& transactionList.getFirst().getWhen().equals(asOfDate))) {
// Add current Value and current date
transactionList.add(new Transaction(getCurrentValuation(fundId, currentBalance, asOfDate), asOfDate));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ public class XirrCalculatorHelper {

// ensures that balance will never be null
public static Double getBalance(List<UserTransactionDetailsProjection> transactionDetailsProjectionList) {
Double balance = transactionDetailsProjectionList
.get(transactionDetailsProjectionList.size() - 1)
.getBalance();
Double balance = transactionDetailsProjectionList.getLast().getBalance();
if (balance == null) {
if (transactionDetailsProjectionList.size() < 2) {
throw new IllegalArgumentException("Insufficient data to calculate balance.");
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/learning/mfscreener/utils/TestData.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ public static CasDTO getCasDTO() {
"OK",
"OK",
List.of(getCanaraScheme())));
casDTO.folios().get(0).schemes().add(getICICIUSBlueChipScheme());
casDTO.folios().getFirst().schemes().add(getICICIUSBlueChipScheme());
casDTO.folios()
.get(0)
.getFirst()
.schemes()
.get(0)
.getFirst()
.transactions()
.add(new UserTransactionDTO(
LocalDate.parse("2021-02-04"),
Expand Down

0 comments on commit df007e6

Please sign in to comment.