How to Implement Custom Calculation Breakdown for Honoraires, Frais, TVA, and RAS in Invoices

Hello everyone,

I’m currently working on implementing an invoicing logic in Dolibarr based on Moroccan tax rules for services (Honoraires). I need to apply the following:

:small_blue_diamond: A 10% RAS (withholding tax) deducted from the HT (before tax)
:small_blue_diamond: A 75% retention of the VAT (TVA 20%) by the client
:small_blue_diamond: The final amount the client pays should be 95 MAD for a base HT of 100 MAD +
20% VAT
β€” Invoice Details β€”

Base Price (HT): 100.00 MAD
VAT 20%: 20.00 MAD
Total (TTC): 120.00 MAD

β€” Deductions β€”

– RAS 10% (on HT): –10.00 MAD
– 75% VAT Retention: –15.00 MAD

β€” Final Amount Due β€”

Net Amount to Pay: 95.00 MAD

I would like to ask:

  • How is HT, total HT, and TTC calculated internally in Dolibarr?
  • What’s the best way to implement this logic automatically in the system?
  • Is it possible to add these deductions in the invoice or the PDF model?
  • Any suggestion to handle this properly through custom PDF templates or modules?
    @ ksar
    Thank you for any support!