Subversion Repositories SmartDukaan

Rev

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

Rev 31238 Rev 31281
Line 850... Line 850...
850
 
850
 
851
		Map<String, LastMonthCreditedIncomeModel> lastMonthPendingIncomeMap = schemeInOutRepository
851
		Map<String, LastMonthCreditedIncomeModel> lastMonthPendingIncomeMap = schemeInOutRepository
852
				.selectLastMonthPendingIncomeByFofoId(loginDetails.getFofoId(), currentStartMonth, currentDate).stream()
852
				.selectLastMonthPendingIncomeByFofoId(loginDetails.getFofoId(), currentStartMonth, currentDate).stream()
853
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
853
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
854
 
854
 
855
		LOGGER.info("lastMonthCreditedIncomeModels" + lastMonthCreditedIncomeModels);
-
 
856
		LOGGER.info("lastMonthFrontEndIncomes" + lastMonthFrontEndIncomes);
-
 
857
		LOGGER.info("lastMonthPurchaseInMargins" + lastMonthPurchaseInMargins);
-
 
858
		LOGGER.info("lastMonthCategoryUpgradeMarginMap" + lastMonthCategoryUpgradeMarginMap);
-
 
859
 
-
 
860
		Map<String, LastMonthCreditedIncomeModel> lastMonthPurchaseInMarginMap = new HashMap<>();
855
		Map<String, LastMonthCreditedIncomeModel> lastMonthPurchaseInMarginMap = new HashMap<>();
861
 
856
 
862
		lastMonthPurchaseInMarginMap = lastMonthPurchaseInMargins.stream()
857
		lastMonthPurchaseInMarginMap = lastMonthPurchaseInMargins.stream()
863
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
858
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
864
 
859
 
Line 875... Line 870...
875
 
870
 
876
		});
871
		});
877
		Map<String, Float> totalAmountMap = lastMonthSaleMarginMap.entrySet().stream()
872
		Map<String, Float> totalAmountMap = lastMonthSaleMarginMap.entrySet().stream()
878
				.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue().getAmount()));
873
				.collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue().getAmount()));
879
 
874
 
880
		Set<String> keySet = new HashSet<String>();
875
		Set<String> keySet = new HashSet<>();
881
		keySet.addAll(lastMonthPurchaseInMarginMap.keySet());
876
		keySet.addAll(lastMonthPurchaseInMarginMap.keySet());
882
		keySet.addAll(lastMonthSaleMarginMap.keySet());
877
		keySet.addAll(lastMonthSaleMarginMap.keySet());
883
		keySet.addAll(lastMonthPendingIncomeMap.keySet());
878
		keySet.addAll(lastMonthPendingIncomeMap.keySet());
884
 
879
 
