private void preparNewForm() {
    LOGGER.debug("Start preparNewForm");
    // Getting all the sanction fees for the service type and putting inside
    // the sanctionfeelist<BpaFee> and iterating this list in the jsp.
    if (registrationObj != null) {
      santionFeeList =
          feeExtnService.getAllSanctionedFeesbyServiceType(
              registrationObj.getServiceType().getId());

      List<InspectionExtn> inspectionList =
          inspectionExtnService.getSiteInspectionListforRegistrationObject(registrationObj);
      if (inspectionList != null && inspectionList.isEmpty()) {
        addActionError(
            "Inspection is mandatory. Please enter site inspection details before calculating Fee.");

      } else {
        for (BpaFeeExtn fe : santionFeeList) {
          fe.setFeeAmount(BigDecimal.ZERO);
        }

        if (null != registrationObj
            && inspectionList.get(0) != null
            && registrationObj.getServiceType() != null
            && registrationObj.getServiceType().getCode() != null
            && (registrationObj
                    .getServiceType()
                    .getCode()
                    .equals(BpaConstants.NEWBUILDINGONVACANTPLOTCODE)
                || registrationObj
                    .getServiceType()
                    .getCode()
                    .equals(BpaConstants.DEMOLITIONRECONSTRUCTIONCODE)
                || registrationObj
                    .getServiceType()
                    .getCode()
                    .equals(BpaConstants.ADDITIONALCONSTRUCTIONCODE))) {

          calculateFee(santionFeeList, registrationObj, inspectionList.get(0));
        }
      }
    }

    setFeeRemarks(BpaConstants.FeeRemarks);
    splitFeelistintosublists();
    LOGGER.debug("Exit preparNewForm");
  }
  @SkipValidation
  public void buildVieworModify(RegistrationExtn registrationObj) {
    LOGGER.debug("Start buildVieworModify");
    if (registrationObj.getEgDemand() != null
        && registrationObj.getEgDemand().getEgDemandDetails() != null) {
      Set<EgDemandDetails> demandDetailsSet = registrationObj.getEgDemand().getEgDemandDetails();
      HashMap<String, BigDecimal> feecodeamountmap = new HashMap<String, BigDecimal>();
      HashMap<String, Long> feecodedemanddetailsIdmap = new HashMap<String, Long>();

      // Getting fee amounts from demand to set into the sanctionfees

      for (EgDemandDetails demandDetails : demandDetailsSet) {
        feecodeamountmap.put(
            demandDetails.getEgDemandReason().getEgDemandReasonMaster().getCode(),
            demandDetails.getAmount());
        feecodedemanddetailsIdmap.put(
            demandDetails.getEgDemandReason().getEgDemandReasonMaster().getCode(),
            demandDetails.getId());
      }

      // Getting fee amounts from registrationdfeedetails to set into the
      // sanctionfees
      RegistrationFeeExtn latesetregistrationFeeObj =
          bpaCommonExtnService.getLatestApprovedRegistrationFee(registrationObj);
      if (latesetregistrationFeeObj != null) {
        Set<RegistrationFeeDetailExtn> regFeeDtlSet =
            latesetregistrationFeeObj.getRegistrationFeeDetailsSet();
        for (RegistrationFeeDetailExtn regFeeDtl : regFeeDtlSet) {
          if (feecodeamountmap.get(regFeeDtl.getBpaFee().getFeeCode()) == null) {
            feecodeamountmap.put(regFeeDtl.getBpaFee().getFeeCode(), regFeeDtl.getAmount());
          }
        }
      }

      santionFeeList =
          feeExtnService.getAllSanctionedFeesbyServiceType(
              registrationObj.getServiceType().getId());
      for (BpaFeeExtn fees : santionFeeList) {
        if (fees.getFeeGroup().equals(BpaConstants.COCFEE)) {
          fees.setFeeAmount(
              feecodeamountmap.get(fees.getFeeCode()) != null
                  ? feecodeamountmap.get(fees.getFeeCode())
                  : BigDecimal.ZERO);
          fees.setDemandDetailId(feecodedemanddetailsIdmap.get(fees.getFeeCode()));
          feeTotal = feeTotal.add(fees.getFeeAmount());
        } else if (fees.getFeeGroup().equals(BpaConstants.CMDAFEE)) {
          fees.setFeeAmount(
              feecodeamountmap.get(fees.getFeeCode()) != null
                  ? feecodeamountmap.get(fees.getFeeCode())
                  : BigDecimal.ZERO);
          fees.setDemandDetailId(feecodedemanddetailsIdmap.get(fees.getFeeCode()));
          feeTotal = feeTotal.add(fees.getFeeAmount());
          // TODO: WE MAY NEED TO PASS DEMANDDETAILID ALONG WITH UI.
        } else if (fees.getFeeGroup().equals(BpaConstants.MWGWFFEE)) {
          fees.setFeeAmount(
              feecodeamountmap.get(fees.getFeeCode()) != null
                  ? feecodeamountmap.get(fees.getFeeCode())
                  : BigDecimal.ZERO);
          fees.setDemandDetailId(feecodedemanddetailsIdmap.get(fees.getFeeCode()));
          feeTotal = feeTotal.add(fees.getFeeAmount());
          // TODO: WE MAY NEED TO PASS DEMANDDETAILID ALONG WITH UI.
        }
      }

      if (latesetregistrationFeeObj != null) {
        registrationObj.setRegistrationFeeChallanNumber(
            latesetregistrationFeeObj.getChallanNumber());

      } else registrationObj.setRegistrationFeeChallanNumber("NA");

      if (latesetregistrationFeeObj != null) {
        setFeeRemarks(latesetregistrationFeeObj.getFeeRemarks());
        registrationObj.setFeeDate(sdf.format(latesetregistrationFeeObj.getFeeDate()));
      } else {
        setFeeRemarks(registrationObj.getFeeRemarks());
        registrationObj.setFeeDate(null); // get date from demanddetl
      }
    }
    splitFeelistintosublists();
    LOGGER.debug("Exit buildVieworModify");
  }