Overview
Tax calculations in UBL invoices involve a hierarchical structure:- Tax Scheme: The taxation system (e.g., IVA, INC, ICA)
- Tax Category: The tax category with rate and exemptions
- Tax Subtotal: The tax calculated for a category
- Tax Total: The sum of all tax subtotals for a scheme
Tax Structure
Basic Tax Configuration
Create Tax Scheme
Define the taxation system:
Colombian tax scheme IDs:
01: IVA (Value Added Tax)02: IC (Consumption Tax)03: ICA (Industry and Commerce Tax)04: INC (National Consumption Tax)05: ReteIVA (VAT Withholding)06: ReteRenta (Income Withholding)07: ReteICA (ICA Withholding)
Colombian Tax Examples
IVA (VAT) - Standard Rate
IVA - Multiple Rates
INC (National Consumption Tax)
ICA (Industry and Commerce Tax)
Zero-Rated (Exempt) Items
Multiple Tax Schemes
Combine different taxes on the same invoice:Tax Calculation Helpers
Calculate Tax Amount
Calculate Total with Tax
Find Tax by Scheme ID
The Invoice class provides a helper to retrieve tax amounts:Invoice Line Taxes
Add tax information to individual invoice lines:Withholding Taxes
For withholding tax (retenciones):Advanced Tax Configuration
Tiered Tax Rates
Per-Unit Tax
Testing Tax Calculations
Complete Example
Best Practices
Tax Calculation
- Always calculate tax amounts before creating tax objects
- Use proper decimal precision (2 decimals for COP)
- Set
taxAmountexplicitly; don’t rely oncalculateTotalTaxAmount() - Verify tax amounts match legal requirements
- Include all applicable taxes for your jurisdiction
Tax Categories
- Use correct tax scheme IDs (‘01’ for IVA, ‘04’ for INC, etc.)
- Set appropriate tax category IDs for different rates
- Include exemption reason codes when applicable
- Document tax exemptions with reason text
Testing
- Test calculations with known values
- Verify tax totals sum correctly
- Check rounding behavior
- Test edge cases (zero rates, exempt items)
- Validate against official tax tables
Next Steps
Creating Invoices
Complete guide to invoice creation
DIAN Extensions
Colombian e-invoicing compliance