/** @return */
  @Action(value = "/collectPropertyTax-generateBill")
  public String generateBill() {
    if (LOGGER.isDebugEnabled())
      LOGGER.debug(
          "Entered method generatePropertyTaxBill, Generating bill for index no : " + propertyId);
    if (propertyId == null || propertyId.isEmpty()) {
      setErrorMsg(getText("mandatory.assessmentNo"));
      return RESULT_ERROR;
    }
    final BasicProperty basicProperty =
        basicPropertyService.findByNamedQuery(
            PropertyTaxConstants.QUERY_BASICPROPERTY_BY_UPICNO, propertyId);
    if (basicProperty == null) {
      setErrorMsg(getText("validation.property.doesnot.exists"));
      return RESULT_ERROR;
    }
    if (LOGGER.isDebugEnabled())
      LOGGER.debug("generatePropertyTaxBill : BasicProperty :" + basicProperty);

    if (basicProperty.getProperty().getIsExemptedFromTax()) {
      args.add(propertyId);
      setErrorMsg(getText("msg.collection.tax.exempted", args));
      return RESULT_ERROR;
    }

    final Map<String, BigDecimal> demandCollMap =
        propertyTaxUtil.getDemandAndCollection(basicProperty.getProperty());
    final BigDecimal currDue =
        demandCollMap.get(CURR_DMD_STR).subtract(demandCollMap.get(CURR_COLL_STR));
    final BigDecimal arrDue =
        demandCollMap.get(ARR_DMD_STR).subtract(demandCollMap.get(ARR_COLL_STR));

    if (currDue.compareTo(BigDecimal.ZERO) <= 0 && arrDue.compareTo(BigDecimal.ZERO) <= 0) {
      args.add(propertyId);
      isAssessmentNoValid = Boolean.TRUE;
      setErrorMsg(getText("msg.collection.fully.paid", args));
      return RESULT_ERROR;
    }
    propertyTaxBillable.setLevyPenalty(true);
    propertyTaxBillable.setBasicProperty(basicProperty);
    propertyTaxBillable.setUserId(Long.valueOf(getSession().get("userid").toString()));
    propertyTaxBillable.setReferenceNumber(
        propertyTaxNumberGenerator.generateBillNumber(
            basicProperty.getPropertyID().getWard().getBoundaryNum().toString()));
    propertyTaxBillable.setBillType(propertyTaxUtil.getBillTypeByCode(BILLTYPE_AUTO));

    final String billXml = ptBillServiceImpl.getBillXML(propertyTaxBillable);
    try {
      collectXML = URLEncoder.encode(billXml, "UTF-8");
    } catch (final UnsupportedEncodingException e) {
      throw new RuntimeException(e.getMessage());
    }
    if (LOGGER.isDebugEnabled())
      LOGGER.debug(
          "Exiting method generatePropertyTaxBill, collectXML (before decode): " + billXml);
    return RESULT_VIEW;
  }
 /**
  * @param pmv
  * @return
  */
 private List<Map<String, String>> getResultsFromMv(final PropertyMaterlizeView pmv) {
   if (LOGGER.isDebugEnabled()) {
     LOGGER.debug("Entered into getSearchResults method");
     LOGGER.debug("Assessment Number : " + pmv.getPropertyId());
   }
   BasicProperty basicProperty =
       basicPropertyDAO.getBasicPropertyByPropertyID(pmv.getPropertyId());
   Property property = basicProperty.getProperty();
   if (basicProperty != null) {
     checkIsDemandActive(basicProperty.getProperty());
   }
   if (pmv.getPropertyId() != null
       || org.apache.commons.lang.StringUtils.isNotEmpty(pmv.getPropertyId()))
     if (pmv != null) {
       final Map<String, String> searchResultMap = new HashMap<String, String>();
       searchResultMap.put("assessmentNum", pmv.getPropertyId());
       searchResultMap.put("ownerName", pmv.getOwnerName());
       searchResultMap.put("parcelId", pmv.getGisRefNo());
       searchResultMap.put("address", pmv.getPropertyAddress());
       searchResultMap.put("source", pmv.getSource().toString());
       searchResultMap.put("isDemandActive", String.valueOf(isDemandActive));
       searchResultMap.put(
           "propType", property.getPropertyDetail().getPropertyTypeMaster().getCode());
       searchResultMap.put("isTaxExempted", String.valueOf(property.getIsExemptedFromTax()));
       searchResultMap.put("isUnderWorkflow", String.valueOf(basicProperty.isUnderWorkflow()));
       searchResultMap.put(
           "enableVacancyRemission",
           String.valueOf(propertyTaxUtil.enableVacancyRemission(basicProperty.getUpicNo())));
       searchResultMap.put(
           "enableMonthlyUpdate",
           String.valueOf(propertyTaxUtil.enableMonthlyUpdate(basicProperty.getUpicNo())));
       searchResultMap.put(
           "enableVRApproval",
           String.valueOf(propertyTaxUtil.enableVRApproval(basicProperty.getUpicNo())));
       if (pmv.getIsExempted()) {
         searchResultMap.put("currDemand", "0");
         searchResultMap.put("arrDemandDue", "0");
         searchResultMap.put("currDemandDue", "0");
       } else {
         searchResultMap.put("currDemand", pmv.getAggrCurrDmd().toString());
         searchResultMap.put(
             "currDemandDue", pmv.getAggrCurrDmd().subtract(pmv.getAggrCurrColl()).toString());
         searchResultMap.put(
             "arrDemandDue", pmv.getAggrArrDmd().subtract(pmv.getAggrArrColl()).toString());
       }
       searchList.add(searchResultMap);
     }
   if (LOGGER.isDebugEnabled()) {
     LOGGER.debug("Search list : " + (searchList != null ? searchList : ZERO));
     LOGGER.debug("Exit from getSearchResults method");
   }
   return searchList;
 }
 @ModelAttribute
 public VacancyRemissionApproval vacancyRemissionApprovalModel(@PathVariable Long id) {
   VacancyRemissionApproval vacancyRemissionApproval =
       vacancyRemissionService.getVacancyRemissionApprovalById(id);
   designation =
       propertyTaxUtil.getDesignationForUser(vacancyRemissionService.getLoggedInUser().getId());
   return vacancyRemissionApproval;
 }
  /*
   * (non-Javadoc)
   * @see org.egov.infra.web.struts.actions.BaseFormAction#prepare()
   */
  @Override
  public void prepare() {
    final List<Boundary> zoneList =
        boundaryService.getActiveBoundariesByBndryTypeNameAndHierarchyTypeName(
            "Zone", REVENUE_HIERARCHY_TYPE);
    final List<Boundary> wardList =
        boundaryService.getActiveBoundariesByBndryTypeNameAndHierarchyTypeName(
            "Ward", REVENUE_HIERARCHY_TYPE);
    final List<Boundary> locationList =
        boundaryService.getActiveBoundariesByBndryTypeNameAndHierarchyTypeName(
            "Locality", LOCATION_HIERARCHY_TYPE);

    setZoneBndryMap(CommonServices.getFormattedBndryMap(zoneList));
    setWardndryMap(CommonServices.getFormattedBndryMap(wardList));
    prepareWardDropDownData(zoneId != null, wardId != null);
    addDropdownData("Location", locationList);
    addDropdownData(
        "PropTypeMaster",
        getPersistenceService().findAllByNamedQuery(PropertyTaxConstants.GET_PROPERTY_TYPES));
    final Long userId = (Long) session().get(SESSIONLOGINID);
    if (userId != null) setRoleName(propertyTaxUtil.getRolesForUserId(userId));
  }
  @RequestMapping(method = RequestMethod.POST)
  public String update(
      @Valid @ModelAttribute VacancyRemissionApproval vacancyRemissionApproval,
      final BindingResult resultBinder,
      final RedirectAttributes redirectAttributes,
      final HttpServletRequest request,
      final Model model) {

    String senderName = vacancyRemissionApproval.getCurrentState().getSenderName();
    if (!resultBinder.hasErrors()) {
      String workFlowAction = "";
      if (request.getParameter("workFlowAction") != null)
        workFlowAction = request.getParameter("workFlowAction");

      Long approvalPosition = 0l;
      String approvalComent = "";
      String successMsg = "";

      if (request.getParameter("approvalComent") != null)
        approvalComent = request.getParameter("approvalComent");
      if (request.getParameter("approvalPosition") != null
          && !request.getParameter("approvalPosition").isEmpty())
        approvalPosition = Long.valueOf(request.getParameter("approvalPosition"));

      vacancyRemissionService.saveVacancyRemissionApproval(
          vacancyRemissionApproval, approvalPosition, approvalComent, null, workFlowAction);

      if (StringUtils.isNotBlank(workFlowAction)) {
        if (workFlowAction.equalsIgnoreCase(PropertyTaxConstants.WFLOW_ACTION_STEP_APPROVE)) {
          successMsg =
              "Vacancy Remission Approved Successfully in the System and forwarded to "
                  + vacancyRemissionApproval.getVacancyRemission().getCreatedBy().getUsername();
        } else if (workFlowAction.equalsIgnoreCase(PropertyTaxConstants.WFLOW_ACTION_STEP_REJECT)) {
          if (designation.getName().equalsIgnoreCase(REVENUE_INSPECTOR_DESGN)) {
            successMsg =
                "Vacancy Remission rejected successfully and forwarded to : "
                    + vacancyRemissionApproval.getVacancyRemission().getCreatedBy().getUsername();
          } else {
            successMsg =
                "Vacancy Remission rejected successfully and forwarded to : "
                    + vacancyRemissionApproval.getCreatedBy().getUsername();
          }
        } else {
          successMsg =
              "Vacancy Remission Saved Successfully in the System and forwarded to : "
                  + propertyTaxUtil.getApproverUserName(approvalPosition);
        }
      }

      model.addAttribute("successMessage", successMsg);
      if (StringUtils.isNotBlank(workFlowAction)
          && workFlowAction.equalsIgnoreCase(
              PropertyTaxConstants.WFLOW_ACTION_STEP_NOTICE_GENERATE)) {
        String pathVars =
            vacancyRemissionApproval.getVacancyRemission().getBasicProperty().getUpicNo()
                + ","
                + senderName;
        return "redirect:/vacancyremission/rejectionacknowledgement?pathVar=" + pathVars;
      }
    }
    return "vacancyRemission-success";
  }
  /**
   * @param assessmentNumber
   * @return
   */
  private List<Map<String, String>> getSearchResults(final String assessmentNumber) {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Entered into getSearchResults method");
      LOGGER.debug("Assessment Number : " + assessmentNumber);
    }
    if (assessmentNumber != null
        || org.apache.commons.lang.StringUtils.isNotEmpty(assessmentNumber)) {

      final BasicProperty basicProperty =
          basicPropertyDAO.getBasicPropertyByPropertyID(assessmentNumber);
      if (LOGGER.isDebugEnabled()) LOGGER.debug("BasicProperty : " + basicProperty);
      if (basicProperty != null) {
        final Property property = basicProperty.getProperty();
        if (LOGGER.isDebugEnabled()) LOGGER.debug("Property : " + property);

        checkIsDemandActive(property);

        final Map<String, BigDecimal> demandCollMap = ptDemandDAO.getDemandCollMap(property);

        final Map<String, String> searchResultMap = new HashMap<String, String>();
        searchResultMap.put("assessmentNum", assessmentNumber);
        searchResultMap.put("ownerName", basicProperty.getFullOwnerName());
        searchResultMap.put("address", basicProperty.getAddress().toString());
        searchResultMap.put("source", basicProperty.getSource().toString());
        searchResultMap.put("isDemandActive", String.valueOf(isDemandActive));
        searchResultMap.put(
            "propType", property.getPropertyDetail().getPropertyTypeMaster().getCode());
        searchResultMap.put("isTaxExempted", String.valueOf(property.getIsExemptedFromTax()));
        searchResultMap.put("isUnderWorkflow", String.valueOf(basicProperty.isUnderWorkflow()));
        searchResultMap.put(
            "enableVacancyRemission",
            String.valueOf(propertyTaxUtil.enableVacancyRemission(basicProperty.getUpicNo())));
        searchResultMap.put(
            "enableMonthlyUpdate",
            String.valueOf(propertyTaxUtil.enableMonthlyUpdate(basicProperty.getUpicNo())));
        searchResultMap.put(
            "enableVRApproval",
            String.valueOf(propertyTaxUtil.enableVRApproval(basicProperty.getUpicNo())));
        if (!property.getIsExemptedFromTax()) {
          searchResultMap.put("currDemand", demandCollMap.get(CURR_DMD_STR).toString());
          searchResultMap.put(
              "arrDemandDue",
              demandCollMap.get(ARR_DMD_STR).subtract(demandCollMap.get(ARR_COLL_STR)).toString());
          searchResultMap.put(
              "currDemandDue",
              demandCollMap
                  .get(CURR_DMD_STR)
                  .subtract(demandCollMap.get(CURR_COLL_STR))
                  .toString());
        } else {
          searchResultMap.put("currDemand", "0");
          searchResultMap.put("arrDemandDue", "0");
          searchResultMap.put("currDemandDue", "0");
        }
        if (LOGGER.isDebugEnabled())
          LOGGER.debug(
              "Assessment Number : "
                  + searchResultMap.get("assessmentNum")
                  + ", "
                  + "Owner Name : "
                  + searchResultMap.get("ownerName")
                  + ", "
                  + "Parcel id : "
                  + searchResultMap.get("parcelId")
                  + ", "
                  + "Address : "
                  + searchResultMap.get("address")
                  + ", "
                  + "Current Demand : "
                  + searchResultMap.get("currDemand")
                  + ", "
                  + "Arrears Demand Due : "
                  + searchResultMap.get("arrDemandDue")
                  + ", "
                  + "Current Demand Due : "
                  + searchResultMap.get("currDemandDue"));
        searchList.add(searchResultMap);
      }
    }
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Search list : " + (searchList != null ? searchList : ZERO));
      LOGGER.debug("Exit from getSearchResults method");
    }
    return searchList;
  }