ProdyPanda Factures Knowledge & Architecture Wiki

🌐 Language: English | Français | العربية

Level 4 — Advanced / Tunisian Tax, Treasury, P&L & Accountant Close#

Level 4 is written for company owners, finance controllers, and Tunisian accountants (Experts-Comptables). Here you will master the exact arithmetic of ProdyPanda's Tunisian calculation engine, manage Client & Supplier Withholding Tax (Retenue à la Source), reconcile multi-account Treasury balances, read the Profit & Loss (Compte de Résultat) and profitability analytics, enforce category budgets, and execute a clean 1-click month-end and year-end accountant close.


1. The Tunisian Calculation Engine Deep Dive#

Tunisian accounting works to 3 decimal places (millimes, 0.001 DT), where a single millime discrepancy can cause an invoice total to disagree with your ERP or tax declaration.

A. Truncation (truncate) vs Rounding (round) — Why Facture 20260300001 Equals 6 571.989 DT#

In public/js/calculator.js, every monetary step passes through applyPrecision(value, decimals, mode):

  • roundingMode: 'truncate' (default for ProdyPanda. Sarl): strips digits beyond the 3rd decimal place (with a 1e-7 floating-point epsilon guard so exact binary fractions like 0.1 + 0.2 never underflow).
  • roundingMode: 'round': applies standard half-up rounding at the 3rd decimal place (configurable in Paramètres & Taxes or per document).

Look at how this affects ProdyPanda's real reference invoice Facture N° 20260300001 (Pulire Tunisie, 06-03-2026):

StepFormulaExact Raw Valuetruncate (Default)round
Gross Services Subtotal3×1378 + 1×1378 + 110 + 3806 002.00006 002.000 DT6 002.000 DT
Loyalty Discount WD-R26 (-8%)-6 002.000 × 0.08-480.1600-480.160 DT-480.160 DT
Net Total H.T.6 002.000 − 480.1605 521.84005 521.840 DT5 521.840 DT
TVA (19%)5 521.840 × 0.191 049.14961 049.149 DT1 049.150 DT
Timbre fiscalFixed Tunisian stamp duty1.00001.000 DT1.000 DT
Net à payer (T.T.C.)5 521.840 + 1 049.149 + 1.0006 571.98906 571.989 DT6 571.990 DT

Because 1 049.1496 truncates cleanly to 1 049.149 DT, ProdyPanda matches official Tunisian billing software down to the last millime!

B. Multi-Rate Per-Line TVA (19% / 13% / 7% / 0%) & Custom Fees#

In Studio Facture's Configuration Fiscale : TVA, Timbre & Frais panel:

  • 1-Click Fiscal Presets:
    • Standard (TVA 19% + Timbre 1 DT) — standard domestic Tunisian B2B/B2C invoicing
    • Suspension TVA (0% + Timbre) — for clients holding a Tunisian Attestation d'achat en suspension de TVA (add the attestation number & date in the tvaExemptNote box!)
    • Export / Hors Taxe (0% sans Timbre) — international export invoices exempt from both TVA and Timbre fiscal
    • + FODEC (1%) — adds the 1% Tunisian industrial development tax before TVA
    • + Retenue Source (-1%) — applies a -1% withholding line after TVA
  • Per-Line TVA (perLineTva): Enable this when one invoice mixes items at different Tunisian VAT rates (19% services, 13% professional/IT-adjacent rates, 7% qualifying goods/services, or 0% exempt lines). Both the A4 PDF and branded email summary automatically render a grouped TVA breakdown table by rate!
  • Custom Fees Order (+ Ajouter un frais / taxe):
    • Avant TVA (applyBeforeTva: true) — e.g., FODEC 1% or Frais de dossier 50.000 DT: added to the Taxable Base H.T. before TVA is computed (so TVA is calculated on Net H.T. + FODEC, per Tunisian fiscal law!).
    • Après TVA (applyBeforeTva: false) — e.g., Retenue à la source -1%: applied after TVA on the post-tax total.

C. Reverse Calculator (+ Calculateur TTC → H.T.)#

When a client says "My total budget is strictly 5 000.000 DT all taxes included":

  1. In Studio Facture (A4), click + Calculateur TTC → H.T. (Calculateur Inversé : T.T.C. → H.T.).
  2. Enter the target T.T.C. (5 000.000), and toggle your active discount %, pre-TVA fee %, TVA rate, and Timbre.
  3. BillingCalculator.reverseCalculateHT() solves backward to millime precision (±0.001 DT).
  4. Click Appliquer à une nouvelle ligne to drop the exact calculated H.T. amount straight into your invoice!
  • French (amountToFrenchLegalSentence): Adapts dynamically to document type (la présente facture, le présent devis, la présente facture proforma, le présent avoir, le présent bon de commande, le présent bon de livraison) and optionally spells millimes in words (millimesInWords: true).
  • English (amountToEnglishLegalSentence): Handles Dinars/millimes, Euros/cents, US Dollars/cents, and Pounds/pence with proper singular/plural grammar.

