feat(issued-orders): editable PDF heading 'Text objednavky (na PDF)' (order_text)
New nullable issued_orders.order_text column (migration applied to dev+test). The heading above the PDF items table is now editable per order, mirroring invoices' billing_text: empty falls back to the default, which is now 'Objednavame si u Vas:' per user wording. Field sits above Dodaci podminky in the detail form; persisted via create + update strFields (both schemas - the invoices Update-schema gap is not repeated). Tests: persistence round-trip incl. null-clears, PDF custom heading + default fallback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -170,6 +170,23 @@ describe("createIssuedOrder", () => {
|
||||
const res = await createIssuedOrder({ supplier_id: 99999999 });
|
||||
expect("error" in res && res.error).toBe("supplier_not_found");
|
||||
});
|
||||
|
||||
it("persists order_text on create, updates and clears it on update", async () => {
|
||||
const order = await mkIssued({ order_text: "Objednáváme dle smlouvy:" });
|
||||
let row = await prisma.issued_orders.findUnique({
|
||||
where: { id: order.id },
|
||||
});
|
||||
expect(row!.order_text).toBe("Objednáváme dle smlouvy:");
|
||||
|
||||
await updateIssuedOrder(order.id, { order_text: "Jiný text:" });
|
||||
row = await prisma.issued_orders.findUnique({ where: { id: order.id } });
|
||||
expect(row!.order_text).toBe("Jiný text:");
|
||||
|
||||
// null clears back to the PDF default.
|
||||
await updateIssuedOrder(order.id, { order_text: null });
|
||||
row = await prisma.issued_orders.findUnique({ where: { id: order.id } });
|
||||
expect(row!.order_text).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("updateIssuedOrder status transitions", () => {
|
||||
@@ -507,6 +524,29 @@ describe("renderIssuedOrderHtml", () => {
|
||||
expect(html).not.toContain("alert(1)");
|
||||
});
|
||||
|
||||
it("renders the custom order_text heading when set, default when not", () => {
|
||||
const custom = renderIssuedOrderHtml(
|
||||
{ ...order, order_text: "Objednáváme dle nabídky č. 123:" },
|
||||
items,
|
||||
null,
|
||||
null,
|
||||
"cs",
|
||||
issuer,
|
||||
);
|
||||
expect(custom).toContain("Objednáváme dle nabídky č. 123:");
|
||||
expect(custom).not.toContain("Objednáváme si u Vás:");
|
||||
|
||||
const fallback = renderIssuedOrderHtml(
|
||||
order,
|
||||
items,
|
||||
null,
|
||||
null,
|
||||
"cs",
|
||||
issuer,
|
||||
);
|
||||
expect(fallback).toContain("Objednáváme si u Vás:");
|
||||
});
|
||||
|
||||
it("with VAT: keeps the VAT columns and the DPH cell holds ONLY the line VAT", () => {
|
||||
const html = renderIssuedOrderHtml(order, items, null, null, "cs", issuer);
|
||||
expect(html).toContain("%DPH");
|
||||
|
||||
Reference in New Issue
Block a user