use of org.mifos.domain.builders.LoanAccountBuilder in project head by mifos.
the class StandardAccountServiceTest method setup.
@Before
public void setup() {
standardAccountService = new StandardAccountService(legacyAccountDao, legacyLoanDao, acceptedPaymentTypePersistence, personnelDao, customerDao, loanBusinessService, transactionHelper, legacyMasterDao, monthClosingServiceFacade, savingsServiceFacade, groupLoanAccountServiceFacade);
Money.setDefaultCurrency(TestUtils.RUPEE);
accountBO = new LoanAccountBuilder().withCustomer(customerBO).build();
accountBO.setlegacyAccountDao(legacyAccountDao);
}
use of org.mifos.domain.builders.LoanAccountBuilder in project head by mifos.
the class LoanBOTest method testCopyInstallmentSchedule.
/**
* does't work when changing applicatonConfiguration.custom.properties file.
* Need to pull out static references to AccountingRules in used classes.
*/
@Ignore
@Test
public void testCopyInstallmentSchedule() {
Money.setDefaultCurrency(rupee);
LoanBO loanBO = new LoanAccountBuilder().build();
loanBO.addAccountActionDate(getLoanScheduleEntity(rupee, getDate(23, 10, 2010), "100", "10", "1", Money.zero(rupee)));
loanBO.addAccountActionDate(getLoanScheduleEntity(rupee, getDate(23, 11, 2010), "100", "10", "2", Money.zero(rupee)));
loanBO.addAccountActionDate(getLoanScheduleEntity(rupee, getDate(23, 12, 2010), "100", "10", "3", Money.zero(rupee)));
List<RepaymentScheduleInstallment> installments = new ArrayList<RepaymentScheduleInstallment>();
installments.add(getRepaymentScheduleInstallment("24-Oct-2010", 1, "123", "12"));
installments.add(getRepaymentScheduleInstallment("24-Nov-2010", 2, "231", "23"));
installments.add(getRepaymentScheduleInstallment("24-Dec-2010", 3, "312", "31"));
loanBO.updateInstallmentSchedule(installments);
Set<LoanScheduleEntity> loanScheduleEntities = loanBO.getLoanScheduleEntities();
LoanScheduleEntity[] loanScheduleEntitiesArr = loanScheduleEntities.toArray(new LoanScheduleEntity[loanScheduleEntities.size()]);
assertLoanScheduleEntity(loanScheduleEntitiesArr[0], "123.0", "12.0", "2010-10-24");
assertLoanScheduleEntity(loanScheduleEntitiesArr[1], "231.0", "23.0", "2010-11-24");
assertLoanScheduleEntity(loanScheduleEntitiesArr[2], "312.0", "31.0", "2010-12-24");
}
use of org.mifos.domain.builders.LoanAccountBuilder in project head by mifos.
the class LoanBOTest method testLoanSummaryShouldBeUpdateOnInstallmentScheduleUpdate.
/**
* does't work when changing applicatonConfiguration.custom.properties file.
* Need to pull out static references to AccountingRules in used classes.
*/
@Ignore
@Test
public void testLoanSummaryShouldBeUpdateOnInstallmentScheduleUpdate() {
Money.setDefaultCurrency(rupee);
LoanBO loanBO = new LoanAccountBuilder().build();
loanBO.addAccountActionDate(getLoanScheduleEntity(rupee, getDate(23, 10, 2010), "100", "10", "1", Money.zero(rupee)));
loanBO.addAccountActionDate(getLoanScheduleEntity(rupee, getDate(23, 11, 2010), "100", "10", "2", Money.zero(rupee)));
loanBO.addAccountActionDate(getLoanScheduleEntity(rupee, getDate(23, 12, 2010), "100", "10", "3", Money.zero(rupee)));
List<RepaymentScheduleInstallment> installments = new ArrayList<RepaymentScheduleInstallment>();
installments.add(getRepaymentScheduleInstallment("24-Oct-2010", 1, "123", "12"));
installments.add(getRepaymentScheduleInstallment("24-Nov-2010", 2, "231", "23"));
installments.add(getRepaymentScheduleInstallment("24-Dec-2010", 3, "312", "31"));
loanBO.updateInstallmentSchedule(installments);
Set<LoanScheduleEntity> loanScheduleEntities = loanBO.getLoanScheduleEntities();
LoanScheduleEntity[] loanScheduleEntitiesArr = loanScheduleEntities.toArray(new LoanScheduleEntity[loanScheduleEntities.size()]);
assertLoanScheduleEntity(loanScheduleEntitiesArr[0], "123.0", "12.0", "2010-10-24");
assertLoanScheduleEntity(loanScheduleEntitiesArr[1], "231.0", "23.0", "2010-11-24");
assertLoanScheduleEntity(loanScheduleEntitiesArr[2], "312.0", "31.0", "2010-12-24");
LoanSummaryEntity loanSummary = loanBO.getLoanSummary();
assertEquals("666.0", loanSummary.getOriginalPrincipal().toString());
assertEquals("66.0", loanSummary.getOriginalInterest().toString());
}
use of org.mifos.domain.builders.LoanAccountBuilder in project head by mifos.
the class ClientStatusChangeIntegrationTest method givenClientHasActiveAccountsShouldNotPassValidationWhenTryingToTranistionClientToClosed.
@Test
public void givenClientHasActiveAccountsShouldNotPassValidationWhenTryingToTranistionClientToClosed() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
GroupBO existingActiveGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_ACTIVE).withParentCustomer(existingCenter).formedBy(existingUser).build();
IntegrationTestObjectMother.createGroup(existingActiveGroup, existingMeeting);
ClientBO existingActiveClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_ACTIVE).withParentCustomer(existingActiveGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingActiveClient, existingMeeting);
StaticHibernateUtil.flushAndClearSession();
DateTime startDate = new DateTime().minusDays(14);
LoanOfferingBO clientLoanProduct = new LoanProductBuilder().appliesToClientsOnly().withGlobalProductNumber("XXX-00002").active().withMeeting(existingMeeting).withName("Loan-client").withShortName("dsvd").withStartDate(startDate).withDefaultInterest(1.2).buildForIntegrationTests();
IntegrationTestObjectMother.createProduct(clientLoanProduct);
LoanBO clientLoan = new LoanAccountBuilder().withLoanProduct(clientLoanProduct).withCustomer(existingActiveClient).withOriginalLoanAmount(600.0).build();
IntegrationTestObjectMother.saveLoanAccount(clientLoan);
existingActiveGroup = this.customerDao.findGroupBySystemId(existingActiveGroup.getGlobalCustNum());
existingActiveClient = this.customerDao.findClientBySystemId(existingActiveClient.getGlobalCustNum());
existingActiveClient.setUserContext(TestUtils.makeUser());
CustomerStatusFlag customerStatusFlag = null;
CustomerNoteEntity customerNote = new CustomerNoteEntity("go active", new Date(), existingActiveClient.getPersonnel(), existingActiveClient);
// exercise test
try {
customerService.updateClientStatus(existingActiveClient, existingActiveClient.getStatus(), CustomerStatus.CLIENT_CLOSED, customerStatusFlag, customerNote);
fail("should fail validation");
} catch (CustomerException expected) {
assertThat(expected.getKey(), is(CustomerConstants.CUSTOMER_HAS_ACTIVE_ACCOUNTS_EXCEPTION));
assertThat(existingActiveClient.getStatus(), is(CustomerStatus.CLIENT_ACTIVE));
}
}
use of org.mifos.domain.builders.LoanAccountBuilder in project head by mifos.
the class GroupValidationTest method givenAnActiveLoanAccountExistsGroupTransferToCenterShouldFailValidation.
@Test
public void givenAnActiveLoanAccountExistsGroupTransferToCenterShouldFailValidation() {
// setup
CenterBO center = new CenterBuilder().build();
GroupBO group = new GroupBuilder().withParentCustomer(center).build();
LoanBO loan = new LoanAccountBuilder().activeInGoodStanding().build();
group.addAccount(loan);
// exercise test
try {
group.validateNoActiveAccountsExist();
fail("should fail validation");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_HAS_ACTIVE_ACCOUNT));
}
}
Aggregations