| Line 573... |
Line 573... |
| 573 |
model.addAllAttributes(map);
|
573 |
model.addAllAttributes(map);
|
| 574 |
|
574 |
|
| 575 |
return "sale-history";
|
575 |
return "sale-history";
|
| 576 |
}
|
576 |
}
|
| 577 |
|
577 |
|
| - |
|
578 |
@RequestMapping(value = "/downloadInvoices")
|
| - |
|
579 |
public ResponseEntity<?> downloadInvoices(HttpServletRequest request,
|
| - |
|
580 |
@RequestParam(name = "searchValue", defaultValue = "") String searchValue,
|
| - |
|
581 |
@RequestParam(name = "searchType", defaultValue = "") SearchType searchType,
|
| - |
|
582 |
@RequestParam(required = false) LocalDateTime startTime,
|
| - |
|
583 |
@RequestParam(required = false) LocalDateTime endTime,
|
| - |
|
584 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| - |
|
585 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| - |
|
586 |
throws ProfitMandiBusinessException {
|
| - |
|
587 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
588 |
|
| - |
|
589 |
Map<String, Object> map = orderService.getSaleHistory(loginDetails.getFofoId(), searchType, searchValue,
|
| - |
|
590 |
startTime, endTime, offset, 100);
|
| - |
|
591 |
List<FofoOrder> fofoOrders = (List<FofoOrder>)map.get("saleHistories");
|
| - |
|
592 |
|
| - |
|
593 |
final HttpHeaders headers = new HttpHeaders();
|
| - |
|
594 |
if(fofoOrders.size() > 0) {
|
| - |
|
595 |
throw new ProfitMandiBusinessException("Search criteria", "", "No orders found for criteria");
|
| - |
|
596 |
}
|
| - |
|
597 |
|
| - |
|
598 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
| - |
|
599 |
headers.set("Content-disposition", "inline; filename=invoices.pdf");
|
| - |
|
600 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| - |
|
601 |
List<PdfModel> pdfModels = new ArrayList<>();
|
| - |
|
602 |
for(FofoOrder fofoOrder : fofoOrders) {
|
| - |
|
603 |
try {
|
| - |
|
604 |
pdfModels.add(orderService.getInvoicePdfModel(fofoOrder.getId()));
|
| - |
|
605 |
} catch(Exception e) {
|
| - |
|
606 |
LOGGER.info("could not create invoice for {}, invoice number {}", fofoOrder.getId(), fofoOrder.getInvoiceNumber());
|
| - |
|
607 |
}
|
| - |
|
608 |
}
|
| - |
|
609 |
PdfUtils.generateAndWrite(pdfModels, byteArrayOutputStream);
|
| - |
|
610 |
headers.setContentLength(byteArrayOutputStream.toByteArray().length);
|
| - |
|
611 |
final InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
| - |
|
612 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
| - |
|
613 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
| - |
|
614 |
}
|
| - |
|
615 |
|
| 578 |
@RequestMapping(value = "/credit-note/{creditNoteId}")
|
616 |
@RequestMapping(value = "/credit-note/{creditNoteId}")
|
| 579 |
public ResponseEntity<?> downloadCreditNote(HttpServletRequest request, @PathVariable int creditNoteId)
|
617 |
public ResponseEntity<?> downloadCreditNote(HttpServletRequest request, @PathVariable int creditNoteId)
|
| 580 |
throws ProfitMandiBusinessException {
|
618 |
throws ProfitMandiBusinessException {
|
| 581 |
CreditNotePdfModel creditNotePdfModel = orderService.getCreditNotePdfModel(creditNoteId);
|
619 |
CreditNotePdfModel creditNotePdfModel = orderService.getCreditNotePdfModel(creditNoteId);
|
| 582 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
620 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| Line 707... |
Line 745... |
| 707 |
model.addAttribute("size", size);
|
745 |
model.addAttribute("size", size);
|
| 708 |
model.addAttribute("insurancePolicies", insurancePolicies);
|
746 |
model.addAttribute("insurancePolicies", insurancePolicies);
|
| 709 |
model.addAttribute("providerPolicyNameAndIdMap", providerPolicyNameAndIdMap);
|
747 |
model.addAttribute("providerPolicyNameAndIdMap", providerPolicyNameAndIdMap);
|
| 710 |
return "insurance-details";
|
748 |
return "insurance-details";
|
| 711 |
}
|
749 |
}
|
| 712 |
|
750 |
|
| 713 |
@GetMapping("/insuranceDetailsPaginated")
|
751 |
@GetMapping("/insuranceDetailsPaginated")
|
| 714 |
public String getInsuranceDetailsPaginated(HttpServletRequest request,
|
752 |
public String getInsuranceDetailsPaginated(HttpServletRequest request,
|
| 715 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
753 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 716 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
754 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| 717 |
throws ProfitMandiBusinessException {
|
755 |
throws ProfitMandiBusinessException {
|