| Line 5... |
Line 5... |
| 5 |
import java.io.InputStream;
|
5 |
import java.io.InputStream;
|
| 6 |
import java.time.LocalDate;
|
6 |
import java.time.LocalDate;
|
| 7 |
import java.time.LocalDateTime;
|
7 |
import java.time.LocalDateTime;
|
| 8 |
import java.time.LocalTime;
|
8 |
import java.time.LocalTime;
|
| 9 |
import java.time.Month;
|
9 |
import java.time.Month;
|
| - |
|
10 |
import java.time.YearMonth;
|
| 10 |
import java.util.ArrayList;
|
11 |
import java.util.ArrayList;
|
| 11 |
import java.util.Arrays;
|
12 |
import java.util.Arrays;
|
| 12 |
import java.util.HashMap;
|
13 |
import java.util.HashMap;
|
| 13 |
import java.util.HashSet;
|
14 |
import java.util.HashSet;
|
| 14 |
import java.util.List;
|
15 |
import java.util.List;
|
| Line 106... |
Line 107... |
| 106 |
@Autowired
|
107 |
@Autowired
|
| 107 |
private StateGstRateRepository stateGstRateRepository;
|
108 |
private StateGstRateRepository stateGstRateRepository;
|
| 108 |
|
109 |
|
| 109 |
@Autowired
|
110 |
@Autowired
|
| 110 |
private ItemRepository itemRepository;
|
111 |
private ItemRepository itemRepository;
|
| 111 |
|
- |
|
| 112 |
|
112 |
|
| 113 |
@Autowired
|
113 |
@Autowired
|
| 114 |
private ReporticoService reporticoService;
|
114 |
private ReporticoService reporticoService;
|
| 115 |
|
115 |
|
| 116 |
@Autowired
|
116 |
@Autowired
|
| 117 |
private SchemeRepository schemeRepository;
|
117 |
private SchemeRepository schemeRepository;
|
| Line 144... |
Line 144... |
| 144 |
@Autowired
|
144 |
@Autowired
|
| 145 |
private RetailerService retailerService;
|
145 |
private RetailerService retailerService;
|
| 146 |
|
146 |
|
| 147 |
@Autowired
|
147 |
@Autowired
|
| 148 |
private Mongo mongoClient;
|
148 |
private Mongo mongoClient;
|
| 149 |
|
149 |
|
| 150 |
@Autowired
|
150 |
@Autowired
|
| 151 |
WalletService walletService;
|
151 |
WalletService walletService;
|
| 152 |
|
152 |
|
| 153 |
@Autowired
|
153 |
@Autowired
|
| 154 |
PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
154 |
PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| 155 |
|
155 |
|
| 156 |
|
- |
|
| 157 |
@Autowired
|
156 |
@Autowired
|
| 158 |
private PartnerTypeChangeService partnerTypeChangeService;
|
157 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| 159 |
|
158 |
|
| 160 |
@Autowired
|
159 |
@Autowired
|
| 161 |
InventoryItemRepository inventoryItemRepository;
|
160 |
InventoryItemRepository inventoryItemRepository;
|
| Line 169... |
Line 168... |
| 169 |
@Autowired
|
168 |
@Autowired
|
| 170 |
SchemeInOutRepository schemeInOutRepository;
|
169 |
SchemeInOutRepository schemeInOutRepository;
|
| 171 |
|
170 |
|
| 172 |
@RequestMapping(value = "/createScheme", method = RequestMethod.GET)
|
171 |
@RequestMapping(value = "/createScheme", method = RequestMethod.GET)
|
| 173 |
public String createScheme(HttpServletRequest request, Model model) {
|
172 |
public String createScheme(HttpServletRequest request, Model model) {
|
| 174 |
|
173 |
|
| 175 |
LocalDate currentdate = LocalDate.now();
|
174 |
LocalDate currentdate = LocalDate.now();
|
| 176 |
Month month = currentdate.getMonth().minus(1);
|
175 |
Month month = currentdate.getMonth().minus(1);
|
| 177 |
model.addAttribute("month", month);
|
176 |
model.addAttribute("month", month);
|
| 178 |
|
177 |
|
| 179 |
// Map<Integer, String> itemIdItemDescriptionMap =
|
178 |
// Map<Integer, String> itemIdItemDescriptionMap =
|
| 180 |
// inventoryService.getAllItemIdItemDescriptionMap();
|
179 |
// inventoryService.getAllItemIdItemDescriptionMap();
|
| 181 |
// model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
180 |
// model.addAttribute("itemIdItemDescriptionMap", itemIdItemDescriptionMap);
|
| 182 |
Set<String> brands = inventoryService.getAllTagListingBrands(ProfitMandiConstants.MOBILE_CATEGORY_ID);
|
181 |
Set<String> brands = inventoryService.getAllTagListingBrands(ProfitMandiConstants.MOBILE_CATEGORY_ID);
|
| 183 |
brands.addAll(inventoryService.getAllTagListingBrands(14206));
|
182 |
brands.addAll(inventoryService.getAllTagListingBrands(14206));
|
| 184 |
model.addAttribute("brands", brands);
|
183 |
model.addAttribute("brands", brands);
|
| 185 |
model.addAttribute("retailerTypes", PartnerType.values());
|
184 |
model.addAttribute("retailerTypes", PartnerType.values());
|
| 186 |
return "create-scheme";
|
185 |
return "create-scheme";
|
| 187 |
}
|
186 |
}
|
| 188 |
|
- |
|
| 189 |
|
- |
|
| 190 |
|
187 |
|
| 191 |
@RequestMapping(value = "/getTagListingItemsByBrand", method = RequestMethod.POST)
|
188 |
@RequestMapping(value = "/getTagListingItemsByBrand", method = RequestMethod.POST)
|
| 192 |
public String getTagListingItemsByBrand(HttpServletRequest request, @RequestBody List<String> brands, Model model) {
|
189 |
public String getTagListingItemsByBrand(HttpServletRequest request, @RequestBody List<String> brands, Model model) {
|
| 193 |
Map<Integer, String> itemIdItemDescriptionMap = new HashMap<>();
|
190 |
Map<Integer, String> itemIdItemDescriptionMap = new HashMap<>();
|
| 194 |
LOGGER.info("brands" + brands);
|
191 |
LOGGER.info("brands" + brands);
|
| Line 210... |
Line 207... |
| 210 |
if (!roleManager.isAdmin(loginDetails.getRoleIds())) {
|
207 |
if (!roleManager.isAdmin(loginDetails.getRoleIds())) {
|
| 211 |
throw new ProfitMandiBusinessException("User", loginDetails.getEmailId(), "Unauthorised access");
|
208 |
throw new ProfitMandiBusinessException("User", loginDetails.getEmailId(), "Unauthorised access");
|
| 212 |
}
|
209 |
}
|
| 213 |
return "update-schemes-page";
|
210 |
return "update-schemes-page";
|
| 214 |
}
|
211 |
}
|
| 215 |
|
- |
|
| 216 |
|
212 |
|
| 217 |
@RequestMapping(value = "/payMonthlyInvestment", method = RequestMethod.POST)
|
213 |
@RequestMapping(value = "/payMonthlyInvestment", method = RequestMethod.POST)
|
| 218 |
public void payMonthlyInvestment(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
214 |
public void payMonthlyInvestment(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 219 |
|
215 |
|
| 220 |
LocalDate firstDateOfCurrentMonth = LocalDateTime.now().withDayOfMonth(1).toLocalDate();
|
216 |
LocalDate firstDateOfCurrentMonth = LocalDateTime.now().withDayOfMonth(1).toLocalDate();
|
| 221 |
LocalDate startOfPreviousMonth = firstDateOfCurrentMonth.minusMonths(1);
|
217 |
LocalDate startOfPreviousMonth = firstDateOfCurrentMonth.minusMonths(1);
|
| 222 |
int referenceId = Integer.parseInt(FormattingUtils.getYearMonth(startOfPreviousMonth.atStartOfDay()));
|
218 |
int referenceId = Integer.parseInt(FormattingUtils.getYearMonth(startOfPreviousMonth.atStartOfDay()));
|
| 223 |
LocalDate lastOfPreviousMonth = firstDateOfCurrentMonth.minusDays(1);
|
219 |
LocalDate lastOfPreviousMonth = firstDateOfCurrentMonth.minusDays(1);
|
| 224 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
220 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
| Line 227... |
Line 223... |
| 227 |
.filter(x -> x.getShortPercentage() <= 10)
|
223 |
.filter(x -> x.getShortPercentage() <= 10)
|
| 228 |
.collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.counting()));
|
224 |
.collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.counting()));
|
| 229 |
LOGGER.info("investmentMaintainedDaysMap {}", investmentMaintainedDaysMap);
|
225 |
LOGGER.info("investmentMaintainedDaysMap {}", investmentMaintainedDaysMap);
|
| 230 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectAllPending(SchemeType.INVESTMENT,
|
226 |
List<SchemeInOut> schemeInOuts = schemeInOutRepository.selectAllPending(SchemeType.INVESTMENT,
|
| 231 |
startOfPreviousMonth.atStartOfDay(), firstDateOfCurrentMonth.atStartOfDay());
|
227 |
startOfPreviousMonth.atStartOfDay(), firstDateOfCurrentMonth.atStartOfDay());
|
| 232 |
|
228 |
|
| 233 |
if(schemeInOuts.isEmpty())
|
229 |
if (schemeInOuts.isEmpty()) {
|
| 234 |
{
|
- |
|
| 235 |
throw new ProfitMandiBusinessException("Investment Payout", "",
|
230 |
throw new ProfitMandiBusinessException("Investment Payout", "", "No data Found");
|
| 236 |
"No data Found");
|
- |
|
| 237 |
}
|
231 |
}
|
| 238 |
|
232 |
|
| 239 |
Map<Integer, List<SchemeInOut>> inventoryItemIdSchemeMap = schemeInOuts.stream()
|
233 |
Map<Integer, List<SchemeInOut>> inventoryItemIdSchemeMap = schemeInOuts.stream()
|
| 240 |
.collect(Collectors.groupingBy(x -> x.getInventoryItemId()));
|
234 |
.collect(Collectors.groupingBy(x -> x.getInventoryItemId()));
|
| 241 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByIds(inventoryItemIdSchemeMap.keySet());
|
235 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByIds(inventoryItemIdSchemeMap.keySet());
|
| 242 |
Map<Integer, List<Integer>> retailerInventoryItemIdMap = inventoryItems.stream().collect(
|
236 |
Map<Integer, List<Integer>> retailerInventoryItemIdMap = inventoryItems.stream().collect(
|
| 243 |
Collectors.groupingBy(x -> x.getFofoId(), Collectors.mapping(x -> x.getId(), Collectors.toList())));
|
237 |
Collectors.groupingBy(x -> x.getFofoId(), Collectors.mapping(x -> x.getId(), Collectors.toList())));
|
| Line 248... |
Line 242... |
| 248 |
: investmentMaintainedDaysMap.get(fofoId);
|
242 |
: investmentMaintainedDaysMap.get(fofoId);
|
| 249 |
|
243 |
|
| 250 |
List<SchemeInOut> schemeInouts = retailerEntry.getValue().stream().map(x -> inventoryItemIdSchemeMap.get(x))
|
244 |
List<SchemeInOut> schemeInouts = retailerEntry.getValue().stream().map(x -> inventoryItemIdSchemeMap.get(x))
|
| 251 |
.flatMap(List::stream).filter(x -> x.getRolledBackTimestamp() == null).collect(Collectors.toList());
|
245 |
.flatMap(List::stream).filter(x -> x.getRolledBackTimestamp() == null).collect(Collectors.toList());
|
| 252 |
float totalAmount = 0;
|
246 |
float totalAmount = 0;
|
| 253 |
for(SchemeInOut sio : schemeInouts) {
|
247 |
for (SchemeInOut sio : schemeInouts) {
|
| 254 |
|
248 |
|
| 255 |
if (investmentMaintainedDays < 8) {
|
249 |
if (investmentMaintainedDays < 8) {
|
| 256 |
sio.setStatus(SchemePayoutStatus.REJECTED);
|
250 |
sio.setStatus(SchemePayoutStatus.REJECTED);
|
| 257 |
//sio.setRolledBackTimestamp(LocalDateTime.now());
|
251 |
// sio.setRolledBackTimestamp(LocalDateTime.now());
|
| 258 |
sio.setStatusDescription("Investment maintained for " + investmentMaintainedDays + "(< 8) days");
|
252 |
sio.setStatusDescription("Investment maintained for " + investmentMaintainedDays + "(< 8) days");
|
| 259 |
} else if (investmentMaintainedDays < 12) {
|
253 |
} else if (investmentMaintainedDays < 12) {
|
| 260 |
sio.setStatus(SchemePayoutStatus.CREDITED);
|
254 |
sio.setStatus(SchemePayoutStatus.CREDITED);
|
| 261 |
sio.setAmount(sio.getAmount()/2);
|
255 |
sio.setAmount(sio.getAmount() / 2);
|
| 262 |
sio.setCreditTimestamp(LocalDateTime.now());
|
256 |
sio.setCreditTimestamp(LocalDateTime.now());
|
| 263 |
sio.setStatusDescription("Investment maintained for " + investmentMaintainedDays + "(< 12) days");
|
257 |
sio.setStatusDescription("Investment maintained for " + investmentMaintainedDays + "(< 12) days");
|
| 264 |
totalAmount += sio.getAmount();
|
258 |
totalAmount += sio.getAmount();
|
| 265 |
} else {
|
259 |
} else {
|
| 266 |
sio.setStatus(SchemePayoutStatus.CREDITED);
|
260 |
sio.setStatus(SchemePayoutStatus.CREDITED);
|
| 267 |
sio.setCreditTimestamp(LocalDateTime.now());
|
261 |
sio.setCreditTimestamp(LocalDateTime.now());
|
| 268 |
totalAmount += sio.getAmount();
|
262 |
totalAmount += sio.getAmount();
|
| 269 |
}
|
263 |
}
|
| 270 |
}
|
264 |
}
|
| 271 |
if(totalAmount > 0) {
|
265 |
if (totalAmount > 0) {
|
| - |
|
266 |
String description = "Investment margin paid for "
|
| 272 |
String description = "Investment margin paid for " + FormattingUtils.formatYearMonth(startOfPreviousMonth.atStartOfDay());
|
267 |
+ FormattingUtils.formatYearMonth(startOfPreviousMonth.atStartOfDay());
|
| 273 |
if(investmentMaintainedDays < 12) {
|
268 |
if (investmentMaintainedDays < 12) {
|
| 274 |
description += ", as maintained for " + investmentMaintainedDays + "(< 12) days";
|
269 |
description += ", as maintained for " + investmentMaintainedDays + "(< 12) days";
|
| 275 |
}
|
270 |
}
|
| 276 |
walletService.addAmountToWallet(fofoId,referenceId, WalletReferenceType.INVESTMENT_PAYOUT, description, totalAmount, lastOfPreviousMonth.atTime(LocalTime.MAX));
|
271 |
walletService.addAmountToWallet(fofoId, referenceId, WalletReferenceType.INVESTMENT_PAYOUT, description,
|
| - |
|
272 |
totalAmount, lastOfPreviousMonth.atTime(LocalTime.MAX));
|
| 277 |
}
|
273 |
}
|
| 278 |
System.out.printf("%d\t%d\t%f%n", fofoId, investmentMaintainedDays, totalAmount);
|
274 |
System.out.printf("%d\t%d\t%f%n", fofoId, investmentMaintainedDays, totalAmount);
|
| 279 |
}
|
275 |
}
|
| 280 |
|
- |
|
| 281 |
|
276 |
|
| 282 |
}
|
277 |
}
|
| 283 |
|
278 |
|
| 284 |
@RequestMapping(value = "/evaluateActualInvestmentPayout", method = RequestMethod.GET)
|
279 |
@RequestMapping(value = "/evaluateActualInvestmentPayout", method = RequestMethod.GET)
|
| 285 |
public ResponseEntity<?> evaluateActualInvestmentPayout(HttpServletRequest request,Model model) throws Exception {
|
280 |
public ResponseEntity<?> evaluateActualInvestmentPayout(HttpServletRequest request, Model model) throws Exception {
|
| 286 |
|
281 |
|
| 287 |
List<List<?>> rows = new ArrayList<>();
|
282 |
List<List<?>> rows = new ArrayList<>();
|
| 288 |
LocalDate firstDateOfCurrentMonth = LocalDateTime.now().withDayOfMonth(1).toLocalDate();
|
283 |
LocalDate firstDateOfCurrentMonth = LocalDateTime.now().withDayOfMonth(1).toLocalDate();
|
| 289 |
LocalDate startOfPreviousMonth = firstDateOfCurrentMonth.minusMonths(1);
|
284 |
LocalDate startOfPreviousMonth = firstDateOfCurrentMonth.minusMonths(1);
|
| 290 |
LocalDate lastOfPreviousMonth = firstDateOfCurrentMonth.minusDays(1);
|
285 |
LocalDate lastOfPreviousMonth = firstDateOfCurrentMonth.minusDays(1);
|
| 291 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
286 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
| Line 314... |
Line 309... |
| 314 |
totalAmount = 0;
|
309 |
totalAmount = 0;
|
| 315 |
} else if (investmentMaintainedDays < 12) {
|
310 |
} else if (investmentMaintainedDays < 12) {
|
| 316 |
totalAmount = totalAmount / 2;
|
311 |
totalAmount = totalAmount / 2;
|
| 317 |
}
|
312 |
}
|
| 318 |
System.out.printf("%d\t%d\t%f%n", fofoId, investmentMaintainedDays, totalAmount);
|
313 |
System.out.printf("%d\t%d\t%f%n", fofoId, investmentMaintainedDays, totalAmount);
|
| 319 |
CustomRetailer customRetailer= retailerService.getFofoRetailer(fofoId);
|
314 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(fofoId);
|
| 320 |
|
315 |
|
| 321 |
rows.add(Arrays.asList(fofoId,customRetailer.getBusinessName(),customRetailer.getCode(),investmentMaintainedDays,totalAmount));
|
316 |
rows.add(Arrays.asList(fofoId, customRetailer.getBusinessName(), customRetailer.getCode(),
|
| - |
|
317 |
investmentMaintainedDays, totalAmount));
|
| 322 |
}
|
318 |
}
|
| 323 |
|
319 |
|
| 324 |
|
- |
|
| 325 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
|
320 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil.getCSVByteStream(
|
| 326 |
.getCSVByteStream(Arrays.asList("fofoId","Name", "Code", "investmentMaintainedDays","totalAmount"), rows);
|
321 |
Arrays.asList("fofoId", "Name", "Code", "investmentMaintainedDays", "totalAmount"), rows);
|
| 327 |
|
322 |
|
| 328 |
final HttpHeaders headers = new HttpHeaders();
|
323 |
final HttpHeaders headers = new HttpHeaders();
|
| 329 |
headers.set("Content-Type", "text/csv");
|
324 |
headers.set("Content-Type", "text/csv");
|
| 330 |
headers.set("Content-disposition", "inline; filename=investmentMaintainedDays.csv");
|
325 |
headers.set("Content-disposition", "inline; filename=investmentMaintainedDays.csv");
|
| 331 |
headers.setContentLength(baos.toByteArray().length);
|
326 |
headers.setContentLength(baos.toByteArray().length);
|
| 332 |
|
327 |
|
| 333 |
final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
|
328 |
final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
|
| 334 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
329 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
| 335 |
|
330 |
|
| 336 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
331 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| 337 |
|
332 |
|
| 338 |
}
|
333 |
}
|
| 339 |
|
334 |
|
| 340 |
@RequestMapping(value = "/processInvestmentDryRun", method = RequestMethod.GET)
|
335 |
@RequestMapping(value = "/processInvestmentDryRun", method = RequestMethod.GET)
|
| 341 |
public ResponseEntity<?> processInvestmentDryRun(HttpServletRequest request,Model model) throws Exception {
|
336 |
public ResponseEntity<?> processInvestmentDryRun(HttpServletRequest request, Model model) throws Exception {
|
| 342 |
|
337 |
|
| 343 |
LocalDate firstDateOfCurrentMonth = LocalDateTime.now().withDayOfMonth(1).toLocalDate();
|
338 |
LocalDate firstDateOfCurrentMonth = LocalDateTime.now().withDayOfMonth(1).toLocalDate();
|
| 344 |
LocalDate startOfPreviousMonth = firstDateOfCurrentMonth.minusMonths(1);
|
339 |
LocalDate startOfPreviousMonth = firstDateOfCurrentMonth.minusMonths(1);
|
| 345 |
LocalDate lastOfPreviousMonth = firstDateOfCurrentMonth.minusDays(1);
|
340 |
LocalDate lastOfPreviousMonth = firstDateOfCurrentMonth.minusDays(1);
|
| 346 |
List<List<?>> rows = new ArrayList<>();
|
341 |
List<List<?>> rows = new ArrayList<>();
|
| 347 |
|
342 |
|
| 348 |
Map<String, String> params = new HashMap<>();
|
343 |
Map<String, String> params = new HashMap<>();
|
| 349 |
|
344 |
|
| 350 |
params.put("MANUAL_datesBetween_FROMDATE",firstDateOfCurrentMonth.toString());
|
345 |
params.put("MANUAL_datesBetween_FROMDATE", firstDateOfCurrentMonth.toString());
|
| 351 |
params.put("MANUAL_datesBetween_TODATE",firstDateOfCurrentMonth.plusDays(9).toString());
|
346 |
params.put("MANUAL_datesBetween_TODATE", firstDateOfCurrentMonth.plusDays(9).toString());
|
| 352 |
|
347 |
|
| 353 |
params.put("type","INVESTMENT");
|
348 |
params.put("type", "INVESTMENT");
|
| 354 |
|
349 |
|
| 355 |
List<EvaluateSchemeInvestmentPayoutModel> evaluateSchemeInvestmentPayouts = reporticoService.getReports(EvaluateSchemeInvestmentPayoutModel.class,
|
350 |
List<EvaluateSchemeInvestmentPayoutModel> evaluateSchemeInvestmentPayouts = reporticoService.getReports(
|
| 356 |
ReporticoProject.FOCO, "schemepayout.xml", params);
|
351 |
EvaluateSchemeInvestmentPayoutModel.class, ReporticoProject.FOCO, "schemepayout.xml", params);
|
| 357 |
LOGGER.info("reportResponse {}", evaluateSchemeInvestmentPayouts);
|
352 |
LOGGER.info("reportResponse {}", evaluateSchemeInvestmentPayouts);
|
| 358 |
|
- |
|
| 359 |
|
- |
|
| 360 |
|
353 |
|
| 361 |
int referenceId = Integer.parseInt(FormattingUtils.getYearMonth(startOfPreviousMonth.atStartOfDay()));
|
354 |
int referenceId = Integer.parseInt(FormattingUtils.getYearMonth(startOfPreviousMonth.atStartOfDay()));
|
| 362 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
355 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
| 363 |
.selectAll(startOfPreviousMonth, lastOfPreviousMonth);
|
356 |
.selectAll(startOfPreviousMonth, lastOfPreviousMonth);
|
| 364 |
Map<Integer, Long> investmentMaintainedDaysMap = partnerDailyInvestments.stream()
|
357 |
Map<Integer, Long> investmentMaintainedDaysMap = partnerDailyInvestments.stream()
|
| 365 |
.filter(x -> x.getShortPercentage() <= 10)
|
358 |
.filter(x -> x.getShortPercentage() <= 10)
|
| 366 |
.collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.counting()));
|
359 |
.collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.counting()));
|
| 367 |
|
360 |
|
| 368 |
for (EvaluateSchemeInvestmentPayoutModel esip : evaluateSchemeInvestmentPayouts) {
|
361 |
for (EvaluateSchemeInvestmentPayoutModel esip : evaluateSchemeInvestmentPayouts) {
|
| 369 |
|
362 |
|
| 370 |
long investmentMaintainedDays = investmentMaintainedDaysMap.get(esip.getFofoId()) == null ? 0
|
363 |
long investmentMaintainedDays = investmentMaintainedDaysMap.get(esip.getFofoId()) == null ? 0
|
| 371 |
: investmentMaintainedDaysMap.get(esip.getFofoId());
|
364 |
: investmentMaintainedDaysMap.get(esip.getFofoId());
|
| 372 |
|
365 |
|
| 373 |
esip.setInvestmentDays(investmentMaintainedDays);
|
366 |
esip.setInvestmentDays(investmentMaintainedDays);
|
| 374 |
|
367 |
|
| 375 |
float processAmount = esip.getPaidAmount()/2;
|
368 |
float processAmount = esip.getPaidAmount() / 2;
|
| 376 |
|
369 |
|
| 377 |
esip.setProcessAmount(processAmount);
|
370 |
esip.setProcessAmount(processAmount);
|
| 378 |
|
371 |
|
| 379 |
rows.add(Arrays.asList(esip.getCode(),esip.getStoreName(),esip.getFofoId(),esip.getItemId(),esip.getBrand(),esip.getModelName(),esip.getModelNumber(),
|
372 |
rows.add(Arrays.asList(esip.getCode(), esip.getStoreName(), esip.getFofoId(), esip.getItemId(),
|
| 380 |
esip.getColor(),esip.getSchemeInDp(),esip.getSchemeOutDp(),esip.getSchemeId(),
|
373 |
esip.getBrand(), esip.getModelName(), esip.getModelNumber(), esip.getColor(), esip.getSchemeInDp(),
|
| 381 |
esip.getName(),esip.getType(),esip.getPartnerType(),esip.getAmountType(),esip.getAmount(),esip.getPurchaseInvoice(),esip.getSaleInovoice(),
|
- |
|
| 382 |
esip.getPaidAmount(),esip.getCreateTimestamp(),esip.getRolledBackTimestamp(),esip.getSerialNumber(),esip.getInRef(),esip.getOutRef()
|
- |
|
| 383 |
,esip.getBusinessDate(),esip.getStatus(),esip.getDescription(),esip.getProcessAmount(),esip.getInvestmentDays()));
|
374 |
esip.getSchemeOutDp(), esip.getSchemeId(), esip.getName(), esip.getType(), esip.getPartnerType(),
|
| 384 |
}
|
- |
|
| 385 |
|
- |
|
| 386 |
|
- |
|
| 387 |
|
- |
|
| 388 |
|
- |
|
| 389 |
|
- |
|
| 390 |
|
- |
|
| 391 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
|
- |
|
| 392 |
.getCSVByteStream(Arrays.asList("Code","Store Name","Fofo Id","Item Id","Brand","Model Name",
|
- |
|
| 393 |
"Model Number","Color","Scheme In Dp","Scheme Out Dp","Scheme Id",
|
- |
|
| 394 |
"Name","Type","Partner Type","Amount Type","Amount","Purchase Invoice","Sale Inovoice",
|
375 |
esip.getAmountType(), esip.getAmount(), esip.getPurchaseInvoice(), esip.getSaleInovoice(),
|
| 395 |
"Paid Amount","Create Timestamp","Rolled Back Timestamp",
|
376 |
esip.getPaidAmount(), esip.getCreateTimestamp(), esip.getRolledBackTimestamp(),
|
| 396 |
"Serial Number","In Ref","Out Ref","Business Date","Status","Description","Process Amount","Investment Days"), rows);
|
377 |
esip.getSerialNumber(), esip.getInRef(), esip.getOutRef(), esip.getBusinessDate(), esip.getStatus(),
|
| 397 |
|
- |
|
| 398 |
final HttpHeaders headers = new HttpHeaders();
|
- |
|
| 399 |
headers.set("Content-Type", "text/csv");
|
- |
|
| 400 |
headers.set("Content-disposition", "inline; filename=schemePayout.csv");
|
- |
|
| 401 |
headers.setContentLength(baos.toByteArray().length);
|
- |
|
| 402 |
|
- |
|
| 403 |
final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
|
378 |
esip.getDescription(), esip.getProcessAmount(), esip.getInvestmentDays()));
|
| 404 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
- |
|
| 405 |
|
- |
|
| 406 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
- |
|
| 407 |
|
- |
|
| 408 |
}
|
379 |
}
|
| 409 |
|
380 |
|
| - |
|
381 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
|
| - |
|
382 |
.getCSVByteStream(Arrays.asList("Code", "Store Name", "Fofo Id", "Item Id", "Brand", "Model Name",
|
| - |
|
383 |
"Model Number", "Color", "Scheme In Dp", "Scheme Out Dp", "Scheme Id", "Name", "Type",
|
| - |
|
384 |
"Partner Type", "Amount Type", "Amount", "Purchase Invoice", "Sale Inovoice", "Paid Amount",
|
| - |
|
385 |
"Create Timestamp", "Rolled Back Timestamp", "Serial Number", "In Ref", "Out Ref",
|
| - |
|
386 |
"Business Date", "Status", "Description", "Process Amount", "Investment Days"), rows);
|
| - |
|
387 |
|
| - |
|
388 |
final HttpHeaders headers = new HttpHeaders();
|
| - |
|
389 |
headers.set("Content-Type", "text/csv");
|
| - |
|
390 |
headers.set("Content-disposition", "inline; filename=schemePayout.csv");
|
| - |
|
391 |
headers.setContentLength(baos.toByteArray().length);
|
| - |
|
392 |
|
| - |
|
393 |
final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
|
| - |
|
394 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
| - |
|
395 |
|
| - |
|
396 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| - |
|
397 |
|
| - |
|
398 |
}
|
| - |
|
399 |
|
| 410 |
@RequestMapping(value = "/schemes/update", method = RequestMethod.POST)
|
400 |
@RequestMapping(value = "/schemes/update", method = RequestMethod.POST)
|
| 411 |
public String updateShcemes(HttpServletRequest request, @RequestBody SchemeItems schemeItems, Model model)
|
401 |
public String updateShcemes(HttpServletRequest request, @RequestBody SchemeItems schemeItems, Model model)
|
| 412 |
throws Exception {
|
402 |
throws Exception {
|
| 413 |
for (int schemeId : schemeItems.getSchemeIds()) {
|
403 |
for (int schemeId : schemeItems.getSchemeIds()) {
|
| 414 |
if (schemeRepository.selectById(schemeId) != null)
|
404 |
if (schemeRepository.selectById(schemeId) != null)
|
| Line 416... |
Line 406... |
| 416 |
if (tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(Arrays.asList(itemId)),
|
406 |
if (tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(Arrays.asList(itemId)),
|
| 417 |
new HashSet<>(Arrays.asList(4, 7))).size() > 0) {
|
407 |
new HashSet<>(Arrays.asList(4, 7))).size() > 0) {
|
| 418 |
SchemeItem si = new SchemeItem();
|
408 |
SchemeItem si = new SchemeItem();
|
| 419 |
si.setItemId(itemId);
|
409 |
si.setItemId(itemId);
|
| 420 |
si.setSchemeId(schemeId);
|
410 |
si.setSchemeId(schemeId);
|
| - |
|
411 |
si.setCreateTimestamp(LocalDateTime.now());
|
| 421 |
try {
|
412 |
try {
|
| 422 |
schemeItemRepository.persist(si);
|
413 |
schemeItemRepository.persist(si);
|
| 423 |
} catch (Exception e) {
|
414 |
} catch (Exception e) {
|
| 424 |
LOGGER.info("Scheme aleady exist");
|
415 |
LOGGER.info("Scheme aleady exist");
|
| 425 |
}
|
416 |
}
|
| Line 443... |
Line 434... |
| 443 |
if (tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(Arrays.asList(itemId)),
|
434 |
if (tagListingRepository.selectByItemIdsAndTagIds(new HashSet<>(Arrays.asList(itemId)),
|
| 444 |
new HashSet<>(Arrays.asList(4, 7))).size() > 0 && (!(itemIds.contains(itemId)))) {
|
435 |
new HashSet<>(Arrays.asList(4, 7))).size() > 0 && (!(itemIds.contains(itemId)))) {
|
| 445 |
SchemeItem si = new SchemeItem();
|
436 |
SchemeItem si = new SchemeItem();
|
| 446 |
si.setItemId(itemId);
|
437 |
si.setItemId(itemId);
|
| 447 |
si.setSchemeId(schemeId);
|
438 |
si.setSchemeId(schemeId);
|
| - |
|
439 |
si.setCreateTimestamp(LocalDateTime.now());
|
| 448 |
try {
|
440 |
try {
|
| 449 |
schemeItemRepository.persist(si);
|
441 |
schemeItemRepository.persist(si);
|
| 450 |
} catch (Exception e) {
|
442 |
} catch (Exception e) {
|
| 451 |
LOGGER.info("Scheme already exist");
|
443 |
LOGGER.info("Scheme already exist");
|
| 452 |
}
|
444 |
}
|
| Line 560... |
Line 552... |
| 560 |
List<SchemeInOut> schemeInOut = null;
|
552 |
List<SchemeInOut> schemeInOut = null;
|
| 561 |
|
553 |
|
| 562 |
long size = 0;
|
554 |
long size = 0;
|
| 563 |
date = date.isAfter(LocalDate.now()) ? LocalDate.now() : date;
|
555 |
date = date.isAfter(LocalDate.now()) ? LocalDate.now() : date;
|
| 564 |
if (partnerType == null) {
|
556 |
if (partnerType == null) {
|
| 565 |
//TODO - SCHEME
|
557 |
// TODO - SCHEME
|
| 566 |
/*
|
558 |
|
| 567 |
* partnerType =
|
- |
|
| 568 |
* partnerTypeChangeService.getTypeOnMonth(loginDetails.getFofoId(),
|
559 |
partnerType = partnerTypeChangeService.getTypeOnMonth(loginDetails.getFofoId(), YearMonth.from(date));
|
| 569 |
* YearMonth.of(date.getYear(), date.getMonth()));
|
- |
|
| - |
|
560 |
|
| 570 |
*/
|
561 |
// partnerType =
|
| 571 |
partnerType = partnerTypeChangeService.getTypeOnDate(loginDetails.getFofoId(), date);
|
562 |
// partnerTypeChangeService.getTypeOnDate(loginDetails.getFofoId(), date);
|
| 572 |
}
|
563 |
}
|
| 573 |
if (!(searchTerm.equals(""))) {
|
564 |
if (!(searchTerm.equals(""))) {
|
| 574 |
schemes = schemeRepository.selectBySearchTerm(searchTerm, offset, limit);
|
565 |
schemes = schemeRepository.selectBySearchTerm(searchTerm, offset, limit);
|
| 575 |
for (Scheme scheme : schemes) {
|
566 |
for (Scheme scheme : schemes) {
|
| 576 |
if (scheme.getAmountType().equals(AmountType.PERCENTAGE)) {
|
567 |
if (scheme.getAmountType().equals(AmountType.PERCENTAGE)) {
|