Search in sources :

Example 6 with SavingsTrxnDetailEntity

use of org.mifos.accounts.savings.business.SavingsTrxnDetailEntity in project head by mifos.

the class InterestPostingAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    SavingsTrxnDetailEntity savingsTrxn = (SavingsTrxnDetailEntity) financialActivity.getAccountTrxn();
    FinancialActionTypeEntity finIntPostingAction = getFinancialAction(FinancialActionConstants.SAVINGS_INTERESTPOSTING);
    SavingsOfferingBO savingsOffering = ((SavingsBO) savingsTrxn.getAccount()).getSavingsOffering();
    addAccountEntryDetails(savingsTrxn.getInterestAmount(), finIntPostingAction, savingsOffering.getInterestGLCode(), FinancialConstants.DEBIT);
    addAccountEntryDetails(savingsTrxn.getInterestAmount(), finIntPostingAction, savingsOffering.getDepositGLCode(), FinancialConstants.CREDIT);
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsTrxnDetailEntity(org.mifos.accounts.savings.business.SavingsTrxnDetailEntity)

Example 7 with SavingsTrxnDetailEntity

use of org.mifos.accounts.savings.business.SavingsTrxnDetailEntity in project head by mifos.

the class SavingsAdjustmentAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    SavingsTrxnDetailEntity savingsTrxn = (SavingsTrxnDetailEntity) financialActivity.getAccountTrxn();
    SavingsBO savings = (SavingsBO) savingsTrxn.getAccount();
    if (isAdjustmentForWithdrawal(savings)) {
        adjustWithdrawal(savings, savingsTrxn);
    } else {
        adjustDeposit(savings, savingsTrxn);
    }
}
Also used : SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsTrxnDetailEntity(org.mifos.accounts.savings.business.SavingsTrxnDetailEntity)

Example 8 with SavingsTrxnDetailEntity

use of org.mifos.accounts.savings.business.SavingsTrxnDetailEntity in project head by mifos.

the class SavingsTestHelper method createAccountPaymentToPersist.

public AccountPaymentEntity createAccountPaymentToPersist(AccountBO account, Money amount, Money balance, Date trxnDate, Short accountAction, SavingsBO savingsObj, PersonnelBO createdBy, CustomerBO customer) throws Exception {
    AccountPaymentEntity payment = createAccountPayment(account, amount, new Date(), createdBy);
    SavingsTrxnDetailEntity savingsTrxnDetail = SavingsTrxnDetailEntity.savingsAdjustment(payment, customer, balance, amount, createdBy, trxnDate, trxnDate, new DateTime().toDate(), "", null);
    payment.addAccountTrxn(savingsTrxnDetail);
    return payment;
}
Also used : AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) SavingsTrxnDetailEntity(org.mifos.accounts.savings.business.SavingsTrxnDetailEntity) Date(java.util.Date) DateTime(org.joda.time.DateTime)

Example 9 with SavingsTrxnDetailEntity

use of org.mifos.accounts.savings.business.SavingsTrxnDetailEntity in project head by mifos.

the class SavingsPostInterestTest method whenPostingInterestASingleAccountTransactionIsAssociatedWithAccountPayment.

