| Line 55... |
Line 55... |
| 55 |
import javax.servlet.http.HttpServletRequest;
|
55 |
import javax.servlet.http.HttpServletRequest;
|
| 56 |
import javax.servlet.http.HttpServletResponse;
|
56 |
import javax.servlet.http.HttpServletResponse;
|
| 57 |
import java.io.ByteArrayInputStream;
|
57 |
import java.io.ByteArrayInputStream;
|
| 58 |
import java.io.ByteArrayOutputStream;
|
58 |
import java.io.ByteArrayOutputStream;
|
| 59 |
import java.io.InputStream;
|
59 |
import java.io.InputStream;
|
| - |
|
60 |
import java.nio.charset.StandardCharsets;
|
| 60 |
import java.time.LocalDate;
|
61 |
import java.time.LocalDate;
|
| 61 |
import java.time.LocalDateTime;
|
62 |
import java.time.LocalDateTime;
|
| 62 |
import java.time.LocalTime;
|
63 |
import java.time.LocalTime;
|
| 63 |
import java.time.format.DateTimeFormatter;
|
64 |
import java.time.format.DateTimeFormatter;
|
| 64 |
import java.time.temporal.ChronoUnit;
|
65 |
import java.time.temporal.ChronoUnit;
|
| Line 546... |
Line 547... |
| 546 |
private String getFileName(String invoiceNumber) {
|
547 |
private String getFileName(String invoiceNumber) {
|
| 547 |
return "INV-" + invoiceNumber.replace("/", "-") + ".pdf";
|
548 |
return "INV-" + invoiceNumber.replace("/", "-") + ".pdf";
|
| 548 |
}
|
549 |
}
|
| 549 |
|
550 |
|
| 550 |
private String getPublicInvoiceUrl(String invoiceNumber) {
|
551 |
private String getPublicInvoiceUrl(String invoiceNumber) {
|
| - |
|
552 |
String base64Encoded = Base64.getMimeEncoder().encodeToString(invoiceNumber.getBytes(StandardCharsets.UTF_8));
|
| 551 |
String publicUrl = "https://partners.smartdukaan.com/wa-invoice-send/" + invoiceNumber + ".pdf";
|
553 |
String publicUrl = "https://partners.smartdukaan.com/wa-invoice-send/" + base64Encoded + ".pdf";
|
| 552 |
return publicUrl;
|
554 |
return publicUrl;
|
| 553 |
}
|
555 |
}
|
| 554 |
|
556 |
|
| 555 |
@RequestMapping(value = "/order/bad_return", method = RequestMethod.POST)
|
557 |
@RequestMapping(value = "/order/bad_return", method = RequestMethod.POST)
|
| 556 |
public ResponseEntity<?> badReturn(HttpServletRequest request, @RequestBody FoiBadReturnRequest foiBadReturnRequest,
|
558 |
public ResponseEntity<?> badReturn(HttpServletRequest request, @RequestBody FoiBadReturnRequest foiBadReturnRequest,
|
| Line 566... |
Line 568... |
| 566 |
custmoerCreditNote = orderService.badReturn(fofoDetails.getFofoId(), foiBadReturnRequest);
|
568 |
custmoerCreditNote = orderService.badReturn(fofoDetails.getFofoId(), foiBadReturnRequest);
|
| 567 |
}
|
569 |
}
|
| 568 |
return responseSender.ok(custmoerCreditNote.getId());
|
570 |
return responseSender.ok(custmoerCreditNote.getId());
|
| 569 |
}
|
571 |
}
|
| 570 |
|
572 |
|
| 571 |
@GetMapping(value = "/wa-invoice-send/{partnerCode}/{number}")
|
573 |
@GetMapping(value = "/wa-invoice-send/{invoiceHash}")
|
| 572 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response, @PathVariable String partnerCode, @PathVariable int number) throws ProfitMandiBusinessException {
|
574 |
public ResponseEntity<?> generateInvoice(@PathVariable String invoiceHash) throws ProfitMandiBusinessException {
|
| - |
|
575 |
String decodedInvoiceNumber = new String(Base64.getMimeDecoder().decode(invoiceHash));
|
| 573 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(partnerCode + "/" + number);
|
576 |
FofoOrder fofoOrder = fofoOrderRepository.selectByInvoiceNumber(decodedInvoiceNumber);
|
| - |
|
577 |
|
| 574 |
InvoicePdfModel pdfModel = orderService.getInvoicePdfModel(fofoOrder.getId());
|
578 |
InvoicePdfModel pdfModel = orderService.getInvoicePdfModel(fofoOrder.getId());
|
| 575 |
|
579 |
|
| 576 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
580 |
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
| 577 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
581 |
PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
|
| 578 |
LOGGER.info("Pdf Stream length {}", byteArrayOutputStream.toByteArray().length);
|
582 |
LOGGER.info("Pdf Stream length {}", byteArrayOutputStream.toByteArray().length);
|