private void buildAgencyWiseDemand(final Set<AgencyWiseCollectionDetail> agencyWiseCollectionDetails,final BigDecimal totalAmount,final AgencyWiseCollection agencyWiseCollection,final Installment installment){
  final EgDemand agencyWiseDemand=new EgDemand();
  final HashMap<EgDemandReason,BigDecimal> demandReasonWiseList=getAmountGroupingDemandReason(agencyWiseCollectionDetails);
  if (demandReasonWiseList.size() > 0)   demandReasonWiseList.forEach(null);
  agencyWiseDemand.setEgInstallmentMaster(installment);
  agencyWiseDemand.setIsHistory("Y");
  agencyWiseDemand.setCreateDate(new Date());
  agencyWiseDemand.setBaseDemand(totalAmount);
  agencyWiseDemand.setModifiedDate(new Date());
  agencyWiseCollection.setAgencyWiseDemand(agencyWiseDemand);
}

private void buildAgencyWiseDemand ( final Set < AgencyWiseCollectionDetail > agencyWiseCollectionDetails , final BigDecimal totalAmount , final AgencyWiseCollection agencyWiseCollection , final Installment installment ) { final EgDemand agencyWiseDemand = new EgDemand ( ) ; final HashMap < EgDemandReason , BigDecimal > demandReasonWiseList = getAmountGroupingDemandReason ( agencyWiseCollectionDetails ) ; if ( demandReasonWiseList . size ( ) > 0 ) demandReasonWiseList . forEach ( null ) ; agencyWiseDemand . setEgInstallmentMaster ( installment ) ; agencyWiseDemand . setIsHistory ( "Y" ) ; agencyWiseDemand . setCreateDate ( new Date ( ) ) ; agencyWiseDemand . setBaseDemand ( totalAmount ) ; agencyWiseDemand . setModifiedDate ( new Date ( ) ) ; agencyWiseCollection . setAgencyWiseDemand ( agencyWiseDemand ) ; }
grouping all the agency wise collection details to temporary demand . default adding status as history for this demand .
