use of org.springframework.web.bind.annotation.ResponseBody in project head by mifos.
the class CustomerRESTController method getApplicableFees.
@RequestMapping(value = "/customer/num-{globalCustNum}/fees", method = RequestMethod.GET)
@ResponseBody
public Map<String, Map<String, String>> getApplicableFees(@PathVariable String globalCustNum) throws Exception {
CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
Integer accountId = customerBO.getCustomerAccount().getAccountId();
List<ApplicableCharge> applicableCharges = this.accountServiceFacade.getApplicableFees(accountId);
Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();
for (ApplicableCharge applicableCharge : applicableCharges) {
Map<String, String> feeMap = new HashMap<String, String>();
feeMap.put("feeId", applicableCharge.getFeeId());
feeMap.put("amountOrRate", applicableCharge.getAmountOrRate());
feeMap.put("formula", applicableCharge.getFormula());
feeMap.put("periodicity", applicableCharge.getPeriodicity());
feeMap.put("paymentType", applicableCharge.getPaymentType());
feeMap.put("isRateType", applicableCharge.getIsRateType());
map.put(applicableCharge.getFeeName(), feeMap);
}
return map;
}
use of org.springframework.web.bind.annotation.ResponseBody in project head by mifos.
the class GroupRESTController method createGroup.
@RequestMapping(value = "group/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createGroup(@RequestBody String request) throws Throwable {
ObjectMapper om = createGroupMapping();
CreateGroupCreationDetailDto creationDetail = null;
MeetingBO meetingBO = null;
try {
creationDetail = om.readValue(request, CreateGroupCreationDetailDto.class);
} catch (JsonMappingException e) {
throw e.getCause();
}
validate(creationDetail);
meetingBO = (MeetingBO) creationDetail.getMeeting().toBO();
GroupCreationDetail group = createGroup(creationDetail);
CustomerDetailsDto groupDetails = groupServiceFacade.createNewGroup(group, meetingBO.toDto());
GroupInformationDto groupInfo = groupServiceFacade.getGroupInformationDto(groupDetails.getGlobalCustNum());
Map<String, String> map = new HashMap<String, String>();
map.put("status", "success");
map.put("globalCusNum", groupInfo.getGroupDisplay().getGlobalCustNum());
map.put("accountNum", groupInfo.getCustomerAccountSummary().getGlobalAccountNum());
map.put("address", groupInfo.getAddress().getDisplayAddress());
map.put("city", groupInfo.getAddress().getCity());
map.put("state", groupInfo.getAddress().getState());
map.put("country", groupInfo.getAddress().getCountry());
map.put("postal code", groupInfo.getAddress().getZip());
map.put("phone", groupInfo.getAddress().getPhoneNumber());
map.put("dispalyName", groupInfo.getGroupDisplay().getDisplayName());
map.put("externalId", groupInfo.getGroupDisplay().getExternalId());
map.put("loanOfficer", groupInfo.getGroupDisplay().getLoanOfficerName());
return map;
}
use of org.springframework.web.bind.annotation.ResponseBody in project head by mifos.
the class GroupRESTController method getGroupChargesByNumber.
@RequestMapping(value = "group/num-{globalCustNum}/charges", method = RequestMethod.GET)
@ResponseBody
public CustomerChargesDetailsDto getGroupChargesByNumber(@PathVariable String globalCustNum) {
GroupBO groupBO = customerDao.findGroupBySystemId(globalCustNum);
CustomerChargesDetailsDto groupCharges = centerServiceFacade.retrieveChargesDetails(groupBO.getCustomerId());
groupCharges.addActivities(centerServiceFacade.retrieveRecentActivities(groupBO.getCustomerId(), 3));
return groupCharges;
}
use of org.springframework.web.bind.annotation.ResponseBody in project head by mifos.
the class LoanAccountRESTController method createLoanAccount.
@RequestMapping(value = "/account/loan/create", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> createLoanAccount(@RequestBody String request) throws Throwable {
ObjectMapper om = createLoanAccountMapping();
Map<String, String> map = new HashMap<String, String>();
CreationLoanAccountDto creationDetails = null;
try {
creationDetails = om.readValue(request, CreationLoanAccountDto.class);
} catch (JsonMappingException e) {
e.getCause();
}
loanValidator(creationDetails);
List<QuestionGroupDetail> questionGroups = new ArrayList<QuestionGroupDetail>();
LoanCreationResultDto loanResult = null;
LoanBO loanInfo = null;
CreateLoanAccount loanAccount = createLoan(creationDetails);
if (creationDetails.getGlim()) {
List<GroupMemberAccountDto> memberAccounts = creationDetails.glimsAsGroupMemberAccountDto(creationDetails.getGlimAccounts());
CreateGlimLoanAccount createGroupLoanAccount = new CreateGlimLoanAccount(memberAccounts, creationDetails.getLoanAmount(), loanAccount);
loanResult = loanAccountServiceFacade.createGroupLoanWithIndividualMonitoring(createGroupLoanAccount, questionGroups, null);
List<LoanBO> individuals = loanDao.findIndividualLoans(loanResult.getAccountId());
for (int i = 0; i < individuals.size(); i++) {
map.put("individualCustomer[" + i + "]", individuals.get(i).getCustomer().getDisplayName());
map.put("individualAccount[" + i + "]", individuals.get(i).getGlobalAccountNum());
map.put("individualAmmount[" + i + "]", individuals.get(i).getLoanAmount().toString());
}
} else {
loanResult = loanAccountServiceFacade.createLoan(loanAccount, questionGroups, null);
}
loanInfo = loanDao.findByGlobalAccountNum(loanResult.getGlobalAccountNum());
map.put("status", "success");
map.put("accountNum", loanInfo.getGlobalAccountNum());
map.put("GLIM", creationDetails.getGlim().toString());
map.put("customer", loanInfo.getCustomer().getDisplayName());
map.put("loanAmmount", loanInfo.getLoanAmount().toString());
map.put("noOfInstallments", loanInfo.getNoOfInstallments().toString());
map.put("externalId", loanInfo.getExternalId());
return map;
}
use of org.springframework.web.bind.annotation.ResponseBody in project head by mifos.
the class LoanAccountRESTController method fullRepay.
@RequestMapping(value = "/account/loan/num-{globalAccountNum}/fullrepay", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> fullRepay(@PathVariable String globalAccountNum, @RequestParam(required = false) String paymentDate, @RequestParam(required = false) Short receiptId, @RequestParam(required = false) String receiptDate, @RequestParam(required = false) Short paymentModeId, @RequestParam Boolean waiveInterest) throws Exception {
LoanBO loan = this.loanDao.findByGlobalAccountNum(globalAccountNum);
validateLoanAccountState(loan);
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
RepayLoanDto repayLoanDto = this.loanAccountServiceFacade.retrieveLoanRepaymentDetails(globalAccountNum);
DateTime today = new DateTime();
Date paymentDateTime = new Date(today.toDate().getTime());
if (paymentDate != null && !paymentDate.isEmpty()) {
paymentDateTime = new Date(validateDateString(paymentDate, format).toDate().getTime());
}
String receiptIdString = null;
if (receiptId != null) {
receiptIdString = receiptId.toString();
}
Date receiptDateTime = null;
if (receiptDate != null && !receiptDate.isEmpty()) {
receiptDateTime = new Date(validateDateString(receiptDate, format).toDate().getTime());
}
String paymentTypeId = null;
if (paymentModeId != null) {
paymentTypeId = paymentModeId.toString();
}
validateDisbursementPaymentTypeId(paymentModeId, accountService.getLoanPaymentTypes());
BigDecimal totalRepaymentAmount = (new Money(loan.getCurrency(), repayLoanDto.getEarlyRepaymentMoney())).getAmount();
BigDecimal waivedAmount = (new Money(loan.getCurrency(), repayLoanDto.getWaivedRepaymentMoney())).getAmount();
BigDecimal earlyRepayAmount = totalRepaymentAmount;
if (Boolean.TRUE.equals(waiveInterest)) {
earlyRepayAmount = waivedAmount;
}
RepayLoanInfoDto repayLoanInfoDto = new RepayLoanInfoDto(globalAccountNum, Double.toString(earlyRepayAmount.doubleValue()), receiptIdString, receiptDateTime, paymentTypeId, (short) user.getUserId(), waiveInterest.booleanValue(), paymentDateTime, totalRepaymentAmount, waivedAmount);
Money outstandingBeforePayment = loan.getLoanSummary().getOutstandingBalance();
this.loanAccountServiceFacade.makeEarlyRepaymentWithCommit(repayLoanInfoDto);
CustomerBO client = loan.getCustomer();
Map<String, String> map = new HashMap<String, String>();
map.put("status", "success");
map.put("clientName", client.getDisplayName());
map.put("clientNumber", client.getGlobalCustNum());
map.put("loanDisplayName", loan.getLoanOffering().getPrdOfferingName());
map.put("paymentDate", today.toLocalDate().toString());
map.put("paymentTime", today.toLocalTime().toString());
map.put("paymentAmount", loan.getLastPmnt().getAmount().toString());
map.put("paymentMadeBy", personnelDao.findPersonnelById((short) user.getUserId()).getDisplayName());
map.put("outstandingBeforePayment", outstandingBeforePayment.toString());
map.put("outstandingAfterPayment", loan.getLoanSummary().getOutstandingBalance().toString());
return map;
}
Aggregations