-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FINERACT-1960: Accrual Transactions For Savings batch job - Interest #3973
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,22 @@ | |
"null", | ||
"string" | ||
] | ||
}, | ||
{ | ||
"default": null, | ||
"name": "accruedTillDate", | ||
"type": [ | ||
"null", | ||
"string" | ||
] | ||
}, | ||
{ | ||
"default": null, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it support accrued fee and penalty as well no? |
||
"name": "totalInterestAccrued", | ||
"type": [ | ||
"null", | ||
"bigdecimal" | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,13 +56,15 @@ public class SavingsAccountSummaryData implements Serializable { | |
private LocalDate interestPostedTillDate; | ||
private LocalDate prevInterestPostedTillDate; | ||
private transient BigDecimal runningBalanceOnInterestPostingTillDate = BigDecimal.ZERO; | ||
private LocalDate accruedTillDate; | ||
private BigDecimal totalInterestAccrued; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dont we need accrued fee and penalty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Accrual Fee mainly will be in other PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering whether it would be better to send support for fee and penalty as well in the same PR or disable the job till it is not complete. THoughts? |
||
|
||
public SavingsAccountSummaryData(final CurrencyData currency, final BigDecimal totalDeposits, final BigDecimal totalWithdrawals, | ||
final BigDecimal totalWithdrawalFees, final BigDecimal totalAnnualFees, final BigDecimal totalInterestEarned, | ||
final BigDecimal totalInterestPosted, final BigDecimal accountBalance, final BigDecimal totalFeeCharge, | ||
final BigDecimal totalPenaltyCharge, final BigDecimal totalOverdraftInterestDerived, final BigDecimal totalWithholdTax, | ||
final BigDecimal interestNotPosted, final LocalDate lastInterestCalculationDate, final BigDecimal availableBalance, | ||
final LocalDate interestPostedTillDate) { | ||
final LocalDate interestPostedTillDate, final LocalDate accruedTillDate) { | ||
this.currency = currency; | ||
this.totalDeposits = totalDeposits; | ||
this.totalWithdrawals = totalWithdrawals; | ||
|
@@ -79,6 +81,7 @@ public SavingsAccountSummaryData(final CurrencyData currency, final BigDecimal t | |
this.lastInterestCalculationDate = lastInterestCalculationDate; | ||
this.availableBalance = availableBalance; | ||
this.interestPostedTillDate = interestPostedTillDate; | ||
this.accruedTillDate = accruedTillDate; | ||
} | ||
|
||
public void setPrevInterestPostedTillDate(LocalDate interestPostedTillDate) { | ||
|
@@ -255,6 +258,7 @@ public void updateSummary(final CurrencyData currency, final SavingsAccountTrans | |
this.totalPenaltyCharge = wrapper.calculateTotalPenaltyChargeWaived(currency, transactions); | ||
this.totalOverdraftInterestDerived = wrapper.calculateTotalOverdraftInterest(currency, transactions); | ||
this.totalWithholdTax = wrapper.calculateTotalWithholdTaxWithdrawal(currency, transactions); | ||
this.totalInterestAccrued = wrapper.calculateTotalInterestAccrued(currency, transactions); | ||
|
||
// boolean isUpdated = false; | ||
updateRunningBalanceAndPivotDate(false, transactions, null, null, null); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,4 +142,15 @@ public BigDecimal calculateTotalWithholdTaxWithdrawal(CurrencyData currency, Lis | |
} | ||
return total.getAmountDefaultedToNullIfZero(); | ||
} | ||
|
||
public BigDecimal calculateTotalInterestAccrued(CurrencyData currency, List<SavingsAccountTransactionData> transactions) { | ||
Money total = Money.zero(currency); | ||
for (final SavingsAccountTransactionData transaction : transactions) { | ||
if (transaction.isAccrual() && !transaction.isReversalTransaction()) { | ||
total = total.plus(transaction.getAmount()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. THis will be incorrect the moment accrual will be done for fee and penalties as well. I think we should immediately use the interest portion here, instead of the transaction amount. |
||
} | ||
} | ||
return total.getAmountDefaultedToNullIfZero(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,12 +203,13 @@ public SavingsDTO populateSavingsDtoFromMap(final Map<String, Object> accounting | |
if (map.containsKey("savingsChargesPaid")) { | ||
@SuppressWarnings("unchecked") | ||
final List<Map<String, Object>> savingsChargesPaidData = (List<Map<String, Object>>) map.get("savingsChargesPaid"); | ||
for (final Map<String, Object> loanChargePaid : savingsChargesPaidData) { | ||
final Long chargeId = (Long) loanChargePaid.get("chargeId"); | ||
final Long loanChargeId = (Long) loanChargePaid.get("savingsChargeId"); | ||
final boolean isPenalty = (Boolean) loanChargePaid.get("isPenalty"); | ||
final BigDecimal chargeAmountPaid = (BigDecimal) loanChargePaid.get("amount"); | ||
for (final Map<String, Object> savingsChargesPaid : savingsChargesPaidData) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice catch! :) |
||
final Long chargeId = (Long) savingsChargesPaid.get("chargeId"); | ||
final Long loanChargeId = (Long) savingsChargesPaid.get("savingsChargeId"); | ||
final boolean isPenalty = (Boolean) savingsChargesPaid.get("isPenalty"); | ||
final BigDecimal chargeAmountPaid = (BigDecimal) savingsChargesPaid.get("amount"); | ||
final ChargePaymentDTO chargePaymentDTO = new ChargePaymentDTO(chargeId, chargeAmountPaid, loanChargeId); | ||
|
||
if (isPenalty) { | ||
penaltyPayments.add(chargePaymentDTO); | ||
} else { | ||
|
@@ -602,6 +603,21 @@ public void createAccrualBasedJournalEntriesAndReversalsForSavingsTax(final Offi | |
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal); | ||
} | ||
|
||
public void createAccrualBasedJournalEntriesAndReversalsForSavings(final Office office, final String currencyCode, | ||
final Integer accountTypeToBeDebited, final Integer accountTypeToBeCredited, final Long savingsProductId, | ||
final Long paymentTypeId, final Long loanId, final String transactionId, final LocalDate transactionDate, | ||
final BigDecimal amount, final Boolean isReversal) { | ||
int accountTypeToDebitId = accountTypeToBeDebited; | ||
int accountTypeToCreditId = accountTypeToBeCredited; | ||
// reverse debits and credits for reversals | ||
if (isReversal) { | ||
accountTypeToDebitId = accountTypeToBeCredited; | ||
accountTypeToCreditId = accountTypeToBeDebited; | ||
} | ||
createJournalEntriesForSavings(office, currencyCode, accountTypeToDebitId, accountTypeToCreditId, savingsProductId, paymentTypeId, | ||
loanId, transactionId, transactionDate, amount); | ||
} | ||
|
||
public void createCashBasedDebitJournalEntriesAndReversalsForSavings(final Office office, final String currencyCode, | ||
final Integer accountTypeToBeDebited, final Long savingsProductId, final Long paymentTypeId, final Long savingsId, | ||
final String transactionId, final LocalDate transactionDate, final BigDecimal amount, final Boolean isReversal) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why to remove this?