Statistics & Profitability
Relevant source files
The following files were used as context for generating this wiki page:
The Statistics & Profitability module is a core component of the Duplicator application, designed to provide printing collectives with a comprehensive overview of their operational efficiency and financial health. It aggregates data from various printing machines (duplicators and photocopiers) to track production volumes, calculate revenue, and monitor profitability.
This system serves two primary purposes: providing real-time data analysis via the "Fill Rate" (taux de remplissage) tool for cost estimation and offering a high-level administrative dashboard for long-term reporting. The module leverages aggregated metrics such as total page counts, revenue from different payment methods (cash vs. credit card), and consumable usage to generate insights into the collective's performance.
Sources: README.md, app/view/admin.stats.html.php:26-37, app/view/taux_remplissage.html.php:12-16
Administrative Statistics Management
The administrative interface allows managers to configure how statistics are presented to users. A central feature is the customizable introduction text, which supports dynamic variables that are replaced with real-time data from the database.
Data Aggregation and Variables
The StatsManager class handles the retrieval of statistical data stored in the site_settings table. This data is used to populate a set of predefined variables in the statistics introduction text.
| Variable | Description |
|---|---|
{nb_f} | Total number of sheets printed |
{nb_t} | Total number of print runs (tirages) |
{nb_t_par_mois} | Average number of print runs per month |
{nbf_par_mois} | Average number of sheets per month |
{nb_moy_par_mois} | Average copies per print run |
{ca} | Total revenue (Chiffre d'affaire) |
{ca2} | Declared paid revenue |
{ca1} | Revenue paid via Credit Card (CB) |
{doit} | Amount owed to the collective |
{benf} | Net profit |
Sources: app/view/admin.stats.html.php:26-37, app/models/admin/StatsManager.php:12-25
StatsManager Architecture
The StatsManager facilitates the persistence of statistical settings using a key-value store approach within the SQLite database.
The manager specifically interacts with the site_settings table where the setting_name is 'stats_intro_text'.
Sources: app/models/admin/StatsManager.php:12-40, app/tests/Feature/AdminStatsManagerTest.php:1-30
Profitability Analysis: Fill Rate Tool
Profitability is heavily influenced by consumable consumption, particularly ink and toner. The "Fill Rate" (Taux de Remplissage) system provides technical analysis of documents to estimate these costs before or after printing.
Analysis Logic
The system performs a pixel-by-pixel analysis of uploaded PDF or image files (JPEG, PNG, GIF). It identifies "filled" vs. "empty" (white) pixels based on a user-defined tolerance level.
Technical Metrics Provided
- Dimensions: Image size in pixels.
- Total Pixels: Calculated as width × height.
- Filled/Empty Pixels: Raw counts based on the tolerance threshold (default: 245/255).
- Dominant Colors: Identification of the top 8 hex colors to determine which ink drums or toner cartridges will be most utilized.
Sources: app/view/taux_remplissage.html.php:48-96, app/translations/en.json:490-505
Data Flow for Financial Reporting
Financial statistics are derived from multiple tables depending on the machine type (e.g., a3, a4, photocop).
Revenue Tracking
Revenue is segmented into three categories to ensure accurate accounting:
- Total CA: Calculated from all recorded print runs across all tables.
- Paid CA: Filters for print runs marked as "paid" (
paid = 1orpaid = 'yes'). - Credit Card (CB) CA: Specifically tracks payments made via the integrated card system.
Conclusion
The Statistics & Profitability system provides a dual-layered approach to management. Administratively, it offers a flexible reporting tool using dynamic variables to communicate the collective's history and financial standing. Operationally, the Fill Rate analysis tool allows for precise cost prediction by analyzing the digital footprint of documents, ensuring that pricing remains sustainable relative to consumable consumption.
Sources: app/view/admin.stats.html.php:39-40, app/view/taux_remplissage.html.php:110-120