2. Retenue à la Source (RS) — Clients & Suppliers#

In Tunisia, B2B payments of ≥ 1 000 DT T.T.C. (as well as rents, professional fees, and foreign services) are subject to statutory Withholding Tax (Retenue à la Source) payable to the Recette des Finances. ProdyPanda handles both directions cleanly.

Built-In Tunisian RS Rate Reference#

RS RateCommon Tunisian Fiscal Application
1%Standard commercial markets, goods & services ≥ 1 000 DT T.T.C. (when supplier is subject to corporate tax IS)
1.5%Specific services / non-corporate or sector-specific regimes
3%Professional fees (Honoraires) / commissions paid to entities taxed under the real regime
10%Office rent (Loyer) & specific non-resident / professional payments
15%General professional fees (Honoraires), royalties, or non-resident foreign tech/cloud services (e.g., OVHcloud when applicable)

A. Client-Side RS (Withheld by Your Customers)#

When a Tunisian corporate client pays your 6 571.989 DT invoice and withholds 1% (65.709 DT on H.T. + TVA, excluding Timbre):

  1. Open Suivi des Paiements & Retenue à la Source on the invoice (or click Certificat RS in Studio Facture).
  2. Click Imprimer Certificat RS (1%) (/print-rs/:id or /api/documents/:id/rs-pdf) to view or print a pre-filled A4 Certificat de Retenue à la Source containing ProdyPanda's MF (1618295T), the client's MF, gross base, RS amount, and net amount paid (Net servi).
  3. You can also attach the client's RS certificate directly when emailing the invoice!

B. Supplier-Side RS (Withheld by YOU & Paid to Recette des Finances)#

When ProdyPanda. Sarl pays a Tunisian vendor bill ≥ 1 000 DT T.T.C. (or pays office rent):

  1. Inside Nouvelle Dépense / Facture Fournisseur, as soon as a DT bill reaches ≥ 1 000 DT T.T.C., ProdyPanda automatically suggests applying RS!
  2. Tick Retenue à la Source and select the rate (1%, 1.5%, 3%, 10%, 15%).
  3. The live preview strip shows:
    • Retenue à la source (amount you keep and remit to the Recette des Finances)
    • Net à payer fournisseur (Total T.T.C. − RS — exact amount you wire/check to the supplier!)
  4. Automatic Treasury Precision: When you mark that expense Payée, Treasury automatically debits only the Net à payer fournisseur from your bank account (so your Banque Zitouna balance matches the exact bank transfer!), while the withheld RS is tracked separately in the Supplier RS Registry!
  5. Open Fournisseurs & BC → Retenues à la Source Fournisseurs (or click Voir le registre RS Fournisseurs → inside Fiscalité & TVA) to:
    • Filter by Year and Month and see the Total RS Due to Recette des Finances
    • Print/Download an official A4 Certificat de Retenue à la Source PDF for each supplier (/api/expenses/:id/rs-pdf) to hand over with their payment
    • Click Exporter CSV Recette des Finances (/api/expenses/rs-csv) to download RS_Fournisseurs_Recette_Finances.csv!

3. Multi-Account Treasury (Trésorerie) & Bank Reconciliation#

Open Trésorerie in the left sidebar to manage real cash flow across every liquidity account.

The 3 Pre-Seeded Tunisian Accounts#

Out of the box, ProdyPanda seeds three accounts tailored to Tunisian business operations:

  1. Banque Zitouna (BANK, default account, pre-filled with RIB 25047000000140621604)
  2. Caisse Espèces (CASH — office petty cash box)
  3. Portefeuille Chèques & Traites (CHECKS — checks & bills of exchange awaiting bank deposit)

Click Comptes & Soldes initiaux anytime to set your Opening Balances (Solde initial) (for example, your actual bank balance on January 1st) or add additional banks (BIAT, Attijari, Amen Bank, etc.).

How Automatic Payment & Expense Sync Works#

