| Line 1463... |
Line 1463... |
| 1463 |
return "credit-block-logs";
|
1463 |
return "credit-block-logs";
|
| 1464 |
}
|
1464 |
}
|
| 1465 |
|
1465 |
|
| 1466 |
/** Switch a partner to a different credit gateway (e.g. SIDBI) and activate it. */
|
1466 |
/** Switch a partner to a different credit gateway (e.g. SIDBI) and activate it. */
|
| 1467 |
@RequestMapping(value = "/switchCreditGateway", method = RequestMethod.POST)
|
1467 |
@RequestMapping(value = "/switchCreditGateway", method = RequestMethod.POST)
|
| 1468 |
public String switchCreditGateway(HttpServletRequest request, @RequestParam int id, Model model, @RequestParam Gateway gateway) throws Exception {
|
1468 |
public String switchCreditGateway(HttpServletRequest request, @RequestParam int id, Model model, @RequestParam Gateway gateway, @RequestParam String reason) throws Exception {
|
| 1469 |
CreditAccount creditAccount = creditAccountRepository.selectById(id);
|
1469 |
CreditAccount creditAccount = creditAccountRepository.selectById(id);
|
| 1470 |
if (creditAccount.getGateway().equals(gateway)) {
|
1470 |
if (!creditAccount.isActive()) {
|
| - |
|
1471 |
// Checks reason + loan-default rule before any gateway side effect; the transaction rolls back on later failures.
|
| - |
|
1472 |
String activationReason = reason.trim().isEmpty() ? reason : reason.trim() + " (gateway " + gateway + ")";
|
| 1471 |
creditAccount.setActive(true);
|
1473 |
sdCreditService.activateCredit(creditAccount, activationReason, cookiesProcessor.getCookiesObject(request).getEmailId());
|
| 1472 |
} else {
|
1474 |
}
|
| - |
|
1475 |
if (!creditAccount.getGateway().equals(gateway)) {
|
| 1473 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(creditAccount.getFofoId());
|
1476 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(creditAccount.getFofoId());
|
| 1474 |
|
1477 |
|
| 1475 |
if (sdCreditRequirement.getUtilizedAmount().compareTo(BigDecimal.ZERO) != 0) {
|
1478 |
if (sdCreditRequirement.getUtilizedAmount().compareTo(BigDecimal.ZERO) != 0) {
|
| 1476 |
LOGGER.info("sdCreditRequirement - {}", sdCreditRequirement);
|
1479 |
LOGGER.info("sdCreditRequirement - {}", sdCreditRequirement);
|
| 1477 |
throw new ProfitMandiBusinessException("Could not change to " + gateway + " unless previous loans are settled", "", "");
|
1480 |
throw new ProfitMandiBusinessException("Could not change to " + gateway + " unless previous loans are settled", "", "");
|
| Line 1488... |
Line 1491... |
| 1488 |
creditAccount.setSanctionedAmount((float) fofoSidbiSanction.getLoanAmount());
|
1491 |
creditAccount.setSanctionedAmount((float) fofoSidbiSanction.getLoanAmount());
|
| 1489 |
}
|
1492 |
}
|
| 1490 |
creditAccount.setAvailableAmount(creditAccount.getSanctionedAmount());
|
1493 |
creditAccount.setAvailableAmount(creditAccount.getSanctionedAmount());
|
| 1491 |
sdCreditRequirement.setUtilizedAmount(BigDecimal.ZERO);
|
1494 |
sdCreditRequirement.setUtilizedAmount(BigDecimal.ZERO);
|
| 1492 |
creditAccount.setActive(true);
|
1495 |
creditAccount.setActive(true);
|
| - |
|
1496 |
creditAccount.setInactiveReason(null);
|
| 1493 |
creditAccount.setGateway(gateway);
|
1497 |
creditAccount.setGateway(gateway);
|
| 1494 |
}
|
1498 |
}
|
| 1495 |
|
1499 |
|
| 1496 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailers();
|
1500 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailers();
|
| 1497 |
|
1501 |
|