Skip to content

feat(ksef): print KSeF number + verification QR on invoice PDF - #28

Merged
Panelica merged 5 commits into
Panelica:mainfrom
hedon77:feat/ksef-qr-on-invoice
Sep 6, 2026
Merged

feat(ksef): print KSeF number + verification QR on invoice PDF#28
Panelica merged 5 commits into
Panelica:mainfrom
hedon77:feat/ksef-qr-on-invoice

Conversation

@hedon77

@hedon77 hedon77 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Zmiana

Na PDF faktury (VAT) nanoszony jest numer KSeF i kod QR weryfikacji — wyłącznie, gdy moduł KSeF jest włączony i faktura została zaakceptowana w KSeF (ma \ksef_number). Na instalacjach bez KSeF nic się nie drukuje.

Szczegóły

  • \Invoice::ksefInvoice()\ — nowa relacja \hasOne(KsefInvoice::class).
  • \InvoicePdfService::ksefInfo()\ — zwraca {number, qr}\ albo
    ull:
    • warunek: \AddonManager::isActive('ksef')\ + niepusty \ksef_number,
    • QR = PNG data-URI wygenerowany przez \�acon/bacon-qr-code\ (GD), kodujący oficjalny URL weryfikacji \https://ksef.mf.gov.pl/web/verify?nr=…\ (dla integration/demo → \ksef-test),
    • generowanie w try/catch → awaria GD nigdy nie psuje PDF.

  • esources/views/pdf/invoice.blade.php\ — blok QR+numer po sumach, przed stopką.
  • \pdf.ksef_number\ — tłumaczenie en/pl.

Weryfikacja

  • Faktura z \ksef_number\ zwraca numer + QR PNG (data URI).
  • Faktura bez KSeF zwraca
    ull\ (brak bloku).

@Panelica
Panelica merged commit 2da2c15 into Panelica:main Sep 6, 2026
1 check passed
Panelica pushed a commit that referenced this pull request Sep 6, 2026
PRs #27 (dashboard currency/labels) and #28 (KSeF invoice email) added new
strings to en+pl only. Add the Turkish and Simplified Chinese translations for
the 42 admin.dashboard.* keys, the email.ksef_issued.* block and pdf.ksef_number,
and realign the zh files to English's exact structure (mirror test). Also
exclude KsefInvoiceIssuedMail from the template-coverage test: like BulkMassMail
it renders its own fixed layout (with the PDF and verification QR) and is not an
operator-edited template. Parity and the Simplified Chinese mirror stay green.
@Panelica

Panelica commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Merged — thank you, this is well guarded. The ksefInfo() gate (addon inactive or no ksef_number → returns null, nothing prints) means non-KSeF installs render invoices unchanged, and wrapping QR generation in catch (\Throwable) so a missing GD/BaconQrCode never breaks an invoice is the right instinct. bacon/bacon-qr-code ^3.0 is already in composer, and KsefInvoiceIssuedMail correctly reuses the LocalizesToRecipient trait from #26. Emailing the definitive PDF only after a KSeF number is issued is the correct trigger point. #29's footer change is folded in here as you noted.

Two things I completed on merge (follow-up 09b7c5c):

  1. email.ksef_issued.* and pdf.ksef_number were en+pl only — added tr/zh (same parity/mirror reason as fix(dashboard): configured currency + localized widget labels #27).
  2. EmailTemplateCoverageTest asserts every app/Mail/* mailable an operator can edit is bound to a template. KsefInvoiceIssuedMail isn't one of those — it renders its own fixed layout with the PDF + QR attached, like BulkMassMail — so I excluded it from that test with a comment, rather than forcing it into the template system.

Full suite green (2333 passing, only the two pre-existing environmental db-backup tests remain).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants