Subversion Repositories SmartDukaan

Rev

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

Rev 30155 Rev 30235
Line 743... Line 743...
743
		List<LastMonthCreditedIncomeModel> lastMonthPurchaseInMargins = schemeInOutRepository
743
		List<LastMonthCreditedIncomeModel> lastMonthPurchaseInMargins = schemeInOutRepository
744
				.selectLastMonthPurchaseInMarginByFofoId(loginDetails.getFofoId(), currentStartMonth, currentDate);
744
				.selectLastMonthPurchaseInMarginByFofoId(loginDetails.getFofoId(), currentStartMonth, currentDate);
745
 
745
 
746
		List<LastMonthCreditedIncomeModel> lastMonthFrontEndIncomes = schemeInOutRepository
746
		List<LastMonthCreditedIncomeModel> lastMonthFrontEndIncomes = schemeInOutRepository
747
				.selectFrontIncomeByBrand(loginDetails.getFofoId(), currentStartMonth, currentDate);
747
				.selectFrontIncomeByBrand(loginDetails.getFofoId(), currentStartMonth, currentDate);
-
 
748
		
-
 
749
	
-
 
750
		Map<String,LastMonthCreditedIncomeModel>lastMonthPendingIncomeMap = schemeInOutRepository
-
 
751
				.selectLastMonthPendingIncomeByFofoId(loginDetails.getFofoId(), currentStartMonth, currentDate).stream().collect(Collectors.toMap(x-> x.getBrand(), x-> x));
748
 
752
 
-
 
753
	
749
		LOGGER.info("lastMonthCreditedIncomeModels" + lastMonthCreditedIncomeModels);
754
		LOGGER.info("lastMonthCreditedIncomeModels" + lastMonthCreditedIncomeModels);
750
		LOGGER.info("lastMonthFrontEndIncomes" + lastMonthFrontEndIncomes);
755
		LOGGER.info("lastMonthFrontEndIncomes" + lastMonthFrontEndIncomes);
751
		LOGGER.info("lastMonthPurchaseInMargins" + lastMonthPurchaseInMargins);
756
		LOGGER.info("lastMonthPurchaseInMargins" + lastMonthPurchaseInMargins);
752
		LOGGER.info("lastMonthCategoryUpgradeMarginMap" + lastMonthCategoryUpgradeMarginMap);
757
		LOGGER.info("lastMonthCategoryUpgradeMarginMap" + lastMonthCategoryUpgradeMarginMap);
753
 
758
 
754
		Map<String, LastMonthCreditedIncomeModel> lastMonthPurchaseInMarginMap = new HashMap<>();
759
		Map<String, LastMonthCreditedIncomeModel> lastMonthPurchaseInMarginMap = new HashMap<>();
755
 
760
 
-
 
761
 
756
		lastMonthPurchaseInMarginMap = lastMonthPurchaseInMargins.stream()
762
		lastMonthPurchaseInMarginMap = lastMonthPurchaseInMargins.stream()
757
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
763
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
758
 
764
 
759
		Map<String, LastMonthCreditedIncomeModel> lastMonthSaleMarginMap = lastMonthCreditedIncomeModels.stream()
765
		Map<String, LastMonthCreditedIncomeModel> lastMonthSaleMarginMap = lastMonthCreditedIncomeModels.stream()
760
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
766
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
Line 772... Line 778...
772
				.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue().getAmount()));
778
				.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue().getAmount()));
773
 
779
 
774
		Set<String> keySet = new HashSet<String>();
780
		Set<String> keySet = new HashSet<String>();
775
		keySet.addAll(lastMonthPurchaseInMarginMap.keySet());
781
		keySet.addAll(lastMonthPurchaseInMarginMap.keySet());
776
		keySet.addAll(lastMonthSaleMarginMap.keySet());
782
		keySet.addAll(lastMonthSaleMarginMap.keySet());
-
 
783
		keySet.addAll(lastMonthPendingIncomeMap.keySet());
777
 
784
 
