feat: add KSeF invoice submission flow#2508
Open
kcem wants to merge 8 commits into
Open
Conversation
4a2da47 to
7647218
Compare
added 8 commits
April 28, 2026 15:42
0eba3ef to
d6914ab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds KSeF sales invoice submission flow.
What is included:
bin/lms-ksef.phpscript for sending eligible sales invoices to KSeF and synchronizing pending KSeF statuses/UPO files;n1ebieski/ksef-php-client;ksefdocuments.permanent_storage_datenullable, matching PostgreSQL and allowing pending outbound documents before KSeF returns permanent storage date;lms-ksef.phpusage:bin/lms-ksef.php --sendsends eligible invoices.bin/lms-ksef.php --syncsynchronizes pending documents and downloads UPO files when available.bin/lms-ksef.php --send --syncsends invoices and then synchronizes pending documents.bin/lms-ksef.php --test --sendprints send candidate count only.bin/lms-ksef.php --test --syncprints pending document count only.bin/lms-ksef.php --section=<section>reads configuration from a custom uiconfig section; default isksef.bin/lms-ksef.php --division=<shortname>limits send/sync to one division.bin/lms-ksef.php --customerid=<id>limits send/sync to one customer.Practical use:
ksef.environmentand authentication first (ksef.tokenwithksef.auth_method=token, orksef.certificate/ksef.passwordwithksef.auth_method=certificate);bin/lms-ksef.php --test --sendto check how many invoices are eligible before sending anything;bin/lms-ksef.php --send --syncfrom cron to send eligible invoices and immediately try to collect statuses/UPO files using the same sync flow as invoice-list submission;1s, 2s, 3s, 5s, 10sand then keeps retrying every10sup to 10 minutes per KSeF session;bin/lms-ksef.php --syncfrom cron as a follow-up job if KSeF has not returned final statuses/UPO files during the send run;--division=<shortname>when each division has separate KSeF credentials configured in uiconfig;--customerid=<id>for controlled troubleshooting of one customer.KSeF uiconfig options used by this flow:
ksef.environment: KSeF environment. Supported values:test,demo,prod,production. Numeric aliases are also accepted:1=test,2=production,3=demo. Default:test.ksef.auth_method: authentication method. Supported values:token,certificate. If not set, token auth is selected whenksef.tokenis present, otherwise certificate auth is selected.ksef.token: token used whenauth_method=token.ksef.certificate: certificate path used whenauth_method=certificate. Relative paths are resolved againstSYS_DIR.ksef.password: certificate password used whenauth_method=certificate.ksef.max_documents: maximum number of documents processed in one script run. Default:10000; clamped to1..10000.ksef.invoice_reference_page_size: page size for KSeF invoice reference listing during sync. Default:1000; clamped to10..1000.ksef.delay: minimum invoice age in seconds before it is eligible for KSeF submission. Default:3600;-1disables submission for the division.ksef.boundary_date: earliest invoice date eligible for KSeF submission. Default:2026/04/01.ksef.all_consumers: when enabled, consumer invoices are eligible too. When disabled, only company invoices and customers with KSeF invoice consent are eligible.ksef.show_balance_summary: adds balance summary information to generated KSeF invoice XML.ksef.xml_add_all_values: adds optional XML values supported by the existing KSeF invoice XML builder.Existing KSeF options like
ksef.offline_support,ksef.offline_certificate,ksef.offline_password,ksef.invoice_headerandksef.purchase_invoice_default_orderare not changed by this submission flow.Test coverage: