use of org.mifos.accounts.business.AccountPaymentEntity 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;
}
use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class SavingsCloseTest method whenClosingAccountShouldSetStatusAsClosed.
@Test
public void whenClosingAccountShouldSetStatusAsClosed() {
Money remainingBalance = TestUtils.createMoney("100");
savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(remainingBalance).build();
AccountPaymentEntity payment = new AccountPaymentEntityBuilder().with(savingsAccount).with(remainingBalance).build();
AccountNotesEntity notes = new AccountNotesEntityBuilder().build();
CustomerBO customer = new ClientBuilder().buildForUnitTests();
PersonnelBO loggedInUser = new PersonnelBuilder().build();
// exercise test
savingsAccount.closeAccount(payment, notes, customer, loggedInUser);
// verification
assertTrue(savingsAccount.getAccountState().isInState(AccountState.SAVINGS_CLOSED));
}
use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testTrxnDetailEntityObjectsForMultipleInstallmentsWhenOnlyCustomerAccountFeesAreDue.
@Test
public void testTrxnDetailEntityObjectsForMultipleInstallmentsWhenOnlyCustomerAccountFeesAreDue() throws Exception {
createCenter();
CustomerAccountBO customerAccount = center.getCustomerAccount();
Date transactionDate = incrementCurrentDate(14);
PaymentData paymentData = PaymentData.createPaymentData(new Money(getCurrency(), "300"), center.getPersonnel(), Short.valueOf("1"), transactionDate);
paymentData.setCustomer(center);
IntegrationTestObjectMother.applyAccountPayment(customerAccount, paymentData);
if (customerAccount.getAccountPayments() != null && customerAccount.getAccountPayments().size() == 1) {
for (AccountPaymentEntity accountPaymentEntity : customerAccount.getAccountPayments()) {
final Money zeroAmount = new Money(getCurrency(), "0.0");
final Money OneHundredAmount = new Money(getCurrency(), "100.0");
if (accountPaymentEntity.getAccountTrxns() != null && accountPaymentEntity.getAccountTrxns().size() == 3) {
for (AccountTrxnEntity accountTrxnEntity : accountPaymentEntity.getAccountTrxns()) {
CustomerTrxnDetailEntity customerTrxnDetailEntity = (CustomerTrxnDetailEntity) accountTrxnEntity;
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getTotalAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getMiscFeeAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getMiscPenaltyAmount());
if (customerTrxnDetailEntity.getFeesTrxnDetails() != null && customerTrxnDetailEntity.getFeesTrxnDetails().size() == 1) {
for (FeesTrxnDetailEntity feesTrxnDetailEntity : customerTrxnDetailEntity.getFeesTrxnDetails()) {
Assert.assertEquals(OneHundredAmount, feesTrxnDetailEntity.getFeeAmount());
}
} else {
throw new Exception("Expected one FeesTrxnDetailEntity, found none or more than one");
}
}
} else {
throw new Exception("Expected three CustomerTrxnDetailEntity, found none or not three");
}
}
} else {
throw new Exception("Expected one AccountPaymentEntity, found none or more than one");
}
}
use of org.mifos.accounts.business.AccountPaymentEntity in project head by mifos.
the class CustomerAccountBOIntegrationTest method testTrxnDetailEntityObjectsForMultipleInstallmentsWhenOnlyCustomerAccountChargesAreDue.
@Test
public void testTrxnDetailEntityObjectsForMultipleInstallmentsWhenOnlyCustomerAccountChargesAreDue() throws Exception {
MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter((CenterBO) center, weeklyMeeting);
CustomerAccountBO customerAccount = center.getCustomerAccount();
final Money fiftyAmount = new Money(getCurrency(), "50.0");
final Money seventyAmount = new Money(getCurrency(), "70.0");
final Money oneHundredTwentyAmount = new Money(getCurrency(), "120.0");
final Money twoHundredFortyAmount = new Money(getCurrency(), "240.0");
for (AccountActionDateEntity accountActionDateEntity : customerAccount.getAccountActionDates()) {
CustomerScheduleEntity customerSchedule = (CustomerScheduleEntity) accountActionDateEntity;
if (customerSchedule.getInstallmentId() != 2) {
customerSchedule.setMiscFee(fiftyAmount);
customerSchedule.setMiscPenalty(seventyAmount);
}
}
Date transactionDate = incrementCurrentDate(14);
PaymentData paymentData = PaymentData.createPaymentData(twoHundredFortyAmount, center.getPersonnel(), Short.valueOf("1"), transactionDate);
paymentData.setCustomer(center);
IntegrationTestObjectMother.applyAccountPayment(customerAccount, paymentData);
if (customerAccount.getAccountPayments() != null && customerAccount.getAccountPayments().size() == 1) {
for (AccountPaymentEntity accountPaymentEntity : customerAccount.getAccountPayments()) {
final Money zeroAmount = new Money(accountPaymentEntity.getAmount().getCurrency(), "0.0");
if (accountPaymentEntity.getAccountTrxns() != null && accountPaymentEntity.getAccountTrxns().size() == 3) {
for (AccountTrxnEntity accountTrxnEntity : accountPaymentEntity.getAccountTrxns()) {
CustomerTrxnDetailEntity customerTrxnDetailEntity = (CustomerTrxnDetailEntity) accountTrxnEntity;
if (customerTrxnDetailEntity.getInstallmentId() != 2) {
Assert.assertEquals(oneHundredTwentyAmount, customerTrxnDetailEntity.getAmount());
Assert.assertEquals(oneHundredTwentyAmount, customerTrxnDetailEntity.getTotalAmount());
Assert.assertEquals(fiftyAmount, customerTrxnDetailEntity.getMiscFeeAmount());
Assert.assertEquals(seventyAmount, customerTrxnDetailEntity.getMiscPenaltyAmount());
} else {
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getTotalAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getMiscFeeAmount());
Assert.assertEquals(zeroAmount, customerTrxnDetailEntity.getMiscPenaltyAmount());
}
Assert.assertEquals(0, customerTrxnDetailEntity.getFeesTrxnDetails().size());
}
} else {
throw new Exception("Expected three CustomerTrxnDetailEntity, found none or not three");
}
}
} else {
throw new Exception("Expected one AccountPaymentEntity, found none or more than one");
}
}
use of org.mifos.accounts.business.AccountPaymentEntity 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()));
}
Aggregations