- Added light gray backgrounds to all section titles in detailed pages
- Enhanced visual hierarchy for better readability
- Improved professional appearance of PDF exports
- Updated module version to 2.5.1
- Remove 'Actions' title from configuration page
- Add missing UpdateConfiguration translation to French and English
- Fix button text to display properly in both languages
- Clean up configuration page by removing unnecessary title
- Update French language file: ConfigurePCGAccounts = Configuration
- Update English language file: ConfigurePCGAccounts = Configuration
- Simplify button text for better user experience
- Maintain consistency across both languages
- Split configuration page into two tabs: PCG Mapping and Template Management
- Move CA-3 PDF template upload section to separate 'Template Management' tab
- Add JavaScript for tab switching functionality
- Add language strings for tab labels in French and English
- Improve user experience by organizing configuration options logically
- Maintain all existing functionality while improving navigation
- Replaced onclick='return confirm()' with onclick='confirmUnvalidation()'
- Added confirmUnvalidation() JavaScript function with Dolibarr-style modal
- Added closeUnvalidationModal() and proceedUnvalidation() functions
- Modal has red warning styling to indicate destructive action
- Added UnvalidationConfirmationMessage and YesUnvalidate translations
- Modal includes escape key handler and proper styling
- Consistent with validation modal design and behavior
- Modified hasValidatedDocument() to check file system instead of database
- Added getValidatedPDFPath() method to get PDF file path
- Updated declaration list to show clickable PDF download links
- Added DownloadPDF translation in French and English
- PDF icons now link directly to downloadable PDF files
- Fixed issue where validated declarations didn't show PDF availability
- Added unvalidateDeclaration() method to DeclarationTVA class
- Added unvalidate action handler in declarationtva_view.php
- Added red 'Unvalidate' button for validated declarations
- Added confirmation dialog for unvalidate action
- Added French and English language strings
- Allows reverting validated declarations back to draft status
- Useful for testing validation process multiple times
- Added comprehensive PDF export combining CA-3 form with detailed breakdown pages
- Implemented pdftk-based PDF merging that preserves form fields
- Added support for new CA-3 lines (25, 26, 27, TD, 28, 32) with conditional visibility
- Fixed multi-select configuration saving issues
- Enhanced error handling and debugging for PDF generation
- Added French status translation for detailed PDFs
- Optimized page breaks to reduce paper usage
- Improved form field preservation during PDF merging
Technical improvements:
- Better error handling with comprehensive logging
- Modular PDF generation with fallback options
- Fixed pdftk filename conflicts
- Enhanced debugging capabilities
- Status translation without external dependencies
NEW FEATURES:
✅ Gitea API Integration for Template Management
✅ Automatic Template Update Checking
✅ Version Control and Manifest System
✅ One-Click Template Updates in Configuration
✅ Professional Template Management Workflow
TECHNICAL IMPLEMENTATION:
- Enhanced DeclarationTVA_PDF class with auto-update methods
- Template manifest system (templates/manifest.json)
- Gitea API integration for template downloads
- Update status display in configuration page
- Version comparison and automatic updates
TEMPLATE MANAGEMENT:
- Current version: 30 (10963*30)
- Gitea repository: https://git.covago.com/frank/DeclarationTVA
- Manifest URL: templates/manifest.json
- Auto-update on module activation
- Fallback to built-in template
MAINTENANCE WORKFLOW:
1. Tax authority updates form → Create fillable version (5 min)
2. Update manifest.json with new version (1 min)
3. Upload template to Gitea (2 min)
4. Users get automatic updates (0 min for maintainer)
This creates a professional, self-hosted template management system with minimal maintenance overhead!
NEW FEATURES:
✅ PDF Generation Class (DeclarationTVA_PDF)
✅ Template Management System (Official + Custom)
✅ PDF Export Button in Declaration View
✅ Template Upload/Reset in Configuration
✅ Official CA-3 Template Support (10963*30)
TECHNICAL IMPLEMENTATION:
- core/class/declarationtva_pdf.class.php: Complete PDF generation system
- templates/declarationtva/: Template storage directory
- Template management in admin/setup_mvp.php
- PDF export action in declarationtva_view.php
- Bilingual support (French/English)
TEMPLATE SYSTEM:
- Built-in official template (10963*30)
- Custom template upload capability
- Template validation and version management
- Fallback to official template if custom not available
PDF FEATURES:
- Professional CA-3 layout with all sections
- Company information and declaration details
- Complete CA-3 line data with amounts
- Totals and calculations display
- Downloadable PDF files
This adds professional PDF export functionality to the CA-3 declaration system!
Fixed:
- Separated totals for BASE accounts vs VAT accounts
- Added subtotal rows for each account type
- Clear visual separation between base and VAT contributions
- Added 'Grand Total' row showing combined totals
- Added translations for subtotal labels
This eliminates confusion by showing:
- Subtotal for BASE accounts (sales amounts)
- Subtotal for VAT accounts (VAT amounts)
- Grand Total (combined total)
Users can now clearly see which accounts contribute to base vs VAT amounts.
Fixed:
- Grouped BASE and VAT accounts separately for lines 08, 09, 9B
- Added clear section headers: 'Base Accounts (Sales)' and 'VAT Accounts'
- Improved visual organization of account breakdown
- Removed debugging code
- Added translations for new section headers
This ensures users can clearly see which accounts contribute to base amounts vs VAT amounts for the special lines.
Features:
- Replaced separate page with inline dropdown panels
- Click any CA-3 line code to expand/collapse account details
- AJAX loading of account breakdown data
- Professional styling matching Dolibarr UI
- JavaScript toggle functionality with loading states
- Account details table with:
* Account codes and labels
* Base amounts, VAT amounts, total amounts
* Mapping types and totals
* Summary information
- Removed separate line details page
- Added comprehensive translations for dropdown interface
This provides seamless inline access to account breakdowns without page navigation.
Features added:
- New getCA3LineDetails() method in DeclarationTVA class
- New declarationtva_line_details.php page for detailed view
- All CA-3 line codes are now clickable in declaration view
- Detailed breakdown shows:
* Account codes and labels
* Base amounts, VAT amounts, total amounts
* Mapping types (A1, 08_BASE, 08_VAT, etc.)
* Calculated totals vs account totals
- Added comprehensive translations for detailed view
- Navigation breadcrumbs and back buttons
- Professional styling with Dolibarr UI components
This provides complete transparency into which accounts contribute to each CA-3 line without touching the calculation logic.
Updated:
- BaseAmount: 'Montant HT' → 'Base hors taxe'
- VATAmount: 'Montant TVA' → 'Taxe due'
- More accurate French terminology for CA-3 form
- Professional tax terminology
Reverted:
- Main table back to 3 columns (Line, Description, Amount)
- Sections A, C, D use normal 3-column layout
- Only lines 08, 09, 9B have special 4-column layout (Line, Description, Base HT, VAT)
- Added special header 'Base HT et TVA par taux' for these lines
- Line 17 uses normal 3-column layout
- Added language translations for new header
Enhanced:
- Updated CA-3 line definitions for 08, 09, 9B to show both base and VAT
- Changed type from 'vat' to 'base_vat' for these fields
- Updated view table to show 5 columns: Line, Description, Base HT, VAT, Total
- Added language translations for new columns
- Fields 08, 09, 9B now display both base amounts and VAT amounts
- Enhanced debugging to show final amounts for each line
Enhanced Declaration View:
- Restored all declaration fields (number, name, period, status, created date)
- Added totals section with VAT collected, deductible, net due, and credit
- Bold formatting for totals to highlight important amounts
- Added translations for all new fields
- Complete layout with all necessary information
Recalculate Button Integration:
- Replaced placeholder CA-3 data with real database queries
- getCA3Lines() now fetches actual calculated amounts
- Shows 'No CA-3 data' message when no calculations exist
- Displays real VAT amounts from database after recalculation
- Added translations for 'No CA-3 data' message
Now the recalculate button will:
1. Trigger calculation engine
2. Query accounting data
3. Display real calculated amounts
4. Show debugging info in error logs
Delete Feature:
- Added deleteDeclaration() method to DeclarationTVA class
- Only allows deletion of draft declarations (safety check)
- Deletes CA-3 lines first, then declaration record
- Added delete button to main interface for draft declarations
- Added confirmation dialog before deletion
- Added success/error messages for delete operations
- Added translations in both English and French
Security:
- Only draft declarations can be deleted
- Confirmation dialog prevents accidental deletion
- Proper error handling and user feedback
The interface now shows a delete button for each draft declaration!
Security Fixes:
- Added CSRF token field to form
- Added token validation in form processing
- Added proper error handling for missing dates
- Added ErrorMissingDates translation in both languages
- Form now properly validates CSRF tokens before processing
This fixes the 'Token not provided' error when submitting the form.
New Pages Added:
- declarationtva_create.php: Complete declaration creation form
- declarationtva_view.php: Declaration details and CA-3 amounts display
Features Implemented:
- Period selection for new declarations
- Declaration naming with helpful examples
- Optional date range override
- Complete CA-3 form structure display
- Status-based action buttons (Validate/Submit)
- Proper error handling and success messages
- Full bilingual support (English/French)
Create Page Features:
- Period dropdown with date ranges
- Declaration name field with help text
- Optional date override
- Configuration reminder with link to setup
View Page Features:
- Complete declaration details
- CA-3 amounts table with all 16 lines
- Status-based actions
- Navigation back to main list
The module now has a complete declaration workflow!
Translation Updates:
- Added all missing translations for main interface elements
- Added translations for periods, declarations, and status messages
- Added success and error message translations
- Added French translations for all new keys
- Improved user experience with proper bilingual support
Main Interface Translations Added:
- DeclarationTVAMainInterface, DeclarationTVAPeriods, DeclarationTVADeclarations
- PeriodName, StartDate, EndDate, Status, Actions
- CreateDeclaration, DeclarationNumber, NetVATDue
- Validate, Submit, View buttons
- Status indicators (Draft, Validated, Submitted)
- Success/Error messages for all operations
The main interface is now fully translated in both English and French!
Main Interface Updates:
- Changed configuration button link from admin/setup.php to admin/setup_mvp.php
- Updated button text from 'ConfigureModule' to 'ConfigurePCGAccounts'
- Added new translation keys in both English and French
- Button now correctly points to our custom MVP setup page
This fixes the issue where the button was taking users to the standard
Dolibarr configuration page instead of our custom CA-3 setup interface.
UI Cleanup:
- Removed 'Hold Ctrl/Cmd to select multiple accounts' help text
- This text is not relevant for Dolibarr's multiselectarray() method
- The native multi-select interface uses checkboxes and buttons
- No need for keyboard shortcuts with modern interface
The interface is now cleaner and more accurate!
Form Submission Fixes:
- Process ALL CA-3 lines (including empty ones to clear mappings)
- Fixed SQL syntax in updateAccountMapping method
- Added proper error handling and success counting
- Added debug output to see what data is being received
Database Operations:
- Replaced ON DUPLICATE KEY UPDATE with proper check/update logic
- Better handling of existing vs new mappings
- Improved SQL query structure for reliability
Debug Features:
- Shows which lines have data and which are empty
- Displays form data being processed
- Helps identify where the issue occurs
The form should now properly save account mappings!
CSRF Protection Implementation:
- Added CSRF token to form with newToken() function
- Added token validation with checkToken() function
- Proper error handling for CSRF token validation
- Security compliance with Dolibarr standards
Form Security:
- Hidden token field in form submission
- Token validation before processing form data
- Error message display for invalid tokens
- Proper security workflow
Language Support:
- Added English error message for CSRF token error
- Added French error message for CSRF token error
- Complete bilingual support for security messages
The configuration form now properly handles CSRF protection and should work without security errors!
Multi-Select Account Mapping:
- Replaced single account dropdown with multi-select field
- Users can now select multiple PCG accounts for each CA-3 line
- Uses Dolibarr native multi-select style with proper styling
- Supports Ctrl/Cmd key for multiple selection
Enhanced Configuration Interface:
- Multi-select dropdown for each CA-3 line
- Account selection from Dolibarr's chart of accounts
- Real-time account validation against existing accounts
- Better visual layout with proper sizing
Technical Updates:
- Updated config class to handle multiple account selections
- Added method to get account mappings grouped by CA-3 line
- Enhanced form submission to process array of account codes
- Improved current configuration display
Database Handling:
- Deactivate existing mappings before adding new ones
- Support for multiple accounts per CA-3 line
- Proper account code validation
- Clean data structure for multi-select support
User Experience:
- Native Dolibarr multi-select styling
- Helper text for multi-selection instructions
- Better account display with codes and labels
- Improved current configuration summary
Language Support:
- Added English translations for multi-select interface
- Added French translations for multi-select interface
- Complete bilingual support for new features
The configuration interface now supports multiple PCG account selection using Dolibarr's native multi-select style!
Complete CA-3 Form Structure:
- Added Section C: Décompte de la TVA déductible (Deductible VAT Calculation)
- Added Section D: Résultat (Result)
- Now includes all 4 sections: A, B, C, D
- Total of 17 CA-3 lines covering complete form
Section C - Deductible VAT Calculation:
- Line 20: TVA déductible sur immobilisations (Deductible VAT on fixed assets)
- Line 21: TVA déductible sur autres biens et services (Deductible VAT on other goods and services)
- Line 22: TVA déductible sur importations (Deductible VAT on imports)
Section D - Result:
- Line 25: TVA brute due (Total VAT due)
- Line 26: TVA déductible totale (Total deductible VAT)
- Line 28: TVA nette à payer (Net VAT to pay)
- Line 29: Crédit de TVA à reporter ou remboursement (VAT credit to carry forward or refund)
Enhanced Configuration:
- Added section C and D headers with proper descriptions
- Added all 7 new CA-3 lines for sections C and D
- Updated PCG account mappings for all new lines
- Enhanced form layout to show all 4 sections
Language Support:
- Added English translations for sections C and D and all lines
- Added French translations for sections C and D and all lines
- Complete bilingual support for all 17 CA-3 lines
Documentation:
- Updated PLANNING.md with complete CA-3 structure
- Added sections C and D documentation with all lines
- Complete Notice 4722 compliance with all 4 sections
The module now includes the COMPLETE CA-3 structure with all 4 sections A, B, C, D!
Complete CA-3 Structure Update:
- Added Section B: Décompte de la TVA due (VAT Due Calculation)
- Added 4 new CA-3 lines for VAT due calculations
- Updated all language files with new section and lines
Section B - VAT Due Calculation:
- Line 08: TVA due au taux de 20% (VAT due at 20% rate)
- Line 09: TVA due au taux de 10% (VAT due at 10% rate)
- Line 9B: TVA due aux taux réduits (VAT due at reduced rates 5,5% and 2,1%)
- Line 17: TVA due au titre des acquisitions intracommunautaires (VAT due on intra-EU acquisitions)
Enhanced Configuration:
- Added section B header with proper description
- Added all 4 VAT due calculation lines
- Updated PCG account mappings for VAT due lines
- Enhanced form layout to show both sections A and B
Language Support:
- Added English translations for Section B and all lines
- Added French translations for Section B and all lines
- Updated section headers in both languages
Documentation:
- Updated PLANNING.md with complete CA-3 structure
- Added Section B documentation with all lines
- Complete Notice 4722 compliance
The module now includes the complete CA-3 structure with both sections A and B!
Major Structure Update:
- Updated to latest official CA-3 form structure (Notice 4722)
- Replaced old structure with new 5-line format (A1-A5)
- All changes based on official notice 4722
New CA-3 Lines (Notice 4722):
- A1: HT amount of all taxable operations that form normal sales
- A2: HT amount of special taxable operations not part of ordinary turnover
- A3: HT amount of services purchased from non-established providers (reverse charge)
- A4: HT amount of imports taxable in France (non-EU), excluding petroleum products
- A5: HT amount of taxable operations at exit from suspensive fiscal regime
Enhanced Configuration Interface:
- Added detailed descriptions for each line
- Added PCG account recommendations
- Added notice reference information
- Improved form layout with additional columns
Updated Files:
- core/class/declarationtva_config.class.php: New CA-3 line definitions
- admin/setup_mvp.php: Enhanced interface with descriptions and PCG accounts
- langs/en_US/declarationtva.lang: English translations for new structure
- langs/fr_FR/declarationtva.lang: French translations for new structure
- PLANNING.md: Updated documentation with new structure
Key Features:
- Official Notice 4722 compliance
- Detailed line descriptions and PCG account guidance
- Enhanced user interface with better information display
- Bilingual support for all new content
The module now uses the latest official CA-3 form structure!
Configuration Interface Improvements:
- Added all missing CA-3 lines from planning document
- Implemented proper section headers (A, B, C, D)
- Added section descriptions for better understanding
- Organized lines by section for logical grouping
CA-3 Lines Added:
- A1, A2: Taxable operations base amounts
- B1-B4: VAT rate breakdowns (20%, 10%, 5.5%, 2.1%)
- 05, 06: Intra-EU operations (B2B)
- 17: VAT due on intra-EU acquisitions
- 20, 21: Deductible VAT (fixed assets, other)
- 22, 28, 29: Result calculations
Section Headers:
- A. Opérations imposables (Taxable Operations)
- B. TVA due (VAT Due)
- C. TVA déductible (Deductible VAT)
- D. Résultat (Result)
Enhanced Features:
- Section-based organization in configuration
- Type indicators (Base/VAT) for each line
- Improved visual layout with section headers
- Better grouping in current configuration display
Language Support:
- Added English translations for all new labels
- Added French translations for all new labels
- Consistent terminology across both languages
The configuration page now shows the complete CA-3 structure as defined in the planning document!
Multiple Account Selection Features:
- Multi-select dropdown for each CA-3 line from Dolibarr's chart of accounts
- Account search and filtering from llx_accounting_account table
- Real-time account validation against existing chart of accounts
- Account preview with current balances and details
- Account weighting and grouping for complex mappings
- Bulk operations for account management (add/remove multiple accounts)
- Account filtering by type (7xxxx, 4457xx, 4456xx, etc.)
Database Structure:
- New table: llx_declarationtva_account_mappings
- Stores multiple account mappings per CA-3 line
- Account code, label, VAT rate, type, weighting
- Active/inactive status and audit trail
Interface Features:
- Multi-select dropdown with search functionality
- Account preview showing current balances
- Account validation ensuring accounts exist and are active
- Bulk operations for efficient account management
- Account filtering by account type and characteristics
Enhanced Configuration:
- Each CA-3 line can map to multiple PCG accounts
- Account weighting for importance/priority
- Account grouping for complex business scenarios
- Real-time validation against Dolibarr's chart of accounts
- Account preview with current balances
Updated estimates: +27 hours for multiple account selection
Total project: 577+ hours with comprehensive account mapping
Dolibarr Hook System Integration:
- Hook into invoice validation and accounting transfer events
- Automatic EU supplier detection and autoliquidation
- Custom fields for VAT processing (EU flag, transaction type)
- Batch processing for multiple invoices
- Workflow triggers for status changes
Available Hooks:
- supplier_invoice_validate: Auto-detect EU suppliers
- supplier_invoice_accountancy_transfer: Create VAT entries
- invoice_validate: Apply EU transaction rules
- invoice_accountancy_transfer: Generate accounting entries
Automation Workflow:
1. User creates EU supplier invoice
2. Hook triggers on validation
3. Auto-detect EU supplier
4. Create VAT due (4452xxx) and deductible (4456xx) entries
5. Entries ready for CA-3 calculations
Custom Fields:
- EU Supplier Flag
- VAT Treatment (autoliquidation vs normal)
- Transaction Type (B2B, B2C, special cases)
- OSS Threshold tracking
- DEB/DES requirement flags
Enhanced Features:
- Automatic VAT processing
- Reduced manual work for EU transactions
- Seamless integration with Dolibarr workflow
- Custom field management
- Batch processing capabilities
Updated estimates: +44 hours for workflow integration
Total project: 456+ hours with full Dolibarr integration
EU Transaction Scenarios:
1️⃣ Incoming EU Invoices (Purchases):
- Supplier invoices HT (no VAT)
- French autoliquidation: 4452xxx (VAT due) + 4456xx (VAT deductible)
- Net effect: zero if fully deductible
- CA-3 impact: Lines 17 (VAT due) + 20/21 (VAT deductible)
2️⃣ Outgoing EU Invoices (Sales):
- Case A (B2B): No French VAT, Lines 05/06 (base HT only)
- Case B (B2C): OSS threshold handling (€10,000)
- Case C (Special): Construction/energy reverse charge
- Invoice text requirements for EU transactions
3️⃣ DEB/DES Integration:
- Link CA-3 lines 05/06 with exchange declarations
- Cross-validation between CA-3 and DEB/DES
- Automatic data import and validation
Enhanced Features:
- EU transaction type detection and classification
- OSS threshold monitoring and alerts
- DEB/DES data integration and validation
- Special case handling (construction, energy)
- Comprehensive EU transaction workflow
Updated estimates: +64 hours for EU transaction handling
Total project: 414+ hours with full EU compliance
Official CA-3 Form Lines:
- Section A: Opérations imposables (A1, A2, B1-B4)
- A1: Base HT of taxable operations
- A2: Special operations (asset sales, self-deliveries)
- B1-B4: Rate breakdowns (20%, 10%, 5.5%, 2.1%) with base + tax
- Section B: TVA due (Line 17)
- Intra-EU acquisitions autoliquidation
- Section C: TVA déductible (Lines 20, 21)
- Line 20: Capital goods VAT
- Line 21: Operating expenses VAT
- Section D: Résultat (Lines 22, 28, 29)
- Line 22: VAT credit to carry forward
- Line 28: Net VAT to pay
- Line 29: VAT credit amount
Enhanced Features:
- Detailed account breakdown for draft declarations
- Drill-down from form lines to individual transactions
- Separate handling of base amounts (HT) and VAT amounts
- Support for all French VAT rates
- Special operations handling (A2 line)
- Export detailed breakdown reports
Updated task estimates: +37 hours for form structure implementation
Added comprehensive bilingual support for all CA-3 form lines
Core Advanced Features:
- Draft system with detailed account breakdowns
- Validation workflow with approval process
- Automatic journal entry generation (445510/445670)
- Complete audit trail and version history
- Multi-entity support for multiple companies
Analytics & Reporting:
- Period comparison tools with variance analysis
- Interactive dashboard with KPIs and trends
- Exception handling for unusual amounts
- Automated alerts and notifications
User Experience:
- Mobile-responsive design
- Document management with attachments
- Email notifications for deadlines
- Keyboard shortcuts and accessibility
Integration & APIs:
- External tax system integration
- Backup/restore functionality
- Webhook support for real-time updates
- API documentation for third-party access
Updated time estimates: 350+ hours total
Added Phase 7 (Advanced Features) with 80+ hours
Enhanced bilingual support for all new features
- Create PLANNING.md with detailed project architecture and phases
- Create TASK.md with 200+ hour development plan broken into 6 phases
- Add French language support (fr_FR/declarationtva.lang)
- Update English translations with CA3-specific terminology
- Define CA3 box structure and PCG account mappings
- Plan bilingual interface for French-speaking users
- Include database schema, testing, and documentation phases