SHARE
TWEET

Untitled

a guest Jan 21st, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Map<Long, ReportVendorTotalsDTO> vendorById = new HashMap<>();
  2.         List<ReportVendorDetailsDTO> secVendors = new ArrayList<>();
  3.        
  4.         for (ReportVendorDetailsDTO dto: result) {
  5.             if (!vendorById.containsKey(dto.getVendorId())) {
  6.                 ReportVendorTotalsDTO mainDTO = new ReportVendorTotalsDTO(dto.getVendorId(),
  7.                         dto.getVendorName(), dto.getVendorNumber(), dto.isCreditCardPayer(), dto.getAmount(), dto.getType1099());
  8.                 vendorById.put(dto.getVendorId(), mainDTO);
  9.             } else {
  10.                 ReportVendorTotalsDTO vendor = vendorById.get(dto.getVendorId());
  11.                 vendor.setAmount(vendor.getAmount().add(dto.getAmount()));
  12.             }
  13.             if (StringUtils.isNotBlank(dto.getSecondaryPayeesName())) {
  14.                 vendorById.get(dto.getVendorId()).getSecondaryPayees().add(dto);
  15.                 if (dto.getSecondaryVendorId() != 0) {
  16.                     secVendors.add(dto);
  17.                 }
  18.             }
  19.         }
  20.  
  21.         for (ReportVendorDetailsDTO dto: secVendors) {
  22.  
  23.             if (dto.getSecondaryVendorId() != 0
  24.                     && vendorById.containsKey(dto.getSecondaryVendorId())
  25.                     && !vendorById.get(dto.getSecondaryVendorId()).isCreditCardPayer()) {
  26.                 ReportVendorTotalsDTO reportVendorTotalsDTO = vendorById.get(dto.getSecondaryVendorId());
  27.                 reportVendorTotalsDTO.setSecondaryPayments(reportVendorTotalsDTO.getSecondaryPayments() == null ? dto.getAmount()
  28.                         : reportVendorTotalsDTO.getSecondaryPayments().add(dto.getAmount()));
  29.             }
  30.         }
  31.        
  32.         List<ReportVendorTotalsDTO> values = new ArrayList<>();
  33.  
  34.         if (VendorRestrictions.OVER_600.equals(vR)) {
  35.            
  36.             for (ReportVendorTotalsDTO dto : vendorById.values() ) {
  37.                 if (dto.getAmount().compareTo(BigDecimal.valueOf(600)) >= 0) {
  38.                     values.add(dto);
  39.                 }
  40.             }
  41.            
  42.         } else {
  43.             values.addAll(vendorById.values());
  44.         }
  45.  
  46.         if (CollectionUtils.isNotEmpty(vendorIds)) {
  47.             values = values.stream().filter(x -> vendorIds.contains(x.getVendorId())).collect(Collectors.toList());
  48.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top