/** * Returns a copy that can be associated with another EgDemand. The copy has the same amounts, * reason, time stamp and (cloned) receipts if any. (Note: making it public instead of protected * to allow any class to use it.) */ @Override public Object clone() { EgDemandDetails clone = null; try { clone = (EgDemandDetails) super.clone(); } catch (CloneNotSupportedException e) { // this should never happen throw new InternalError(e.toString()); } clone.setId(null); clone.setEgwStatus(null); clone.setEgdmCollectedReceipts(new HashSet<EgdmCollectedReceipt>()); for (EgdmCollectedReceipt receipt : getEgdmCollectedReceipts()) { EgdmCollectedReceipt cloneRec = (EgdmCollectedReceipt) receipt.clone(); cloneRec.setEgdemandDetail(this); clone.addEgdmCollectedReceipt(cloneRec); } return clone; }
/** Factory method for convenient creation. */ public static EgDemandDetails fromReasonAndAmounts( BigDecimal demandAmount, EgDemandReason egDemandReason, BigDecimal collectedAmount) { EgDemandDetails dd = new EgDemandDetails(); dd.setAmount(demandAmount); dd.setEgDemandReason(egDemandReason); dd.setAmtCollected(collectedAmount); dd.setModifiedDate(new Date()); dd.setCreateDate(new Date()); return dd; }
@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"); }