778
		lastMonthPurchaseInMarginMap.entrySet().stream().forEach(x -> {
785
		lastMonthPurchaseInMarginMap.entrySet().stream().forEach(x -> {
779
			String brand = x.getKey();
786
			String brand = x.getKey();
780
			float amount = x.getValue().getAmount();
787
			float amount = x.getValue().getAmount();
781
			if (!totalAmountMap.containsKey(brand)) {
788
			if (!totalAmountMap.containsKey(brand)) {
782
				totalAmountMap.put(brand, 0f);
789
				totalAmountMap.put(brand, 0f);
783
			}
790
			}
784
			totalAmountMap.put(brand, totalAmountMap.get(brand) + amount);
791
			totalAmountMap.put(brand, totalAmountMap.get(brand) + amount);
785
 
792
 
786
		});
793
		});
-
 
794
		
-
 
795
		lastMonthPendingIncomeMap.entrySet().stream().forEach(x -> {
-
 
796
			String brand = x.getKey();
-
 
797
			float amount = x.getValue().getAmount();
-
 
798
			if (!totalAmountMap.containsKey(brand)) {
-
 
799
				totalAmountMap.put(brand, 0f);
-
 
800
			}
-
 
801
			totalAmountMap.put(brand, totalAmountMap.get(brand) + amount);
-
 
802
 
-
 
803
		});
787
 
804
 
788
		Map<Integer, String> monthValueMap = new HashMap<>();
805
		Map<Integer, String> monthValueMap = new HashMap<>();
789
		for (int i = 0; i <= 5; i++) {
806
		for (int i = 0; i <= 5; i++) {
790
			LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
807
			LocalDateTime startOfMonth = LocalDateTime.now().withDayOfMonth(1).minusMonths(i);
791
			monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
808
			monthValueMap.put(i, startOfMonth.format(DateTimeFormatter.ofPattern("MMM''uu")));
792
		}
809
		}
793
		model.addAttribute("month", 0);
810
		model.addAttribute("month", 0);
794
		model.addAttribute("monthValueMap", monthValueMap);
811
		model.addAttribute("monthValueMap", monthValueMap);
795
		model.addAttribute("keySet", keySet);
812
		model.addAttribute("keySet", keySet);
-
 
813
		model.addAttribute("lastMonthPendingIncomeMap", lastMonthPendingIncomeMap);
796
 
814
 
797
		model.addAttribute("lastMonthCategoryUpgradeMarginMap", lastMonthCategoryUpgradeMarginMap);
815
		model.addAttribute("lastMonthCategoryUpgradeMarginMap", lastMonthCategoryUpgradeMarginMap);
798
		model.addAttribute("lastMonthPurchaseInMarginMap", lastMonthPurchaseInMarginMap);
816
		model.addAttribute("lastMonthPurchaseInMarginMap", lastMonthPurchaseInMarginMap);
799
		model.addAttribute("lastMonthSaleMarginMap", lastMonthSaleMarginMap);
817
		model.addAttribute("lastMonthSaleMarginMap", lastMonthSaleMarginMap);
800
		model.addAttribute("status", status);
818
		model.addAttribute("status", status);
Line 852... Line 870...
852
				.selectLastMonthFrontEndImei(loginDetails.getFofoId(), catalogItemId, lastMonthStart, currentMonthEnd);
870
				.selectLastMonthFrontEndImei(loginDetails.getFofoId(), catalogItemId, lastMonthStart, currentMonthEnd);
853
		List<LastMonthImeiModel> lmpi = schemeInOutRepository.selectLastMonthPurchaseInImei(loginDetails.getFofoId(),
871
		List<LastMonthImeiModel> lmpi = schemeInOutRepository.selectLastMonthPurchaseInImei(loginDetails.getFofoId(),
854
				catalogItemId, lastMonthStart, currentMonthEnd);
872
				catalogItemId, lastMonthStart, currentMonthEnd);
855
		List<LastMonthImeiModel> lmci = schemeInOutRepository.selectLastMonthCreditedImei(loginDetails.getFofoId(),
873
		List<LastMonthImeiModel> lmci = schemeInOutRepository.selectLastMonthCreditedImei(loginDetails.getFofoId(),
856
				catalogItemId, lastMonthStart, currentMonthEnd);
874
				catalogItemId, lastMonthStart, currentMonthEnd);
