Search in sources :

Example 16 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping 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;
}
Also used : HashMap(java.util.HashMap) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) CustomerBO(org.mifos.customers.business.CustomerBO) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 17 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping 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;
}
Also used : HashMap(java.util.HashMap) MeetingBO(org.mifos.application.meeting.business.MeetingBO) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) CreateGroupCreationDetailDto(org.mifos.application.servicefacade.CreateGroupCreationDetailDto) GroupCreationDetail(org.mifos.dto.domain.GroupCreationDetail) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 18 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping 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;
}
Also used : CustomerChargesDetailsDto(org.mifos.dto.domain.CustomerChargesDetailsDto) GroupBO(org.mifos.customers.group.business.GroupBO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 19 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping 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;
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) HashMap(java.util.HashMap) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) GroupMemberAccountDto(org.mifos.clientportfolio.newloan.applicationservice.GroupMemberAccountDto) CreateLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateLoanAccount) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) LoanCreationResultDto(org.mifos.dto.screen.LoanCreationResultDto) CreateGlimLoanAccount(org.mifos.clientportfolio.newloan.applicationservice.CreateGlimLoanAccount) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) CreationLoanAccountDto(org.mifos.application.servicefacade.CreationLoanAccountDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 20 with RequestMapping

use of org.springframework.web.bind.annotation.RequestMapping 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;
}
Also used : Money(org.mifos.framework.util.helpers.Money) RepayLoanInfoDto(org.mifos.dto.screen.RepayLoanInfoDto) HashMap(java.util.HashMap) RepayLoanDto(org.mifos.dto.screen.RepayLoanDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) CustomerBO(org.mifos.customers.business.CustomerBO) MifosUser(org.mifos.security.MifosUser) DateTime(org.joda.time.DateTime) Date(java.sql.Date) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1622 ModelAndView (org.springframework.web.servlet.ModelAndView)401 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)375 ArrayList (java.util.ArrayList)177 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)175 HashMap (java.util.HashMap)147 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)124 IOException (java.io.IOException)83 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)75 Date (java.util.Date)73 ApiOperation (io.swagger.annotations.ApiOperation)68 User (org.hisp.dhis.user.User)59 HttpServletResponse (javax.servlet.http.HttpServletResponse)56 ResponseEntity (org.springframework.http.ResponseEntity)56 InputStream (java.io.InputStream)53 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)51 Locale (java.util.Locale)50 CommandStringBuilder (org.apache.geode.management.internal.cli.util.CommandStringBuilder)47 DBObject (com.mongodb.DBObject)46 Aggregation (org.springframework.data.mongodb.core.aggregation.Aggregation)45