use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class LoanAccountRESTController method applyCharge.
@RequestMapping(value = "/account/loan/num-{globalAccountNum}/charge", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> applyCharge(@PathVariable String globalAccountNum, @RequestParam BigDecimal amount, @RequestParam Short feeId) throws Exception {
validateAmount(amount);
List<String> applicableFees = new ArrayList<String>();
for (Map<String, String> feeMap : this.getApplicableFees(globalAccountNum).values()) {
applicableFees.add(feeMap.get("feeId"));
}
validateFeeId(feeId, applicableFees);
Map<String, String> map = new HashMap<String, String>();
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
LoanBO loan = loanDao.findByGlobalAccountNum(globalAccountNum);
Integer accountId = loan.getAccountId();
CustomerBO client = loan.getCustomer();
String outstandingBeforeCharge = loan.getLoanSummary().getOutstandingBalance().toString();
this.accountServiceFacade.applyCharge(accountId, feeId, amount.doubleValue(), false);
DateTime today = new DateTime();
map.put("status", "success");
map.put("clientName", client.getDisplayName());
map.put("clientNumber", client.getGlobalCustNum());
map.put("loanDisplayName", loan.getLoanOffering().getPrdOfferingName());
map.put("chargeDate", today.toLocalDate().toString());
map.put("chargeTime", today.toLocalTime().toString());
map.put("chargeAmount", Double.valueOf(amount.doubleValue()).toString());
map.put("chargeMadeBy", personnelDao.findPersonnelById((short) user.getUserId()).getDisplayName());
map.put("outstandingBeforeCharge", outstandingBeforeCharge);
map.put("outstandingAfterCharge", loan.getLoanSummary().getOutstandingBalance().toString());
return map;
}
use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class PersonnelRESTController method getLastRepayments.
@RequestMapping(value = "personnel/id-current/last-repayments", method = RequestMethod.GET)
@ResponseBody
public List<LastRepaymentDto> getLastRepayments() {
List<LastRepaymentDto> lastRepayments = new ArrayList<LastRepaymentDto>();
PersonnelBO loanOfficer = personnelDao.findPersonnelById(getCurrentPersonnel().getPersonnelId());
List<CustomerBO> borrowers = new ArrayList<CustomerBO>();
for (CustomerDetailDto group : this.customerDao.findGroupsUnderUser(loanOfficer)) {
borrowers.add(customerDao.findGroupBySystemId(group.getGlobalCustNum()));
for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsUnderParent(group.getSearchId(), loanOfficer.getOffice().getOfficeId())) {
borrowers.add(client);
}
}
for (ClientBO client : this.customerDao.findAllExceptClosedAndCancelledClientsWithoutGroupForLoanOfficer(loanOfficer.getPersonnelId(), loanOfficer.getOffice().getOfficeId())) {
borrowers.add(client);
}
for (CustomerBO borrower : borrowers) {
List<LoanBO> loans = borrower.getOpenLoanAccountsAndGroupLoans();
if (loans != null && loans.size() != 0) {
LoanBO lastLoan = null;
Date lastLoanDate = null;
for (LoanBO loan : loans) {
Date lastAction = null;
for (AccountActionDateEntity accountAction : loan.getAccountActionDates()) {
if (lastAction == null || lastAction.before(accountAction.getActionDate())) {
lastAction = accountAction.getActionDate();
}
}
if (lastLoanDate == null || lastLoanDate.before(lastAction)) {
lastLoan = loan;
lastLoanDate = lastAction;
}
}
if (lastLoan == null || lastLoanDate == null) {
continue;
}
ClientDescriptionDto clientDescription = new ClientDescriptionDto(borrower.getCustomerId(), borrower.getDisplayName(), borrower.getGlobalCustNum(), borrower.getSearchId());
LoanDetailDto loanDetails = new LoanDetailDto(lastLoan.getGlobalAccountNum(), lastLoan.getLoanOffering().getPrdOfferingName(), lastLoan.getAccountState().getId(), lastLoan.getAccountState().getName(), lastLoan.getLoanBalance().toString(), lastLoan.getTotalAmountDue().toString(), lastLoan.getAccountType().getAccountTypeId(), lastLoan.getTotalAmountInArrears().toString());
LastRepaymentDto lastRepayment = new LastRepaymentDto(clientDescription, loanDetails, lastLoanDate);
if (borrower instanceof GroupBO) {
lastRepayment.setGroup(true);
}
lastRepayments.add(lastRepayment);
}
}
return lastRepayments;
}
use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class CustomerPersistenceIntegrationTest method testGetAllChildern.
@Test
public void testGetAllChildern() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group);
ClientBO client4 = TestObjectFactory.createClient("client4", CustomerStatus.CLIENT_PENDING, group);
List<CustomerBO> customerList = customerPersistence.getChildren(center.getSearchId(), center.getOffice().getOfficeId(), CustomerLevel.CLIENT, ChildrenStateType.ALL);
Assert.assertEquals(new Integer("4").intValue(), customerList.size());
for (CustomerBO customer : customerList) {
if (customer.getCustomerId().equals(client2.getCustomerId())) {
Assert.assertTrue(true);
}
}
// TestObjectFactory.cleanUp(client2);
// TestObjectFactory.cleanUp(client3);
// TestObjectFactory.cleanUp(client4);
}
use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class CustomerPersistenceIntegrationTest method testGetChildernActiveAndHold.
@Test
public void testGetChildernActiveAndHold() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_PARTIAL, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_PENDING, group);
ClientBO client4 = TestObjectFactory.createClient("client4", CustomerStatus.CLIENT_HOLD, group);
List<CustomerBO> customerList = customerPersistence.getChildren(center.getSearchId(), center.getOffice().getOfficeId(), CustomerLevel.CLIENT, ChildrenStateType.ACTIVE_AND_ONHOLD);
Assert.assertEquals(new Integer("2").intValue(), customerList.size());
for (CustomerBO customer : customerList) {
if (customer.getCustomerId().intValue() == client.getCustomerId().intValue()) {
Assert.assertTrue(true);
}
if (customer.getCustomerId().intValue() == client4.getCustomerId().intValue()) {
Assert.assertTrue(true);
}
}
// TestObjectFactory.cleanUp(client2);
// TestObjectFactory.cleanUp(client3);
// TestObjectFactory.cleanUp(client4);
}
use of org.mifos.customers.business.CustomerBO in project head by mifos.
the class CustomerPersistenceIntegrationTest method testGetActiveCentersUnderUser.
@Test
public void testGetActiveCentersUnderUser() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("center", meeting, Short.valueOf("1"), Short.valueOf("1"));
PersonnelBO personnel = TestObjectFactory.getPersonnel(Short.valueOf("1"));
List<CustomerBO> customers = new CustomerPersistence().getActiveCentersUnderUser(personnel);
Assert.assertNotNull(customers);
Assert.assertEquals(1, customers.size());
}
Aggregations