-
 
875
		
-
 
876
		LOGGER.info("lmci {}", lmci);
857
 
877
 
858
		Map<String, Double> lastmonthCategoryUpgradeMargin = schemeInOutRepository
878
		Map<String, Double> lastmonthCategoryUpgradeMargin = schemeInOutRepository
859
				.selectLastMonthCategoryUpgradeMarginByImei(loginDetails.getFofoId(), catalogItemId, lastMonthStart,
879
				.selectLastMonthCategoryUpgradeMarginByImei(loginDetails.getFofoId(), catalogItemId, lastMonthStart,
860
						currentMonthEnd)
880
						currentMonthEnd)
861
				.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x.getAmount()));
881
				.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x.getAmount()));
Line 866... Line 886...
866
 
886
 
867
		List<String> allImeiList = new ArrayList<>(allImeiSet);
887
		List<String> allImeiList = new ArrayList<>(allImeiSet);
868
 
888
 
869
		LOGGER.info("allImeiList" + allImeiList);
889
		LOGGER.info("allImeiList" + allImeiList);
870
		LOGGER.info("lmcm" + lastmonthCategoryUpgradeMargin);
890
		LOGGER.info("lmcm" + lastmonthCategoryUpgradeMargin);
-
 
891
		
871
		List<LastMonthFrontEndImeiModel> lastMonthFrontEndImeis = schemeInOutRepository
892
		List<LastMonthFrontEndImeiModel> lastMonthFrontEndImeis = schemeInOutRepository
872
				.selectLastMonthFrontEndByImei(loginDetails.getFofoId(), allImeiList);
893
				.selectLastMonthFrontEndByImei(loginDetails.getFofoId(), allImeiList);
873
		List<LastMonthImeiModel> lastMonthPurchaseInImeis = schemeInOutRepository
894
		List<LastMonthImeiModel> lastMonthPurchaseInImeis = schemeInOutRepository
874
				.selectLastMonthPurchaseInByImei(loginDetails.getFofoId(), allImeiList);
895
				.selectLastMonthPurchaseInByImei(loginDetails.getFofoId(), allImeiList);
875
		List<LastMonthImeiModel> lastMonthCreditedImeis = schemeInOutRepository
896
		List<LastMonthImeiModel> lastMonthCreditedImeis = schemeInOutRepository
876
				.selectLastMonthCreditedByImei(loginDetails.getFofoId(), allImeiList);
897
				.selectLastMonthCreditedByImei(loginDetails.getFofoId(), allImeiList);
-
 
898
		
877
 
899
	
878
		LOGGER.info("lastMonthFrontEndImei {}", lastMonthFrontEndImeis);
900
		LOGGER.info("lastMonthFrontEndImei {}", lastMonthFrontEndImeis);
879
		LOGGER.info("lastMonthPurchaseInImei {}", lastMonthPurchaseInImeis);
901
		LOGGER.info("lastMonthPurchaseInImei {}", lastMonthPurchaseInImeis);
880
		LOGGER.info("lastMonthCreditedImei {}", lastMonthCreditedImeis);
902
		LOGGER.info("lastMonthCreditedImei {}", lastMonthCreditedImeis);
-
 
903
		
-
 
904
		Map<String, Float>  imeiWisePendingSaleAmount =	lastMonthCreditedImeis.stream().filter(x->x.getStatus().equals(SchemePayoutStatus.PENDING) ).collect(Collectors.toMap(x->x.getImei(), x->x.getPendingSaleAmount()));
-
 
905
		
881
 
906
		
882
		Map<IncomeImeiDate, Map<String, Double>> lastMonthPurchaseInMapPairMap = lastMonthPurchaseInImeis.stream()
907
		Map<IncomeImeiDate, Map<String, Double>> lastMonthPurchaseInMapPairMap = lastMonthPurchaseInImeis.stream()
