/** * Method returns how much discount is already offered * * @param lineItems * @return */ private Double getTotalDiscountOffered(Set<LineItem> lineItems) { LOGGER.info("Calculating Total Discount Offered"); Double totalDiscountOffrd = 0D; Map<String, String> qualifyngTypeLI = proposalService.getQualifyingLineItems(); for (LineItem lineItem : lineItems) { if (qualifyngTypeLI.containsKey(lineItem.getPriceType()) || LineItemPriceTypeEnum.ADDEDVALUE.getOptionValue().equals(lineItem.getPriceType())) { if (lineItem.getPriceType().equals(LineItemPriceTypeEnum.ADDEDVALUE.getOptionValue())) { if (lineItem.getRateCardPrice() != null) { totalDiscountOffrd = totalDiscountOffrd + ((lineItem.getRateCardPrice() * lineItem.getImpressionTotal()) / 1000); } } else { if (lineItem.getRateCardPrice() > lineItem.getRate()) { totalDiscountOffrd = totalDiscountOffrd + ((lineItem.getRateCardPrice() - NumberUtil.round(lineItem.getRate(), 2)) * lineItem.getImpressionTotal()) / 1000; } } } } return totalDiscountOffrd; }
/* (non-Javadoc) * @see com.nyt.mpt.service.IPricingStatusCalculatorService#getPricingStatus(com.nyt.mpt.domain.LineItem, boolean) */ @Override public PricingStatus getPricingStatus(LineItem lineItem, boolean isSpecialAdvertiser) { PricingStatus pricingStatus; if (isSpecialAdvertiser || lineItem.getPriceType().equals(LineItemPriceTypeEnum.FLATRATE.getOptionValue())) { pricingStatus = PricingStatus.SYSTEM_APPROVED; } else if (lineItem.getRateCardPrice().equals(0.0)) { pricingStatus = PricingStatus.UNAPPROVED; } else { double difference = NumberUtil.round( ((lineItem.getRateCardPrice() - NumberUtil.round(lineItem.getRate(), 2)) * 100) / lineItem.getRateCardPrice(), 2); if (difference <= Double.valueOf(TOLERANCE_PERCENT)) { pricingStatus = PricingStatus.SYSTEM_APPROVED; } else { pricingStatus = PricingStatus.UNAPPROVED; } } lineItem.setPackageObj(null); return pricingStatus; }