885
		lastMonthPurchaseInMarginMap.entrySet().stream().forEach(x -> {
880
		lastMonthPurchaseInMarginMap.entrySet().stream().forEach(x -> {
Line 1203... Line 1198...
1203
	public String publishedOffersOnMonthBefore(HttpServletRequest request, @PathVariable int yearMonth, Model model)
1198
	public String publishedOffersOnMonthBefore(HttpServletRequest request, @PathVariable int yearMonth, Model model)
1204
			throws ProfitMandiBusinessException {
1199
			throws ProfitMandiBusinessException {
1205
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1200
		LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
1206
 
1201
 
1207
		LocalDateTime lastMonthStart = LocalDate.now().minusMonths(yearMonth).withDayOfMonth(1).atStartOfDay();
1202
		LocalDateTime lastMonthStart = LocalDate.now().minusMonths(yearMonth).withDayOfMonth(1).atStartOfDay();
1208
		LocalDateTime currentMonthEnd = lastMonthStart.plusMonths(1).withDayOfMonth(1).toLocalDate().atStartOfDay();
1203
		LocalDateTime lastMonthEnd = lastMonthStart.plusMonths(1);
1209
 
1204
 
1210
		YearMonth monthYear = YearMonth.now();
1205
		YearMonth monthYear = YearMonth.now();
1211
 
1206
 
1212
		boolean partnerType = partnerTypeChangeService.isPartnerTypeUpgraded(loginDetails.getFofoId(), monthYear);
1207
		boolean partnerType = partnerTypeChangeService.isPartnerTypeUpgraded(loginDetails.getFofoId(), monthYear);
1213
 
1208
 
Line 1216... Line 1211...
1216
		Map<String, Double> lastMonthCategoryUpgradeMarginMap = new HashMap<>();
1211
		Map<String, Double> lastMonthCategoryUpgradeMarginMap = new HashMap<>();
1217
 
1212
 
1218
		if (partnerType) {
1213
		if (partnerType) {
1219
			lastMonthCategoryUpgradeMarginMap = schemeInOutRepository
1214
			lastMonthCategoryUpgradeMarginMap = schemeInOutRepository
1220
					.selectLastMonthCategoryUpgradeMarginByBrand(loginDetails.getFofoId(), lastMonthStart,
1215
					.selectLastMonthCategoryUpgradeMarginByBrand(loginDetails.getFofoId(), lastMonthStart,
1221
							currentMonthEnd)
1216
							lastMonthEnd)
1222
					.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x.getAmount()));
1217
					.stream().collect(Collectors.toMap(x -> x.getBrand(), x -> x.getAmount()));
1223
		}
1218
		}
1224
 
1219
 
1225
		String status = "CREDITED";
1220
		String status = "CREDITED";
-
 
1221
 
1226
		LOGGER.info("lastMonthStart" + lastMonthStart);
1222
		List<LastMonthCreditedIncomeModel> lastMonthPendingIncomeModels = schemeInOutRepository
1227
		LOGGER.info("currentMonthEnd" + currentMonthEnd);
1223
				.selectLastMonthPendingIncomeByFofoId(loginDetails.getFofoId(), lastMonthStart, lastMonthEnd);
1228
 
1224
 
1229
		List<LastMonthCreditedIncomeModel> lastMonthCreditedIncomeModels = schemeInOutRepository
1225
		List<LastMonthCreditedIncomeModel> lastMonthCreditedIncomeModels = schemeInOutRepository
1230
				.selectLastMonthCreditedIncomeByFofoId(loginDetails.getFofoId(), lastMonthStart, currentMonthEnd);
1226
				.selectLastMonthCreditedIncomeByFofoId(loginDetails.getFofoId(), lastMonthStart, lastMonthEnd);
1231
 
1227
 
1232
		List<LastMonthCreditedIncomeModel> lastMonthPurchaseInMargins = schemeInOutRepository
1228
		List<LastMonthCreditedIncomeModel> lastMonthPurchaseInMargins = schemeInOutRepository
1233
				.selectLastMonthPurchaseInMarginByFofoId(loginDetails.getFofoId(), lastMonthStart, currentMonthEnd);
1229
				.selectLastMonthPurchaseInMarginByFofoId(loginDetails.getFofoId(), lastMonthStart, lastMonthEnd);
1234
 
1230
 
1235
		List<LastMonthCreditedIncomeModel> lastMonthFrontEndIncomes = schemeInOutRepository
1231
		List<LastMonthCreditedIncomeModel> lastMonthFrontEndIncomes = schemeInOutRepository
1236
				.selectFrontIncomeByBrand(loginDetails.getFofoId(), lastMonthStart, currentMonthEnd);
1232
				.selectFrontIncomeByBrand(loginDetails.getFofoId(), lastMonthStart, lastMonthEnd);
1237
 
-
 
1238
		LOGGER.info("lastMonthCreditedIncomeModels" + lastMonthCreditedIncomeModels);
-
 
1239
		LOGGER.info("lastMonthFrontEndIncomes" + lastMonthFrontEndIncomes);
-
 
1240
		LOGGER.info("lastMonthPurchaseInMargins" + lastMonthPurchaseInMargins);
-
 
1241
 
1233
 
1242
		Map<String, LastMonthCreditedIncomeModel> lastMonthPurchaseInMarginMap = new HashMap<>();
-
 
1243
 
1234
 
1244
		lastMonthPurchaseInMarginMap = lastMonthPurchaseInMargins.stream()
1235
		Map<String, LastMonthCreditedIncomeModel> lastMonthPurchaseInMarginMap = lastMonthPurchaseInMargins.stream()
1245
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
1236
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
1246
 
1237
 
1247
		Map<String, LastMonthCreditedIncomeModel> lastMonthSaleMarginMap = lastMonthCreditedIncomeModels.stream()
1238
		Map<String, LastMonthCreditedIncomeModel> lastMonthSaleMarginMap = lastMonthCreditedIncomeModels.stream()
1248
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
1239
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
1249
 
1240
 
-
 
1241
 
-
 
1242
		Map<String, LastMonthCreditedIncomeModel> lastMonthPendingIncomeMap = lastMonthPendingIncomeModels.stream()
-
 
1243
				.collect(Collectors.toMap(x -> x.getBrand(), x -> x));
-
 
1244
 
1250
		lastMonthFrontEndIncomes.stream().forEach(x -> {
1245
		lastMonthFrontEndIncomes.stream().forEach(x -> {
1251
			if (lastMonthSaleMarginMap.containsKey(x.getBrand())) {
1246
			if (lastMonthSaleMarginMap.containsKey(x.getBrand())) {
1252
				x.setAmount(lastMonthSaleMarginMap.get(x.getBrand()).getAmount() + x.getAmount());
1247
				x.setAmount(lastMonthSaleMarginMap.get(x.getBrand()).getAmount() + x.getAmount());
1253
 
1248
 
1254
				lastMonthSaleMarginMap.put(x.getBrand(), x);
1249
				lastMonthSaleMarginMap.put(x.getBrand(), x);
Line 1281... Line 1276...
1281
		model.addAttribute("monthValueMap", monthValueMap);
1276
		model.addAttribute("monthValueMap", monthValueMap);
1282
 
1277
 
1283
		model.addAttribute("keySet", keySet);
1278
		model.addAttribute("keySet", keySet);
1284
		model.addAttribute("lastMonthPurchaseInMarginMap", lastMonthPurchaseInMarginMap);
1279
		model.addAttribute("lastMonthPurchaseInMarginMap", lastMonthPurchaseInMarginMap);
1285
		model.addAttribute("lastMonthSaleMarginMap", lastMonthSaleMarginMap);
1280
		model.addAttribute("lastMonthSaleMarginMap", lastMonthSaleMarginMap);
-
 
1281
		model.addAttribute("lastMonthPendingIncomeMap", lastMonthPendingIncomeMap);
1286
 
1282
 
1287
		model.addAttribute("totalAmountMap", totalAmountMap);
1283
		model.addAttribute("totalAmountMap", totalAmountMap);
1288
		model.addAttribute("status", status);
1284
		model.addAttribute("status", status);
1289
		model.addAttribute("month", yearMonth);
1285
		model.addAttribute("month", yearMonth);
1290
		model.addAttribute("lastMonthCategoryUpgradeMarginMap", lastMonthCategoryUpgradeMarginMap);
1286
		model.addAttribute("lastMonthCategoryUpgradeMarginMap", lastMonthCategoryUpgradeMarginMap);