feat(orders): PDF footer = issuer name+email, 'Zobrazit objednávku' button, per-currency list totals

- Issued-order PDF: drop the Vystavil/Schválil signature row; footer now shows
  'Vystavil: <name>' + 'E-mail: <email>' from the logged-in user (authData).
- IssuedOrderDetail PDF button 'Export PDF' -> 'Zobrazit objednávku' (already
  opens inline like invoices' 'Zobrazit fakturu').
- New /orders/stats + /issued-orders/stats endpoints sum order total (incl VAT)
  per currency across the active filter; rendered as 'Celkem: …' beneath both
  the received and issued lists. formatMultiCurrency lifted to a shared util.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-09 21:50:05 +02:00
parent 78cd7cf2d8
commit 5462fcf944
14 changed files with 627 additions and 84 deletions

View File

@@ -276,6 +276,8 @@ describe("renderIssuedOrderHtml", () => {
},
];
const issuer = { name: "Jan Novák", email: "jan.novak@firma.cz" };
it("renders the PO number, items, and both party names (PO direction)", () => {
const html = renderIssuedOrderHtml(
order,
@@ -283,6 +285,7 @@ describe("renderIssuedOrderHtml", () => {
{ name: "Dodavatel s.r.o." },
{ company_name: "Naše firma" },
"cs",
issuer,
);
expect(html).toContain("26720001");
expect(html).toContain("Materiál");
@@ -297,8 +300,28 @@ describe("renderIssuedOrderHtml", () => {
});
it("strips script tags from notes", () => {
const html = renderIssuedOrderHtml(order, items, null, null, "cs");
const html = renderIssuedOrderHtml(order, items, null, null, "cs", issuer);
expect(html).not.toContain("<script>");
expect(html).not.toContain("alert(1)");
});
it("footer shows the logged-in user's name + e-mail, not the Schválil column", () => {
const html = renderIssuedOrderHtml(order, items, null, null, "cs", issuer);
// New footer: Vystavil <name> + E-mail <email> from authData.
expect(html).toContain("Jan Novák");
expect(html).toContain("jan.novak@firma.cz");
expect(html).toContain("E-mail:");
// The old two-column signature footer is gone.
expect(html).not.toContain("footer-row");
expect(html).not.toContain("Schválil:");
});
it("omits the e-mail line when the issuer has no e-mail", () => {
const html = renderIssuedOrderHtml(order, items, null, null, "cs", {
name: "Jan Novák",
email: "",
});
expect(html).toContain("Jan Novák");
expect(html).not.toContain("E-mail:");
});
});