Download the PHP package ezesha/end-year-reports without Composer
On this page you can find all versions of the php package ezesha/end-year-reports. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ezesha/end-year-reports
More information about ezesha/end-year-reports
Files in ezesha/end-year-reports
Package end-year-reports
Short Description Asynchronous end-year financial report generation module for CodeIgniter 4 (SQS-backed worker pipeline).
License MIT
Informations about the package end-year-reports
ezesha/end-year-reports
Asynchronous end‑year financial report generation for CodeIgniter 4.
A user picks an office and a closure date and clicks Generate Package; the
HTTP request enqueues the job on Amazon SQS (LocalStack‑friendly) and returns
immediately, a background worker runs an ordered pipeline
(Trial Balance → Income Statement → Balance Sheet), writes the results back, and
the browser polls until the package is READY. Failed jobs self‑heal via a retry
command.
This module is a self‑contained CodeIgniter 4 package: controllers, worker
commands, model, migration, services, views and frontend assets, all under the
Ezesha\EndYearReports\ namespace and auto‑discovered by the framework.
Requirements
- PHP
^8.1 - CodeIgniter 4
^4.4 aws/aws-sdk-php^3.0(pulled in automatically)- An SQS queue — real AWS, or LocalStack for local dev
codeigniter4/tasks(optional) — only if you want the bundled scheduled workers
Installation
1. Require the package
Published to a Git host / Packagist:
Or, while developing it locally, add a path repository to the application's
composer.json and require it:
CodeIgniter auto‑discovers the module's routes, commands, migrations, services and config as soon as Composer registers the namespace — no manual wiring in
App\Config\*is required (Config\Modules::$discoverInComposermust staytrue, which is the default).
2. Configure the environment
Add to the application .env:
3. Run the migration
The migration lives in the package namespace, so run migrations for all namespaces (or target this one):
4. Publish the frontend assets
Copies the module's JS and CSS into the app's public/ directory:
This writes public/ezesha/js/end_year_report/* and
public/ezesha/styles/end_year_report.css, which the shipped view references at
/ezesha/js/... and /ezesha/styles/.... The ezesha/ sub-folder namespaces
the assets so they never collide with the host app's own public/js or
public/styles.
5. Run the worker
Open /end_year_report in the browser, choose an office and closure date,
and click Generate Package.
Usage summary
| Route | Purpose |
|---|---|
GET /end_year_report |
The dashboard web page |
GET /api/reports/office/{officeId}/{date} |
Enqueue + poll; returns PROCESSING/READY/FAILED |
| Command | Purpose |
|---|---|
workers:process-reports [--once] [--max-messages N] |
Consume the queue and run the compilation pipeline |
workers:retry-failed [--max-age-hours N] [--dry-run] |
Re‑queue reports stuck in the failed state |
endyearreports:publish |
Publish frontend assets into public/ezesha/ |
API states
The API is idempotent per (office_id, closure_date) (enforced by a unique
key) and returns a queue_state:
PROCESSING(202) — queued / in flight; the frontend polls every 5s.READY(200) — compiled; response carries the three statements underdata.FAILED(500) — pipeline rolled back, or the job stalled past the threshold.
A user "Generate" click sends ?retry=1 to clear a previous failure and re‑run;
passive polls omit it so genuine failures surface instead of looping.
Configuration & extension
Everything tunable lives in
Ezesha\EndYearReports\Config\EndYearReports.
Override it by publishing an App\Config\EndYearReports class (same short name)
in the host app — CodeIgniter's Factories resolve the app namespace first.
| Property | Default | Meaning |
|---|---|---|
$dataProvider |
MockFinancialDataProvider |
Class that supplies the raw financial package |
$pipeline |
trial → income → balance | Ordered stageKey => serviceClass map |
$staleThresholdSeconds |
240 |
When a pending job is treated as stalled/failed |
$sqsUrl / $aws* |
env‑driven | Connection settings (host .env overrides at construct time) |
Plugging in real data (the important one)
The shipped MockFinancialDataProvider returns a static fixture so the module
runs out of the box. To feed real ledger data, implement
FinancialDataProviderInterface:
Then point config at it (via your App\Config\EndYearReports):
The pipeline services resolve the provider through
service('financialDataProvider'), so no other change is needed.
Scheduling (optional, requires codeigniter4/tasks)
The package does not force a scheduler on you. To run the workers automatically,
add these to the host app's App\Config\Tasks::init():
…and wire the CodeIgniter task runner into system cron:
Why bounded worker runs? A long‑lived PHP process caches every class in memory, so it keeps running stale code after you edit a service. Running a fresh, bounded process each tick (
--max-messages) always loads current code.
Data model
Table end_year_report (see the migration):
- Unique key
unique_office_closureon(fk_office_id, end_year_report_closure_date)blocks duplicate placeholders under concurrency. end_year_report_is_valid:0= pending,1= valid/ready,2= failed/rolled back.- The JSON column is physically named
trail_balance(historical spelling) while the pipeline/API key istrial_balance; the code readstrail_balance ?? trial_balanceand the model allows both.
Package layout
License
MIT — see LICENSE.