| Line 226... |
Line 226... |
| 226 |
List<UserWalletHistory> all_entries = userWalletHistoryRepository
|
226 |
List<UserWalletHistory> all_entries = userWalletHistoryRepository
|
| 227 |
.selectAllByreferenceIdandreferenceType(transactionId, walletReferenceType);
|
227 |
.selectAllByreferenceIdandreferenceType(transactionId, walletReferenceType);
|
| 228 |
UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);
|
228 |
UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);
|
| 229 |
int walletAmount = walletService.getWalletAmount(retailerId);
|
229 |
int walletAmount = walletService.getWalletAmount(retailerId);
|
| 230 |
LOGGER.info("userWallet" + userWallet);
|
230 |
LOGGER.info("userWallet" + userWallet);
|
| 231 |
int creditable_amount_for_reference = 0;
|
231 |
int max_eligible_credit_amount = 0;
|
| 232 |
|
232 |
|
| 233 |
for (UserWalletHistory history : all_entries) {
|
233 |
for (UserWalletHistory history : all_entries) {
|
| 234 |
creditable_amount_for_reference -= history.getAmount();
|
234 |
max_eligible_credit_amount -= history.getAmount();
|
| 235 |
|
- |
|
| 236 |
LOGGER.info("creditable_amount_for_reference" + creditable_amount_for_reference);
|
- |
|
| 237 |
|
- |
|
| 238 |
LOGGER.info("walletAmount" + amountToRefund);
|
- |
|
| 239 |
|
- |
|
| 240 |
}
|
235 |
}
|
| 241 |
if (creditable_amount_for_reference < amountToRefund) {
|
236 |
if (max_eligible_credit_amount < amountToRefund) {
|
| 242 |
|
237 |
|
| 243 |
LOGGER.info("Cant be credited back to wallet as most of it has been already credited");
|
238 |
LOGGER.info("Cant be credited back to wallet as most of it has been already credited");
|
| 244 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.USER_ID, userWallet.getUserId(),
|
239 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.USER_ID, userWallet.getUserId(),
|
| 245 |
"Cant be credited back to wallet as most of it has been already credited");
|
240 |
"Cant be credited back to wallet as most of it has been already credited");
|
| 246 |
}
|
241 |
}
|
| 247 |
|
242 |
|
| 248 |
userWallet.setAmount(walletAmount + Math.round(amountToRefund));
|
243 |
userWallet.setAmount(walletAmount + Math.round(amountToRefund));
|
| 249 |
|
244 |
|
| 250 |
LOGGER.info("userWallet" + userWallet);
|
245 |
LOGGER.info("userWallet" + userWallet);
|
| 251 |
|
246 |
|
| 252 |
UserWalletHistory userWalletHistory = new UserWalletHistory();
|
247 |
UserWalletHistory userWalletHistory = new UserWalletHistory();
|