- Added ECM integration toggle for easy enable/disable
- Temporarily disabled ECM integration to prevent fatal errors
- Added debugging logs to track ECM files path resolution
- PDF saving to disk still works without ECM integration
- Declaration validation will work without document management
- Can be re-enabled once ECM files path is properly resolved
- Create dedicated VAT declarations folder structure under Dolibarr documents
- Organize by year and month: /documents/declarationtva/YYYY/MM/
- Updated PDF saving to use proper directory structure
- Enhanced ECM file records with proper filepath and descriptions
- Added helper methods for directory management
- Better document organization following Dolibarr conventions
- VAT declarations now have their own dedicated space
- Updated paths to include correct ECM files location
- Added multiple fallback paths for ecmfiles.class.php
- Prioritized /ecm/class/ path over /core/class/ path
- Enhanced error logging to show all attempted paths
- Should resolve the 'Failed opening required' error
- ECM files integration should now work properly
- Replaced basic JavaScript popup with professional modal dialog
- Added proper header with title and close button
- Added warning icon and better visual hierarchy
- Improved styling with Dolibarr color scheme
- Added escape key support for better UX
- Better button styling and layout
- More professional appearance matching Dolibarr interface
- Enhanced user experience with proper modal behavior
- 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
- Made ECM files integration optional and graceful
- Added file existence check before requiring ecmfiles.class.php
- Wrapped ECM file creation in try-catch to prevent fatal errors
- PDF is still saved to disk even if ECM integration fails
- Added detailed error logging for troubleshooting
- System now works regardless of ECM files availability
- Enhanced validateDeclaration() to check for column existence
- Falls back to basic validation if enhanced columns don't exist
- Updated migration script with proper column existence checks
- Uses dynamic SQL to avoid errors on existing columns
- System now works with or without the additional columns
- Graceful degradation for different database states
- Removed all error_log debug statements from PDF generation
- Removed debug logging from CA-3 data processing
- Removed debug logging from account amount calculations
- Cleaned up merge methods debug output
- Production-ready code without debug noise
- 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
- Removed debug logging that was added to troubleshoot line 08 display issues
- The issue was identified as database field length limit (varchar(255) vs TEXT)
- Calculation is working correctly - line 08 shows base=1410.57, vat=186.34, total=1596.91
- User needs to run the database migration to fix the line_label field length
- Added debug logging to see how many BASE and VAT mappings are found
- Added logging to show which accounts are being processed and their amounts
- Added logging to show available mappings when none are found for a line
- This will help identify why line 08 base amounts are not displaying in the main view
- Created migration to change line_label from varchar(255) to TEXT
- Added truncation logic to prevent future line_label length issues (1000 char limit)
- This fixes the issue where 11 accounts mapped to line 08 base caused display problems
- The calculation should now work correctly with any number of account mappings
- Updated getCA3LineAmount method to handle duplicate CA-3 line entries
- Prioritizes 'Calculated' entries over 'No accounts mapped' entries
- This fixes lines 28 and 29 not displaying in PDF (they were showing 0 instead of calculated values)
- The method now correctly extracts calculated values: D28=357, D29=0
- Added debug logging for DTD_amount, D28_amount, D29_amount values
- Added debug logging for all D-section field values being sent to PDF
- This will help identify why lines 28 and 29 are not displaying in PDF
- Debug will show if the values are being extracted correctly and what's being sent to PDF
- Added debug logging to see D28_amount and D29_amount values
- This will help identify why lines 28 and 29 are not displaying in PDF
- Debug will show if the values are being extracted correctly from ca3_data
- Changed from 3 spaces after first 2 chars to 2 extra spaces
- Changed from 43 spaces after first 4 chars to 2 extra spaces
- Updated method documentation to reflect correct spacing
- Example: FR85489417469 → F R 8 5 4 8 9 4 1 7 4 6 9 (with 2 extra spaces after positions 1 and 3)
- Added formatVatNumber() method for special VAT number formatting
- Space between every character
- 3 extra spaces after first 2 characters
- 43 extra spaces after first 4 characters
- Example: FR85489417469 → F R 8 5 4 8 9 4 1 7 4 6 9
- Handles edge cases like empty or short VAT numbers
- Cleans input by removing non-alphanumeric characters and converting to uppercase
- Changed from 4 total spaces to 3 spaces before last 5 characters
- Updated method documentation to reflect the change
- Example: 48941746900033 → 4 8 9 4 1 7 4 6 9 0 0 0 3 3 (with 3 spaces before last 5)
- Changed from 2 extra spaces to 4 total spaces before last 5 characters
- Updated method documentation to reflect the change
- Example: 48941746900033 → 4 8 9 4 1 7 4 6 9 0 0 0 3 3 (with 4 spaces before last 5)
- Changed from 1 extra space to 2 extra spaces before last 5 characters
- Updated method documentation to reflect the change
- Example: 48941746900033 → 4 8 9 4 1 7 4 6 9 0 0 0 3 3 (with 2 spaces before last 5)
- Added formatSiret() method for special SIRET formatting
- Spaces between every character in main part
- Extra space before last 5 characters
- Example: 48941746900033 → 4 8 9 4 1 7 4 6 9 0 0 0 3 3
- Handles edge cases like SIRET_NOT_CONFIGURED
- Cleans input by removing non-numeric characters
- Removed duplicate F1/F2 field mappings that were overwriting correct values
- Updated all remaining fields to use getCA3LineAmount() helper method
- Fixed D25, D26, DTD, D28, D29, subtotal_B16, subtotal_C23 fields
- All fields now consistently use the correct array structure lookup
- F2 should now display correct amount instead of 0,00
- Updated formatAmount() method to use 0 decimal places instead of 2
- All amounts in PDF will now display as whole numbers (e.g., 1 958 instead of 1 958,00)
- Maintains French number formatting with comma as decimal separator and space as thousands separator
- Added getCA3LineAmount() helper method to search through numeric array
- Updated all field mappings to use the new helper method
- Fixed A1_amount and other fields to correctly extract from ca3_data array
- The data structure is numeric array with ca3_line field, not associative
- Now correctly extracts A1 amount (1958.00) from the data structure
- Added detailed logging to see what's actually in ca3_data['A1']
- This will help identify why A1_amount shows 0,00 in PDF
- Debug will show if A1 exists and what data it contains
- Every field that shows on the view page should also show on the PDF
- Restored A1-A5 field mapping with proper amount extraction
- Added all Section A additional fields: E1-E6, F1-F2, F6-F8
- Updated debug logging to show actual field values
- Enhanced manual data file generation to include all fields
- PDF now mirrors the complete view page structure
- A1-A5 fields are reference only and don't have actual amounts
- Real amounts come from B section calculation fields (B08, B09, 9B, etc.)
- Updated field mapping to correctly show 0,00 for reference fields
- Enhanced debug logging to reflect correct data structure
- Updated manual data file generation with proper field descriptions
- Added comprehensive field naming documentation (CA3_FIELD_NAMING.md)
- Implemented PDFTK-based PDF form filling with FDF generation
- Added PDFTK installation guide for Linux/Mac/Windows
- Enhanced PDF generation with company data integration
- Added new CA-3 lines: F1, F2 (intracom acquisitions), E1-E6, F6-F8, line 18
- Updated section structure: merged Section C into Section B as sub-section
- Added lines 19, 20 to TVA DÉDUCTIBLE sub-section
- Updated all field descriptions to match official CA-3 form
- Improved visual hierarchy with dark blue section headers
- Enhanced calculation logic for VAT deductible amounts
- Added comprehensive language translations
- Updated database schema with new fields
- Fixed font settings to use Courier New 9pt for official documents
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!
Major milestone release with complete CA-3 declaration functionality:
- Full French VAT declaration system (Notice 4722 - 3310-CA3-SD)
- Advanced multi-account configuration with search & filtering
- Intelligent calculation engine with VAT rounding
- Professional UI with clickable lines & account breakdowns
- Visual enhancements with calculated line highlighting
- Production-ready Dolibarr integration
- Bilingual support (French/English)
This represents a complete, feature-rich VAT declaration module ready for production use.
MAJOR ACHIEVEMENTS:
✅ Complete CA-3 Declaration System (Notice 4722 - 3310-CA3-SD)
✅ Advanced Multi-Account Configuration with Search & Filtering
✅ Intelligent Calculation Engine with VAT Rounding
✅ Professional UI with Clickable Lines & Account Breakdowns
✅ Visual Enhancement with Light Red Background for Calculated Lines
✅ Full Database Schema with Automatic Migration
✅ Bilingual Support (French/English)
✅ Production-Ready Dolibarr Integration
TECHNICAL STATS:
- 15+ core files created
- 5 database tables with relationships
- 2,000+ lines of PHP/JavaScript
- 25+ major features implemented
- Complete French VAT compliance
The MVP is now feature-complete and ready for real-world French VAT declarations!
Fixed:
- Added !important to all background-color declarations to override Dolibarr's striped table CSS
- Applied to both <tr> and individual <td> elements for complete coverage
- This ensures the light red background (#ffe6e6) shows on calculated lines despite Dolibarr's pair/impair classes
The !important declaration forces the custom background color to take precedence over Dolibarr's default table styling.
Enhanced:
- Line 16 (Sous-total TVA due): Light red background (#ffe6e6)
- Line 23 (Sous-total TVA déductible): Light red background (#ffe6e6)
- All D-section lines (25, 26, TD, 28, 29): Light red background (#ffe6e6)
This makes calculated/result lines stand out visually from mapped lines, improving user experience and making it clear which lines are automatically calculated vs manually configured.
Fixed:
- Removed clickable links and dropdown panels for lines 25, 26, TD, 28, 29
- These lines are calculated automatically and have no account mappings
- Changed from clickable links to simple bold text for line numbers
- Removed dropdown rows and AJAX loading for D-section
- Kept dropdowns only for mapped lines (A1-A5, 08, 09, 9B, 17, 20, 21, 22)
This makes the interface cleaner and more logical since D-section lines are calculated, not mapped.
Fixed:
- Replaced class='right' with style='text-align: right;' for all amount columns
- Applied to header, data rows, subtotals, and grand total
- This ensures proper right alignment regardless of Dolibarr CSS classes
- All monetary values now display consistently right-aligned
The inline CSS approach guarantees the alignment works across different Dolibarr themes and configurations.
Fixed:
- Removed confusing 'Base hors taxe', 'Montant de la TVA', 'Montant Total' columns
- Now shows only: Account Code, Account Label, Amount, Mapping Type
- BASE accounts show base amounts
- VAT accounts show VAT amounts
- Other accounts show VAT amounts (for consistency)
- Updated colspan for section headers (4 columns instead of 6)
- Simplified subtotals and grand total
This eliminates the confusion of showing the same values in multiple columns for individual accounts.
Fixed:
- Removed old getAccountMappings() method on line 615
- Kept the new version that joins with chart of accounts
- This fixes the 'Cannot redeclare' PHP Fatal error
The new method properly retrieves account labels from Dolibarr's accounting_account table.
Fixed:
- Added missing getAccountMappings() method to DeclarationTVA class
- Joins with Dolibarr's accounting_account table to get labels
- Retrieves account labels from chart of accounts (llx_accounting_account)
- Falls back to stored label if chart of accounts label not available
- Returns array with rowid, ca3_line, account_code, account_label, vat_rate, is_active
This fixes the issue where account labels were not showing in dropdown panels.
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.
Fixed:
- Updated getCA3LineDetails() to handle special cases for lines 08, 09, 9B
- These lines have _BASE and _VAT suffixes in the database
- Added proper matching logic for both normal lines and special cases
- Added debugging to AJAX endpoint and backend method
- Added error logging to trace mapping issues
This should fix the issue where only A1 works but other lines show no accounts.
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.
Changed:
- Module family from 'other' to 'financial'
- Module will now appear in Financial category instead of Others
- More appropriate categorization for VAT declaration module
Changed:
- Removed top menu entry for DeclarationTVA
- Moved module link to Comptabilité (Accounting) left menu
- Changed mainmenu from 'declarationtva' to 'accountancy'
- Changed fk_menu to 'fk_mainmenu=accountancy'
- Module now appears under Accounting menu where it belongs