Skip to content

πŸ‡¬πŸ‡§ Autonomous PHP automation engine for invoicing and revenue tracking (CLI-based) πŸ‡«πŸ‡· Moteur d’automatisation PHP autonome pour la facturation et le suivi des recettes (CLI)

License

Notifications You must be signed in to change notification settings

Palks-Studio/automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Palks Studio

πŸ‡¬πŸ‡§ English | πŸ‡«πŸ‡· FranΓ§ais

Palks Studio β€” Automation System

Financial automation built for rigor, traceability, and longevity

This README documents design principles and system architecture.
It intentionally avoids operational procedures and sensitive details.


Overview

This repository presents a financial automation system designed to handle:

  • invoice generation (single & batch)
  • revenue tracking
  • payment reconciliation
  • client balances
  • accounting-ready exports

The system is deterministic, auditable, and explicit by design.

It operates:

  • without a database
  • without a CMS
  • without a SaaS dependency
  • without any exposed web interface

All executions run server-side, via CLI scripts and cron, with a strict separation of responsibilities.

This project is not a product, not a SaaS, and not a plug-and-play tool.
It documents a production-grade approach to financial automation.


Project structure

automation/
β”‚
β”œβ”€β”€ engine/
β”‚   β”œβ”€β”€ run.php                     β†’ Moteur principal d’automatisation (cron / CLI) (FR)
β”‚   β”‚                               β†’ Main automation engine (cron / CLI) (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.php                  β†’ Gestion des alertes et notifications d’exΓ©cution (FR)
β”‚   β”‚                               β†’ Execution alerts and notifications handling (EN)
β”‚   β”‚
β”‚   β”œβ”€β”€ import_csv.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)
β”‚   β”œβ”€β”€ batch_sent/
β”‚   β”‚   └── xxx.zip                 β†’ Zip envoyΓ©s (FR)
β”‚   β”‚                               β†’ Zip sent (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/
β”‚   β”œβ”€β”€ 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)
β”‚   β”‚
β”‚   β”œβ”€β”€ recettes_year.php           β†’ Script PHP d’export des recettes encaissΓ©es sur une annΓ©e complΓ¨te (FR)
β”‚   β”‚                               β†’ PHP script to export actually received revenues for a full year (EN)
β”‚   β”‚
β”‚   β”œβ”€β”€ recettes_month.php          β†’ Script PHP d’export des recettes encaissΓ©es sur un mois donnΓ© (FR)
β”‚   β”‚                               β†’ PHP script to export actually received revenues for a given month (EN)
β”‚   β”‚
β”‚   └── 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/
β”‚   β”œβ”€β”€ recettes/
β”‚   β”‚   └── recettes.csv            β†’ CSV mensuels / annuels gΓ©nΓ©rΓ©s Γ  la demande (FR)
β”‚   β”‚                               β†’ Monthly CSV exports generated on demand / Yearly CSV exports generated on demand (EN)
β”‚   β”‚
β”‚   └── payments/                   β†’ CSV gΓ©nΓ©rΓ© Γ  partir des fichiers JSON de paiements reΓ§us (FR)
β”‚       └── payments.csv            β†’ CSV generated from the received payments JSON files (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)
β”‚
β”œβ”€β”€ LICENCE.md                      β†’ Conditions d’utilisation et cadre lΓ©gal (FR)
β”œβ”€β”€ LICENSE.md                      β†’ Terms of use and legal Framework (EN)
β”‚
β”œβ”€β”€ README_FR.md                    β†’ Documentation gΓ©nΓ©rale du systΓ¨me (FR)
└── README.md                       β†’ General system documentation (EN)

What this repository is (and is not)

This repository is

  • a documented architecture for financial automation
  • a system designed to be predictable and auditable
  • an example of strict separation between billing, payments, and accounting
  • a real-world system used in production

This repository is not

  • a certified accounting software
  • a ready-to-use invoicing tool
  • a payment processing system
  • a web application or API service

The outputs produced by this system are intended for internal operational use and for integration with standard accounting workflows.


Core design principles

This system follows a small set of non-negotiable principles:

  • No magic
    Every operation is explicit and traceable.

  • No silent processing
    Errors stop execution. They are logged and surfaced.

  • No implicit correction
    Invalid inputs are rejected, not β€œfixed”.

  • Files are proofs
    Generated artifacts are considered immutable evidence, not disposable outputs.

  • Strict separation of responsibilities
    Billing, payments, balances, receipts, and exports are handled independently.

  • CLI-only execution
    No web exposure, no background ambiguity.

These principles favor predictability over convenience and clarity over speed.


System architecture (high-level)

The system is composed of independent layers, each with a single responsibility:

  • Billing engines

    • direct invoicing
    • batch invoicing (CSV-driven)
  • Business rules

    • centralized pricing and billing logic
    • single source of truth
  • Alerting layer

    • blocking vs informational alerts
    • explicit execution feedback
  • Payment layer

    • manual payment records
    • deliberately decoupled from billing
  • Balance reconciliation

    • computed state (invoiced vs paid)
    • paid / unpaid detection
  • Export layer

    • accounting-ready CSV outputs
    • reproducible at any time

No layer mutates another implicitly.


Project structure (conceptual view)

The directory layout mirrors the system’s responsibilities:

engine/ β†’ execution engines & business logic clients/ β†’ client configuration (one file per client) batch_clients/ β†’ batch client definitions data/ β†’ immutable operational data (logs, invoices, balances) docs/ β†’ internal specifications (e.g. CSV format) tools/ β†’ reconciliation and export utilities exports/ β†’ generated accounting artifacts downloads/ β†’ packaged invoice archives

Each directory exists for one reason only.
Cross-responsibility coupling is intentionally avoided.


Execution model

The system runs on a closed, repeatable cycle:

  1. Generation phase
    Invoices are generated based on explicit rules and configurations.

  2. Payment phase
    Payments are recorded independently, without automation or assumptions.

  3. Reconciliation phase
    Invoiced amounts are compared against received payments.

  4. Consolidation phase
    Client balances are computed and statuses updated.

  5. Export phase
    Accounting-ready artifacts are produced on demand.

At no point does the system infer or guess missing information.


Batch invoicing model

In batch mode:

  • one client provides one CSV file
  • one CSV line equals one invoice
  • validation is strict and structural
  • the entire batch stops on the first error
  • raw inputs are archived before consumption

This model favors data integrity over partial success.


Integrity & safeguards

Several mechanisms are enforced across the system:

  • anti-duplicate protections
  • annual sequential counters
  • immutable archives
  • explicit execution flags
  • categorized alerts
  • exhaustive logging

A failed execution is considered safer than a partial one.


Security posture

  • CLI-only execution
  • no exposed endpoints
  • no browser access
  • no external API dependency for core operations
  • data stored locally on the server

Security is achieved through absence of surface, not complexity.


Maintenance & longevity

The system is designed to:

  • be understandable without its original author
  • be auditable months or years later
  • degrade loudly rather than silently
  • integrate cleanly with standard accounting processes

This repository documents an engineering approach, not a shortcut.


Project status

Status: Stable β€” used in real production conditions.

The system has been designed to operate autonomously,
with a strong emphasis on rigor, traceability, and long-term maintainability.


Β© Palks Studio β€” see LICENSE.md
https://palks-studio.com

About

πŸ‡¬πŸ‡§ Autonomous PHP automation engine for invoicing and revenue tracking (CLI-based) πŸ‡«πŸ‡· Moteur d’automatisation PHP autonome pour la facturation et le suivi des recettes (CLI)

Topics

Resources

License

Stars

Watchers

Forks