| Line 1302... |
Line 1302... |
| 1302 |
|
1302 |
|
| 1303 |
@Autowired
|
1303 |
@Autowired
|
| 1304 |
LoanTransactionRepository loanTransactionRepository;
|
1304 |
LoanTransactionRepository loanTransactionRepository;
|
| 1305 |
|
1305 |
|
| 1306 |
private void fixBlockedCredit() throws ProfitMandiBusinessException {
|
1306 |
private void fixBlockedCredit() throws ProfitMandiBusinessException {
|
| 1307 |
List<Loan> unsettledBlockedLoans = loanRepository.selectAllActiveLoan().stream().filter(Loan::isLimit).collect(toList());
|
1307 |
List<Loan> unsettledBlockedLoans = loanRepository.selectAllBlockedLoans();
|
| 1308 |
//unsettledBlockedLoans = unsettledBlockedLoans.stream().filter(x -> x.getId() == 52310).collect(toList());
|
1308 |
//unsettledBlockedLoans = unsettledBlockedLoans.stream().filter(x -> x.getId() == 52310).collect(toList());
|
| 1309 |
for (Loan unsettledBlockedLoan : unsettledBlockedLoans) {
|
1309 |
for (Loan unsettledBlockedLoan : unsettledBlockedLoans) {
|
| 1310 |
LoanTransaction loanTransaction = loanTransactionRepository.selectByLoanId(unsettledBlockedLoan.getId());
|
1310 |
LoanTransaction loanTransaction = loanTransactionRepository.selectByLoanId(unsettledBlockedLoan.getId());
|
| 1311 |
if (loanTransaction == null) {
|
1311 |
if (loanTransaction == null) {
|
| 1312 |
System.out.println("Cant find Transaction Id for Loan - " + unsettledBlockedLoan.getId() + "-- Created On ->" + unsettledBlockedLoan.getCreatedOn());
|
1312 |
System.out.println("Cant find Transaction Id for Loan - " + unsettledBlockedLoan.getId() + "-- Created On ->" + unsettledBlockedLoan.getCreatedOn());
|
| Line 3857... |
Line 3857... |
| 3857 |
public void dailyLoanAlert() throws Exception {
|
3857 |
public void dailyLoanAlert() throws Exception {
|
| 3858 |
List<Loan> loans = loanRepository.selectAllActiveLoan();
|
3858 |
List<Loan> loans = loanRepository.selectAllActiveLoan();
|
| 3859 |
|
3859 |
|
| 3860 |
Map<Integer, Double> partnerLoanAmount = new HashMap<>();
|
3860 |
Map<Integer, Double> partnerLoanAmount = new HashMap<>();
|
| 3861 |
|
3861 |
|
| 3862 |
if (!loans.isEmpty()) {
|
- |
|
| 3863 |
|
- |
|
| 3864 |
for (Loan loan : loans) {
|
3862 |
for (Loan loan : loans) {
|
| 3865 |
|
- |
|
| 3866 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
- |
|
| 3867 |
|
- |
|
| 3868 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
- |
|
| 3869 |
if (partnerLoanAmount.get(loan.getFofoId()) != null) {
|
- |
|
| 3870 |
amount += partnerLoanAmount.get(loan.getFofoId());
|
3863 |
double amount = partnerLoanAmount.getOrDefault(loan.getFofoId(), 0.0);
|
| 3871 |
partnerLoanAmount.put(loan.getFofoId(), amount);
|
3864 |
amount += loan.getPendingAmount().doubleValue() + loan.getInterestAccrued().doubleValue() - loan.getInterestPaid().doubleValue();
|
| 3872 |
} else {
|
- |
|
| 3873 |
partnerLoanAmount.put(loan.getFofoId(), amount);
|
3865 |
partnerLoanAmount.put(loan.getFofoId(), amount);
|
| 3874 |
}
|
- |
|
| 3875 |
|
- |
|
| 3876 |
}
|
- |
|
| 3877 |
|
- |
|
| 3878 |
}
|
3866 |
}
|
| 3879 |
|
3867 |
|
| 3880 |
if (!partnerLoanAmount.isEmpty()) {
|
3868 |
if (!partnerLoanAmount.isEmpty()) {
|
| 3881 |
|
3869 |
|
| 3882 |
for (Entry<Integer, Double> partnerLoanAmountEnrty : partnerLoanAmount.entrySet()) {
|
3870 |
for (Entry<Integer, Double> partnerLoanAmountEnrty : partnerLoanAmount.entrySet()) {
|
| Line 4117... |
Line 4105... |
| 4117 |
}
|
4105 |
}
|
| 4118 |
String messageText = this.getMessageForDueDateExtend(defaultLoans);
|
4106 |
String messageText = this.getMessageForDueDateExtend(defaultLoans);
|
| 4119 |
this.sendMailOfHtmlFormat(googleMailSender, new String[]{"puneet.wahi@smartdukaan.com", "rahul.latwal@smartdukaan.com", "dilbag.singh@smartdukaan.com"}, messageText, null, subject);
|
4107 |
this.sendMailOfHtmlFormat(googleMailSender, new String[]{"puneet.wahi@smartdukaan.com", "rahul.latwal@smartdukaan.com", "dilbag.singh@smartdukaan.com"}, messageText, null, subject);
|
| 4120 |
|
4108 |
|
| 4121 |
for (Loan defaultLoan : defaultLoans) {
|
4109 |
for (Loan defaultLoan : defaultLoans) {
|
| 4122 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(defaultLoan.getId());
|
4110 |
double principal = defaultLoan.getPendingAmount().doubleValue();
|
| 4123 |
|
- |
|
| 4124 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
4111 |
double interest = defaultLoan.getInterestAccrued().doubleValue() - defaultLoan.getInterestPaid().doubleValue();
|
| - |
|
4112 |
double total = principal + interest;
|
| 4125 |
|
4113 |
|
| 4126 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(defaultLoan.getFofoId());
|
- |
|
| 4127 |
|
- |
|
| 4128 |
Address address = addressRepository.selectById(user.getAddressId());
|
- |
|
| 4129 |
|
- |
|
| 4130 |
String title = "Outstanding Credit Payment Overdue!";
|
4114 |
String title = "Credit Default Alert!";
|
| 4131 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
4115 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
| 4132 |
String message = "Your Outstanding Credit payment due date " + defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + " has been exceeded. Please note " + ProfitMandiConstants.NEW_DELAYED_INTEREST_RATE + " shall be levied on daily basis." + " Your total pending Loan amount is Rs." + FormattingUtils.formatDecimal(Math.abs(amount)) + ". !!Pay Now!!";
|
4116 |
String message = "Your credit payment (due " + defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + ") is now in default. A penalty interest of " + ProfitMandiConstants.NEW_DELAYED_INTEREST_RATE + "% per day is being charged. Total outstanding: Rs." + FormattingUtils.formatDecimal(total) + " (Principal: Rs." + FormattingUtils.formatDecimal(principal) + " + Interest: Rs." + FormattingUtils.formatDecimal(interest) + "). Pay immediately to avoid further penalties.";
|
| 4133 |
notificationService.sendNotification(defaultLoan.getFofoId(), title, MessageType.notification, title, message, url);
|
4117 |
notificationService.sendNotification(defaultLoan.getFofoId(), title, MessageType.notification, title, message, url);
|
| 4134 |
|
4118 |
|
| 4135 |
// notificationService.sendWhatsappMessage(message, title,
|
- |
|
| 4136 |
// address.getPhoneNumber());
|
- |
|
| 4137 |
|
- |
|
| 4138 |
}
|
4119 |
}
|
| 4139 |
}
|
4120 |
}
|
| 4140 |
|
4121 |
|
| 4141 |
private String getMessageForDueDateExtend(List<Loan> loans) throws ProfitMandiBusinessException {
|
4122 |
private String getMessageForDueDateExtend(List<Loan> loans) throws ProfitMandiBusinessException {
|
| 4142 |
Map<Integer, com.spice.profitmandi.dao.model.FofoReportingModel> fofoReportingModelMap = csService.getPartnerIdSalesHeaders();
|
4123 |
Map<Integer, com.spice.profitmandi.dao.model.FofoReportingModel> fofoReportingModelMap = csService.getPartnerIdSalesHeaders();
|
| Line 4144... |
Line 4125... |
| 4144 |
List<AST> asts = astRepository.selectAll();
|
4125 |
List<AST> asts = astRepository.selectAll();
|
| 4145 |
Map<Integer, AST> astMap = asts.stream()
|
4126 |
Map<Integer, AST> astMap = asts.stream()
|
| 4146 |
.collect(Collectors.toMap(AST::getId, ast -> ast));
|
4127 |
.collect(Collectors.toMap(AST::getId, ast -> ast));
|
| 4147 |
StringBuilder sb = new StringBuilder();
|
4128 |
StringBuilder sb = new StringBuilder();
|
| 4148 |
sb.append(
|
4129 |
sb.append(
|
| 4149 |
"<html><body><p>Alert</p><p>Default Partners :-</p>" + "<br/><p>EveryDay Rs.100 charged as Penalty</p>" + "<br/>" +
|
4130 |
"<html><body><p>Alert</p><p>Default Partners :-</p>" + "<br/><p>Penalty interest of " + ProfitMandiConstants.NEW_DELAYED_INTEREST_RATE + "% per day is being charged on outstanding amount.</p>" + "<br/>" +
|
| 4150 |
"<table style='border:1px solid black ;padding: 5px';>");
|
4131 |
"<table style='border:1px solid black ;padding: 5px';>");
|
| 4151 |
sb.append("<tbody>\n" +
|
4132 |
sb.append("<tbody>\n" +
|
| 4152 |
"<tr>\n" +
|
4133 |
"<tr>\n" +
|
| 4153 |
"<th style='border:1px solid black;padding: 5px'>PartnerName</th>\n" +
|
4134 |
"<th style='border:1px solid black;padding: 5px'>PartnerName</th>\n" +
|
| 4154 |
"<th style='border:1px solid black;padding: 5px'>State Name</th>\n" +
|
4135 |
"<th style='border:1px solid black;padding: 5px'>State Name</th>\n" +
|
| Line 4160... |
Line 4141... |
| 4160 |
"<th style='border:1px solid black;padding: 5px'>RBM L2</th>\n" +
|
4141 |
"<th style='border:1px solid black;padding: 5px'>RBM L2</th>\n" +
|
| 4161 |
"<th style='border:1px solid black;padding: 5px'>RBM L1</th>\n" +
|
4142 |
"<th style='border:1px solid black;padding: 5px'>RBM L1</th>\n" +
|
| 4162 |
"<th style='border:1px solid black;padding: 5px'>Sales L1</th>\n" +
|
4143 |
"<th style='border:1px solid black;padding: 5px'>Sales L1</th>\n" +
|
| 4163 |
"<th style='border:1px solid black;padding: 5px'>Sales L2</th>\n" +
|
4144 |
"<th style='border:1px solid black;padding: 5px'>Sales L2</th>\n" +
|
| 4164 |
"</tr>");
|
4145 |
"</tr>");
|
| - |
|
4146 |
DecimalFormat df = new DecimalFormat("#.##");
|
| 4165 |
for (Loan entry : loans) {
|
4147 |
for (Loan entry : loans) {
|
| 4166 |
|
4148 |
|
| 4167 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(entry.getId());
|
- |
|
| 4168 |
|
- |
|
| 4169 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
4149 |
double amount = entry.getPendingAmount().doubleValue() + entry.getInterestAccrued().doubleValue() - entry.getInterestPaid().doubleValue();
|
| 4170 |
|
4150 |
|
| 4171 |
long noOfdaysBetween = ChronoUnit.DAYS.between(entry.getDueDate().toLocalDate(), LocalDateTime.now());
|
4151 |
long noOfdaysBetween = ChronoUnit.DAYS.between(entry.getDueDate().toLocalDate(), LocalDateTime.now());
|
| 4172 |
|
4152 |
|
| 4173 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
|
4153 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
|
| 4174 |
|
4154 |
|
| Line 4177... |
Line 4157... |
| 4177 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getAddress().getState() + "</td>");
|
4157 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getAddress().getState() + "</td>");
|
| 4178 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + astMap.get(customRetailer.getAstId()).getArea() + "</td>");
|
4158 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + astMap.get(customRetailer.getAstId()).getArea() + "</td>");
|
| 4179 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + astMap.get(customRetailer.getAstId()).getTerritory() + "</td>");
|
4159 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + astMap.get(customRetailer.getAstId()).getTerritory() + "</td>");
|
| 4180 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getDueDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "</td>");
|
4160 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getDueDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "</td>");
|
| 4181 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + noOfdaysBetween + "</td>");
|
4161 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + noOfdaysBetween + "</td>");
|
| 4182 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + new DecimalFormat("#.##").format(Math.abs(amount)) + "</td>");
|
4162 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + df.format(amount) + "</td>");
|
| 4183 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoRbmReportingModelMap.get(entry.getFofoId()).getL1Manager() + "</td>");
|
4163 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoRbmReportingModelMap.get(entry.getFofoId()).getL1Manager() + "</td>");
|
| 4184 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoRbmReportingModelMap.get(entry.getFofoId()).getL2Manager() + "</td>");
|
4164 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoRbmReportingModelMap.get(entry.getFofoId()).getL2Manager() + "</td>");
|
| 4185 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoReportingModelMap.get(entry.getFofoId()).getTerritoryManager() + "</td>");
|
4165 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoReportingModelMap.get(entry.getFofoId()).getTerritoryManager() + "</td>");
|
| 4186 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoReportingModelMap.get(entry.getFofoId()).getRegionalManager() + "</td>");
|
4166 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoReportingModelMap.get(entry.getFofoId()).getRegionalManager() + "</td>");
|
| 4187 |
|
4167 |
|
| 4188 |
|
- |
|
| 4189 |
sb.append("</tr>");
|
4168 |
sb.append("</tr>");
|
| 4190 |
|
4169 |
|
| 4191 |
}
|
4170 |
}
|
| 4192 |
|
4171 |
|
| 4193 |
sb.append("</tbody></table></body></html>");
|
4172 |
sb.append("</tbody></table></body></html>");
|
| Line 4201... |
Line 4180... |
| 4201 |
List<AST> asts = astRepository.selectAll();
|
4180 |
List<AST> asts = astRepository.selectAll();
|
| 4202 |
Map<Integer, AST> astMap = asts.stream()
|
4181 |
Map<Integer, AST> astMap = asts.stream()
|
| 4203 |
.collect(Collectors.toMap(AST::getId, ast -> ast));
|
4182 |
.collect(Collectors.toMap(AST::getId, ast -> ast));
|
| 4204 |
|
4183 |
|
| 4205 |
StringBuilder sb = new StringBuilder();
|
4184 |
StringBuilder sb = new StringBuilder();
|
| 4206 |
sb.append("<html><body><p>Alert</p><p>Partner Credit Report :-</p>" + "<br/><p>Additional penal interest of shall be levied on daily basis.</p>" + "<br/>" +
|
4185 |
sb.append("<html><body><p>Alert</p><p>Partner Credit Report - Overdue :-</p>" + "<br/><p>Overdue interest of " + ProfitMandiConstants.TIER2_INTEREST_RATE + "% per day is being charged on outstanding amount.</p>" + "<br/>" +
|
| 4207 |
"<table style='border:1px solid black ;padding: 5px';>");
|
4186 |
"<table style='border:1px solid black ;padding: 5px';>");
|
| 4208 |
sb.append("<tbody>\n" + "<tr>\n" +
|
4187 |
sb.append("<tbody>\n" + "<tr>\n" +
|
| 4209 |
"<th style='border:1px solid black;padding: 5px'>PartnerName</th>\n" +
|
4188 |
"<th style='border:1px solid black;padding: 5px'>PartnerName</th>\n" +
|
| 4210 |
"<th style='border:1px solid black;padding: 5px'>State Name</th>\n" +
|
4189 |
"<th style='border:1px solid black;padding: 5px'>State Name</th>\n" +
|
| 4211 |
"<th style='border:1px solid black;padding: 5px'>Area</th>\n" +
|
4190 |
"<th style='border:1px solid black;padding: 5px'>Area</th>\n" +
|
| Line 4218... |
Line 4197... |
| 4218 |
"<th style='border:1px solid black;padding: 5px'>Sales L1</th>\n" +
|
4197 |
"<th style='border:1px solid black;padding: 5px'>Sales L1</th>\n" +
|
| 4219 |
"<th style='border:1px solid black;padding: 5px'>Sales L2</th>\n" +
|
4198 |
"<th style='border:1px solid black;padding: 5px'>Sales L2</th>\n" +
|
| 4220 |
"<th style='border:1px solid black;padding: 5px'>Limit Assigned</th>\n" +
|
4199 |
"<th style='border:1px solid black;padding: 5px'>Limit Assigned</th>\n" +
|
| 4221 |
"</tr>");
|
4200 |
"</tr>");
|
| 4222 |
|
4201 |
|
| - |
|
4202 |
DecimalFormat df = new DecimalFormat("#.##");
|
| 4223 |
for (Loan entry : dueDateCrossLoans) {
|
4203 |
for (Loan entry : dueDateCrossLoans) {
|
| 4224 |
DecimalFormat df = new DecimalFormat("#.##");
|
- |
|
| 4225 |
|
- |
|
| 4226 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(entry.getId());
|
- |
|
| 4227 |
|
4204 |
|
| 4228 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
4205 |
double amount = entry.getPendingAmount().doubleValue() + entry.getInterestAccrued().doubleValue() - entry.getInterestPaid().doubleValue();
|
| 4229 |
|
4206 |
|
| 4230 |
long noOfdaysBetween = ChronoUnit.DAYS.between(entry.getDueDate().toLocalDate(), LocalDateTime.now());
|
4207 |
long noOfdaysBetween = ChronoUnit.DAYS.between(entry.getDueDate().toLocalDate(), LocalDateTime.now());
|
| 4231 |
|
4208 |
|
| 4232 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
|
4209 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
|
| 4233 |
|
4210 |
|
| Line 4236... |
Line 4213... |
| 4236 |
sb.append("<tr>");
|
4213 |
sb.append("<tr>");
|
| 4237 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getBusinessName() + "(" + customRetailer.getCode() + ")" + "</td>");
|
4214 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getBusinessName() + "(" + customRetailer.getCode() + ")" + "</td>");
|
| 4238 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getAddress().getState() + "</td>");
|
4215 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + customRetailer.getAddress().getState() + "</td>");
|
| 4239 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + astMap.get(customRetailer.getAstId()).getArea() + "</td>");
|
4216 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + astMap.get(customRetailer.getAstId()).getArea() + "</td>");
|
| 4240 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + astMap.get(customRetailer.getAstId()).getTerritory() + "</td>");
|
4217 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + astMap.get(customRetailer.getAstId()).getTerritory() + "</td>");
|
| 4241 |
|
- |
|
| 4242 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getDueDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "</td>");
|
4218 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + entry.getDueDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + "</td>");
|
| 4243 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + noOfdaysBetween + "</td>");
|
4219 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + noOfdaysBetween + "</td>");
|
| 4244 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + new DecimalFormat("#.##").format(Math.abs(amount)) + "</td>");
|
4220 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + df.format(amount) + "</td>");
|
| 4245 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoRbmReportingModelMap.get(entry.getFofoId()).getL1Manager() + "</td>");
|
4221 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoRbmReportingModelMap.get(entry.getFofoId()).getL1Manager() + "</td>");
|
| 4246 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoRbmReportingModelMap.get(entry.getFofoId()).getL2Manager() + "</td>");
|
4222 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoRbmReportingModelMap.get(entry.getFofoId()).getL2Manager() + "</td>");
|
| 4247 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoReportingModelMap.get(entry.getFofoId()).getTerritoryManager() + "</td>");
|
4223 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoReportingModelMap.get(entry.getFofoId()).getTerritoryManager() + "</td>");
|
| 4248 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoReportingModelMap.get(entry.getFofoId()).getRegionalManager() + "</td>");
|
4224 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + fofoReportingModelMap.get(entry.getFofoId()).getRegionalManager() + "</td>");
|
| 4249 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + df.format(sdCreditRequirement.getLimit()) + "</td>");
|
4225 |
sb.append("<td style='border:1px solid black;padding: 5px'>" + df.format(sdCreditRequirement.getLimit()) + "</td>");
|
| Line 4326... |
Line 4302... |
| 4326 |
}
|
4302 |
}
|
| 4327 |
|
4303 |
|
| 4328 |
|
4304 |
|
| 4329 |
if (!dueDateCrossLoans.isEmpty()) {
|
4305 |
if (!dueDateCrossLoans.isEmpty()) {
|
| 4330 |
for (Loan loan : dueDateCrossLoans) {
|
4306 |
for (Loan loan : dueDateCrossLoans) {
|
| 4331 |
|
- |
|
| 4332 |
long noOfdaysBetween = ChronoUnit.DAYS.between(loan.getDueDate().toLocalDate(), LocalDate.now());
|
4307 |
double principal = loan.getPendingAmount().doubleValue();
|
| 4333 |
|
- |
|
| 4334 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(loan.getFofoId());
|
- |
|
| 4335 |
|
- |
|
| 4336 |
Address address = addressRepository.selectById(user.getAddressId());
|
4308 |
double interest = loan.getInterestAccrued().doubleValue() - loan.getInterestPaid().doubleValue();
|
| 4337 |
|
- |
|
| 4338 |
LOGGER.info("noOfdaysBetween {} ", noOfdaysBetween);
|
4309 |
double total = principal + interest;
|
| 4339 |
|
- |
|
| 4340 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
- |
|
| 4341 |
|
- |
|
| 4342 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
- |
|
| 4343 |
|
4310 |
|
| 4344 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
4311 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
| 4345 |
|
4312 |
|
| 4346 |
String title = "Alert!";
|
4313 |
String title = "Credit Payment Overdue!";
|
| 4347 |
String message = "Your Outstanding Credit Payment due date " + loan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + " has been exceeded. Additional penal interest of " + loan.getInterestRate().setScale(2, RoundingMode.HALF_UP) + "% shall be levied on daily basis. Your total pending loan amount is Rs." + FormattingUtils.formatDecimal(Math.abs(amount)) + ". !!Pay Now!!";
|
4314 |
String message = "Your credit payment (due " + loan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + ") is overdue. An interest of " + ProfitMandiConstants.TIER2_INTEREST_RATE + "% per day is now being charged. Total outstanding: Rs." + FormattingUtils.formatDecimal(total) + " (Principal: Rs." + FormattingUtils.formatDecimal(principal) + " + Interest: Rs." + FormattingUtils.formatDecimal(interest) + "). Pay now to avoid higher penalties.";
|
| 4348 |
|
4315 |
|
| 4349 |
notificationService.sendNotification(loan.getFofoId(), title, MessageType.notification, title, message, url);
|
4316 |
notificationService.sendNotification(loan.getFofoId(), title, MessageType.notification, title, message, url);
|
| 4350 |
|
4317 |
|
| 4351 |
//notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
- |
|
| 4352 |
|
- |
|
| 4353 |
}
|
4318 |
}
|
| 4354 |
}
|
4319 |
}
|
| 4355 |
|
4320 |
|
| 4356 |
}
|
4321 |
}
|
| 4357 |
|
4322 |
|
| Line 4372... |
Line 4337... |
| 4372 |
"RBM L2", "RBM L1", "Sales L1", "Sales L2", "Limit Assigned"
|
4337 |
"RBM L2", "RBM L1", "Sales L1", "Sales L2", "Limit Assigned"
|
| 4373 |
);
|
4338 |
);
|
| 4374 |
|
4339 |
|
| 4375 |
List<List<?>> rows = new ArrayList<>();
|
4340 |
List<List<?>> rows = new ArrayList<>();
|
| 4376 |
|
4341 |
|
| - |
|
4342 |
DecimalFormat df = new DecimalFormat("#.##");
|
| 4377 |
for (Loan entry : loans) {
|
4343 |
for (Loan entry : loans) {
|
| 4378 |
|
4344 |
|
| 4379 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(entry.getId());
|
- |
|
| 4380 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
4345 |
double amount = entry.getPendingAmount().doubleValue() + entry.getInterestAccrued().doubleValue() - entry.getInterestPaid().doubleValue();
|
| 4381 |
|
4346 |
|
| 4382 |
// long noOfdaysBetween = ChronoUnit.DAYS.between(entry.getDueDate().toLocalDate(), LocalDateTime.now());
|
- |
|
| 4383 |
long noOfdaysBetween = ChronoUnit.DAYS.between(entry.getCreatedOn().toLocalDate(), LocalDateTime.now());
|
4347 |
long noOfdaysBetween = ChronoUnit.DAYS.between(entry.getCreatedOn().toLocalDate(), LocalDateTime.now());
|
| 4384 |
|
4348 |
|
| 4385 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
|
4349 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(entry.getFofoId());
|
| 4386 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(customRetailer.getPartnerId());
|
4350 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(customRetailer.getPartnerId());
|
| 4387 |
DecimalFormat df = new DecimalFormat("#.##");
|
- |
|
| 4388 |
List<String> row = Arrays.asList(
|
4351 |
List<String> row = Arrays.asList(
|
| 4389 |
customRetailer.getBusinessName() + "(" + customRetailer.getCode() + ")",
|
4352 |
customRetailer.getBusinessName() + "(" + customRetailer.getCode() + ")",
|
| 4390 |
customRetailer.getAddress().getState(),
|
4353 |
customRetailer.getAddress().getState(),
|
| 4391 |
astMap.get(customRetailer.getAstId()).getArea(),
|
4354 |
astMap.get(customRetailer.getAstId()).getArea(),
|
| 4392 |
astMap.get(customRetailer.getAstId()).getTerritory(),
|
4355 |
astMap.get(customRetailer.getAstId()).getTerritory(),
|
| 4393 |
entry.getDueDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")),
|
4356 |
entry.getDueDate().format(DateTimeFormatter.ofPattern("dd/MM/yyyy")),
|
| 4394 |
String.valueOf(noOfdaysBetween),
|
4357 |
String.valueOf(noOfdaysBetween),
|
| 4395 |
df.format(Math.abs(amount)),
|
4358 |
df.format(amount),
|
| 4396 |
fofoRbmReportingModelMap.get(entry.getFofoId()).getL1Manager(),
|
4359 |
fofoRbmReportingModelMap.get(entry.getFofoId()).getL1Manager(),
|
| 4397 |
fofoRbmReportingModelMap.get(entry.getFofoId()).getL2Manager(),
|
4360 |
fofoRbmReportingModelMap.get(entry.getFofoId()).getL2Manager(),
|
| 4398 |
fofoReportingModelMap.get(entry.getFofoId()).getTerritoryManager(),
|
4361 |
fofoReportingModelMap.get(entry.getFofoId()).getTerritoryManager(),
|
| 4399 |
fofoReportingModelMap.get(entry.getFofoId()).getRegionalManager(),
|
4362 |
fofoReportingModelMap.get(entry.getFofoId()).getRegionalManager(),
|
| 4400 |
df.format(sdCreditRequirement.getLimit())
|
4363 |
df.format(sdCreditRequirement.getLimit())
|
| Line 4417... |
Line 4380... |
| 4417 |
|
4380 |
|
| 4418 |
public void alertForDueDate() throws Exception {
|
4381 |
public void alertForDueDate() throws Exception {
|
| 4419 |
|
4382 |
|
| 4420 |
List<Loan> loans = loanRepository.selectAllActiveLoan();
|
4383 |
List<Loan> loans = loanRepository.selectAllActiveLoan();
|
| 4421 |
|
4384 |
|
| 4422 |
if (!loans.isEmpty()) {
|
- |
|
| 4423 |
for (Loan loan : loans) {
|
4385 |
for (Loan loan : loans) {
|
| 4424 |
|
- |
|
| 4425 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(loan.getFofoId());
|
- |
|
| 4426 |
|
- |
|
| 4427 |
Address address = addressRepository.selectById(user.getAddressId());
|
- |
|
| 4428 |
|
- |
|
| 4429 |
long noOfdaysBetween = ChronoUnit.DAYS.between(LocalDate.now(), loan.getDueDate().toLocalDate());
|
4386 |
long noOfdaysBetween = ChronoUnit.DAYS.between(LocalDate.now(), loan.getDueDate().toLocalDate());
|
| 4430 |
|
- |
|
| 4431 |
LOGGER.info("noOfdaysBetween {} ", noOfdaysBetween);
|
- |
|
| 4432 |
|
- |
|
| 4433 |
if (noOfdaysBetween <= 4 && noOfdaysBetween >= 0) {
|
- |
|
| 4434 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
- |
|
| 4435 |
double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
|
- |
|
| 4436 |
|
- |
|
| 4437 |
String title = "Alert!";
|
- |
|
| 4438 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
- |
|
| 4439 |
String message = null;
|
- |
|
| 4440 |
if (noOfdaysBetween == 0) {
|
- |
|
| 4441 |
|
- |
|
| 4442 |
message = "Your total outstanding Credit amount is Rs." + FormattingUtils.formatDecimal(Math.abs(amount)) + " is due for Today, Pay Now!!";
|
- |
|
| 4443 |
|
- |
|
| 4444 |
} else {
|
- |
|
| 4445 |
|
4387 |
|
| 4446 |
message = "Your total outstanding Credit amount is Rs." + FormattingUtils.formatDecimal(Math.abs(amount)) + " is due by " + loan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + " , Pay Now!!";
|
4388 |
LOGGER.info("noOfdaysBetween {} ", noOfdaysBetween);
|
| 4447 |
|
4389 |
|
| 4448 |
}
|
4390 |
if (noOfdaysBetween <= 4 && noOfdaysBetween >= 0) {
|
| 4449 |
notificationService.sendNotification(loan.getFofoId(), title, MessageType.notification, title, message, url);
|
4391 |
double amount = loan.getPendingAmount().doubleValue() + loan.getInterestAccrued().doubleValue() - loan.getInterestPaid().doubleValue();
|
| 4450 |
//notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
- |
|
| 4451 |
|
4392 |
|
| - |
|
4393 |
String title = "Alert!";
|
| - |
|
4394 |
String url = "http://app.smartdukaan.com/pages/home/credit";
|
| - |
|
4395 |
String message;
|
| - |
|
4396 |
if (noOfdaysBetween == 0) {
|
| - |
|
4397 |
message = "Your total outstanding Credit amount is Rs." + FormattingUtils.formatDecimal(amount) + " is due for Today, Pay Now!!";
|
| - |
|
4398 |
} else {
|
| - |
|
4399 |
message = "Your total outstanding Credit amount is Rs." + FormattingUtils.formatDecimal(amount) + " is due by " + loan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + " , Pay Now!!";
|
| 4452 |
}
|
4400 |
}
|
| - |
|
4401 |
notificationService.sendNotification(loan.getFofoId(), title, MessageType.notification, title, message, url);
|
| 4453 |
}
|
4402 |
}
|
| 4454 |
}
|
4403 |
}
|
| 4455 |
|
4404 |
|
| 4456 |
}
|
4405 |
}
|
| 4457 |
|
4406 |
|
| Line 5105... |
Line 5054... |
| 5105 |
}
|
5054 |
}
|
| 5106 |
|
5055 |
|
| 5107 |
public void sendLoanAlert(List<Loan> defaultLoans) throws
|
5056 |
public void sendLoanAlert(List<Loan> defaultLoans) throws
|
| 5108 |
Exception {
|
5057 |
Exception {
|
| 5109 |
|
5058 |
|
| 5110 |
List<Integer> categoryIds = Arrays.asList(
|
- |
|
| 5111 |
ProfitMandiConstants.TICKET_CATEGORY_CATEGORY,
|
- |
|
| 5112 |
ProfitMandiConstants.TICKET_CATEGORY_RBM,
|
- |
|
| 5113 |
ProfitMandiConstants.TICKET_CATEGORY_SALES,
|
- |
|
| 5114 |
ProfitMandiConstants.TICKET_CATEGORY_ABM,
|
- |
|
| 5115 |
ProfitMandiConstants.TICKET_CATEGORY_ACCOUNTS,
|
- |
|
| 5116 |
ProfitMandiConstants.TICKET_CATEGORY_BUSINESSINTELLIGENT);
|
- |
|
| 5117 |
|
- |
|
| 5118 |
/*for (Map.Entry<String, Set<Integer>> storeGuyEntry : csService.getAuthUserPartnerIdMappingByCategoryIds(categoryIds, false).entrySet()) {
|
- |
|
| 5119 |
List<Loan> filteredRows = defaultLoans.stream()
|
5059 |
// Sort by lowest dueDate first (most overdue)
|
| 5120 |
.filter(loan -> storeGuyEntry.getValue().contains(loan.getFofoId()))
|
5060 |
defaultLoans.sort(Comparator.comparing(Loan::getDueDate));
|
| 5121 |
.collect(Collectors.toList());
|
- |
|
| 5122 |
|
5061 |
|
| 5123 |
if (!filteredRows.isEmpty()) {
|
- |
|
| 5124 |
for (Loan defaultLoan : filteredRows) {
|
- |
|
| 5125 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(defaultLoan.getId());
|
- |
|
| 5126 |
double amount = loanStatements.stream().map(LoanStatement::getAmount).collect(Collectors.summingDouble(BigDecimal::doubleValue));
|
- |
|
| 5127 |
String messageText = getMessageForDueDateExtend(defaultLoan,amount);
|
- |
|
| 5128 |
// String[] email = new String[]{storeGuyEntry.getKey()};
|
- |
|
| 5129 |
|
- |
|
| 5130 |
sendMailOfHtmlFormat(mailSender, email, messageText, null, subject);
|
- |
|
| 5131 |
|
- |
|
| 5132 |
}
|
- |
|
| 5133 |
}
|
- |
|
| 5134 |
}*/
|
- |
|
| 5135 |
//Send single whatsapp to tv
|
- |
|
| 5136 |
String title = "SD Credit Alert!";
|
5062 |
String title = "SD Credit Alert!";
|
| 5137 |
boolean notYetSent = true;
|
5063 |
int whatsAppCount = 0;
|
| 5138 |
for (Loan defaultLoan : defaultLoans) {
|
5064 |
for (Loan defaultLoan : defaultLoans) {
|
| 5139 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(defaultLoan.getId());
|
5065 |
double principal = defaultLoan.getPendingAmount().doubleValue();
|
| 5140 |
|
- |
|
| 5141 |
double amount = loanStatements.stream().map(LoanStatement::getAmount).collect(Collectors.summingDouble(BigDecimal::doubleValue));
|
5066 |
double interest = defaultLoan.getInterestAccrued().doubleValue() - defaultLoan.getInterestPaid().doubleValue();
|
| - |
|
5067 |
double total = principal + interest;
|
| 5142 |
|
5068 |
|
| 5143 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(defaultLoan.getFofoId());
|
5069 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(defaultLoan.getFofoId());
|
| 5144 |
|
5070 |
|
| 5145 |
Address address = addressRepository.selectById(user.getAddressId());
|
5071 |
Address address = addressRepository.selectById(user.getAddressId());
|
| 5146 |
|
5072 |
|
| 5147 |
//String url = "http://app.smartdukaan.com/pages/home/credit";
|
5073 |
// WhatsApp: only top 2 most overdue loans
|
| 5148 |
|
- |
|
| 5149 |
String message = getMessageForDueDateExtend(defaultLoan, amount);
|
5074 |
if (whatsAppCount < 2) {
|
| 5150 |
String whatsAppMessage = getWhatsAppMessageForDueDateExtend(defaultLoan, amount);
|
5075 |
String whatsAppMessage = getWhatsAppMessageForDefaultLoan(defaultLoan, total, user.getName());
|
| 5151 |
if (whatsAppMessage != null) {
|
- |
|
| 5152 |
notificationService.sendWhatsappMessage(whatsAppMessage, title, address.getPhoneNumber());
|
5076 |
notificationService.sendWhatsappMessage(whatsAppMessage, title, address.getPhoneNumber());
|
| 5153 |
if (notYetSent) {
|
5077 |
whatsAppCount++;
|
| 5154 |
notificationService.sendWhatsappMessage(whatsAppMessage, title, "9911565032");
|
- |
|
| 5155 |
notYetSent = false;
|
- |
|
| 5156 |
}
|
- |
|
| 5157 |
}
|
5078 |
}
|
| 5158 |
|
5079 |
|
| - |
|
5080 |
String emailMessage = getEmailMessageForDefaultLoan(defaultLoan, principal, interest, total, user.getName());
|
| 5159 |
String[] email = {user.getEmailId()};
|
5081 |
String[] email = {user.getEmailId()};
|
| 5160 |
sendMailOfHtmlFormat(mailSender, email, message, null, "Loan Alert - SmartDukaan");
|
5082 |
sendMailOfHtmlFormat(mailSender, email, emailMessage, null, "Loan Alert - SmartDukaan");
|
| 5161 |
}
|
5083 |
}
|
| 5162 |
}
|
5084 |
}
|
| 5163 |
|
5085 |
|
| 5164 |
private String getMessageForDueDateExtend(Loan defaultLoan, double amount) throws ProfitMandiBusinessException {
|
5086 |
private String getEmailMessageForDefaultLoan(Loan loan, double principal, double interest, double total, String name) {
|
| 5165 |
|
- |
|
| 5166 |
double absoluteAmount = Math.abs(amount);
|
- |
|
| 5167 |
long roundedAmount = Math.round(absoluteAmount);
|
5087 |
String formattedTotal = FormattingUtils.formatDecimal(total);
|
| 5168 |
String formattedAmount = (amount < 0) ? "" + roundedAmount : "" + roundedAmount;
|
5088 |
String formattedPrincipal = FormattingUtils.formatDecimal(principal);
|
| 5169 |
|
- |
|
| 5170 |
LocalDate dueDate = defaultLoan.getDueDate().toLocalDate();
|
5089 |
String formattedInterest = FormattingUtils.formatDecimal(interest);
|
| 5171 |
LocalDate defaultDate = defaultLoan.getDueDate().toLocalDate().plusDays(15);
|
5090 |
long daysInDefault = ChronoUnit.DAYS.between(loan.getPenaltyDate(), LocalDate.now());
|
| 5172 |
|
5091 |
|
| 5173 |
// Retrieve the name of the user associated with the loan
|
- |
|
| 5174 |
String name = userUserRepository.selectById(defaultLoan.getFofoId()).getName();
|
- |
|
| 5175 |
|
- |
|
| 5176 |
// Initialize a StringBuilder to construct the HTML message
|
- |
|
| 5177 |
StringBuilder sb = new StringBuilder();
|
5092 |
StringBuilder sb = new StringBuilder();
|
| 5178 |
|
- |
|
| 5179 |
if (LocalDate.now().isBefore(dueDate)) {
|
- |
|
| 5180 |
long noOfdaysBetween = ChronoUnit.DAYS.between(LocalDate.now(), defaultLoan.getDueDate().toLocalDate());
|
- |
|
| 5181 |
String payDate = defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
|
- |
|
| 5182 |
// 5 Days Before Due Date - daily
|
- |
|
| 5183 |
if (noOfdaysBetween <= 5) {
|
5093 |
sb.append("<html><body>");
|
| 5184 |
sb.append("<html><body><p><b>Loan Repayment Alert !</b></p></br><p>Dear " + name + "</p>");
|
- |
|
| 5185 |
sb.append("<p>This is a friendly reminder that your loan payment is due in " + noOfdaysBetween + "days, on " +
|
- |
|
| 5186 |
payDate +
|
- |
|
| 5187 |
". Please ensure that the payment is made on time to avoid any late fees or penalties.</p>");
|
- |
|
| 5188 |
sb.append("<p>As per the terms of your loan agreement, the total amount due is Rs. " + formattedAmount + ". " +
|
- |
|
| 5189 |
"You can make the payment by adding money to your wallet. If you have any questions or need assistance, " +
|
- |
|
| 5190 |
"our customer service team is available to help you.</p>");
|
- |
|
| 5191 |
sb.append("<p>Thank you for your cooperation and prompt attention to this matter.</p></br><p> Smart Dukaan Team !!</p>");
|
- |
|
| 5192 |
}
|
- |
|
| 5193 |
} else if (LocalDate.now().isBefore(defaultDate)) {
|
- |
|
| 5194 |
long noOfdaysBetween = ChronoUnit.DAYS.between(defaultDate, LocalDate.now());
|
- |
|
| 5195 |
|
- |
|
| 5196 |
// After Due Date – Alternate days
|
- |
|
| 5197 |
if ((noOfdaysBetween % 2 == 0) && (noOfdaysBetween > 5)) {
|
- |
|
| 5198 |
sb.append("<html><body><p><b>Loan Repayment Alert !</b></p></br><p>Dear " + name + "</p>");
|
- |
|
| 5199 |
sb.append("<p>We would like to remind you that your payment for the outstanding balance on your account is now overdue. " +
|
- |
|
| 5200 |
"As per our terms and conditions, a higher interest rate will be levied on the overdue amount Rs. " + formattedAmount + ".</p>");
|
- |
|
| 5201 |
sb.append("<p>To avoid further charges and any negative impact on your Credit score, we kindly request that you settle the " +
|
- |
|
| 5202 |
"outstanding balance as soon as possible.</p>");
|
- |
|
| 5203 |
sb.append("<p>Thank you for your attention to this matter.</p></br><p> Smart Dukaan Team !!</p>");
|
- |
|
| 5204 |
}
|
- |
|
| 5205 |
// 5 Days before default - daily
|
- |
|
| 5206 |
if (noOfdaysBetween <= 5) {
|
- |
|
| 5207 |
sb.append("<html><body><p><b>Loan Repayment Alert !</b></p></br>");
|
5094 |
sb.append("<p><b>Credit Default Alert!</b></p><br/>");
|
| 5208 |
sb.append("<p>Attention: High Alert</p>");
|
- |
|
| 5209 |
sb.append("<p>Dear " + name + "</p>");
|
5095 |
sb.append("<p>Dear " + name + ",</p>");
|
| 5210 |
sb.append("<p>This is to inform you that the due date for your payment of Rs. " + formattedAmount + " has been crossed, " +
|
- |
|
| 5211 |
"and you are approaching the default date on " + defaultDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + ". " +
|
- |
|
| 5212 |
"Please be aware that this will have a significant impact on your Credit score and may result in substantial penalties as well.</p>");
|
- |
|
| 5213 |
sb.append("<p>To rectify this situation, it is imperative that you take immediate action. " +
|
5096 |
sb.append("<p>Your credit payment has been in default for " + daysInDefault + " days. " +
|
| 5214 |
"Please make the necessary payment immediately to avoid further consequences.</p>");
|
5097 |
"A penalty interest of " + ProfitMandiConstants.NEW_DELAYED_INTEREST_RATE + "% per day is being charged.</p>");
|
| 5215 |
sb.append("<p>Thank you for your attention to this matter.</p></br><p> Smart Dukaan Team !!</p>");
|
5098 |
sb.append("<p><b>Total Outstanding: Rs. " + formattedTotal + "</b><br/>");
|
| 5216 |
}
|
- |
|
| 5217 |
} else {
|
- |
|
| 5218 |
// Post Default - Daily
|
- |
|
| 5219 |
sb.append("<html><body><p><b>Loan Repayment Alert !</b></p></br><p>Dear " + name + "</p>");
|
5099 |
sb.append("Principal: Rs. " + formattedPrincipal + "<br/>");
|
| 5220 |
sb.append("<p>We regret to inform you that you are currently in loan default. As a result, " +
|
5100 |
sb.append("Interest: Rs. " + formattedInterest + "</p>");
|
| 5221 |
"higher penalties are being charged, which is also negatively impacting your Credit score. " +
|
- |
|
| 5222 |
"It is imperative that you make an immediate payment to rectify this situation.</p>");
|
- |
|
| 5223 |
sb.append("<p>Please note that failing to make the payment promptly will result in further consequences, " +
|
5101 |
sb.append("<p>Continued default will impact your Credit score and may result in legal action. " +
|
| 5224 |
"including potential legal action and additional financial penalties. " +
|
- |
|
| 5225 |
"We strongly urge you to take this matter seriously and settle the outstanding amount as soon as possible.</p>");
|
5102 |
"Please settle the outstanding amount immediately.</p>");
|
| 5226 |
sb.append("<p>To make the payment, please add Rs. " + formattedAmount + " to your wallet. We are here to help you resolve this issue and get back on track.</p>");
|
5103 |
sb.append("<p>To make the payment, please add Rs. " + formattedTotal + " to your wallet.</p>");
|
| 5227 |
sb.append("<p>Thank you for your attention to this matter.</p></br><p> Smart Dukaan Team !!</p>");
|
- |
|
| 5228 |
|
- |
|
| 5229 |
}
|
- |
|
| 5230 |
|
- |
|
| 5231 |
// Return the constructed HTML message
|
5104 |
sb.append("<p>Team SmartDukaan</p>");
|
| 5232 |
sb.append("</body></html>");
|
5105 |
sb.append("</body></html>");
|
| 5233 |
return sb.toString();
|
5106 |
return sb.toString();
|
| 5234 |
}
|
5107 |
}
|
| 5235 |
|
5108 |
|
| 5236 |
private String getWhatsAppMessageForDueDateExtend(Loan defaultLoan, double amount) throws
|
5109 |
private String getWhatsAppMessageForDefaultLoan(Loan loan, double total, String name) {
|
| 5237 |
ProfitMandiBusinessException {
|
- |
|
| 5238 |
|
- |
|
| 5239 |
double absoluteAmount = Math.abs(amount);
|
- |
|
| 5240 |
long roundedAmount = Math.round(absoluteAmount);
|
5110 |
String formattedAmount = FormattingUtils.formatDecimal(total);
|
| 5241 |
String formattedAmount = (amount < 0) ? "" + roundedAmount : "" + roundedAmount;
|
- |
|
| 5242 |
|
- |
|
| 5243 |
LocalDate dueDate = defaultLoan.getDueDate().toLocalDate();
|
- |
|
| 5244 |
LocalDate defaultDate = defaultLoan.getDueDate().toLocalDate().plusDays(15);
|
- |
|
| 5245 |
|
- |
|
| 5246 |
// Retrieve the name of the user associated with the loan
|
- |
|
| 5247 |
String name = userUserRepository.selectById(defaultLoan.getFofoId()).getName();
|
- |
|
| 5248 |
|
- |
|
| 5249 |
// Initialize a StringBuilder to construct the HTML message
|
- |
|
| 5250 |
String message = null;
|
- |
|
| 5251 |
|
- |
|
| 5252 |
if (LocalDate.now().isBefore(dueDate)) {
|
- |
|
| 5253 |
long noOfdaysBetween = ChronoUnit.DAYS.between(LocalDate.now(), defaultLoan.getDueDate().toLocalDate());
|
5111 |
long daysInDefault = ChronoUnit.DAYS.between(loan.getPenaltyDate(), LocalDate.now());
|
| 5254 |
String payDate = defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
|
- |
|
| 5255 |
// 5 Days Before Due Date - daily
|
- |
|
| 5256 |
if (noOfdaysBetween <= 5) {
|
- |
|
| 5257 |
|
5112 |
|
| 5258 |
message = "Dear %s, This is a friendly reminder that your outstanding credit payment is due in %d days, on %s.\n" +
|
- |
|
| 5259 |
"\n" +
|
- |
|
| 5260 |
"Please ensure that the payment is made on time to avoid any late fees or penalties.As per the terms of your loan agreement, the total amount due is Rs. %s. You can make the payment by adding money to wallet.\n" +
|
- |
|
| 5261 |
"\n" +
|
5113 |
return String.format(
|
| 5262 |
"If you have any questions or need assistance, our customer service team is available to help you.\n" +
|
- |
|
| 5263 |
"Thank you for your cooperation and prompt attention to this matter.\n" +
|
5114 |
"Dear %s, Your credit payment has been in default for %d days. " +
|
| 5264 |
"\n" +
|
- |
|
| 5265 |
"Team SmartDukaan";
|
- |
|
| 5266 |
message = String.format(message, name, noOfdaysBetween, payDate, formattedAmount);
|
- |
|
| 5267 |
}
|
- |
|
| 5268 |
} else if (LocalDate.now().isBefore(defaultDate)) {
|
- |
|
| 5269 |
long noOfdaysBetween = ChronoUnit.DAYS.between(defaultDate, LocalDate.now());
|
- |
|
| 5270 |
// After Due Date – Alternate days
|
- |
|
| 5271 |
if ((noOfdaysBetween % 2 == 0) && (noOfdaysBetween > 5)) {
|
- |
|
| 5272 |
message = "Dear %s, We would like to remind you that your payment for the outstanding balance on your account is now overdue. \n" +
|
- |
|
| 5273 |
"As per our terms and conditions, a higher interest rate will be levied on the overdue amount Rs.%s.\n" +
|
5115 |
"A penalty interest of %s%% per day is being charged on your outstanding amount of Rs. %s. " +
|
| 5274 |
"To avoid further charges and any negative impact on your Credit ratings, we kindly request that you settle the outstanding balance as soon as possible.\n" +
|
- |
|
| 5275 |
"Thank you for your attention to this matter. \n" +
|
5116 |
"Please settle immediately to avoid legal action.\n\nTeam SmartDukaan",
|
| 5276 |
"\n" +
|
- |
|
| 5277 |
"Team SmartDukaan";
|
- |
|
| 5278 |
message = String.format(message, name, formattedAmount);
|
5117 |
name, daysInDefault, ProfitMandiConstants.NEW_DELAYED_INTEREST_RATE, formattedAmount);
|
| 5279 |
}
|
- |
|
| 5280 |
// 5 Days before default - daily
|
- |
|
| 5281 |
if (noOfdaysBetween <= 5) {
|
- |
|
| 5282 |
String defaultPayDate = defaultDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
|
- |
|
| 5283 |
message = "Attention: High Alert!! Dear %s, \n" +
|
- |
|
| 5284 |
"\n" +
|
- |
|
| 5285 |
"This is to inform you that the due date for your payment of Rs. %s has been crossed, and as a result, you are now about to reach default date %s.\n" +
|
- |
|
| 5286 |
"Please be aware that this will have a significant impact on your Credit score and may result in substantial penalties as well. To rectify this situation, it is imperative that you take immediate action.\n" +
|
- |
|
| 5287 |
"\n" +
|
- |
|
| 5288 |
"Please make the necessary payment immediately to avoid further consequences. Thank you for your attention to this matter.\n" +
|
- |
|
| 5289 |
"\n" +
|
- |
|
| 5290 |
"Team SmartDukaan";
|
- |
|
| 5291 |
message = String.format(message, name, formattedAmount, defaultPayDate);
|
- |
|
| 5292 |
}
|
- |
|
| 5293 |
} else {
|
- |
|
| 5294 |
// Post Default - Daily
|
- |
|
| 5295 |
message = "Dear %s, We regret to inform you that you are currently in Credit default. As a result, higher penalties are being charged, which is also negatively impacting your Credit score. \n" +
|
- |
|
| 5296 |
"\n" +
|
- |
|
| 5297 |
"It is imperative that you make an immediate payment to rectify this situation. \n" +
|
- |
|
| 5298 |
"\n" +
|
- |
|
| 5299 |
"Please note that failing to make the payment promptly will result in further consequences, including potential legal action and additional financial penalties. \n" +
|
- |
|
| 5300 |
"\n" +
|
- |
|
| 5301 |
"We strongly urge you to take this matter seriously and settle the outstanding amount as soon as possible. \n" +
|
- |
|
| 5302 |
"\n" +
|
- |
|
| 5303 |
"To make the payment, please add Rs. %s to wallet. We are here to help you resolve this issue and get back on track. Thank you for your attention to this matter. \n" +
|
- |
|
| 5304 |
"\n" +
|
- |
|
| 5305 |
"Team SmartDukaan";
|
- |
|
| 5306 |
message = String.format(message, name, formattedAmount);
|
- |
|
| 5307 |
|
- |
|
| 5308 |
}
|
- |
|
| 5309 |
// Return the constructed HTML message
|
- |
|
| 5310 |
return message;
|
- |
|
| 5311 |
}
|
5118 |
}
|
| 5312 |
|
5119 |
|
| 5313 |
@Autowired
|
5120 |
@Autowired
|
| 5314 |
private FofoOpeningStockRepository fofoOpeningStockRepository;
|
5121 |
private FofoOpeningStockRepository fofoOpeningStockRepository;
|
| 5315 |
@Autowired
|
5122 |
@Autowired
|