| Line 234... |
Line 234... |
| 234 |
private Map<String, Object> getSales(int fofoId) {
|
234 |
private Map<String, Object> getSales(int fofoId) {
|
| 235 |
|
235 |
|
| 236 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
236 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
| 237 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
237 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 238 |
int monthLength = LocalDate.now().lengthOfMonth();
|
238 |
int monthLength = LocalDate.now().lengthOfMonth();
|
| 239 |
float todaySale = fofoOrderItemRepository.selectSumBetweenCreatedTime(fofoId, curDate,
|
239 |
Float todaySale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate, curDate.with(LocalTime.MAX),
|
| 240 |
curDate.with(LocalTime.MAX));
|
240 |
fofoId, false).get(fofoId);
|
| 241 |
float mtdSale = fofoOrderItemRepository.selectSumBetweenCreatedTime(fofoId, curDate.withDayOfMonth(1),
|
241 |
Float mtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1),
|
| 242 |
curDate.with(LocalTime.MAX));
|
242 |
curDate.with(LocalTime.MAX), fofoId, false).get(fofoId);
|
| 243 |
float lmtdSale = fofoOrderItemRepository.selectSumBetweenCreatedTime(fofoId,
|
243 |
Float lmtdSale = fofoOrderItemRepository.selectSumAmountGroupByRetailer(curDate.withDayOfMonth(1).minusMonths(1),
|
| 244 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1));
|
244 |
curDate.with(LocalTime.MAX).minusMonths(1), fofoId, false).get(fofoId);
|
| 245 |
|
245 |
|
| 246 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
246 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
| 247 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
247 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
| 248 |
if (partnerTargetDetails.isEmpty()) {
|
248 |
if (partnerTargetDetails.isEmpty()) {
|
| 249 |
partnerTargetDetails = partnerTargetRepository
|
249 |
partnerTargetDetails = partnerTargetRepository
|
| Line 258... |
Line 258... |
| 258 |
float reqdAmount = partnerTypeChangeService.getMinimumAmount(partnerType.next());
|
258 |
float reqdAmount = partnerTypeChangeService.getMinimumAmount(partnerType.next());
|
| 259 |
int requiredRate = (int) ((reqdAmount - mtdSale) / (monthLength - curDate.getDayOfMonth()));
|
259 |
int requiredRate = (int) ((reqdAmount - mtdSale) / (monthLength - curDate.getDayOfMonth()));
|
| 260 |
salesMap.put("requiredRate", requiredRate);
|
260 |
salesMap.put("requiredRate", requiredRate);
|
| 261 |
salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
|
261 |
salesMap.put("requiredTypeImage", PartnerType.imageMap.get(partnerType.next()));
|
| 262 |
|
262 |
|
| 263 |
salesMap.put("todaySale", todaySale);
|
263 |
salesMap.put("todaySale", todaySale == null ? 0 : todaySale);
|
| 264 |
salesMap.put("mtdSale", mtdSale);
|
264 |
salesMap.put("mtdSale", mtdSale == null ? 0 : mtdSale);
|
| 265 |
salesMap.put("lmtdSale", lmtdSale);
|
265 |
salesMap.put("lmtdSale", lmtdSale == null ? 0 : lmtdSale);
|
| 266 |
|
266 |
|
| 267 |
PartnerType currentType = partnerTypeChangeService.getPartnerTypeByAmount(currentRate * monthLength);
|
267 |
PartnerType currentType = partnerTypeChangeService.getPartnerTypeByAmount(currentRate * monthLength);
|
| 268 |
salesMap.put("currentRate", currentRate);
|
268 |
salesMap.put("currentRate", currentRate);
|
| 269 |
salesMap.put("currentType", currentType);
|
269 |
salesMap.put("currentType", currentType);
|
| 270 |
salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
|
270 |
salesMap.put("currentTypeImage", PartnerType.imageMap.get(currentType));
|