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();
}
}
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());
}
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;
}
}
}
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);
}
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);
}
Aggregations