Subversion Repositories SmartDukaan

Rev

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

Rev 30891 Rev 30892
Line 1832... Line 1832...
1832
	public void addMissingWalletDebitsForInsurance() throws Exception {
1832
	public void addMissingWalletDebitsForInsurance() throws Exception {
1833
		List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectAllByProviderId(5, Optional.empty());
1833
		List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectAllByProviderId(5, Optional.empty());
1834
		for (InsurancePolicy insurancePolicy : insurancePolicies) {
1834
		for (InsurancePolicy insurancePolicy : insurancePolicies) {
1835
			FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(insurancePolicy.getInvoiceNumber());
1835
			FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(insurancePolicy.getInvoiceNumber());
1836
			List<UserWalletHistory> userWalletHistories = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(insurancePolicy.getId(), WalletReferenceType.DAMAGE_PROTECTION);
1836
			List<UserWalletHistory> userWalletHistories = userWalletHistoryRepository.selectAllByreferenceIdandreferenceType(insurancePolicy.getId(), WalletReferenceType.DAMAGE_PROTECTION);
1837
			if (userWalletHistories.size() == 0) {
1837
			if (userWalletHistories.size() > 1) {
1838
 
-
 
-
 
1838
				UserWalletHistory userWalletHistory = userWalletHistories.get(0);
-
 
1839
				walletService.rollbackAmountFromWallet(insurancePolicy.getRetailerId(), 99, userWalletHistory.getReference(), WalletReferenceType.DAMAGE_PROTECTION, "Deduction reversal", LocalDateTime.now());
1839
			}
1840
			}
1840
			String walletDescription = String.format("Policy purchased against Sale Invoice#%s",
-
 
1841
					insurancePolicy.getInvoiceNumber());
-
 
1842
			// Try consuming wallet before insurance
-
 
1843
			walletService.consumeAmountFromWallet(insurancePolicy.getRetailerId(), insurancePolicy.getId(),
-
 
1844
					WalletReferenceType.DAMAGE_PROTECTION, walletDescription, insurancePolicy.getPurchaseAmount(),
-
 
1845
					LocalDateTime.now(), true);
-
 
1846
		}
1841
		}
1847
	}
1842
	}
1848
 
1843
 
1849
 
1844
 
1850
}
1845
}