Subversion Repositories SmartDukaan

Rev

Rev 30463 | Rev 30472 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30463 Rev 30471
Line 142... Line 142...
142
	private NotificationService notificationService;
142
	private NotificationService notificationService;
143
 
143
 
144
	@Autowired
144
	@Autowired
145
	private FofoStoreRepository fofoStoreRepository;
145
	private FofoStoreRepository fofoStoreRepository;
146
 
146
 
-
 
147
	private static final List<String> SELLINS = Arrays.asList("Base Payout", "Cash Discount", "Upfront Margin");
-
 
148
	private static final List<String> SELLOUTS = Arrays.asList("Tertiary Payout", "Hygiene Payout", "Investment Payout", "Category Payout", "Activation Margin", "Special Support");
-
 
149
	private static final List<String> ALL_MARGINS = Arrays.asList(SELLINS, SELLOUTS).stream().flatMap(x -> x.stream()).collect(Collectors.toList());
-
 
150
 
147
	@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
151
	@RequestMapping(value = "/getItemDescription", method = RequestMethod.GET)
148
	public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
152
	public String getItemDescription(HttpServletRequest request, Model model) throws Throwable {
149
		List<PriceDrop> priceDrops = priceDropRepository.selectAllIncomplete();
153
		List<PriceDrop> priceDrops = priceDropRepository.selectAllIncomplete();
150
		Set<Integer> catalogIds = priceDrops.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
154
		Set<Integer> catalogIds = priceDrops.stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
151
 
155
 
Line 649... Line 653...
649
		PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
653
		PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
650
		List<PartnerType> partnerTypes = new ArrayList<>();
654
		List<PartnerType> partnerTypes = new ArrayList<>();
651
		partnerTypes.add(partnerType);
655
		partnerTypes.add(partnerType);
652
		partnerTypes.add(PartnerType.ALL);
656
		partnerTypes.add(PartnerType.ALL);
653
		PriceCircularModel priceCircular = priceCircularService.getPriceCircularByOffer(fofoId, brand);
657
		PriceCircularModel priceCircular = priceCircularService.getPriceCircularByOffer(fofoId, brand);
-
 
658
		PriceCircularItemModel summaryModel = this.getSummaryModel(priceCircular);
-
 
659
		List<String> allMargins = ALL_MARGINS.stream().filter(payoutType -> summaryModel.getByPayoutType(payoutType) > 0).collect(Collectors.toList());
-
 
660
		List<String> sellins = SELLINS.stream().filter(x -> allMargins.contains(x)).collect(Collectors.toList());
-
 
661
		List<String> sellouts = SELLOUTS.stream().filter(x -> allMargins.contains(x)).collect(Collectors.toList());
-
 
662
		LOGGER.info("All margins - {}", allMargins);
-
 
663
		LOGGER.info("Sellins - {}", sellins);
654
 
-
 
-
 
664
		LOGGER.info("Sellouts - {}", sellouts);
655
		FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoId);
665
		FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoId);
656
		model.addAttribute("priceCircular", priceCircular.getPriceCircularItemModels());
666
		model.addAttribute("priceCircular", priceCircular.getPriceCircularItemModels());
-
 
667
		model.addAttribute("allMargins", allMargins);
-
 
668
		model.addAttribute("sellins", sellins);
-
 
669
		model.addAttribute("sellouts", sellouts);
657
		model.addAttribute("offers", priceCircular.getOffers());
670
		model.addAttribute("offers", priceCircular.getOffers());
658
		model.addAttribute("upgradeOffer", priceCircular.isUpgradeOffer());
671
		model.addAttribute("upgradeOffer", priceCircular.isUpgradeOffer());
659
		model.addAttribute("partnerCode", fs.getCode());
672
		model.addAttribute("partnerCode", fs.getCode());
660
		return "price-circular-detail";
673
		return "price-circular-detail";
661
	}
674
	}
662
 
675
 
-
 
676
	private PriceCircularItemModel getSummaryModel(PriceCircularModel priceCircular) {
-
 
677
 
-
 
678
		PriceCircularItemModel summaryModel = new PriceCircularItemModel();
-
 
679
		priceCircular.getPriceCircularItemModels().stream().forEach(x -> {
-
 
680
			if (summaryModel.getSpecialSupport() == 0 && x.getSpecialSupport() > 0) {
-
 
681
				summaryModel.setSpecialSupport(1);
-
 
682
			}
-
 
683
			if (summaryModel.getBasePayout() == 0 && x.getBasePayout() > 0) {
-
 
684
				summaryModel.setBasePayout(1);
-
 
685
			}
-
 
686
			if (summaryModel.getSpecialSupport() == 0 && x.getSpecialSupport() > 0) {
-
 
687
				summaryModel.setSpecialSupport(1);
-
 
688
			}
-
 
689
			if (summaryModel.getCategoryPayout() == 0 && x.getCategoryPayout() > 0) {
-
 
690
				summaryModel.setSpecialSupport(1);
-
 
691
			}
-
 
692
			if (summaryModel.getTertiaryPayout() == 0 && x.getTertiaryPayout() > 0) {
-
 
693
				summaryModel.setTertiaryPayout(1);
-
 
694
			}
-
 
695
			if (summaryModel.getModelSpecfic() == 0 && x.getModelSpecfic() > 0) {
-
 
696
				summaryModel.setModelSpecfic(1);
-
 
697
			}
-
 
698
			if (summaryModel.getUpfrontMargin() == 0 && x.getUpfrontMargin() > 0) {
-
 
699
				summaryModel.setUpfrontMargin(1);
-
 
700
			}
-
 
701
			if (summaryModel.getHygienePayout() == 0 && x.getHygienePayout() > 0) {
-
 
702
				summaryModel.setHygienePayout(1);
-
 
703
			}
-
 
704
			if (summaryModel.getInvestmentPayout() == 0 && x.getInvestmentPayout() > 0) {
-
 
705
				summaryModel.setInvestmentPayout(1);
-
 
706
			}
-
 
707
		});
-
 
708
 
-
 
709
		return summaryModel;
-
 
710
	}
-
 
711
 
663
 
712
 
664
	@RequestMapping(value = "/downloadNlcByBrand")
713
	@RequestMapping(value = "/downloadNlcByBrand")
665
	public ResponseEntity<ByteArrayResource> downloadNlcByBrand(HttpServletRequest request,
714
	public ResponseEntity<ByteArrayResource> downloadNlcByBrand(HttpServletRequest request,
666
																@RequestParam String brand, Model model, @RequestParam(defaultValue = "0", required = false) int fofoId) throws Exception {
715
																@RequestParam String brand, Model model, @RequestParam(defaultValue = "0", required = false) int fofoId) throws Exception {
667
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
716
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);