π¬π§ English | π«π· FranΓ§ais
This repository contains an invoice and revenue automation system designed to operate:
- without a CMS
- without external SaaS services
- without a database
- without any exposed web interface
The entire system relies on PHP scripts executed via cron jobs, with a deliberately simple, readable, and auditable architecture.
The system provides:
- automatic PDF invoice generation (FR / EN)
- automatic invoice delivery by email
- per-client revenue tracking (JSON)
- revenue export to CSV (accounting-ready)
- reliable yearly invoice numbering
It is not a certified accounting software and does not replace:
- a certified accountant
- a regulated accounting software
- nor any legal tax or reporting obligations
The data produced by this system is intended for internal and operational use only.
This repository does not provide:
- a user interface
- a ready-to-use SaaS product
- a certified invoicing system
- an automated payment processing system
It is a documented technical architecture,
designed to illustrate a robust and autonomous automation approach.
- One client = one configuration file
- No sensitive data exposed on the web
- No dependency on third-party invoicing services
- Full traceability (logs, invoices, revenues)
- CLI-only execution (no browser access)
This system is designed to be:
- robust
- predictable
- maintainable over time
- understandable without advanced knowledge
automation/
β
βββ engine/
β βββ run.php β Moteur principal dβautomatisation (cron / CLI) (FR)
β β β Main automation engine (cron / CLI) (EN)
β β
β βββ export_accounting_year.php β Export annuel des recettes (FR)
β β β Annual revenue export (EN)
β β
β βββ billing_rules.php β RΓ¨gles de facturation et de tarification dynamique (FR)
β β β Billing rules and dynamic pricing logic (EN)
β β
β βββ run_batch.php β Moteur dβautomatisation BATCH pour la facturation clients (FR)
β β β Batch automation engine for client invoicing (EN)
β β
β βββ vendor/ β DΓ©pendances PHP (ex: DomPDF) (FR)
β β β PHP dependencies (e.g. DomPDF) (EN)
β β
β βββ alerts β Gestion des alertes et notifications dβexΓ©cution (FR)
β β β Execution alerts and notifications handling (EN)
β β
β βββ import_cvs.php β Import et validation des fichiers CSV clients (FR)
β β β Client CSV import and validation handler (EN)
β β
β βββ mailer.php β Envoi des emails avec facture en piΓ¨ce jointe (FR)
β β β Email sender with invoice attachment (EN)
β βββ templates/
β βββ invoice.html.php β Template PDF de facture (bilingue FR / EN) (FR)
β β β Invoice PDF template (bilingual FR / EN) (EN)
β β
β βββ invoices_batch.html.php β Facture CLIENTS (batch) (FR)
β β Client Invoices (Batch) (EN)
βββ clients/
β βββ client_xxx.php β Fiche client (seul fichier Γ modifier par client) (FR)
β β Client configuration file (only file to edit per client) (EN)
βββ batch_clients/
β βββ client_xxx.php β Configuration batch dβun client final (facturation mensuelle) (FR)
β β Batch configuration for an end client (monthly invoicing) (EN)
βββ data/
β βββ logs/
β β βββ xxx.log β Logs dβexΓ©cution par client (FR)
β β β Execution logs per client (EN)
β βββ archive_batch/
β β βββ xxx.csv β CSV client archivΓ© (FR)
β β β Archived client CSV (EN)
β βββ usage/
β β βββ xxx.json β Suivi dβusage mensuel par client (FR)
β β β Monthly client usage tracking (EN)
β βββ revenues/
β β βββ xxx.json β Recettes cumulΓ©es (source comptable interne) (FR)
β β β Cumulative revenues (internal accounting source) (EN)
β βββ payments/
β β βββ xxx.json β Paiements reΓ§us du client (virements, montants rΓ©ellement encaissΓ©s) (FR)
β β β Payments received from the client (bank transfers, actually received amounts) (EN)
β βββ balance/
β β βββ xxx.json β Solde comptable du client (facturΓ© vs payΓ©, statut payΓ© / impayΓ©) (FR)
β β β Client accounting balance (invoiced vs paid, paid / unpaid status) (EN)
β βββ invoices/
β β βββ client/ β Factures de lβactivitΓ© principale (facturation directe, usage interne) (FR)
β β β Invoices from the main activity (direct invoicing, internal use) (EN)
β βββ invoices_batch/
β β βββ client/ β Factures gΓ©nΓ©rΓ©es dans le cadre du service batch (clients finaux) (FR)
β β β Invoices generated as part of the batch service (end clients) (EN)
β βββ inbox_batch/
β β βββ batch.csv β Fichier CSV fourni par le client (source de facturation batch) (FR)
β β β Client-provided CSV file (batch invoicing source) (EN)
β βββ counters/
β β βββ xxx.json β Compteur annuel de factures par client (facturation directe) (FR)
β β β Annual invoice counter per client (direct invoicing) (EN)
β βββ counters_batch/
β βββ xxx.json β Compteur annuel de factures par client (facturation batch) (FR)
β β Annual invoice counter per client (batch invoicing) (EN)
βββ docs/
β βββ format_csv.md β SpΓ©cification officielle du format CSV attendu (FR)
β β Official specification of the expected CSV format (EN)
βββ tools/
β βββ update_balances.php β Met Γ jour les soldes clients Γ partir des recettes et des paiements (FR)
β β β Updates client balances based on revenues and payments (EN)
β β
β βββ purge_log.php β Script de nettoyage (FR)
β β β Cleanup Script (EN)
β β
β βββ export_revenues_csv.php β Script PHP dβexport des recettes vers un fichier CSV (comptabilitΓ©) (FR)
β β PHP script to export revenues to a CSV file (accounting) (EN)
βββ exports/
β βββ export_revenues.csv β Fichier CSV contenant les recettes exportΓ©es (donnΓ©es tabulaires) (FR)
β β CSV file containing exported revenues (tabular data) (EN)
βββ downloads/
β βββ *.zip β Archives ZIP mensuelles par client, contenant les factures PDF gΓ©nΓ©rΓ©es automatiquement (FR)
β β Monthly ZIP archives per client, containing automatically generated PDF invoices (EN)
β
βββ LICENSE.md β Conditions dβutilisation et cadre lΓ©gal (FR)
β β Terms of use and legal Framework (EN)
β
βββ README.md β Documentation gΓ©nΓ©rale du systΓ¨me (FR)
β General system documentation (EN)
Each client is defined in a dedicated file:
clients/client_xxx.phpThis file contains:
- client identity
- billing information
- currency
- language (FR / EN)
- execution mode (
testorlive)
This is the only file to edit when adding or adjusting a client.
The main script is:
engine/run.php
It is executed via a cron job (daily, monthly, or scheduled as needed).
At each execution:
- active clients are processed
- an invoice is generated if applicable
- the invoice is archived
- revenues are updated
- an email is sent to the client
- execution logs are written
- Invoices are generated as PDF files using DomPDF
- The template supports both French and English
- The language depends solely on the client configuration
- Legal mentions (VAT, exemptions, etc.) are handled automatically
Invoices are archived per client in:
data/invoices/{client_id}/For each client, a JSON file is maintained:
data/revenues/{client_id}.jsonIt contains:
- cumulative total
- detailed invoice history
- currency
- invoice numbers and dates
This file is the internal accounting source of the system.
An export tool is provided:
tools/export_revenues_csv.phpIt generates CSV files usable by:
- spreadsheets
- accountants
- accounting software
CSV files can be deleted and regenerated at any time
(with no impact on source data).
The system operates on a simple and predictable monthly cycle.
Clients make their payment (bank transfer).
No emails are automatically sent before this date.
Check received payments on the bank account.
Update the files in data/payments/:
- one file per client
- empty if no payment was received
- filled if a payment was received
Run the following script from the command line:
php tools/update_balances.phpThis script:
- compares invoiced amounts vs paid amounts
- computes the balance
- automatically sets the status to
paidorunpaid
The results are written to:
data/balance/{client_id}.jsonInvoices are automatically generated.
Emails are sent only if:
- the client is active
options.auto_send = true- the script is executed on the 15th
No email is sent outside of this date.
Invoice email delivery is strictly controlled.
All of the following conditions must be met for an email to be sent:
- the client is active (
active = true) options.auto_send = true- the script is executed on the 15th of the month
- execution is done via CLI (cron)
This rule is deliberately enforced in mailer.php
to prevent any accidental or out-of-cycle email delivery.
The system includes a batch invoicing engine designed for clients who provide their own billing data via CSV files.
How it works:
- one CSV file per client
- one CSV row = one PDF invoice
- automatic invoice generation
- monthly grouping into a ZIP archive
- email delivery of the download link (optional)
Related script:
engine/run_batch.phpImportant rules:
- PDF invoices are always generated
- sending (ZIP + email) depends only on
options.auto_send - sending is restricted to the 15th of the month
- one send per client per month (anti-duplicate safeguard)
The expected CSV format is documented in:
docs/format_csv.md
This document is intended for internal use
or for a supervised technical client.
- The engine refuses execution outside CLI
- No web endpoint is exposed
- Data is stored locally on the server
- No direct browser access is possible
logs/and CSV export files can be safely cleanedinvoices/,revenues/, andcounters/must never be deleted- Invoice numbering is automatic and yearly
Status: Stable β production-ready.
This system is used in real conditions,
has no critical external dependencies,
and is designed to operate autonomously over the long term.
Β© Palks Studio β see LICENSE.md
https://palks-studio.com
