| Line 124... |
Line 124... |
| 124 |
boolean limitChanged = suggestedAmount.compareTo(existing.getSuggestedLimit()) != 0;
|
124 |
boolean limitChanged = suggestedAmount.compareTo(existing.getSuggestedLimit()) != 0;
|
| 125 |
boolean utilizationChanged = utilizationAmount.compareTo(existing.getUtilizedAmount()) != 0;
|
125 |
boolean utilizationChanged = utilizationAmount.compareTo(existing.getUtilizedAmount()) != 0;
|
| 126 |
boolean riskChanged = !newRisk.equals(existing.getRisk());
|
126 |
boolean riskChanged = !newRisk.equals(existing.getRisk());
|
| 127 |
|
127 |
|
| 128 |
if (limitChanged || utilizationChanged || riskChanged) {
|
128 |
if (limitChanged || utilizationChanged || riskChanged) {
|
| 129 |
LOGGER.info("fofoId={} changed: limit {}→{}, util {}→{}, risk {}→{}",
|
129 |
LOGGER.info("fofoId={} changed: limit {}→{}, util {}→{}, risk {}→{}, agedAppleStock={}",
|
| 130 |
fofoId,
|
130 |
fofoId,
|
| 131 |
existing.getSuggestedLimit(), suggestedAmount,
|
131 |
existing.getSuggestedLimit(), suggestedAmount,
|
| 132 |
existing.getUtilizedAmount(), utilizationAmount,
|
132 |
existing.getUtilizedAmount(), utilizationAmount,
|
| 133 |
existing.getRisk(), newRisk);
|
133 |
existing.getRisk(), newRisk,
|
| - |
|
134 |
partnerDailyInvestment != null ? partnerDailyInvestment.getAgedAppleStockAmount() : 0);
|
| 134 |
changedPartners.add(new PartnerLimitUpdateData(
|
135 |
changedPartners.add(new PartnerLimitUpdateData(
|
| 135 |
fofoId, suggestedAmount, utilizationAmount, newAvailable, newRisk, false));
|
136 |
fofoId, suggestedAmount, utilizationAmount, newAvailable, newRisk, false));
|
| 136 |
}
|
137 |
}
|
| 137 |
} catch (Exception e) {
|
138 |
} catch (Exception e) {
|
| 138 |
LOGGER.error("Partner limit calc failed for fofoId={}, skipping: {}", fofoId, e.getMessage());
|
139 |
LOGGER.error("Partner limit calc failed for fofoId={}, skipping: {}", fofoId, e.getMessage());
|
| Line 196... |
Line 197... |
| 196 |
BigDecimal utilizationAmount, BigDecimal sidbiLimit) {
|
197 |
BigDecimal utilizationAmount, BigDecimal sidbiLimit) {
|
| 197 |
BigDecimal suggestedAmount = BigDecimal.ZERO;
|
198 |
BigDecimal suggestedAmount = BigDecimal.ZERO;
|
| 198 |
double utilization = utilizationAmount != null ? utilizationAmount.doubleValue() : 0;
|
199 |
double utilization = utilizationAmount != null ? utilizationAmount.doubleValue() : 0;
|
| 199 |
if (creditAccount == null || creditAccount.getGateway().equals(Gateway.SDDIRECT)) {
|
200 |
if (creditAccount == null || creditAccount.getGateway().equals(Gateway.SDDIRECT)) {
|
| 200 |
if (partnerDailyInvestment != null) {
|
201 |
if (partnerDailyInvestment != null) {
|
| - |
|
202 |
double creditableInvestment = getCreditableInvestment(partnerDailyInvestment);
|
| 201 |
if (hundredPercentLimitPartnerIds.contains(partnerDailyInvestment.getFofoId())) {
|
203 |
if (hundredPercentLimitPartnerIds.contains(partnerDailyInvestment.getFofoId())) {
|
| 202 |
suggestedAmount = BigDecimal.valueOf((partnerDailyInvestment.getTotalInvestment() - utilization) * 1);
|
204 |
suggestedAmount = BigDecimal.valueOf((creditableInvestment - utilization) * 1);
|
| 203 |
suggestedAmount = suggestedAmount.min(FIFTEEN_LAC);
|
205 |
suggestedAmount = suggestedAmount.min(FIFTEEN_LAC);
|
| 204 |
} else {
|
206 |
} else {
|
| 205 |
suggestedAmount = getSuggestedLimit(partnerDailyInvestment.getTotalInvestment() - utilization);
|
207 |
suggestedAmount = getSuggestedLimit(creditableInvestment - utilization);
|
| 206 |
}
|
208 |
}
|
| 207 |
}
|
209 |
}
|
| 208 |
if (suggestedAmount.doubleValue() < 0) {
|
210 |
if (suggestedAmount.doubleValue() < 0) {
|
| 209 |
suggestedAmount = BigDecimal.ZERO;
|
211 |
suggestedAmount = BigDecimal.ZERO;
|
| 210 |
}
|
212 |
}
|
| 211 |
} else if (creditAccount.getGateway().equals(Gateway.SIDBI) && sidbiLimit != null) {
|
213 |
} else if (creditAccount.getGateway().equals(Gateway.SIDBI) && sidbiLimit != null) {
|
| 212 |
suggestedAmount = getSuggestedLimit(partnerDailyInvestment.getTotalInvestment() - utilization);
|
214 |
suggestedAmount = getSuggestedLimit(getCreditableInvestment(partnerDailyInvestment) - utilization);
|
| 213 |
suggestedAmount = suggestedAmount.max(sidbiLimit);
|
215 |
suggestedAmount = suggestedAmount.max(sidbiLimit);
|
| 214 |
}
|
216 |
}
|
| 215 |
return suggestedAmount;
|
217 |
return suggestedAmount;
|
| 216 |
}
|
218 |
}
|
| 217 |
|
219 |
|
| - |
|
220 |
/**
|
| - |
|
221 |
* Investment that counts toward a suggested limit: total investment less the value of Apple
|
| - |
|
222 |
* handsets the partner has held beyond {@link ProfitMandiConstants#AGED_STOCK_APPLE_DAYS} days
|
| - |
|
223 |
* from GRN.
|
| - |
|
224 |
*
|
| - |
|
225 |
* The haircut is applied here only. PartnerDailyInvestment.getTotalInvestment() is deliberately
|
| - |
|
226 |
* left alone, so stock value is unchanged for checkout payment options, the investment-OK gates
|
| - |
|
227 |
* and every partner-facing screen — this is a credit-limit policy, not a change to what the
|
| - |
|
228 |
* stock is worth.
|
| - |
|
229 |
*/
|
| - |
|
230 |
private double getCreditableInvestment(PartnerDailyInvestment partnerDailyInvestment) {
|
| - |
|
231 |
return partnerDailyInvestment.getTotalInvestment() - partnerDailyInvestment.getAgedAppleStockAmount();
|
| - |
|
232 |
}
|
| - |
|
233 |
|
| 218 |
private BigDecimal getSuggestedLimit(double investmentValue) {
|
234 |
private BigDecimal getSuggestedLimit(double investmentValue) {
|
| 219 |
double percentageValue = discountMap.ceilingEntry(investmentValue).getValue();
|
235 |
double percentageValue = discountMap.ceilingEntry(investmentValue).getValue();
|
| 220 |
return BigDecimal.valueOf(investmentValue * percentageValue).min(FIFTEEN_LAC);
|
236 |
return BigDecimal.valueOf(investmentValue * percentageValue).min(FIFTEEN_LAC);
|
| 221 |
}
|
237 |
}
|
| 222 |
}
|
238 |
}
|