fix(back-end): fix test gcode parser
This commit is contained in:
@@ -168,7 +168,16 @@ public class OrderController {
|
|||||||
vars.put("grandTotalFormatted", String.format("CHF %.2f", order.getTotalChf()));
|
vars.put("grandTotalFormatted", String.format("CHF %.2f", order.getTotalChf()));
|
||||||
vars.put("paymentTermsText", "Pagamento entro 7 giorni via Bonifico o TWINT. Grazie.");
|
vars.put("paymentTermsText", "Pagamento entro 7 giorni via Bonifico o TWINT. Grazie.");
|
||||||
|
|
||||||
String qrBillSvg = new String(qrBillService.generateQrBillSvg(order));
|
String qrBillSvg = new String(qrBillService.generateQrBillSvg(order), java.nio.charset.StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// Strip XML declaration and DOCTYPE if present, as they validity break the embedding HTML page
|
||||||
|
if (qrBillSvg.contains("<?xml")) {
|
||||||
|
int svgStartIndex = qrBillSvg.indexOf("<svg");
|
||||||
|
if (svgStartIndex != -1) {
|
||||||
|
qrBillSvg = qrBillSvg.substring(svgStartIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
byte[] pdf = invoiceService.generateInvoicePdfBytesFromTemplate(vars, qrBillSvg);
|
byte[] pdf = invoiceService.generateInvoicePdfBytesFromTemplate(vars, qrBillSvg);
|
||||||
|
|
||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
|
|||||||
@@ -203,6 +203,14 @@ public class OrderService {
|
|||||||
// 1. Generate QR Bill
|
// 1. Generate QR Bill
|
||||||
byte[] qrBillSvgBytes = qrBillService.generateQrBillSvg(order);
|
byte[] qrBillSvgBytes = qrBillService.generateQrBillSvg(order);
|
||||||
String qrBillSvg = new String(qrBillSvgBytes, StandardCharsets.UTF_8);
|
String qrBillSvg = new String(qrBillSvgBytes, StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
// Strip XML declaration and DOCTYPE if present, as they validity break the embedding HTML page
|
||||||
|
if (qrBillSvg.contains("<?xml")) {
|
||||||
|
int svgStartIndex = qrBillSvg.indexOf("<svg");
|
||||||
|
if (svgStartIndex != -1) {
|
||||||
|
qrBillSvg = qrBillSvg.substring(svgStartIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Save QR Bill SVG
|
// Save QR Bill SVG
|
||||||
String qrRelativePath = "orders/" + order.getId() + "/documents/qr-bill.svg";
|
String qrRelativePath = "orders/" + order.getId() + "/documents/qr-bill.svg";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<!doctype html>
|
<!DOCTYPE html>
|
||||||
<html lang="it" xmlns:th="http://www.thymeleaf.org">
|
<html lang="it" xmlns:th="http://www.thymeleaf.org">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user