Subversion Repositories SmartDukaan

Rev

Rev 31091 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 31091 Rev 35690
Line 43... Line 43...
43
	private CartService cartService;
43
	private CartService cartService;
44
 
44
 
45
	public void payThroughWallet(int transactionId) throws ProfitMandiBusinessException {
45
	public void payThroughWallet(int transactionId) throws ProfitMandiBusinessException {
46
		Transaction transaction = transactionRepository.selectById(transactionId);
46
		Transaction transaction = transactionRepository.selectById(transactionId);
47
		List<Order> orders = orderRepository.selectAllByTransactionId(transactionId);
47
		List<Order> orders = orderRepository.selectAllByTransactionId(transactionId);
-
 
48
		payThroughWallet(transaction, orders);
-
 
49
	}
-
 
50
 
-
 
51
	public void payThroughWallet(Transaction transaction, List<Order> orders) throws ProfitMandiBusinessException {
48
		double walletAmount = orders.stream().collect(Collectors.summingDouble(Order::getTotalAmount));
52
		double walletAmount = orders.stream().collect(Collectors.summingDouble(Order::getTotalAmount));
49
		walletService.consumeAmountFromWallet(transaction.getRetailerId(), transactionId,
53
		walletService.consumeAmountFromWallet(transaction.getRetailerId(), transaction.getId(),
50
				WalletReferenceType.PURCHASE, "Against Order purchase", (float) walletAmount, LocalDateTime.now());
54
				WalletReferenceType.PURCHASE, "Against Order purchase", (float) walletAmount, LocalDateTime.now());
51
		this.addPayment(transaction, walletAmount);
55
		this.addPayment(transaction, walletAmount);
52
 
-
 
53
		//
-
 
54
	}
56
	}
55
 
57
 
56
	private void addPayment(Transaction transaction, double walletAmount) {
58
	private void addPayment(Transaction transaction, double walletAmount) {
57
		Payment payment = new Payment();
59
		Payment payment = new Payment();
58
		payment.setAmount(walletAmount);
60
		payment.setAmount(walletAmount);