| Line 218... |
Line 218... |
| 218 |
UserWallet wallet = userWalletRepository.selectByRetailerId(fofoId);
|
218 |
UserWallet wallet = userWalletRepository.selectByRetailerId(fofoId);
|
| 219 |
return userWalletHistoryRepository.getSumTillDate(wallet.getId(), date);
|
219 |
return userWalletHistoryRepository.getSumTillDate(wallet.getId(), date);
|
| 220 |
}
|
220 |
}
|
| 221 |
|
221 |
|
| 222 |
@Override
|
222 |
@Override
|
| 223 |
public void refundToWallet(Integer retailerId, Float amountToRefund, Integer transactionId,
|
223 |
public boolean refundToWallet(Integer retailerId, Float amountToRefund, Integer transactionId,
|
| 224 |
WalletReferenceType walletReferenceType, String description) throws ProfitMandiBusinessException {
|
224 |
WalletReferenceType walletReferenceType, String description) throws ProfitMandiBusinessException {
|
| 225 |
|
225 |
|
| 226 |
List<UserWalletHistory> all_entries = userWalletHistoryRepository
|
226 |
List<UserWalletHistory> all_entries = userWalletHistoryRepository
|
| 227 |
.selectAllByreferenceIdandreferenceType(transactionId, walletReferenceType);
|
227 |
.selectAllByreferenceIdandreferenceType(transactionId, walletReferenceType);
|
| 228 |
|
228 |
|
| Line 234... |
Line 234... |
| 234 |
LOGGER.info("all_entries {}",all_entries);
|
234 |
LOGGER.info("all_entries {}",all_entries);
|
| 235 |
for (UserWalletHistory history : all_entries) {
|
235 |
for (UserWalletHistory history : all_entries) {
|
| 236 |
max_eligible_credit_amount -= history.getAmount();
|
236 |
max_eligible_credit_amount -= history.getAmount();
|
| 237 |
}
|
237 |
}
|
| 238 |
if (max_eligible_credit_amount < amountToRefund) {
|
238 |
if (max_eligible_credit_amount < amountToRefund) {
|
| 239 |
|
- |
|
| 240 |
LOGGER.info("Cant be credited back to wallet as most of it has been already credited");
|
239 |
LOGGER.info("Cant be credited back to wallet as most of it has been already credited");
|
| 241 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.USER_ID, userWallet.getUserId(),
|
- |
|
| 242 |
"Cant be credited back to wallet as most of it has been already credited");
|
240 |
return false;
|
| 243 |
}
|
241 |
}
|
| 244 |
|
242 |
|
| 245 |
userWallet.setAmount(walletAmount + Math.round(amountToRefund));
|
243 |
userWallet.setAmount(walletAmount + Math.round(amountToRefund));
|
| 246 |
|
244 |
|
| 247 |
LOGGER.info("userWallet" + userWallet);
|
245 |
LOGGER.info("userWallet" + userWallet);
|
| Line 253... |
Line 251... |
| 253 |
userWalletHistory.setWalletId(userWallet.getId());
|
251 |
userWalletHistory.setWalletId(userWallet.getId());
|
| 254 |
userWalletHistory.setTimestamp(LocalDateTime.now());
|
252 |
userWalletHistory.setTimestamp(LocalDateTime.now());
|
| 255 |
userWalletHistory.setDescription(description);
|
253 |
userWalletHistory.setDescription(description);
|
| 256 |
|
254 |
|
| 257 |
userWalletHistoryRepository.persist(userWalletHistory);
|
255 |
userWalletHistoryRepository.persist(userWalletHistory);
|
| - |
|
256 |
return true;
|
| 258 |
|
257 |
|
| 259 |
}
|
258 |
}
|
| 260 |
|
259 |
|
| 261 |
@Override
|
260 |
@Override
|
| 262 |
public int getWalletAmount(int retailerId) throws ProfitMandiBusinessException {
|
261 |
public int getWalletAmount(int retailerId) throws ProfitMandiBusinessException {
|