Console commands
Available Console Commands¶
This section details the console commands provided by the KSeF Integration to help you manage and maintain your system data.
migrate-tax-id-to-ksef¶
Availability: Since version 1.2.0
This command facilitates the bulk migration of existing Tax IDs from a legacy database field into the standardized Tax ID structure required by the KSeF integration.
Overview¶
If your application previously stored Tax ID or VAT numbers in a custom or legacy field (for example, a field named tid), this command allows you to seamlessly map and transfer those records. During the migration process, you must specify the legacy field name and classify the type of Tax ID being transferred.
Command Options¶
| Option | Required | Description | Accepted Values |
|---|---|---|---|
--field |
Yes | The exact name of the legacy field currently storing the Tax IDs. | String (e.g., tid) |
--type |
Yes | The specific classification of the Tax IDs being migrated. | NIP, VAT UE, Other |
Usage Examples¶
Basic Migration
If you were previously using a field named tid to store European VAT numbers, you will map tid as the --field and set the --type to VAT UE.
bin/command migrate-tax-id-to-ksef --field='tid' --type='VAT UE'
Generic Syntax
When running the command in your environment, replace the placeholder variables with your specific database parameters:
bin/command migrate-tax-id-to-ksef --field='<OLD_TAX_ID_FIELD>' --type='<TYPE_OF_TAX_ID>'
fetch-expenses-from-ksef¶
Availability: Since version 1.5.0
This command schedules background jobs to fetch expense invoices from KSeF for a selected date range. You can run it for one specific KSeF profile or for all active profiles.
Overview¶
The command validates input dates and then creates queue jobs (q1) using FetchExpensesAfterProfileCreation.
If --ksefProfileId is provided, only that profile is used. If not provided, jobs are scheduled for all active KSeF profiles.
Command Options¶
| Option | Required | Description | Accepted Values |
|---|---|---|---|
--from |
Yes | Start date for fetching expenses. Must be a real date. | YYYY-MM-DD |
--to |
No | End date for fetching expenses. If omitted, current date is used. Must be a real date when provided. | YYYY-MM-DD |
--ksefProfileId |
No | KSeF Profile ID. If omitted, all active profiles are processed. | Valid profile ID |
Usage Examples¶
Single Profile
Schedule fetching expenses for one profile in a fixed range.
php bin/command fetch-expenses-from-ksef --from="2024-01-01" --to="2026-04-31" --ksefProfileId="profile-id"
All Active Profiles
Schedule fetching expenses for all active profiles from a start date until today.
php bin/command fetch-expenses-from-ksef --from="2024-01-01"
Generic Syntax
Replace values with your own parameters.
php bin/command fetch-expenses-from-ksef --from='<FROM_DATE>' --to='<TO_DATE>' --ksefProfileId='<PROFILE_ID>'
Notes¶
--fromis mandatory.- Dates must match
YYYY-MM-DDand be valid calendar dates. - If no active profiles are found (and no profile ID is passed), no jobs are created.
- A success summary is printed with the number of profiles scheduled.
regenerate-ksef-urls¶
Availability: Since version 1.5.0
This command regenerates KSeF public URLs by fixing double-encoded links for a specific entity or for a batch of entities of the selected type.
Overview¶
The command supports Invoice and Expense entities. If --entityId is provided, only that record is processed. If it is omitted, the command scans up to 1000 records of the selected entity type and updates any record whose KSeF URL can be corrected.
Command Options¶
| Option | Required | Description | Accepted Values |
|---|---|---|---|
--entityType |
Yes | Entity type to process. | Invoice, Expense |
--entityId |
No | Specific entity ID to process. If omitted, all matching records are scanned. | Valid entity ID |
Usage Examples¶
Single Entity
Regenerate the KSeF URL for one invoice.
php bin/command regenerate-ksef-urls --entityType='Invoice' --entityId='record-id'
Batch Regeneration
Regenerate KSeF URLs for up to 1000 expense records.
php bin/command regenerate-ksef-urls --entityType='Expense'
Generic Syntax
Replace the placeholders with your own values.
php bin/command regenerate-ksef-urls --entityType='<ENTITY_TYPE>' --entityId='<ENTITY_ID>'
Notes¶
--entityTypeis mandatory and must be eitherInvoiceorExpense.- If
--entityIdis not provided, the command processes up to 1000 records for the selected entity type. - Records without a KSeF hash or public URL are skipped.
- Updated entities are saved silently without hooks.