// DemoFatura.jsx — auto-looping demo: criar e certificar uma fatura (AT e-fatura). // Timeline ~10s: cliente escrito → NIF validado → linhas → total → cursor // clica "Certificar e emitir" → comunicação à AT → carimbo ATCUD + QR + toast. (function () { const STR = { pt: { windowTitle: 'Vendas · Nova fatura', badgeCertified: 'Emitida · ATCUD', badgeSending: 'A comunicar…', badgeDraft: 'Rascunho', clientLabel: 'Cliente', colSku: 'SKU', colDesc: 'Designação', colQty: 'Qtd', colTotal: 'Total', totalVat: 'Total c/ IVA (22%)', series: 'Série 2026 · contínua', btnSending: 'A comunicar à AT…', btnDone: 'Emitida', btnIdle: 'Emitir e comunicar à AT', toast: 'Fatura FT 2026/0042 emitida · ATCUD e QR incluídos', rows: [ { sku: 'CEM-25', name: 'Cimento CEM II 32,5N · 25 kg', qty: '120 un', total: '€ 514,80' }, { sku: 'TIJ-30', name: 'Tijolo cerâmico 30×20×15', qty: '500 un', total: '€ 412,50' }, ], }, en: { windowTitle: 'Sales · New invoice', badgeCertified: 'Issued · ATCUD', badgeSending: 'Submitting…', badgeDraft: 'Draft', clientLabel: 'Customer', colSku: 'SKU', colDesc: 'Description', colQty: 'Qty', colTotal: 'Total', totalVat: 'Total w/ VAT (22%)', series: 'Series 2026 · continuous', btnSending: 'Submitting to AT…', btnDone: 'Issued', btnIdle: 'Issue and submit to AT', toast: 'Invoice FT 2026/0042 issued · ATCUD and QR included', rows: [ { sku: 'CEM-25', name: 'Cement CEM II 32.5N · 25 kg', qty: '120 pcs', total: '€ 514,80' }, { sku: 'TIJ-30', name: 'Ceramic brick 30×20×15', qty: '500 pcs', total: '€ 412,50' }, ], }, es: { windowTitle: 'Ventas · Nueva factura', badgeCertified: 'Emitida · ATCUD', badgeSending: 'Comunicando…', badgeDraft: 'Borrador', clientLabel: 'Cliente', colSku: 'SKU', colDesc: 'Descripción', colQty: 'Cant.', colTotal: 'Total', totalVat: 'Total c/ IVA (22%)', series: 'Serie 2026 · continua', btnSending: 'Comunicando a la AT…', btnDone: 'Emitida', btnIdle: 'Emitir y comunicar a la AT', toast: 'Factura FT 2026/0042 emitida · ATCUD y QR incluidos', rows: [ { sku: 'CEM-25', name: 'Cemento CEM II 32,5N · 25 kg', qty: '120 ud', total: '€ 514,80' }, { sku: 'TIJ-30', name: 'Ladrillo cerámico 30×20×15', qty: '500 ud', total: '€ 412,50' }, ], }, }; function DemoFatura() { const lang = (window.__DEMO_LANG === 'en' || window.__DEMO_LANG === 'es') ? window.__DEMO_LANG : 'pt'; const s = STR[lang]; const D = 10000; const t = window.useDemoLoop(D, 8200); const { dkProg, dkEase, dkTyped, dkCursor, dkEUR } = window; const { DemoCaret, DemoCursor, DemoToast, MiniWindow, DemoStage, FakeQR } = window; const client = dkTyped('Construções Santa Cruz, Lda.', t, 500, 1700); const typing = t >= 500 && t < 1700; const nif = t >= 2000; const rowOn = [t >= 2400, t >= 2850]; // € 927,30 net × 1.22 — Madeira normal rate (2026: 4/12/22) const total = 1131.31 * dkEase(dkProg(t, 3100, 4100)); const sending = t >= 5050 && t < 6600; const done = t >= 6600; const toast = t >= 6950 && t < 9400; const cur = dkCursor(t, [ { at: 0, x: 538, y: 392, hidden: true }, { at: 3900, x: 538, y: 392 }, { at: 4150, x: 447, y: 322 }, { at: 7800, x: 538, y: 392, hidden: true }, ], [4900]); const badge = done ? ( {s.badgeCertified} ) : sending ? ( {s.badgeSending} ) : ( {s.badgeDraft} ); return ( {s.clientLabel} {client} NIF 501 234 567 {s.colSku}{s.colDesc}{s.colQty}{s.colTotal} {s.rows.map((r, i) => ( {r.sku} {r.name} {r.qty} {r.total} ))} {s.totalVat} {dkEUR(total)} {s.series} {sending ? ( {s.btnSending} ) : done ? ( {s.btnDone} ) : ( {s.btnIdle} )} {done && ( AT · e-fatura ATCUD JFF4-0042 FT 2026/0042 )} ); } window.DemoFatura = DemoFatura; })();