883
				.collect(Collectors.groupingBy(x -> new IncomeImeiDate(x.getImei(), x.getCreateTimeStamp()),
908
				.collect(Collectors.groupingBy(x -> new IncomeImeiDate(x.getImei(), x.getCreateTimeStamp()),
884
						Collectors.groupingBy(x -> x.getDescription(), Collectors.summingDouble(x -> x.getAmount()))));
909
						Collectors.groupingBy(x -> x.getDescription(), Collectors.summingDouble(x -> x.getAmount()))));
885
 
910
 
886
		Map<IncomeImeiDate, Map<String, Double>> lastMonthCreditedMapPairMap = lastMonthCreditedImeis.stream()
911
		Map<IncomeImeiDate, Map<String, Double>> lastMonthCreditedMapPairMap = lastMonthCreditedImeis.stream()
887
				.collect(Collectors.groupingBy(x -> new IncomeImeiDate(x.getImei(), x.getCreateTimeStamp()),
912
				.collect(Collectors.groupingBy(x -> new IncomeImeiDate(x.getImei(), x.getCreateTimeStamp()),
888
						Collectors.groupingBy(x -> x.getDescription(), Collectors.summingDouble(x -> x.getAmount()))));
913
						Collectors.groupingBy(x -> x.getDescription(), Collectors.summingDouble(x -> x.getAmount()))));
889
		// descriptionSet.add("")
914
		// descriptionSet.add("")
890
 
-
 
891
		purchaseSet.addAll(lastMonthPurchaseInImeis.stream().map(x -> x.getDescription()).collect(Collectors.toList()));
915
		purchaseSet.addAll(lastMonthPurchaseInImeis.stream().map(x -> x.getDescription()).collect(Collectors.toList()));
892
		saleSet.addAll(lastMonthCreditedImeis.stream().map(x -> x.getDescription()).collect(Collectors.toList()));
916
		saleSet.addAll(lastMonthCreditedImeis.stream().map(x -> x.getDescription()).collect(Collectors.toList()));
893
 
917
 
894
		List<String> purchaseList = new ArrayList<>(purchaseSet);
918
		List<String> purchaseList = new ArrayList<>(purchaseSet);
895
		List<String> saleList = new ArrayList<>(saleSet);
919
		List<String> saleList = new ArrayList<>(saleSet);
-
 
920
	
896
		Map<IncomeImeiDate, ImeiWiseIncomePairAndMapModel> imeiWiseIncomeMapOfMap = new HashMap<>();
921
		Map<IncomeImeiDate, ImeiWiseIncomePairAndMapModel> imeiWiseIncomeMapOfMap = new HashMap<>();
897
 
922
		
898
		for (Map.Entry<IncomeImeiDate, Map<String, Double>> entry : lastMonthPurchaseInMapPairMap.entrySet()) {
923
		for (Map.Entry<IncomeImeiDate, Map<String, Double>> entry : lastMonthPurchaseInMapPairMap.entrySet()) {
899
 
924
 
900
			IncomeImeiDate imeiDate = entry.getKey();
925
			IncomeImeiDate imeiDate = entry.getKey();
901
			Map<String, Double> descriptionAmountMap = entry.getValue();
926
			Map<String, Double> descriptionAmountMap = entry.getValue();
902
 
927
 
Line 937... Line 962...
937
				imeiWiseIncomePairAndMapModel.setTotalIncome(totalAmount);
962
				imeiWiseIncomePairAndMapModel.setTotalIncome(totalAmount);
938
				imeiWiseIncomePairAndMapModel.setFrontMargin(x.getAmount());
963
				imeiWiseIncomePairAndMapModel.setFrontMargin(x.getAmount());
939
			}
964
			}
940
		});
965
		});
941
 
966
 
-
 
967
		lastMonthCreditedImeis.stream().filter(x -> x.getStatus().equals(SchemePayoutStatus.PENDING)).forEach(x -> {
-
 
968
			IncomeImeiDate incomeImeiDate = new IncomeImeiDate(x.getImei(), x.getCreateTimeStamp());
-
 
969
			if (imeiWiseIncomeMapOfMap.containsKey(incomeImeiDate)) {
-
 
970
				ImeiWiseIncomePairAndMapModel imeiWiseIncomePairAndMapModel = imeiWiseIncomeMapOfMap
-
 
971
						.get(incomeImeiDate);
-
 
972
 
-
 
973
				double totalAmount = imeiWiseIncomePairAndMapModel.getTotalIncome() + x.getPendingSaleAmount();
-
 
974
				imeiWiseIncomePairAndMapModel.setTotalIncome(totalAmount);
-
 
975
 
-
 
976
			} else {
-
 
977
 
-
 
978
				ImeiWiseIncomePairAndMapModel newObjectImeiWiseIncomePairAndMapModel = new ImeiWiseIncomePairAndMapModel();
-
 
979
 
-
 
980
				newObjectImeiWiseIncomePairAndMapModel.setSerialNumber(x.getImei());
-
 
981
				newObjectImeiWiseIncomePairAndMapModel.setPurchseDate(x.getCreateTimeStamp());
-
 
982
				newObjectImeiWiseIncomePairAndMapModel.setTotalIncome(x.getPendingSaleAmount());
-
 
983
			}
-
 
984
 
-
 
985
		});
-
 
986
 
-
 
987
		model.addAttribute("imeiWisePendingSaleAmount", imeiWisePendingSaleAmount);
942
		model.addAttribute("month", month);
988
		model.addAttribute("month", month);
943
		model.addAttribute("purchaseList", purchaseList);
989
		model.addAttribute("purchaseList", purchaseList);
944
		model.addAttribute("saleList", saleList);
990
		model.addAttribute("saleList", saleList);
945
		model.addAttribute("lastMonthPurchaseInMapPairMap", lastMonthPurchaseInMapPairMap);
991
		model.addAttribute("lastMonthPurchaseInMapPairMap", lastMonthPurchaseInMapPairMap);
946
		model.addAttribute("lastMonthCreditedMapPairMap", lastMonthCreditedMapPairMap);
992
		model.addAttribute("lastMonthCreditedMapPairMap", lastMonthCreditedMapPairMap);
Line 954... Line 1000...
954
		return "last-month-imei-wise-income";
1000
		return "last-month-imei-wise-income";
955
	}
1001
	}
956
 
1002
 
957
	@RequestMapping(value = "/brandWiseIncome", method = RequestMethod.GET)
1003
	@RequestMapping(value = "/brandWiseIncome", method = RequestMethod.GET)
958
	public String getBrandWiseIncome(HttpServletRequest request,
1004
	public String getBrandWiseIncome(HttpServletRequest request,
959
									 @RequestParam(name = "brand", required = false, defaultValue = "") String brand,
1005
							 @RequestParam(name = "brand", required = false, defaultValue = "") String brand,
960
									 @RequestParam(name = "status", required = false, defaultValue = "") String status,
1006
							 @RequestParam(name = "status", required = false, defaultValue = "") String status,
961
									 @RequestParam(name = "month", required = false, defaultValue = "") int month, Model model)
1007
							 @RequestParam(name = "month", required = false, defaultValue = "") int month, Model model)
