fiscal-year:export)This Artisan command exports data associated with a specific fiscal year (represented by a Company record) into a JSON file. This file can be used for backups, migrations, or as input for the fiscal-year:import command.
Extract specific data sections (like banks, customers, products, configurations, etc.) linked to a single fiscal year from the database and save them in a structured JSON format.
php artisan fiscal-year:export <source_id> [options]
| Argument | Description | Required |
|---|---|---|
source_id |
The numeric ID of the Company record to export. | Yes |
| Option | Description | Required | Default |
|---|---|---|---|
--output |
Relative path within storage/app for the output JSON file (e.g., my_exports/fy_export.json). If omitted, a default name is generated in the exports/ dir. |
No | exports/fiscal_year_<source_id>_<timestamp>.json |
--sections |
Comma-separated list of data sections to export (e.g., banks,customers,products). Valid sections are defined in FiscalYearService::getAvailableSections(). |
No | All available sections |
Available Sections (from FiscalYearService):
configsbanksbank_accountscustomer_groupscustomersproduct_groupsproductssubjectssail artisan fiscal-year:export 1
Output:
storage/app/exports/fiscal_year_1_<timestamp>.json
sail artisan fiscal-year:export 5 --output=data_exports/fy5_banks_customers.json --sections=banks,customers
Output:
storage/app/data_exports/fy5_banks_customers.json
sail artisan fiscal-year:export 2 --output=archive/fiscal_year_2_full.json
Output:
storage/app/archive/fiscal_year_2_full.json
"banks", "customers"), each holding an array of model data."meta" key is included with:
source_idcompany_nametimestampsections_exportedsource_id doesn’t match an existing Company, an error message is displayed.--sections trigger a warning. If no valid sections remain, the command fails.storage/logs/laravel.log.fiscal-year:import)This Artisan command imports data from a JSON file (typically generated by fiscal-year:export) into a new fiscal year (Company record).
Create a new fiscal year and populate it with data (banks, customers, products, etc.) from a previously exported JSON file. This is useful for restoring backups or migrating fiscal year data between environments.
php artisan fiscal-year:import <file> <fiscal_year> --name=<new_name> [options]
| Argument | Description | Required |
|---|---|---|
file |
The path to the JSON import file, relative to the storage/app directory. |
Yes |
fiscal_year |
The fiscal year identifier (positive integer). | Yes |
| Option | Description | Required | Default |
|---|---|---|---|
--name |
The name for the new fiscal year being created. | Yes | |
--force |
Skip the confirmation prompt before starting the import. Use with caution, especially in production environments. | No | false |
| Note: | Depending on your Company model setup, additional required fields might need to be handled within the FiscalYearService::importData method. |
exports/fy1_backup.json into a new fiscal year named “Fiscal Year 2024” with fiscal year identifier 2024:
sail artisan fiscal-year:import exports/fy1_backup.json 2024 --name="Fiscal Year 2024"
This will prompt for confirmation before proceeding.
archive/old_data.json forcefully (no confirmation):
sail artisan fiscal-year:import archive/old_data.json 2023 --name="Restored FY" --force
--name is provided.fiscal_year argument is a positive integer.file exists within storage/app.--force is used.Company record using the provided --name and fiscal_year.FiscalYearService::importData method, passing the decoded JSON data and the new fiscal year details. This service handles the actual creation of the new Company and the insertion of related data (banks, customers, etc.) associated with the new company ID.--name option is missing, an error is shown.fiscal_year argument is not a positive integer, an error is shown.FiscalYearService::importData process (e.g., database errors, validation issues within the service) will result in an error message being displayed, and details are logged to storage/logs/laravel.log.