| Line 1366... |
Line 1366... |
| 1366 |
model.addAttribute("isAdmin", isAdmin);
|
1366 |
model.addAttribute("isAdmin", isAdmin);
|
| 1367 |
return "online-all-order-item";
|
1367 |
return "online-all-order-item";
|
| 1368 |
}
|
1368 |
}
|
| 1369 |
|
1369 |
|
| 1370 |
|
1370 |
|
| - |
|
1371 |
@RequestMapping(value = "/orderReport", method = RequestMethod.GET)
|
| - |
|
1372 |
public String getOrderReport(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
1373 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
1374 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
| - |
|
1375 |
LocalDate startDate = LocalDate.now().withDayOfMonth(1);
|
| - |
|
1376 |
LocalDate endDate = LocalDate.now();
|
| - |
|
1377 |
model.addAttribute("startDate", startDate);
|
| - |
|
1378 |
model.addAttribute("endDate", endDate);
|
| - |
|
1379 |
model.addAttribute("isAdmin", isAdmin);
|
| - |
|
1380 |
return "order-report";
|
| - |
|
1381 |
}
|
| - |
|
1382 |
|
| - |
|
1383 |
@RequestMapping(value = "/downloadOrderReport", method = RequestMethod.GET)
|
| - |
|
1384 |
public ResponseEntity<?> getDownloadOrderReport(HttpServletRequest request,
|
| - |
|
1385 |
@RequestParam(name = "startDate") LocalDate startDate,
|
| - |
|
1386 |
@RequestParam(name = "endDate") LocalDate endDate,
|
| - |
|
1387 |
@RequestParam(name = "fofoId", required = false) Integer fofoId,
|
| - |
|
1388 |
Model model)
|
| - |
|
1389 |
throws Exception {
|
| - |
|
1390 |
// Period not more than a month (safety net behind the date filter)
|
| - |
|
1391 |
if (endDate.isAfter(startDate.plusMonths(1))) {
|
| - |
|
1392 |
endDate = startDate.plusMonths(1);
|
| - |
|
1393 |
}
|
| - |
|
1394 |
|
| - |
|
1395 |
// Scope: an admin may target a partner (blank fofoId = all partners); a non-admin
|
| - |
|
1396 |
// is always restricted to their own store, whatever fofoId the client sends.
|
| - |
|
1397 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
1398 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
| - |
|
1399 |
Integer scopedFofoId = isAdmin ? fofoId : loginDetails.getFofoId();
|
| - |
|
1400 |
|
| - |
|
1401 |
List<com.spice.profitmandi.dao.entity.transaction.Order> orders =
|
| - |
|
1402 |
scopedFofoId == null
|
| - |
|
1403 |
? orderRepository.selectAllByDatesBetween(startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX))
|
| - |
|
1404 |
: orderRepository.selectAllByDatesBetween(scopedFofoId, startDate.atStartOfDay(), endDate.atTime(LocalTime.MAX));
|
| - |
|
1405 |
|
| - |
|
1406 |
List<List<?>> rows = new ArrayList<>();
|
| - |
|
1407 |
rows.add(Arrays.asList(
|
| - |
|
1408 |
"Order ID", "Created", "Verified", "Invoice No", "Billed By", "Billing Date", "Shipping Date",
|
| - |
|
1409 |
"AWB", "Logistics Provider", "Delivery Date", "Quantity", "Amount", "Type", "Status", "Refund Reason",
|
| - |
|
1410 |
"Customer ID", "Customer Name", "Customer City", "Customer Pincode", "Customer State",
|
| - |
|
1411 |
"Item ID", "Product", "Logistics Txn ID", "Received Return Date", "Refund Date"));
|
| - |
|
1412 |
|
| - |
|
1413 |
for (com.spice.profitmandi.dao.entity.transaction.Order o : orders) {
|
| - |
|
1414 |
com.spice.profitmandi.dao.entity.transaction.LineItem li = o.getLineItem();
|
| - |
|
1415 |
float amount = (o.getTotalAmount() == null ? 0f : o.getTotalAmount())
|
| - |
|
1416 |
+ (o.getShippingCost() == null ? 0f : o.getShippingCost());
|
| - |
|
1417 |
String product = li == null ? "" : (defaultString(li.getBrand()) + " "
|
| - |
|
1418 |
+ defaultString(li.getModelName()) + " " + defaultString(li.getModelNumber())).trim();
|
| - |
|
1419 |
rows.add(Arrays.asList(
|
| - |
|
1420 |
o.getId(),
|
| - |
|
1421 |
FormattingUtils.format(o.getCreateTimestamp()),
|
| - |
|
1422 |
FormattingUtils.format(o.getVerificationTimestamp()),
|
| - |
|
1423 |
o.getInvoiceNumber(),
|
| - |
|
1424 |
o.getBilledBy(),
|
| - |
|
1425 |
FormattingUtils.format(o.getBillingTimestamp()),
|
| - |
|
1426 |
FormattingUtils.format(o.getShippingTimestamp()),
|
| - |
|
1427 |
o.getAirwayBillNumber(),
|
| - |
|
1428 |
o.getLogisticsProviderId(),
|
| - |
|
1429 |
FormattingUtils.format(o.getDeliveryTimestamp()),
|
| - |
|
1430 |
li == null ? null : li.getQuantity(),
|
| - |
|
1431 |
amount,
|
| - |
|
1432 |
Boolean.TRUE.equals(o.getCod()) ? "COD" : "PREPAID",
|
| - |
|
1433 |
o.getStatusDescription(),
|
| - |
|
1434 |
o.getRefundReason(),
|
| - |
|
1435 |
o.getRetailerId(),
|
| - |
|
1436 |
o.getRetailerName(),
|
| - |
|
1437 |
o.getRetailerCity(),
|
| - |
|
1438 |
o.getRetailerPinCode(),
|
| - |
|
1439 |
o.getRetailerState(),
|
| - |
|
1440 |
li == null ? null : li.getItemId(),
|
| - |
|
1441 |
product,
|
| - |
|
1442 |
o.getLogisticsTransactionId(),
|
| - |
|
1443 |
FormattingUtils.format(o.getReceiverReturnTimestamp()),
|
| - |
|
1444 |
FormattingUtils.format(o.getRefundTimestamp())));
|
| - |
|
1445 |
}
|
| - |
|
1446 |
|
| - |
|
1447 |
org.apache.commons.io.output.ByteArrayOutputStream baos = FileUtil
|
| - |
|
1448 |
.getCSVByteStream(Arrays.asList("Order Report : " + startDate + " to " + endDate), rows);
|
| - |
|
1449 |
return orderService.downloadReportInCsv(baos, rows, "Order Report " + startDate + " to " + endDate);
|
| - |
|
1450 |
}
|
| - |
|
1451 |
|
| - |
|
1452 |
private static String defaultString(String value) {
|
| - |
|
1453 |
return value == null ? "" : value;
|
| - |
|
1454 |
}
|
| - |
|
1455 |
|
| 1371 |
@RequestMapping(value = "/reports", method = RequestMethod.GET)
|
1456 |
@RequestMapping(value = "/reports", method = RequestMethod.GET)
|
| 1372 |
public String reports(HttpServletRequest httpServletRequest, Model model) throws ProfitMandiBusinessException, UnsupportedOperationException, IOException {
|
1457 |
public String reports(HttpServletRequest httpServletRequest, Model model) throws ProfitMandiBusinessException, UnsupportedOperationException, IOException {
|
| 1373 |
//LoginDetails loginDetails = cookiesProcessor.getCookiesObject(httpServletRequest);
|
1458 |
//LoginDetails loginDetails = cookiesProcessor.getCookiesObject(httpServletRequest);
|
| 1374 |
Map<ReporticoProject, List<ReporticoUrlInfo>> returnMap = ReporticoProject.reporticoProjectMap;
|
1459 |
Map<ReporticoProject, List<ReporticoUrlInfo>> returnMap = ReporticoProject.reporticoProjectMap;
|
| 1375 |
/*if(fofoStoreRepository.getWarehousePartnerMap().get(7720).stream().filter(x->x.getId()==loginDetails.getFofoId()).count() > 0) {
|
1460 |
/*if(fofoStoreRepository.getWarehousePartnerMap().get(7720).stream().filter(x->x.getId()==loginDetails.getFofoId()).count() > 0) {
|