FINERACT-1603- Post Interest Job Fix

This commit is contained in:
apurbraj
2022-05-10 21:20:35 +05:30
parent b0a261cbd5
commit a97a3d0402
8 changed files with 194 additions and 10 deletions
@@ -180,7 +180,7 @@ public final class SavingsAccountData implements Serializable {
this.reasonForBlock = null;
this.timeline = null;
this.currency = null;
this.nominalAnnualInterestRate = nominalAnnualInterestRate;
this.nominalAnnualInterestRate = nominalAnnualInterestRate != null ? nominalAnnualInterestRate : BigDecimal.ZERO;
this.interestCompoundingPeriodType = interestCompoundingPeriodType;
this.interestPostingPeriodType = interestPostingPeriodType;
this.interestCalculationType = interestCalculationType;
@@ -537,7 +537,7 @@ public final class SavingsAccountData implements Serializable {
this.reasonForBlock = null;
this.timeline = null;
this.currency = null;
this.nominalAnnualInterestRate = nominalAnnualInterestRate;
this.nominalAnnualInterestRate = nominalAnnualInterestRate == null ? BigDecimal.ZERO : nominalAnnualInterestRate;
this.interestCompoundingPeriodType = interestCompoundingPeriodType;
this.interestPostingPeriodType = interestPostingPeriodType;
this.interestCalculationType = interestCalculationType;
@@ -959,7 +959,7 @@ public final class SavingsAccountData implements Serializable {
this.reasonForBlock = reasonForBlock;
this.timeline = timeline;
this.currency = currency;
this.nominalAnnualInterestRate = nominalAnnualInterestRate;
this.nominalAnnualInterestRate = nominalAnnualInterestRate == null ? BigDecimal.ZERO : nominalAnnualInterestRate;
this.interestCompoundingPeriodType = interestPeriodType;
this.interestPostingPeriodType = interestPostingPeriodType;
this.interestCalculationType = interestCalculationType;
@@ -78,7 +78,7 @@ public class SavingsAccountSummaryData implements Serializable {
this.interestNotPosted = interestNotPosted;
this.lastInterestCalculationDate = lastInterestCalculationDate;
this.availableBalance = availableBalance;
this.interestPostedTillDate = interestPostedTillDate;
this.interestPostedTillDate = interestPostedTillDate == null ? lastInterestCalculationDate : interestPostedTillDate;
}
public void setPrevInterestPostedTillDate(LocalDate interestPostedTillDate) {
@@ -108,7 +108,7 @@ public class SavingsAccountInterestPostingServiceImpl implements SavingsAccountI
newPostingTransaction = SavingsAccountTransactionData.interestPosting(savingsAccountData,
interestPostingTransactionDate, interestEarnedToBePostedForPeriod, interestPostingPeriod.isUserPosting());
} else {
newPostingTransaction = SavingsAccountTransactionData.interestPosting(savingsAccountData,
newPostingTransaction = SavingsAccountTransactionData.overdraftInterest(savingsAccountData,
interestPostingTransactionDate, interestEarnedToBePostedForPeriod.negated(),
interestPostingPeriod.isUserPosting());
}
@@ -250,7 +250,8 @@ public class SavingsAccountInterestPostingServiceImpl implements SavingsAccountI
final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
Money periodStartingBalance;
if (savingsAccountData.getStartInterestCalculationDate() != null) {
if (savingsAccountData.getStartInterestCalculationDate() != null
&& !savingsAccountData.getStartInterestCalculationDate().equals(savingsAccountData.getActivationLocalDate())) {
final SavingsAccountTransactionData transaction = retrieveLastTransactions(savingsAccountData);
if (transaction == null) {
@@ -361,7 +362,9 @@ public class SavingsAccountInterestPostingServiceImpl implements SavingsAccountI
}
private BigDecimal getEffectiveOverdraftInterestRateAsFraction(MathContext mc, final SavingsAccountData savingsAccountData) {
return savingsAccountData.getNominalAnnualInterestRateOverdraft().divide(BigDecimal.valueOf(100L), mc);
return savingsAccountData.getNominalAnnualInterestRateOverdraft() != null
? savingsAccountData.getNominalAnnualInterestRateOverdraft().divide(BigDecimal.valueOf(100L), mc)
: BigDecimal.ZERO;
}
@SuppressWarnings("unused")
@@ -274,7 +274,8 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
+ "where (CASE WHEN sa.interest_posted_till_date is not null THEN tr.transaction_date >= sa.interest_posted_till_date ELSE tr.transaction_date >= sa.activatedon_date END) ";
}
sql = sql + "and apm.product_type=2 and sa.interest_posted_till_date < '" + java.sql.Date.valueOf(currentDate) + "'";
sql = sql + " and (sa.interest_posted_till_date is null or sa.interest_posted_till_date < '" + java.sql.Date.valueOf(currentDate)
+ "') ";
sql = sql + " order by sa.id, tr.transaction_date, tr.created_date, tr.id";
List<SavingsAccountData> savingsAccountDataList = this.jdbcTemplate.query(sql, this.savingAccountMapperForInterestPosting, // NOSONAR
@@ -359,7 +359,7 @@ public class SavingsSchedularInterestPoster implements Callable<Void> {
query.append("transaction_type_enum, transaction_date, amount, balance_end_date_derived,");
query.append("balance_number_of_days_derived, running_balance_derived, cumulative_balance_derived,");
query.append("created_date, appuser_id, is_manual, is_loan_disbursement, ref_no) VALUES ");
query.append("(?, ?, 0, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?)");
query.append("(?, ?, false, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, false, ?)");
return query.toString();
}