MERMAID DIAGRAM
flowchart TB
    Pay["Client Payment Recorded<br/>(Factures & Documents)"] -->|"Auto CREDIT<br/>(sourceType: PAYMENT)"| Tr["Treasury Ledger<br/>(treasury_transactions)"]
    Exp["Supplier Expense Marked PAID<br/>(Dépenses & Achats)"] -->|"Auto DEBIT of Net Paid<br/>(sourceType: EXPENSE)"| Tr
    Man["Manual Operation<br/>(+ Opération manuelle)"] -->|"MANUAL CREDIT / DEBIT"| Tr
    Xfer["Internal Transfer<br/>(⇄ Virement interne)"] -->|"Balanced Outflow + Inflow<br/>(e.g. Banque → Caisse)"| Tr
    Tr --> Cards["Live Account Balance Cards<br/>(Book Balance + Reconciled Balance)"]
  • Zero Double Entry:
    • Record a client payment via Virement Bancaire → Banque Zitouna is credited automatically. Delete that payment → the Treasury credit vanishes cleanly.
    • Mark a STEG expense PAID → Banque Zitouna (or chosen account) is debited automatically. Change its status back to UNPAID or delete it → the Treasury debit is removed automatically.
  • Internal Transfers (⇄ Virement interne / Retrait Caisse):
    • Moving 500.000 DT cash out of Banque Zitouna into Caisse Espèces (or depositing checks from Portefeuille Chèques & Traites into Banque Zitouna) posts a matched transfer pair between the two accounts without inflating your P&L revenue or expenses!
  • Bank Reconciliation (Rapproché ✓):
    • Click any account card at the top to filter the ledger to that single account.
    • Compare rows against your monthly Banque Zitouna bank statement and tick the Rapproché checkbox on every cleared line.
    • Each account card displays both your Total Book Balance and your Reconciled Balance, making missing checks or unrecorded bank fees immediately obvious!

4. Fiscalité, P&L, SVG Analytics, Margins & Budgets#

Open Fiscalité & TVA and select your period (full year like 2026, specific month like 2026-11, or ALL).

A. Tunisian VAT (TVA) Position#

ProdyPanda computes your monthly or annual VAT declaration figures from active documents (Factures minus Avoirs, automatically excluding CANCELLED documents and non-fiscal Devis/Proforma) and recorded Dépenses:

$$\text{TVA Nette} = \text{TVA Collectée (Sales)} - \text{TVA Déductible (Purchases)}$$

  • If positive (> 0): TVA à Payer — amount owed on your monthly Tunisian tax declaration.
  • If negative (< 0): Crédit de TVA — VAT credit carried forward to next month!
  • Also tracks total Timbre Fiscal collected on invoices and your Retenues à la Source Fournisseurs liability banner.

B. Compte de Résultat (P&L) & Year-over-Year (N / N-1) Comparison#

The Compte de Résultat (P&L) table groups all revenue and expenses automatically by accounting nature (comparing Current Period N vs Prior Year N-1 with % delta badges and a dual-series YoY SVG Bar Chart):

P&L LineCalculation / Category Group
Chiffre d'Affaires H.T.Net invoiced sales H.T. (Factures − Avoirs, converted to TND)
− Achats Clients / DéboursDirect project costs (CLIENT group / CLIENT_PURCHASE scope)
= Marge BruteGross project margin (CA H.T. − Achats Clients)
− Utilitaires (STEG, SONEDE, Télécom)UTILITY group bills
− Charges Fixes (Loyer, Salaires, CNSS...)FIXED group expenses (Rent, Payroll, CNSS, Insurance, Accounting, Bank fees)
− Autres Frais d'ExploitationOPERATING group expenses (Cloud, Software, Marketing, Fuel, Equipment, Supplies)
= Résultat Net d'Exploitation H.T.True operating profit + Operating Margin %!

C. Interactive SVG Expense Donut & Per-Client Profitability#

  • Expense Category Donut Chart: Hover any slice or legend item in Répartition des Dépenses par Catégorie to inspect exact H.T. TND spend, % share of total costs, and receipt count per category.
  • Per-Client Real Profitability (Rentabilité par Client & Projet): Compares each client's Invoiced Revenue H.T. against Direct Client Purchases H.T. (Ventes H.T. − Achats Clients = Marge Réelle DT & %), highlighting both your most profitable accounts and any client with unbilled purchases waiting to be rebilled.

D. Monthly Category Budgets & Spend Alerts#

Control overhead before it surprises you:

  1. Click Gérer les budgets mensuels (or Configurer on the Budgets card).
  2. For any expense category (e.g., Hébergement & Cloud, Marketing & Pub, Carburant & Déplacements), set a Monthly Cap in DT (monthlyCapTnd), an Alert Threshold % (default 80%), and toggle Active.
  3. Click Enregistrer les budgets.
  4. Live progress cards render immediately in Budgets Mensuels & Alertes Dépenses:
    • Green: comfortably under threshold
    • Amber (≥ 80%): approaching monthly cap
    • Crimson (> 100%): over budget — automatically fires a warning inside the global Alert Center!

5. Alert Center, Executive PDF & Accountant ZIP Close#

A. Unified Alert Center (Alertes)#

