Documentation Index
Fetch the complete documentation index at: https://docs.doman.id/llms.txt
Use this file to discover all available pages before exploring further.
FasReporting Subsystem Documentation - Addendum A
Version: 1.1
Date: Nov 23, 2025
Change: Architectural Refactoring of Formula Engine
1. Overview of Changes
This addendum details the refactoring of theFasReporting subsystem to isolate the formula parsing and execution logic into a dedicated, reusable service class. This change enhances modularity, testability, and adherence to the Single Responsibility Principle.
The LineReportService is now a high-level orchestrator, delegating all formula-based calculations to the new FormulaEngineService.
2. Updated Directory Structure
The directory structure for the core services is now:3. New Core Component: FormulaEngineService
A new service has been introduced to encapsulate all formula-related logic.
3.1. Purpose and Responsibility
TheFormulaEngineService is solely responsible for:
- Parsing a given formula string (e.g.,
SUM(KEY1, KEY2)). - Identifying the requested function (e.g.,
SUM,AVG,SUB). - Executing the corresponding calculation logic.
- Performing necessary database queries for formula-based aggregations (e.g.,
AVG(6000..6999)). - Returning a single numerical result.
calculatedValues) for each execution call.
3.2. FormulaEngineService Source Code
File: app/Services/FasReporting/FormulaEngineService.php
4. Refactored Core Component: LineReportService
The LineReportService has been simplified to act as an orchestrator. It relies on dependency injection to gain access to the FormulaEngineService.
4.1. Updated Purpose and Responsibility
- Fetch the report template from the database.
- Iterate through the template lines in the correct sequence.
- Maintain the state of the report generation, specifically the
calculatedValuesarray. - For each line, determine whether to calculate its value from an
account_specor aformula. - Delegate all formula calculations to the
FormulaEngineService. - Handle direct GL queries for
account_specbased lines. - Assemble the final report data structure.
4.2. LineReportService Updated Source Code
File: app/Services/FasReporting/LineReportService.php
5. Conclusion of Changes
This architectural improvement results in a more robust and maintainable system. The separation of concerns ensures that future modifications to the formula language can be made entirely within theFormulaEngineService without affecting the overall report generation flow managed by the LineReportService. This also simplifies unit testing, as the FormulaEngineService can be tested in isolation. All other aspects of the system, including the User Guide for creating Excel templates, remain unchanged.
