use of org.mifos.accounts.financial.business.service.activity.SavingsInterestPostingFinancialActivity in project head by mifos.
the class SavingsBO method doPostInterest.
private void doPostInterest(LocalDate currentPostingDate, Money actualInterestToBePosted, PersonnelBO loggedInUser) {
this.savingsBalance = this.savingsBalance.add(actualInterestToBePosted);
this.savingsPerformance.setTotalInterestDetails(actualInterestToBePosted);
SavingsActivityEntity savingsActivity = SavingsActivityEntity.savingsInterestPosting(this, personnel, this.savingsBalance, actualInterestToBePosted, currentPostingDate.toDateMidnight().toDate());
savingsActivityDetails.add(savingsActivity);
AccountPaymentEntity interestPayment = AccountPaymentEntity.savingsInterestPosting(this, actualInterestToBePosted, currentPostingDate.toDateMidnight().toDate(), loggedInUser);
DateTime dueDate = new DateTime();
SavingsTrxnDetailEntity interestPostingTransaction = SavingsTrxnDetailEntity.savingsInterestPosting(interestPayment, this.customer, this.savingsBalance, currentPostingDate.toDateMidnight().toDate(), dueDate, loggedInUser);
interestPayment.addAccountTrxn(interestPostingTransaction);
this.addAccountPayment(interestPayment);
// NOTE: financial Transaction Processing should be decoupled from application domain model.
try {
BaseFinancialActivity baseFinancialActivity = new SavingsInterestPostingFinancialActivity(interestPostingTransaction);
baseFinancialActivity.buildAccountEntries();
} catch (FinancialException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.financial.business.service.activity.SavingsInterestPostingFinancialActivity in project head by mifos.
the class InterestPostingAccountingEntryTest method testBuildAccountEntryForAction.
@Test
public void testBuildAccountEntryForAction() throws FinancialException {
// setup
DateMidnight savingsTrxnDetailActionDate = new DateMidnight(2009, 9, 9);
DateMidnight savingsTrxnDetailCreationDate = new DateMidnight(2009, 1, 1);
MifosCurrency currency = TestUtils.RUPEE;
// stubbing
when(savingsTrxnDetail.getAccount()).thenReturn(savingsBO);
when(savingsTrxnDetail.getInterestAmount()).thenReturn(new Money(currency, interestAmount));
when(savingsTrxnDetail.getActionDate()).thenReturn(savingsTrxnDetailActionDate.toDate());
when(savingsTrxnDetail.getTrxnCreatedDate()).thenReturn(new Timestamp(savingsTrxnDetailCreationDate.getMillis()));
when(savingsTrxnDetail.getPersonnel()).thenReturn(transactionCreator);
when(savingsBO.getSavingsOffering()).thenReturn(savingsOffering);
when(savingsOffering.getInterestGLCode()).thenReturn(coaSavingsInterestPayable.getAssociatedGlcode());
when(savingsOffering.getDepositGLCode()).thenReturn(coaClientsSavings.getAssociatedGlcode());
SavingsInterestPostingFinancialActivity financialActivity = new SavingsInterestPostingFinancialActivity(savingsTrxnDetail);
// exercise test
interestPostingAccountingEntry.buildAccountEntryForAction(financialActivity);
// verification
List<FinancialTransactionBO> transactions = financialActivity.getFinanacialTransaction();
assertThat(transactions.size(), is(2));
/*
* Sort by GLCode strings so "22100" (interest payable tran) should be first, followed by "22200" (client
* savings tran)
*/
Collections.sort(transactions, new GLCodeComparator());
Iterator<FinancialTransactionBO> it = transactions.iterator();
FinancialTransactionBO interestPostingTrans = it.next();
assertThat(interestPostingTrans.getActionDate(), is(savingsTrxnDetailActionDate.toDate()));
assertThat(interestPostingTrans.getPostedDate(), is(savingsTrxnDetailCreationDate.toDate()));
assertThat(interestPostingTrans.getPostedAmount(), is(new Money(currency, interestAmount)));
assertThat(interestPostingTrans.getGlcode().getGlcode(), is(coaSavingsInterestPayable.getGlCode()));
assertThat(interestPostingTrans.getDebitCreditFlag(), is(FinancialConstants.DEBIT.getValue()));
assertThat(interestPostingTrans.getPostedBy(), is(transactionCreator));
FinancialTransactionBO savingsPostingTrans = it.next();
assertThat(savingsPostingTrans.getActionDate(), is(savingsTrxnDetailActionDate.toDate()));
assertThat(savingsPostingTrans.getPostedDate(), is(savingsTrxnDetailCreationDate.toDate()));
assertThat(savingsPostingTrans.getPostedAmount(), is(new Money(currency, interestAmount)));
assertThat(savingsPostingTrans.getGlcode().getGlcode(), is(coaClientsSavings.getGlCode()));
assertThat(savingsPostingTrans.getDebitCreditFlag(), is(FinancialConstants.CREDIT.getValue()));
assertThat(savingsPostingTrans.getPostedBy(), is(transactionCreator));
}
Aggregations