Click Alertes in the top utility bar anytime to open the priority action drawer organized into 6 tabs:

  1. Toutes — consolidated feed sorted by priority
  2. Achats à refacturer — unbilled client purchases (1-click Refacturer →)
  3. Échéances & Factures à payer — upcoming recurring fixed bills (15-day window) & overdue supplier bills (1-click log/open)
  4. Impayés clients — overdue unpaid client invoices (1-click jump to invoice)
  5. Budgets — monthly categories exceeding alert threshold or cap (1-click jump to Fiscalité)
  6. Devis signés — Quotes recently e-signed on the Client Portal awaiting conversion to Invoice/Deposit!

B. 1-Click Executive Financial Report A4 PDF#

In Fiscalité & TVA, click Rapport de Gestion PDF (A4) (/api/reports/executive-pdf). In 2 seconds, ProdyPanda compiles a clean, branded, print-ready A4 management report containing:

  • ProdyPanda. Sarl header, period covered, and executive KPIs
  • Full Compte de Résultat (P&L) & TVA position
  • Inline vector SVG Expense Category Chart
  • Top Clients profitability & receivables table
  • Consolidated Treasury snapshot across Banque Zitouna, Caisse Espèces, and Portefeuille Chèques & Traites

C. 1-Click Accountant ZIP (Télécharger Dossier Comptable (ZIP))#

Stop spending Sunday evenings gathering folders and spreadsheets for your accountant! Select the target month (e.g., 2026-11) or full year (2026) in Fiscalité & TVA and click Télécharger Dossier Comptable (ZIP) (/api/reports/accountant-zip).

ProdyPanda builds a standard PKZIP archive (100% compatible with Windows Explorer, 7-Zip, and macOS) containing:

TEXT
Dossier_Comptable_2026-11.zip
├── PDFs/
│   ├── Facture_20261100001_Pulire_Tunisie.pdf
│   └── Avoir_20261100001_...pdf
├── Justificatifs_Depenses/
│   ├── 2026-11-05_STEG_FA-2026-88412_facture_steg.pdf
│   └── 2026-11-12_OVHcloud_FR88210_receipt.pdf
├── Journal_Factures_2026-11.csv          # UTF-8 BOM, semicolon-delimited (Excel / Sage ready)
├── Journal_Depenses_2026-11.csv          # Full HT, TVA Déductible, Timbre & TTC ledger
├── RS_Fournisseurs_Recette_Finances.csv  # Auto-included whenever Supplier RS applies!
└── Synthese_Fiscale_TVA_2026-11.txt      # Complete TVA Collectée / Déductible / Timbre / RS summary

✅ Tunisian Month-End & Year-End Accountant Close Checklist#

Monthly Close (Confirm the Applicable Filing Deadline with Your Accountant)#

  • Open the Alert Center (Alertes) and clear all Unbilled Client Purchases (Achats à refacturer) and Upcoming Fixed Bills
  • Verify every finalized invoice of the month is Locked (Verrouiller) so numbers cannot drift after declaration
  • Record all incoming client bank wires/checks and attach any missing supplier PDFs/photos in Dépenses & Achats
  • Open Trésorerie and reconcile Banque Zitouna (Rapproché ✓) against your monthly bank statement
  • Open Fournisseurs & BC → Retenues à la Source Fournisseurs, print all supplier Certificats RS PDF, and verify total RS owed to the Recette des Finances
  • Open Fiscalité & TVA, select the closed month (e.g., 2026-11), verify TVA Collectée − TVA Déductible (TVA à Payer or Crédit de TVA) and Timbre Fiscal
  • Click Télécharger Dossier Comptable (ZIP) and send the single ZIP file to your Expert-Comptable
  • Click Rapport de Gestion PDF (A4) to archive your monthly executive P&L summary

Year-End Close (Annual Financial Statements & Audit Archive)#

  • Reconcile all 3 Treasury accounts (Banque Zitouna, Caisse Espèces, Portefeuille Chèques & Traites) as of December 31
  • Verify every Client's closing balance using Clients & Relevés → Relevé de Compte
  • Export the Annual Accountant ZIP (period = full year, e.g., 2026) and Annual RS_Fournisseurs_Recette_Finances.csv (for Tunisia's annual Déclaration d'Employeur)
  • Go to Paramètres & Taxes → Sauvegarde de Base de Données and download a permanent annual JSON backup (ProdyPanda_Backup_2026-12-31.json) to external/cloud storage

For the monthly tax worksheet and confirmed bank CSV import, see the Agency operations guide. Worksheets are preparation aids, not official filings or tax advice.

← Level 3 — Intermediate | English Index | Level 5 — Expert (Admin, Security, OCR & API) →

ProdyPanda Factures — Complete English Documentation Curriculum