Subversion Repositories SmartDukaan

Rev

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

Rev 28624 Rev 28625
Line 1332... Line 1332...
1332
	public void reverseMaa() throws Exception {
1332
	public void reverseMaa() throws Exception {
1333
		Purchase purchase = purchaseRepository.selectById(28877);
1333
		Purchase purchase = purchaseRepository.selectById(28877);
1334
		Set<Integer> inventoryItemIds = inventoryItemRepository.selectByPurchaseId(28877).stream().map(x -> x.getId())
1334
		Set<Integer> inventoryItemIds = inventoryItemRepository.selectByPurchaseId(28877).stream().map(x -> x.getId())
1335
				.collect(Collectors.toSet());
1335
				.collect(Collectors.toSet());
1336
		double totalAmount = schemeInOutRepository.selectByInventoryItemIds(inventoryItemIds).stream()
1336
		double totalAmount = schemeInOutRepository.selectByInventoryItemIds(inventoryItemIds).stream()
-
 
1337
				/*
1337
				.filter(x -> x.getRolledBackTimestamp() == null || x.getStatusDescription().contains("investment"))
1338
				 * .filter(x -> x.getRolledBackTimestamp() == null ||
1338
				.map(x -> {
1339
				 * x.getStatusDescription().contains("investment")) .map(x -> {
1339
					x.setRolledBackTimestamp(LocalDateTime.now());
1340
				 * x.setRolledBackTimestamp(LocalDateTime.now());
1340
					x.setStatus(SchemePayoutStatus.REJECTED);
1341
				 * x.setStatus(SchemePayoutStatus.REJECTED); x.
1341
					x.setStatusDescription("Invoice-NSLCK3350 was cancelled, hence all schemes were rolled back");
1342
				 * setStatusDescription("Invoice-NSLCK3350 was cancelled, hence all schemes were rolled back"
1342
					return x;
1343
				 * ); return x; })
1343
				})
1344
				 */
1344
				.collect(Collectors.summingDouble(x -> x.getAmount()));
1345
				.collect(Collectors.summingDouble(x -> x.getAmount()));
1345
		WalletReferenceType walletReferenceType = WalletReferenceType.OTHERS;
1346
		WalletReferenceType walletReferenceType = WalletReferenceType.OTHERS;
1346
		ManualPaymentType paymentType = manualPaymentRequestRepository.selectByReferenceType(walletReferenceType);
1347
		ManualPaymentType paymentType = manualPaymentRequestRepository.selectByReferenceType(walletReferenceType);
1347
		if (paymentType == null) {
1348
		if (paymentType == null) {
1348
			paymentType = new ManualPaymentType();
1349
			paymentType = new ManualPaymentType();
1349
			paymentType.setReferenceType(walletReferenceType);
1350
			paymentType.setReferenceType(walletReferenceType);
1350
			manualPaymentRequestRepository.persist(paymentType);
1351
			manualPaymentRequestRepository.persist(paymentType);
1351
		}
1352
		}
1352
		paymentType.setCounter(paymentType.getCounter() + 1);
1353
		paymentType.setCounter(paymentType.getCounter() + 1);
1353
		int reference = paymentType.getCounter();
1354
		int reference = paymentType.getCounter();
1354
		walletService.consumeAmountFromWallet(purchase.getFofoId(), (int)totalAmount, WalletReferenceType.OTHERS, ACCOUNT_ID, reference, LocalDateTime.now());
1355
		walletService.consumeAmountFromWallet(purchase.getFofoId(), reference, WalletReferenceType.OTHERS, "Invoice-NSLCK3350 was cancelled, hence all schemes were rolled back", (int)totalAmount, LocalDateTime.now());
1355
		LOGGER.info("Total Deduction is around Rs. {}", totalAmount);
1356
		LOGGER.info("Total Deduction is around Rs. {}", totalAmount);
1356
	}
1357
	}
1357
 
1358
 
1358
}
1359
}
1359
 
1360