962
			throws ProfitMandiBusinessException {
1008
			throws ProfitMandiBusinessException {
963
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1009
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
964
		LOGGER.info("loginDetails {}", loginDetails);
1010
		LOGGER.info("loginDetails {}", loginDetails);
965
		LOGGER.info("brand" + brand);
1011
		LOGGER.info("brand" + brand);
966
		LOGGER.info("month {}", month);
1012
		LOGGER.info("month {}", month);
Line 968... Line 1014...
968
		model.addAttribute("month", month);
1014
		model.addAttribute("month", month);
969
		LocalDateTime lastMonthStart = LocalDate.now().minusMonths(month).withDayOfMonth(1).atStartOfDay();
1015
		LocalDateTime lastMonthStart = LocalDate.now().minusMonths(month).withDayOfMonth(1).atStartOfDay();
970
		LocalDateTime currentMonthEnd = lastMonthStart.plusMonths(1).withDayOfMonth(1).toLocalDate().atStartOfDay();
1016
		LocalDateTime currentMonthEnd = lastMonthStart.plusMonths(1).withDayOfMonth(1).toLocalDate().atStartOfDay();
971
 
1017
 
972
		List<LastMonthBrandWiseIncomeModel> lastMonthModelWiseIncomes = null;
1018
		List<LastMonthBrandWiseIncomeModel> lastMonthModelWiseIncomes = null;
973
		List<LastMonthBrandWiseIncomeModel> modelWiseFrontIncomes = null;
1019
		List<LastMonthFrontEndBrandWiseIncome> modelWiseFrontIncomes = null;
974
		List<LastMonthBrandWiseIncomeModel> purchaseInModelWiseIncomes = null;
1020
		List<LastMonthBrandWiseIncomeModel> purchaseInModelWiseIncomes = null;
975
 
1021
 
976
		boolean partnerType = partnerTypeChangeService.isPartnerTypeUpgraded(loginDetails.getFofoId(), YearMonth.now());
1022
		boolean partnerType = partnerTypeChangeService.isPartnerTypeUpgraded(loginDetails.getFofoId(), YearMonth.now());
977
 
1023
 
978
		LOGGER.info("partnerType" + partnerType);
1024
		LOGGER.info("partnerType" + partnerType);
Line 985... Line 1031...
985
							currentMonthEnd)
1031
							currentMonthEnd)
986
					.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x.getAmount()));
1032
					.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x.getAmount()));
987
		}
1033
		}
988
		LOGGER.info("partnerType {}", partnerType);
1034
		LOGGER.info("partnerType {}", partnerType);
989
		LOGGER.info("categoryUpradeBrandModelMap {}", categoryUpradeBrandModelMap);
1035
		LOGGER.info("categoryUpradeBrandModelMap {}", categoryUpradeBrandModelMap);
990
 
1036
	
991
		if (status.equals("PENDING")) {
-
 
992
		}
1037
			
993
 
-
 
