Skip to content

Commit

Permalink
fix: Journal entries creation for Accrual Savings transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Alberto Hernandez authored and alberto-art3ch committed Jul 17, 2024
1 parent 21affbe commit 5ab7844
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ else if (savingsTransactionDTO.getTransactionType().isInterestPosting()) {
else if (savingsTransactionDTO.getTransactionType().isAccrual()) {
// Post journal entry for Accrual Recognition
if (savingsTransactionDTO.getAmount().compareTo(BigDecimal.ZERO) > 0) {
if (feePayments.size() >= 0 || penaltyPayments.size() > 0) {
if (feePayments.size() > 0 || penaltyPayments.size() > 0) {
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
AccrualAccountsForSavings.FEES_RECEIVABLE.getValue(), AccrualAccountsForSavings.INCOME_FROM_FEES.getValue(),
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
Expand Down Expand Up @@ -63,6 +65,7 @@ public class SavingsAccrualWritePlatformServiceImpl implements SavingsAccrualWri
private final SavingsAccountRepositoryWrapper savingsAccountRepository;
private final SavingsHelper savingsHelper;
private final ConfigurationDomainService configurationDomainService;
private final SavingsAccountDomainService savingsAccountDomainService;

@Transactional
@Override
Expand Down Expand Up @@ -152,6 +155,11 @@ public SavingsAccountTransaction addSavingsChargeAccrualTransaction(SavingsAccou

private void addAccrualTransactions(SavingsAccount savingsAccount, final LocalDate fromDate, final LocalDate tillDate,
final Integer financialYearBeginningMonth, final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final MathContext mc) {
final Set<Long> existingTransactionIds = new HashSet<>();
final Set<Long> existingReversedTransactionIds = new HashSet<>();
existingTransactionIds.addAll(savingsAccount.findExistingTransactionIds());
existingReversedTransactionIds.addAll(savingsAccount.findExistingReversedTransactionIds());

List<LocalDate> postedAsOnTransactionDates = savingsAccount.getManualPostingDates();
final SavingsPostingInterestPeriodType postingPeriodType = SavingsPostingInterestPeriodType
.fromInt(savingsAccount.getInterestCompoundingPeriodType());
Expand Down Expand Up @@ -213,6 +221,8 @@ private void addAccrualTransactions(SavingsAccount savingsAccount, final LocalDa

savingsAccount.setAccruedTillDate(accruedTillDate);
savingsAccountRepository.saveAndFlush(savingsAccount);

savingsAccountDomainService.postJournalEntries(savingsAccount, existingTransactionIds, existingReversedTransactionIds, false);
}

}

0 comments on commit 5ab7844

Please sign in to comment.