| Line 49... |
Line 49... |
| 49 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
49 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 50 |
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
|
50 |
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
|
| 51 |
import com.spice.profitmandi.dao.entity.fofo.PrebookingOrderItem;
|
51 |
import com.spice.profitmandi.dao.entity.fofo.PrebookingOrderItem;
|
| 52 |
import com.spice.profitmandi.dao.entity.user.Address;
|
52 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 53 |
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
|
53 |
import com.spice.profitmandi.dao.enumuration.dtr.PaymentOptionReferenceType;
|
| - |
|
54 |
import com.spice.profitmandi.dao.enumuration.dtr.RoleType;
|
| 54 |
import com.spice.profitmandi.dao.repository.dtr.PaymentOptionTransactionRepository;
|
55 |
import com.spice.profitmandi.dao.repository.dtr.PaymentOptionTransactionRepository;
|
| 55 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
56 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
| 56 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
57 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
| 57 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
58 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
| 58 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
59 |
import com.spice.profitmandi.dao.repository.fofo.CustomerAddressRepository;
|
| Line 327... |
Line 328... |
| 327 |
|
328 |
|
| 328 |
@RequestMapping(value = "/generateInvoice")
|
329 |
@RequestMapping(value = "/generateInvoice")
|
| 329 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws ProfitMandiBusinessException{
|
330 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws ProfitMandiBusinessException{
|
| 330 |
LOGGER.info("Request received at url {} with params [{}={}] ", request.getRequestURI(), ProfitMandiConstants.ORDER_ID, orderId);
|
331 |
LOGGER.info("Request received at url {} with params [{}={}] ", request.getRequestURI(), ProfitMandiConstants.ORDER_ID, orderId);
|
| 331 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
332 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
333 |
PdfModel pdfModel = null;
|
| - |
|
334 |
if(fofoDetails.getRoleTypes().contains(RoleType.FOFO_ADMIN)) {
|
| - |
|
335 |
pdfModel = orderService.getInvoicePdfModel(orderId);
|
| 332 |
|
336 |
}else {
|
| 333 |
PdfModel pdfModel = orderService.getInvoicePdfModel(fofoDetails.getFofoId(), orderId);
|
337 |
pdfModel = orderService.getInvoicePdfModel(fofoDetails.getFofoId(), orderId);
|
| 334 |
|
338 |
}
|
| 335 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
339 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| 336 |
PdfUtils.generateAndWrite(pdfModel, byteArrayOutputStream);
|
340 |
PdfUtils.generateAndWrite(pdfModel, byteArrayOutputStream);
|
| 337 |
LOGGER.info("Pdf Stream length {}", byteArrayOutputStream.toByteArray().length);
|
341 |
LOGGER.info("Pdf Stream length {}", byteArrayOutputStream.toByteArray().length);
|
| 338 |
final HttpHeaders headers=new HttpHeaders();
|
342 |
final HttpHeaders headers=new HttpHeaders();
|
| 339 |
headers.setContentType(MediaType.APPLICATION_PDF);
|
343 |
headers.setContentType(MediaType.APPLICATION_PDF);
|