Search in sources :

Example 1 with SavingsTrxnDetailEntity

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

the class SavingsPersistenceIntegrationTest method testRetrieveLastTransaction.

@Test
public void testRetrieveLastTransaction() throws Exception {
    try {
        SavingsTestHelper helper = new SavingsTestHelper();
        createInitialObjects();
        PersonnelBO createdBy = legacyPersonnelDao.getPersonnel(userContext.getId());
        savingsOffering = helper.createSavingsOffering("effwe", "231");
        savings = new SavingsBO(userContext, savingsOffering, group, AccountState.SAVINGS_ACTIVE, savingsOffering.getRecommendedAmount(), null);
        AccountPaymentEntity payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "700.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "1700.0"), helper.getDate("15/01/2006"), AccountActionTypes.SAVINGS_DEPOSIT.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.save();
        StaticHibernateUtil.flushSession();
        payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "1000.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "2700.0"), helper.getDate("20/02/2006"), AccountActionTypes.SAVINGS_DEPOSIT.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.update();
        StaticHibernateUtil.flushSession();
        savings = savingsDao.findById(savings.getAccountId());
        savings.setUserContext(userContext);
        payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "500.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "2200.0"), helper.getDate("10/03/2006"), AccountActionTypes.SAVINGS_WITHDRAWAL.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.update();
        StaticHibernateUtil.flushSession();
        savings = savingsDao.findById(savings.getAccountId());
        savings.setUserContext(userContext);
        payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "1200.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "3400.0"), helper.getDate("15/03/2006"), AccountActionTypes.SAVINGS_DEPOSIT.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.update();
        StaticHibernateUtil.flushSession();
        savings = savingsDao.findById(savings.getAccountId());
        savings.setUserContext(userContext);
        payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "2500.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "900.0"), helper.getDate("25/03/2006"), AccountActionTypes.SAVINGS_WITHDRAWAL.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.update();
        StaticHibernateUtil.flushSession();
        savings = savingsDao.findById(savings.getAccountId());
        savings.setUserContext(userContext);
        SavingsTrxnDetailEntity trxn = savingsPersistence.retrieveLastTransaction(savings.getAccountId(), helper.getDate("12/03/2006"));
        Assert.assertEquals(TestUtils.createMoney("500"), trxn.getAmount());
        group = savings.getCustomer();
        center = group.getParentCustomer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsTrxnDetailEntity(org.mifos.accounts.savings.business.SavingsTrxnDetailEntity) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test)

Example 2 with SavingsTrxnDetailEntity

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

the class SavingsBOIntegrationTest method testSuccessfulDepositForCenterAccount.

@Test
public void testSuccessfulDepositForCenterAccount() throws AccountException, Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    client1 = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
    savingsOffering = helper.createSavingsOffering("dfasdasd1", "sad1");
    savings = TestObjectFactory.createSavingsAccount("43245434", center, AccountStates.SAVINGS_ACC_APPROVED, new Date(System.currentTimeMillis()), savingsOffering);
    savings.setSavingsBalance(new Money(getCurrency()));
    savings = (SavingsBO) legacyAccountDao.getAccount(savings.getAccountId());
    Money enteredAmount = new Money(currency, "100.0");
    PaymentData paymentData = PaymentData.createPaymentData(enteredAmount, savings.getPersonnel(), Short.valueOf("1"), new Date(System.currentTimeMillis()));
    paymentData.setCustomer(client1);
    paymentData.setReceiptDate(new Date(System.currentTimeMillis()));
    paymentData.setReceiptNum("34244");
    AccountActionDateEntity accountActionDate = savings.getAccountActionDate(Short.valueOf("1"));
    SavingsPaymentData savingsPaymentData = new SavingsPaymentData(accountActionDate);
    paymentData.addAccountPaymentData(savingsPaymentData);
    IntegrationTestObjectMother.applyAccountPayment(savings, paymentData);
    savings = (SavingsBO) legacyAccountDao.getAccount(savings.getAccountId());
    Assert.assertEquals(AccountStates.SAVINGS_ACC_APPROVED, savings.getAccountState().getId().shortValue());
    Assert.assertEquals(TestUtils.createMoney(100.0), savings.getSavingsBalance());
    Assert.assertEquals(1, savings.getSavingsActivityDetails().size());
    List<AccountPaymentEntity> payments = savings.getAccountPayments();
    Assert.assertEquals(1, payments.size());
    for (AccountPaymentEntity payment : payments) {
        Assert.assertEquals(1, payment.getAccountTrxns().size());
        for (AccountTrxnEntity accountTrxn : payment.getAccountTrxns()) {
            SavingsTrxnDetailEntity trxn = (SavingsTrxnDetailEntity) accountTrxn;
            Assert.assertEquals(enteredAmount, trxn.getBalance());
            Assert.assertEquals(client1.getCustomerId(), trxn.getCustomer().getCustomerId());
        }
    }
    client1 = IntegrationTestObjectMother.findCustomerById(client1.getCustomerId());
}
Also used : SavingsPaymentData(org.mifos.accounts.util.helpers.SavingsPaymentData) Money(org.mifos.framework.util.helpers.Money) PaymentData(org.mifos.accounts.util.helpers.PaymentData) SavingsPaymentData(org.mifos.accounts.util.helpers.SavingsPaymentData) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) MeetingBO(org.mifos.application.meeting.business.MeetingBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) SavingsTrxnDetailEntity(org.mifos.accounts.savings.business.SavingsTrxnDetailEntity) Date(java.util.Date) Test(org.junit.Test)

