| Line 147... |
Line 147... |
| 147 |
|
147 |
|
| 148 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
|
148 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
|
| 149 |
|
149 |
|
| 150 |
Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
150 |
Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 151 |
Map<Integer, com.spice.profitmandi.dao.model.BulkCreditSummary> summaryMap = sdCreditService.getCreditSummaryBulk();
|
151 |
Map<Integer, com.spice.profitmandi.dao.model.BulkCreditSummary> summaryMap = sdCreditService.getCreditSummaryBulk();
|
| - |
|
152 |
|
| - |
|
153 |
// Display-only, deliberately NOT written back onto the entity.
|
| - |
|
154 |
//
|
| - |
|
155 |
// selectAll() returns MANAGED entities and this controller is @Transactional (not
|
| - |
|
156 |
// readOnly), so calling setUtilizedAmount() here was dirty-checked and flushed as an
|
| - |
|
157 |
// UPDATE per partner at commit — merely opening this page rewrote utilized_amount for
|
| - |
|
158 |
// every partner, racing the cron that owns the column. Available limit is derived from
|
| - |
|
159 |
// the same figure (limit - utilized), so it is computed here too rather than read off
|
| - |
|
160 |
// the entity.
|
| - |
|
161 |
Map<Integer, BigDecimal> utilizedAmountMap = new HashMap<>();
|
| - |
|
162 |
Map<Integer, BigDecimal> availableLimitMap = new HashMap<>();
|
| 152 |
for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
|
163 |
for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
|
| 153 |
int fofoId = customRetailerEntry.getKey();
|
164 |
int fofoId = customRetailerEntry.getKey();
|
| 154 |
|
165 |
|
| 155 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementMap.get(fofoId);
|
166 |
SDCreditRequirement sdCreditRequirement = sdCreditRequirementMap.get(fofoId);
|
| 156 |
|
167 |
|
| 157 |
if (sdCreditRequirement != null) {
|
168 |
if (sdCreditRequirement != null) {
|
| 158 |
com.spice.profitmandi.dao.model.BulkCreditSummary bulk = summaryMap.get(fofoId);
|
169 |
com.spice.profitmandi.dao.model.BulkCreditSummary bulk = summaryMap.get(fofoId);
|
| 159 |
BigDecimal utilizedLimit = bulk != null ? bulk.getUtilization() : BigDecimal.ZERO;
|
170 |
BigDecimal utilizedLimit = bulk != null ? bulk.getUtilization() : BigDecimal.ZERO;
|
| - |
|
171 |
utilizedAmountMap.put(fofoId, utilizedLimit);
|
| 160 |
sdCreditRequirement.setUtilizedAmount(utilizedLimit);
|
172 |
if (sdCreditRequirement.getLimit() != null) {
|
| - |
|
173 |
availableLimitMap.put(fofoId, sdCreditRequirement.getLimit().subtract(utilizedLimit));
|
| - |
|
174 |
}
|
| 161 |
}
|
175 |
}
|
| 162 |
|
176 |
|
| 163 |
}
|
177 |
}
|
| 164 |
|
178 |
|
| 165 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
179 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| 166 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
180 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
| - |
|
181 |
model.addAttribute("utilizedAmountMap", utilizedAmountMap);
|
| - |
|
182 |
model.addAttribute("availableLimitMap", availableLimitMap);
|
| 167 |
model.addAttribute("isTarun", isTarun);
|
183 |
model.addAttribute("isTarun", isTarun);
|
| 168 |
return "sd-credit";
|
184 |
return "sd-credit";
|
| 169 |
}
|
185 |
}
|
| 170 |
|
186 |
|
| 171 |
@RequestMapping(value = "/creditRequirement", method = RequestMethod.POST)
|
187 |
@RequestMapping(value = "/creditRequirement", method = RequestMethod.POST)
|