| Line 5... |
Line 5... |
| 5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
5 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 6 |
import com.spice.profitmandi.common.model.*;
|
6 |
import com.spice.profitmandi.common.model.*;
|
| 7 |
import com.spice.profitmandi.common.solr.SolrService;
|
7 |
import com.spice.profitmandi.common.solr.SolrService;
|
| 8 |
import com.spice.profitmandi.common.util.FileUtil;
|
8 |
import com.spice.profitmandi.common.util.FileUtil;
|
| 9 |
import com.spice.profitmandi.common.util.PdfUtils;
|
9 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| - |
|
10 |
import com.spice.profitmandi.common.util.PrinterType;
|
| 10 |
import com.spice.profitmandi.common.util.StringUtils;
|
11 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 11 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
12 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 12 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
13 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 13 |
import com.spice.profitmandi.dao.entity.catalog.CustomerOffer;
|
14 |
import com.spice.profitmandi.dao.entity.catalog.CustomerOffer;
|
| 14 |
import com.spice.profitmandi.dao.entity.catalog.CustomerOfferItem;
|
15 |
import com.spice.profitmandi.dao.entity.catalog.CustomerOfferItem;
|
| Line 565... |
Line 566... |
| 565 |
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
|
566 |
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
|
| 566 |
LocalDate manufactured = LocalDate.parse(manufacturedDate, formatter);
|
567 |
LocalDate manufactured = LocalDate.parse(manufacturedDate, formatter);
|
| 567 |
|
568 |
|
| 568 |
PlanVariant planVariant = insuranceService.getICICIPremiumByVariantId(planCode);
|
569 |
PlanVariant planVariant = insuranceService.getICICIPremiumByVariantId(planCode);
|
| 569 |
|
570 |
|
| 570 |
LOGGER.info("planVariant111 {}",planVariant);
|
571 |
LOGGER.info("planVariant111 {}", planVariant);
|
| 571 |
|
572 |
|
| 572 |
String correlationId = UUID.randomUUID().toString();
|
573 |
String correlationId = UUID.randomUUID().toString();
|
| 573 |
IciciPolicyTracker policyTracker = new IciciPolicyTracker();
|
574 |
IciciPolicyTracker policyTracker = new IciciPolicyTracker();
|
| 574 |
policyTracker.setCorrelationId(correlationId);
|
575 |
policyTracker.setCorrelationId(correlationId);
|
| 575 |
iciciPolicyTrackerRepository.persist(policyTracker);
|
576 |
iciciPolicyTrackerRepository.persist(policyTracker);
|
| Line 734... |
Line 735... |
| 734 |
|
735 |
|
| 735 |
}
|
736 |
}
|
| 736 |
|
737 |
|
| 737 |
@RequestMapping(value = "/generateInvoice")
|
738 |
@RequestMapping(value = "/generateInvoice")
|
| 738 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response,
|
739 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response,
|
| 739 |
@RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws ProfitMandiBusinessException {
|
740 |
@RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId, @RequestParam(required = false) PrinterType printerType) throws ProfitMandiBusinessException {
|
| 740 |
LOGGER.info("Request received at url {} with params [{}={}] ", request.getRequestURI(),
|
741 |
LOGGER.info("Request received at url {} with params [{}={}] ", request.getRequestURI(),
|
| 741 |
ProfitMandiConstants.ORDER_ID, orderId);
|
742 |
ProfitMandiConstants.ORDER_ID, orderId);
|
| 742 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
743 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 743 |
InvoicePdfModel pdfModel = null;
|
744 |
InvoicePdfModel pdfModel = null;
|
| - |
|
745 |
int fofoId;
|
| 744 |
if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
|
746 |
if (roleManager.isAdmin(fofoDetails.getRoleIds())) {
|
| 745 |
pdfModel = orderService.getInvoicePdfModel(orderId);
|
747 |
pdfModel = orderService.getInvoicePdfModel(orderId);
|
| - |
|
748 |
fofoId = pdfModel.getCustomer().getCustomerId();
|
| 746 |
} else {
|
749 |
} else {
|
| 747 |
pdfModel = orderService.getInvoicePdfModel(fofoDetails.getFofoId(), orderId);
|
750 |
pdfModel = orderService.getInvoicePdfModel(fofoDetails.getFofoId(), orderId);
|
| - |
|
751 |
fofoId = fofoDetails.getFofoId();
|
| 748 |
}
|
752 |
}
|
| - |
|
753 |
|
| - |
|
754 |
if (printerType == null) {
|
| - |
|
755 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoId);
|
| - |
|
756 |
//printerType = fs.getPrinterType();
|
| - |
|
757 |
}
|
| - |
|
758 |
|
| - |
|
759 |
|
| 749 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(orderId);
|
760 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(orderId);
|
| 750 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectByRetailerIdInvoiceNumber(fofoOrder.getInvoiceNumber());
|
761 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectByRetailerIdInvoiceNumber(fofoOrder.getInvoiceNumber());
|
| 751 |
|
762 |
|
| 752 |
// Step 1: Generate invoice PDF
|
763 |
// Step 1: Generate invoice PDF
|
| 753 |
ByteArrayOutputStream invoiceOutput = new ByteArrayOutputStream();
|
764 |
ByteArrayOutputStream invoiceOutput = new ByteArrayOutputStream();
|
| - |
|
765 |
|
| 754 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), invoiceOutput);
|
766 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), printerType, invoiceOutput);
|
| 755 |
byte[] invoicePdf = invoiceOutput.toByteArray();
|
767 |
byte[] invoicePdf = invoiceOutput.toByteArray();
|
| 756 |
|
768 |
|
| 757 |
// Step 2: Load all policy certificate PDFs
|
769 |
// Step 2: Load all policy certificate PDFs
|
| 758 |
List<byte[]> pdfFiles = new ArrayList<>();
|
770 |
List<byte[]> pdfFiles = new ArrayList<>();
|
| 759 |
pdfFiles.add(invoicePdf); // first add invoice
|
771 |
pdfFiles.add(invoicePdf); // first add invoice
|
| Line 1336... |
Line 1348... |
| 1336 |
// "Billing is on hold temporarily", "Billing is on hold temporarily");
|
1348 |
// "Billing is on hold temporarily", "Billing is on hold temporarily");
|
| 1337 |
LOGGER.info("request at uri {}", request.getRequestURI());
|
1349 |
LOGGER.info("request at uri {}", request.getRequestURI());
|
| 1338 |
LOGGER.info("request body {}", createOrderRequest);
|
1350 |
LOGGER.info("request body {}", createOrderRequest);
|
| 1339 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
1351 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 1340 |
int fofoOrderId = orderService.createOrder(createOrderRequest, fofoDetails.getFofoId(), accessoriesDeals);
|
1352 |
int fofoOrderId = orderService.createOrder(createOrderRequest, fofoDetails.getFofoId(), accessoriesDeals);
|
| 1341 |
try {
|
1353 |
/*try {
|
| 1342 |
Set<Integer> fofoOrderItemIds = createOrderRequest.getFofoOrderItems()
|
1354 |
Set<Integer> fofoOrderItemIds = createOrderRequest.getFofoOrderItems()
|
| 1343 |
.stream().map(CustomFofoOrderItem::getItemId).collect(Collectors.toSet());
|
1355 |
.stream().map(CustomFofoOrderItem::getItemId).collect(Collectors.toSet());
|
| 1344 |
scratchService.processScratchOffer(fofoOrderId, createOrderRequest.getPaymentOptions(), fofoOrderItemIds);
|
1356 |
scratchService.processScratchOffer(fofoOrderId, createOrderRequest.getPaymentOptions(), fofoOrderItemIds);
|
| 1345 |
} catch (Exception e) {
|
1357 |
} catch (Exception e) {
|
| 1346 |
LOGGER.info("Exception during processScratchOffer - " + e.getMessage());
|
1358 |
LOGGER.info("Exception during processScratchOffer - " + e.getMessage());
|
| 1347 |
}
|
1359 |
}*/
|
| 1348 |
|
1360 |
|
| 1349 |
LOGGER.info("Order has been created successfully...");
|
1361 |
LOGGER.info("Order has been created successfully...");
|
| 1350 |
return "redirect:/get-order/?orderId=" + fofoOrderId;
|
1362 |
return "redirect:/get-order/?orderId=" + fofoOrderId;
|
| 1351 |
}
|
1363 |
}
|
| 1352 |
|
1364 |
|
| Line 1872... |
Line 1884... |
| 1872 |
notEligibleInvoiceNumbers.addAll(existingInvoiceInEInvoiceDtl);
|
1884 |
notEligibleInvoiceNumbers.addAll(existingInvoiceInEInvoiceDtl);
|
| 1873 |
List<IrnResetOrderModel> irnResetOrderModelList = new ArrayList<>();
|
1885 |
List<IrnResetOrderModel> irnResetOrderModelList = new ArrayList<>();
|
| 1874 |
for (Map.Entry<String, List<Order>> invoiceMapEntry : invoiceMap.entrySet()) {
|
1886 |
for (Map.Entry<String, List<Order>> invoiceMapEntry : invoiceMap.entrySet()) {
|
| 1875 |
String invoice = invoiceMapEntry.getKey();
|
1887 |
String invoice = invoiceMapEntry.getKey();
|
| 1876 |
List<Order> orders = invoiceMapEntry.getValue();
|
1888 |
List<Order> orders = invoiceMapEntry.getValue();
|
| - |
|
1889 |
LocalDate earlierDate = LocalDate.now().minusDays(5);
|
| 1877 |
boolean isEligible = !orders.isEmpty() && orders.stream().allMatch(x -> x.getBillingTimestamp().toLocalDate().isAfter(LocalDate.now().minusDays(5)) && x.getIrnGenerated() != null);
|
1890 |
boolean isEligible = !orders.isEmpty() && orders.stream().allMatch(x -> x.getBillingTimestamp().toLocalDate().isAfter(earlierDate) && x.getIrnGenerated() != null);
|
| 1878 |
if (isEligible) {
|
1891 |
if (isEligible) {
|
| 1879 |
Order order = orders.get(0);
|
1892 |
Order order = orders.get(0);
|
| 1880 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(order.getRetailerId());
|
1893 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(order.getRetailerId());
|
| 1881 |
|
1894 |
|
| 1882 |
IrnResetOrderModel irnResetOrderModel = new IrnResetOrderModel();
|
1895 |
IrnResetOrderModel irnResetOrderModel = new IrnResetOrderModel();
|