Example 3 with SavingsTrxnDetailEntity

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

the class SavingsBOIntegrationTest method testSavingsTrxnDetailsWithZeroAmt.

@Test
public void testSavingsTrxnDetailsWithZeroAmt() throws Exception {
    savings = createSavingsAccountPayment();
    for (AccountPaymentEntity accountPaymentEntity : savings.getAccountPayments()) {
        for (AccountTrxnEntity accountTrxnEntity : accountPaymentEntity.getAccountTrxns()) {
            SavingsTrxnDetailEntity trxnEntity = (SavingsTrxnDetailEntity) accountTrxnEntity;
            Assert.assertEquals(new Money(getCurrency(), "5500"), trxnEntity.getBalance());
            Assert.assertEquals(new Money(getCurrency()), trxnEntity.getDepositAmount());
            Assert.assertEquals(new Money(getCurrency()), trxnEntity.getInterestAmount());
            Assert.assertEquals(new Money(getCurrency()), trxnEntity.getWithdrawlAmount());
            break;
        }
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) SavingsTrxnDetailEntity(org.mifos.accounts.savings.business.SavingsTrxnDetailEntity) Test(org.junit.Test)

Example 4 with SavingsTrxnDetailEntity

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

the class WithdrawalAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    SavingsTrxnDetailEntity savingsTrxn = (SavingsTrxnDetailEntity) financialActivity.getAccountTrxn();
    SavingsBO savings = (SavingsBO) savingsTrxn.getAccount();
    FinancialActionTypeEntity finActionWithrawal = null;
    if (savings.isMandatory()) {
        finActionWithrawal = getFinancialAction(FinancialActionConstants.MANDATORYWITHDRAWAL);
    }
    if (savings.isVoluntary()) {
        finActionWithrawal = getFinancialAction(FinancialActionConstants.VOLUNTARYWITHDRAWAL);
    }
    if (savings.getState() == AccountState.SAVINGS_CLOSED) {
        handleRoundingForWithdrawal(savings, savingsTrxn);
    }
    addAccountEntryDetails(savingsTrxn.getWithdrawlAmount(), finActionWithrawal, savings.getSavingsOffering().getDepositGLCode(), FinancialConstants.DEBIT);
    addAccountEntryDetails(savingsTrxn.getWithdrawlAmount(), finActionWithrawal, getGLcode(finActionWithrawal.getApplicableCreditCharts()), FinancialConstants.CREDIT);
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsTrxnDetailEntity(org.mifos.accounts.savings.business.SavingsTrxnDetailEntity)

Example 5 with SavingsTrxnDetailEntity

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

the class DepositAccountingEntry method applySpecificAccountActionEntry.

@Override
protected void applySpecificAccountActionEntry() throws FinancialException {
    SavingsTrxnDetailEntity savingsTrxn = (SavingsTrxnDetailEntity) financialActivity.getAccountTrxn();
    SavingsBO savings = (SavingsBO) savingsTrxn.getAccount();
    FinancialActionTypeEntity finActionDeposit = null;
    if (savings.isMandatory()) {
        finActionDeposit = getFinancialAction(FinancialActionConstants.MANDATORYDEPOSIT);
    } else if (savings.isVoluntary()) {
        finActionDeposit = getFinancialAction(FinancialActionConstants.VOLUNTARYDEPOSIT);
    }
    addAccountEntryDetails(savingsTrxn.getDepositAmount(), finActionDeposit, getGLcode(finActionDeposit.getApplicableDebitCharts()), FinancialConstants.DEBIT);
    addAccountEntryDetails(savingsTrxn.getDepositAmount(), finActionDeposit, savings.getSavingsOffering().getDepositGLCode(), FinancialConstants.CREDIT);
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsTrxnDetailEntity(org.mifos.accounts.savings.business.SavingsTrxnDetailEntity)

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