Subversion Repositories SmartDukaan

Rev

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

Rev 29243 Rev 29249
Line 483... Line 483...
483
		LOGGER.info("Scheme === {}", scheme);
483
		LOGGER.info("Scheme === {}", scheme);
484
		List<SchemeInOut> sios = schemeInOutRepository.selectAllByType(scheme.getType(), inventoryItem.getId());
484
		List<SchemeInOut> sios = schemeInOutRepository.selectAllByType(scheme.getType(), inventoryItem.getId());
485
		float actualCredit = 0;
485
		float actualCredit = 0;
486
		if (sios.stream().filter(x -> x.getRolledBackTimestamp() == null && x.getSchemeId() == scheme.getId())
486
		if (sios.stream().filter(x -> x.getRolledBackTimestamp() == null && x.getSchemeId() == scheme.getId())
487
				.collect(Collectors.toList()).size() == 0) {
487
				.collect(Collectors.toList()).size() == 0) {
-
 
488
			sios = sios.stream().filter(x->x.getRolledBackTimestamp()==null).collect(Collectors.toList());
-
 
489
			//Rejected Scheme for types INVESTMENT and ACTIVATION are considered rolledback only if the item billing is cancelled.
-
 
490
			float amountCredited = (float) sios.stream().mapToDouble(e -> e.getAmount()).sum();
-
 
491
			
488
			LOGGER.info("SIOS ===== {}", sios);
492
			LOGGER.info("SIOS ===== {}", sios);
489
			float amountToCredit = this.getAmount(inventoryItem, scheme);
493
			float amountToCredit = this.getAmount(inventoryItem, scheme);
490
			
494
			
491
			if (!scheme.getType().equals(SchemeType.IN) && sios.size() > 0) {
495
			if (!scheme.getType().equals(SchemeType.IN) && sios.size() > 0) {
492
 
496
 
493
				if(sios.size() > 1) {
497
				if(sios.size() > 1) {
494
					LOGGER.info("SAMESCHEMETYPE has already been credited twice for inventoryItem - {}", inventoryItem.getId());
498
					LOGGER.info("SAMESCHEMETYPE has already been credited twice for inventoryItem - {}", inventoryItem.getId());
495
					return 0;
499
					return 0;
496
				}
500
				}
497
				float amountCredited = (float) sios.stream().mapToDouble(e -> e.getAmount()).sum();
-
 
498
				if(amountToCredit > amountCredited + 1f) {
501
				if(amountToCredit > amountCredited + 1f) {
499
					for (SchemeInOut sio : sios) {
502
					for (SchemeInOut sio : sios) {
500
						sio.setRolledBackTimestamp(LocalDateTime.now());
503
						sio.setRolledBackTimestamp(LocalDateTime.now());
501
						sio.setStatus(SchemePayoutStatus.REJECTED);
504
						sio.setStatus(SchemePayoutStatus.REJECTED);
502
						sio.setStatusDescription("Partner Category upgraded, new entry added");
505
						sio.setStatusDescription("Partner Category upgraded, new entry added");