@Test
public void whenPostingInterestASingleAccountTransactionIsAssociatedWithAccountPayment() {
    // setup
    InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
    Money interestToBePosted = TestUtils.createMoney("100");
    DateTime activationDate = new DateTime().withDate(2010, 7, 20);
    DateTime nextInterestPostingDate = new DateTime().withDate(2010, 7, 31);
    savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withNextInterestPostingDateOf(nextInterestPostingDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
    // pre verification
    assertTrue(savingsAccount.getAccountPayments().isEmpty());
    InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
    InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().from(nextInterestPostingDate.toLocalDate()).to(nextInterestPostingDate.toLocalDate()).with(calculationPeriod).build();
    PersonnelBO createdBy = new PersonnelBuilder().build();
    // exercise
    savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
    // verification
    AccountPaymentEntity interestPostingPayment = savingsAccount.getAccountPayments().get(0);
    assertFalse(interestPostingPayment.getAccountTrxns().isEmpty());
    List<AccountTrxnEntity> accountTransactions = new ArrayList<AccountTrxnEntity>(interestPostingPayment.getAccountTrxns());
    SavingsTrxnDetailEntity interestPostingTransaction = (SavingsTrxnDetailEntity) accountTransactions.get(0);
    assertThat(interestPostingTransaction.getAccount(), is((AccountBO) savingsAccount));
    assertThat(interestPostingTransaction.getAmount(), is(interestToBePosted));
    assertThat(interestPostingTransaction.getInterestAmount(), is(interestToBePosted));
    assertThat(interestPostingTransaction.getAccountActionEntity().getId(), is(AccountActionTypes.SAVINGS_INTEREST_POSTING.getValue()));
    assertThat(new LocalDate(interestPostingTransaction.getActionDate()), is(nextInterestPostingDate.toLocalDate()));
    assertThat(new LocalDate(interestPostingTransaction.getDueDate()), is(today()));
    assertThat(datePartOf(interestPostingTransaction.getTrxnCreatedDate()), is(today()));
}
Also used : InterestPostingPeriodResult(org.mifos.accounts.savings.interest.InterestPostingPeriodResult) PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) InterestCalculationPeriodResult(org.mifos.accounts.savings.interest.InterestCalculationPeriodResult) InterestPostingPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) ArrayList(java.util.ArrayList) SavingsTrxnDetailEntity(org.mifos.accounts.savings.business.SavingsTrxnDetailEntity) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Money(org.mifos.framework.util.helpers.Money) AccountBO(org.mifos.accounts.business.AccountBO) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) InterestCalculationPeriodResultBuilder(org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder) Test(org.junit.Test)

Example 10 with SavingsTrxnDetailEntity

use of org.mifos.accounts.savings.business.SavingsTrxnDetailEntity in project head by mifos.

the class SavingsBOIntegrationTest method createSavingsAccountPayment.

private SavingsBO createSavingsAccountPayment() throws Exception {
    AccountPaymentEntity payment;
    createInitialObjects();
    savingsOffering = helper.createSavingsOffering("2333dsf", "2132");
    savings = helper.createSavingsAccount(savingsOffering, group, AccountState.SAVINGS_ACTIVE, userContext);
    Money initialBal = new Money(currency, "5500");
    payment = helper.createAccountPayment(savings, null, new Money(currency, "5500.0"), new Date(), createdBy);
    SavingsTrxnDetailEntity adjustment = SavingsTrxnDetailEntity.savingsAdjustment(payment, group, initialBal, initialBal, createdBy, helper.getDate("04/01/2006"), helper.getDate("04/01/2006"), new DateTime().toDate(), "", null);
    payment.addAccountTrxn(adjustment);
    AccountTestUtils.addAccountPayment(payment, savings);
    savings.update();
    return TestObjectFactory.getObject(SavingsBO.class, savings.getAccountId());
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) SavingsTrxnDetailEntity(org.mifos.accounts.savings.business.SavingsTrxnDetailEntity) Date(java.util.Date) DateTime(org.joda.time.DateTime)

Aggregations

SavingsTrxnDetailEntity (org.mifos.accounts.savings.business.SavingsTrxnDetailEntity)10 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)6 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)5 Money (org.mifos.framework.util.helpers.Money)5 Test (org.junit.Test)4 Date (java.util.Date)3 DateTime (org.joda.time.DateTime)3 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)3 FinancialActionTypeEntity (org.mifos.accounts.financial.business.FinancialActionTypeEntity)3 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 ArrayList (java.util.ArrayList)1 LocalDate (org.joda.time.LocalDate)1 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)1 AccountBO (org.mifos.accounts.business.AccountBO)1 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)1 InterestCalculationPeriodResult (org.mifos.accounts.savings.interest.InterestCalculationPeriodResult)1 InterestCalculationPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder)1 InterestPostingPeriodResult (org.mifos.accounts.savings.interest.InterestPostingPeriodResult)1 InterestPostingPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder)1 InterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent)1