| Line 1437... |
Line 1437... |
| 1437 |
|
1437 |
|
| 1438 |
|
1438 |
|
| 1439 |
@Autowired
|
1439 |
@Autowired
|
| 1440 |
SidbiService sidbiService;
|
1440 |
SidbiService sidbiService;
|
| 1441 |
|
1441 |
|
| - |
|
1442 |
// Only these admins may block/unblock a partner's credit.
|
| - |
|
1443 |
private void assertCreditBlockAdmin(HttpServletRequest request) throws ProfitMandiBusinessException {
|
| - |
|
1444 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
1445 |
String email = loginDetails.getEmailId();
|
| - |
|
1446 |
boolean isAdmin = "tarun.verma@smartdukaan.com".equals(email) || "kamini.sharma@smartdukaan.com".equals(email);
|
| - |
|
1447 |
if (!isAdmin) {
|
| - |
|
1448 |
throw new ProfitMandiBusinessException("You are not authorized to block/unblock credit", "", "");
|
| - |
|
1449 |
}
|
| - |
|
1450 |
}
|
| - |
|
1451 |
|
| - |
|
1452 |
/** Block (deactivate) a partner's credit. Reason is mandatory and recorded in the block log. */
|
| - |
|
1453 |
@RequestMapping(value = "/blockCredit", method = RequestMethod.POST)
|
| - |
|
1454 |
public String blockCredit(HttpServletRequest request, @RequestParam int id, @RequestParam String reason, Model model) throws Exception {
|
| - |
|
1455 |
assertCreditBlockAdmin(request);
|
| - |
|
1456 |
String performedBy = cookiesProcessor.getCookiesObject(request).getEmailId();
|
| - |
|
1457 |
sdCreditService.blockCredit(id, reason, performedBy);
|
| - |
|
1458 |
|
| - |
|
1459 |
CreditAccount creditAccount = creditAccountRepository.selectById(id);
|
| - |
|
1460 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailers();
|
| - |
|
1461 |
model.addAttribute("creditAccount", creditAccount);
|
| - |
|
1462 |
model.addAttribute("customRetailers", customRetailers);
|
| - |
|
1463 |
return "partner-credit-detail-row";
|
| - |
|
1464 |
}
|
| - |
|
1465 |
|
| - |
|
1466 |
/** Unblock (reactivate) a previously blocked credit account (same gateway). Reason is optional. */
|
| 1442 |
@RequestMapping(value = "/activateKred", method = RequestMethod.POST)
|
1467 |
@RequestMapping(value = "/unblockCredit", method = RequestMethod.POST)
|
| - |
|
1468 |
public String unblockCredit(HttpServletRequest request, @RequestParam int id, @RequestParam(required = false) String reason, Model model) throws Exception {
|
| - |
|
1469 |
assertCreditBlockAdmin(request);
|
| - |
|
1470 |
String performedBy = cookiesProcessor.getCookiesObject(request).getEmailId();
|
| - |
|
1471 |
sdCreditService.unblockCredit(id, reason, performedBy);
|
| - |
|
1472 |
|
| - |
|
1473 |
CreditAccount creditAccount = creditAccountRepository.selectById(id);
|
| - |
|
1474 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailers();
|
| - |
|
1475 |
model.addAttribute("creditAccount", creditAccount);
|
| - |
|
1476 |
model.addAttribute("customRetailers", customRetailers);
|
| - |
|
1477 |
return "partner-credit-detail-row";
|
| - |
|
1478 |
}
|
| - |
|
1479 |
|
| - |
|
1480 |
/** Full block/unblock history for a partner, rendered into the unblock modal. */
|
| - |
|
1481 |
@RequestMapping(value = "/creditBlockLogs", method = RequestMethod.GET)
|
| - |
|
1482 |
public String creditBlockLogs(HttpServletRequest request, @RequestParam int fofoId, Model model) throws Exception {
|
| - |
|
1483 |
model.addAttribute("creditBlockLogs", sdCreditService.getCreditBlockLogs(fofoId));
|
| - |
|
1484 |
return "credit-block-logs";
|
| - |
|
1485 |
}
|
| - |
|
1486 |
|
| - |
|
1487 |
/** Switch a partner to a different credit gateway (e.g. SIDBI) and activate it. */
|
| - |
|
1488 |
@RequestMapping(value = "/switchCreditGateway", method = RequestMethod.POST)
|
| 1443 |
public String activateKred(HttpServletRequest request, @RequestParam int id, Model model, @RequestParam Gateway gateway) throws Exception {
|
1489 |
public String switchCreditGateway(HttpServletRequest request, @RequestParam int id, Model model, @RequestParam Gateway gateway) throws Exception {
|
| 1444 |
CreditAccount creditAccount = creditAccountRepository.selectById(id);
|
1490 |
CreditAccount creditAccount = creditAccountRepository.selectById(id);
|
| 1445 |
if (creditAccount.getGateway().equals(gateway)) {
|
1491 |
if (creditAccount.getGateway().equals(gateway)) {
|
| 1446 |
creditAccount.setActive(true);
|
1492 |
creditAccount.setActive(true);
|
| 1447 |
} else {
|
1493 |
} else {
|
| 1448 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(creditAccount.getFofoId());
|
1494 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(creditAccount.getFofoId());
|
| Line 1477... |
Line 1523... |
| 1477 |
|
1523 |
|
| 1478 |
model.addAttribute("creditAccount", creditAccount);
|
1524 |
model.addAttribute("creditAccount", creditAccount);
|
| 1479 |
model.addAttribute("customRetailers", customRetailers);
|
1525 |
model.addAttribute("customRetailers", customRetailers);
|
| 1480 |
return "partner-credit-detail-row";
|
1526 |
return "partner-credit-detail-row";
|
| 1481 |
}
|
1527 |
}
|
| 1482 |
|
- |
|
| 1483 |
@RequestMapping(value = "/deactivateKred", method = RequestMethod.POST)
|
- |
|
| 1484 |
public String deactivateKred(HttpServletRequest request, @RequestParam int id, Model model) throws Exception {
|
- |
|
| 1485 |
CreditAccount creditAccount = creditAccountRepository.selectById(id);
|
- |
|
| 1486 |
|
- |
|
| 1487 |
creditAccount.setActive(false);
|
- |
|
| 1488 |
|
- |
|
| 1489 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailers();
|
- |
|
| 1490 |
|
- |
|
| 1491 |
model.addAttribute("creditAccount", creditAccount);
|
- |
|
| 1492 |
model.addAttribute("customRetailers", customRetailers);
|
- |
|
| 1493 |
return "partner-credit-detail-row";
|
- |
|
| 1494 |
}
|
- |
|
| 1495 |
|
1528 |
|
| 1496 |
@RequestMapping(value = "/downloadAddWalletRequestReport", method = RequestMethod.GET)
|
1529 |
@RequestMapping(value = "/downloadAddWalletRequestReport", method = RequestMethod.GET)
|
| 1497 |
public ResponseEntity<?> addWalletRequestPendingReport(@RequestParam LocalDate startDate, @RequestParam LocalDate endDate, @RequestParam AddWalletRequestStatus status, Model model) throws Exception {
|
1530 |
public ResponseEntity<?> addWalletRequestPendingReport(@RequestParam LocalDate startDate, @RequestParam LocalDate endDate, @RequestParam AddWalletRequestStatus status, Model model) throws Exception {
|
| 1498 |
if (endDate == null) {
|
1531 |
if (endDate == null) {
|
| 1499 |
endDate = LocalDate.now();
|
1532 |
endDate = LocalDate.now();
|