994
		if (status.equals("CREDITED")) {
-
 
995
			lastMonthModelWiseIncomes = schemeInOutRepository.selectLastMonthBrandWiseIncome(loginDetails.getFofoId(),
1038
		    lastMonthModelWiseIncomes = schemeInOutRepository.selectLastMonthBrandWiseIncome(loginDetails.getFofoId(),
996
					brand, lastMonthStart, currentMonthEnd);
1039
					brand, lastMonthStart, currentMonthEnd);
997
			modelWiseFrontIncomes = schemeInOutRepository.selectFrontIncomeBrandWise(loginDetails.getFofoId(), brand,
1040
			modelWiseFrontIncomes = schemeInOutRepository.selectFrontIncomeBrandWise(loginDetails.getFofoId(), brand,
998
					lastMonthStart, currentMonthEnd);
1041
					lastMonthStart, currentMonthEnd);
999
			purchaseInModelWiseIncomes = schemeInOutRepository.selectLastMonthPurchaseBrandWiseIncome(
1042
			purchaseInModelWiseIncomes = schemeInOutRepository.selectLastMonthPurchaseBrandWiseIncome(
1000
					loginDetails.getFofoId(), brand, lastMonthStart, currentMonthEnd);
1043
					loginDetails.getFofoId(), brand, lastMonthStart, currentMonthEnd);
-
 
1044
			
1001
			LOGGER.info("modelWiseFrontIncomes {}", modelWiseFrontIncomes);
1045
			LOGGER.info("modelWiseFrontIncomes {}", modelWiseFrontIncomes);
1002
			LOGGER.info("lastMonthModelWiseIncomes {}", lastMonthModelWiseIncomes);
1046
			LOGGER.info("lastMonthModelWiseIncomes {}", lastMonthModelWiseIncomes);
1003
			LOGGER.info("purchaseInModelWiseIncomes {}", purchaseInModelWiseIncomes);
1047
			LOGGER.info("purchaseInModelWiseIncomes {}", purchaseInModelWiseIncomes);
1004
			Map<String, LastMonthBrandWiseIncomeModel> modelWiseMap = lastMonthModelWiseIncomes.stream()
1048
			Map<String, LastMonthBrandWiseIncomeModel> modelWiseMap = lastMonthModelWiseIncomes.stream()
1005
					.collect(Collectors.toMap(x -> x.getModelNumber(), x -> x));
1049
					.collect(Collectors.toMap(x -> x.getModelNumber(), x -> x));
1006
 
1050
 
-
 
1051
			
-
 
1052
			LOGGER.info("modelWiseMap1" + modelWiseMap );
1007
			Map<String, LastMonthBrandWiseIncomeModel> purchaseWiseMap = purchaseInModelWiseIncomes.stream()
1053
			Map<String, LastMonthBrandWiseIncomeModel> purchaseWiseMap = purchaseInModelWiseIncomes.stream()
1008
					.collect(Collectors.toMap(x -> x.getModelNumber(), x -> x));
1054
					.collect(Collectors.toMap(x -> x.getModelNumber(), x -> x));
1009
 
1055
 
1010
			Map<String, Double> modelWiseTotalAmount = new HashMap<>();
1056
		Map<String, Double> modelWiseTotalAmount = new HashMap<>();
-
 
1057
		   
1011
			modelWiseFrontIncomes.stream().forEach(x -> {
1058
		modelWiseFrontIncomes.stream().forEach(x -> {
-
 
1059
			LastMonthBrandWiseIncomeModel lmbwi =	modelWiseMap.get(x.getModelNumber());
1012
				if (modelWiseMap.containsKey(x.getModelNumber())) {
1060
			if (modelWiseMap.containsKey(x.getModelNumber())) {
1013
 
1061
 
-
 
1062
				
1014
					x.setAmount(x.getAmount() + modelWiseMap.get(x.getModelNumber()).getAmount());
1063
				lmbwi.setAmount(x.getAmount() + lmbwi.getAmount());	
1015
 
1064
				
1016
					modelWiseMap.put(x.getModelNumber(), x);
1065
				modelWiseMap.put(x.getModelNumber(), lmbwi);
-
 
1066
			} 
1017
				} else {
1067
			else {
-
 
1068
				LastMonthBrandWiseIncomeModel lmbwIncomeModel = new LastMonthBrandWiseIncomeModel();
1018
					modelWiseMap.put(x.getModelNumber(), x);
1069
				lmbwIncomeModel.setAmount(x.getAmount());
1019
				}
-
 
1020
				if (modelWiseTotalAmount.containsKey(x.getModelNumber())) {
1070
				lmbwIncomeModel.setModelName(x.getModelName());
1021
 
-
 
1022
					double amount = x.getAmount() + modelWiseTotalAmount.get(x.getModelNumber());
1071
				lmbwIncomeModel.setModelNumber(x.getModelNumber());
1023
					modelWiseTotalAmount.put(x.getModelNumber(), amount);
1072
				lmbwIncomeModel.setBrand(x.getBrand());
1024
				} else {
1073
				lmbwIncomeModel.setCatalogItemId(x.getCatalogItemId());
1025
					modelWiseTotalAmount.put(x.getModelNumber(), x.getAmount());
1074
				lmbwIncomeModel.setPendingSaleAmount(x.getPendingSaleAmount());
1026
				}
-
 
1027
 
-
 
1028
			});
-
 
1029
			for (LastMonthBrandWiseIncomeModel pmi : purchaseInModelWiseIncomes) {
1075
				lmbwIncomeModel.setQty(x.getQty());
1030
 
-
 
1031
				if (!modelWiseMap.containsKey(pmi.getModelNumber())) {
1076
				lmbwIncomeModel.setStatus(SchemePayoutStatus.CREDITED);
1032
 
-
 
1033
					modelWiseMap.put(pmi.getModelNumber(), null);
1077
				modelWiseMap.put(lmbwIncomeModel.getModelNumber(), lmbwIncomeModel);
1034
				}
1078
			}
1035
 
1079
			
1036
				if (modelWiseTotalAmount.containsKey(pmi.getModelNumber())) {
1080
			if (modelWiseTotalAmount.containsKey(x.getModelNumber())) {
1037
 
1081
 
1038
					double amount = pmi.getAmount() + modelWiseTotalAmount.get(pmi.getModelNumber());
1082
				double amount = x.getAmount() + modelWiseTotalAmount.get(x.getModelNumber());
1039
					modelWiseTotalAmount.put(pmi.getModelNumber(), amount);
1083
				modelWiseTotalAmount.put(x.getModelNumber(), amount);
1040
				} else {
1084
			} else {
-
 
1085
				
-
 
1086
				double amount = modelWiseMap.get(x.getModelNumber()).getAmount();
1041
					modelWiseTotalAmount.put(pmi.getModelNumber(), pmi.getAmount());
1087
				modelWiseTotalAmount.put(x.getModelNumber(), amount);
1042
				}
1088
			}
-
 
1089
         });
-
 
1090
		
-
 
1091
		for (LastMonthBrandWiseIncomeModel pmi : purchaseInModelWiseIncomes) {
1043
 
1092
 
-
 
1093
			if (!modelWiseMap.containsKey(pmi.getModelNumber())) {
-
 
1094
				modelWiseMap.put(pmi.getModelNumber(), null);
1044
			}
1095
			}
-
 
1096
			if (modelWiseTotalAmount.containsKey(pmi.getModelNumber())) {
-
 
1097
 
-
 
1098
				double amount = pmi.getAmount() + modelWiseTotalAmount.get(pmi.getModelNumber());
-
 
1099
				modelWiseTotalAmount.put(pmi.getModelNumber(), amount);
-
 
1100
			} else {
-
 
1101
				modelWiseTotalAmount.put(pmi.getModelNumber(), pmi.getAmount());
-
 
1102
			}
-
 
1103
 
-
 
1104
		}
-
 
1105
		LOGGER.info("modelWiseTotalAmount" + modelWiseTotalAmount );
-
 
1106
		
-
 
1107
		lastMonthModelWiseIncomes.stream().filter(x->x.getStatus().equals(SchemePayoutStatus.PENDING) && x.getPendingSaleAmount() != 0.0).forEach(x-> {
-
 
1108
			
-
 
1109
			if(modelWiseTotalAmount.containsKey(x.getModelNumber()))
-
 
1110
			{
-
 
1111
				double amount = 	modelWiseTotalAmount.get(x.getModelNumber()) + x.getPendingSaleAmount();
-
 
1112
				modelWiseTotalAmount.put(x.getModelNumber(), amount);
-
 
1113
				
-
 
1114
				LOGGER.info("modelWiseTotalAmoun111t" + amount );
-
 
1115
			}
-
 
1116
			else {
-
 
1117
				LOGGER.info("modelWiseTotalAmou2222t" + x.getPendingSaleAmount() );
-
 
1118
				modelWiseTotalAmount.put(x.getModelNumber(), x.getPendingSaleAmount());
-
 
1119
			}
-
 
1120
			
-
 
1121
		});
-
 
1122
		LOGGER.info("modelWiseMap" + modelWiseMap );
1045
 
1123
 
1046
			model.addAttribute("purchaseWiseMap", purchaseWiseMap);
1124
			model.addAttribute("purchaseWiseMap", purchaseWiseMap);
1047
			model.addAttribute("categoryUpradeBrandModelMap", categoryUpradeBrandModelMap);
1125
			model.addAttribute("categoryUpradeBrandModelMap", categoryUpradeBrandModelMap);
1048
			model.addAttribute("modelWiseMap", modelWiseMap);
1126
			model.addAttribute("modelWiseMap", modelWiseMap);
1049
			model.addAttribute("modelWiseTotalAmount", modelWiseTotalAmount);
1127
			model.addAttribute("modelWiseTotalAmount", modelWiseTotalAmount);
1050
 
1128
 
1051
		}
-
 
1052
 
-
 
1053
		return "montly-brand-wise-income";
1129
		return "montly-brand-wise-income";
1054
 
1130
 
1055
	}
1131
	}
1056
 
1132
 
1057
	@RequestMapping(value = "/monthWisePartnerIncome/{yearMonth}", method = RequestMethod.GET)
1133
	@RequestMapping(value = "/monthWisePartnerIncome/{yearMonth}", method = RequestMethod.GET)