Subversion Repositories SmartDukaan

Rev

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

Rev 24242 Rev 24244
Line 327... Line 327...
327
		}
327
		}
328
	}
328
	}
329
 
329
 
330
	// Temporary Method
330
	// Temporary Method
331
	public void evaluateExcessSchemeOut() {
331
	public void evaluateExcessSchemeOut() {
-
 
332
		Map<Integer, String> userNameMap = retailerService.getAllFofoRetailerIdNameMap();
-
 
333
		Map<Integer, String> userEmailMap = retailerService.getAllFofoRetailerIdEmailIdMap();
-
 
334
		Map<Integer, Float> userAmountMap = new HashMap<>();
332
		schemeRepository.selectAll().stream().forEach(x -> {
335
		schemeRepository.selectAll().stream().forEach(x -> {
333
			if (x.getAmountType().equals(AmountType.FIXED)) {
336
			if (x.getAmountType().equals(AmountType.FIXED)) {
334
				List<SchemeInOut> sioList = schemeInOutRepository
337
				List<SchemeInOut> sioList = schemeInOutRepository
335
						.selectBySchemeIds(new HashSet<>(Arrays.asList(x.getId())));
338
						.selectBySchemeIds(new HashSet<>(Arrays.asList(x.getId())));
336
				if (x.getActiveTimestamp() != null) {
339
				if (x.getActiveTimestamp() != null) {
Line 339... Line 342...
339
						endDateTime = x.getExpireTimestamp();
342
						endDateTime = x.getExpireTimestamp();
340
					}
343
					}
341
					for (SchemeInOut sio : sioList) {
344
					for (SchemeInOut sio : sioList) {
342
						Optional<ScanRecord> record = scanRecordRepository.selectByInventoryItemId(sio.getInventoryItemId()).stream().filter(y->y.getType().equals(ScanType.SALE)).findFirst();
345
						Optional<ScanRecord> record = scanRecordRepository.selectByInventoryItemId(sio.getInventoryItemId()).stream().filter(y->y.getType().equals(ScanType.SALE)).findFirst();
343
						if(record.isPresent()) {
346
						if(record.isPresent()) {
-
 
347
							int fofoId = record.get().getFofoId();
344
							if (record.get().getCreateTimestamp().isAfter(endDateTime)
348
							if (record.get().getCreateTimestamp().isAfter(endDateTime)
345
									|| record.get().getCreateTimestamp().isBefore(x.getStartDateTime())) {
349
									|| record.get().getCreateTimestamp().isBefore(x.getStartDateTime())) {
-
 
350
									if(!userAmountMap.containsKey(fofoId)) {
-
 
351
										userAmountMap.put(fofoId, 0f);
-
 
352
									}
-
 
353
								userAmountMap.put(fofoId, sio.getAmount() + userAmountMap.get(fofoId));
346
								LOGGER.info("Scheme disbursed for inventoryItem {} and scheme {}", sio.getInventoryItemId(),
354
								LOGGER.info("Scheme disbursed to user {}({}) for inventoryItem {} and scheme {} for amount {}", userNameMap.get(fofoId), userEmailMap.get(fofoId), 
347
										sio.getSchemeId());
355
										sio.getInventoryItemId(),
-
 
356
										sio.getSchemeId(), sio.getAmount());
348
							}
357
							}
349
						}
358
						}
350
					}
359
					}
351
				}
360
				}
352
			}
361
			}
353
		});
362
		});
-
 
363
		userAmountMap.entrySet().stream().forEach(x->LOGGER.info("{} to be deducted from {}({}) for wrongly disbursed due to technical error.", 
-
 
364
				x.getValue(), userNameMap.get(x.getKey()), userEmailMap.get(x.getKey())));
354
 
365
 
355
	}
366
	}
356
 
367
 
357
	public void processScheme() throws Exception {
368
	public void processScheme() throws Exception {
358
		LocalDateTime fromDate = LocalDateTime.now().minusDays(15);
369
		LocalDateTime fromDate = LocalDateTime.now().minusDays(15);