- Updated detailed page tables to match first page font sizes exactly
- All tables now use identical styling (font size 7, proper spacing)
- Detailed page tables now look identical to journal tables
- Consistent typography and spacing throughout the entire PDF
- Updated module version to 2.5.3
- Applied consistent table styling from journal tables to all tables
- Enhanced visual consistency throughout the entire PDF document
- White backgrounds for data rows, light gray for headers and subtotals
- Unified professional appearance across all pages
- Updated module version to 2.5.2
- 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
- Update module version from 2.3.0 to 2.4.0
- Add comprehensive changelog for version 2.4.0
- Document template management system features
- Document minor version system implementation
- Document bug fixes and technical improvements
- Document template updates and maintenance manual
- Bump template version from 30.1 to 30.2
- Update manifest.json with new version 30.2
- Add release entry for corrected template
- Template now includes proper field positioning
- Other installations will auto-update to version 30.2
- Update isFillablePDF() to recognize ca3_official_template.pdf
- Ensure official template is used for CA-3 form generation
- Fix missing CA-3 pages in PDF output
- Use official template instead of falling back to basic PDF generation
- Use realpath() to get absolute path to templates directory
- Fix template loading for CA-3 PDF generation
- Resolve template path mismatch issue
- Ensure official template is found and used correctly
- Add major.minor version format (30.1)
- Keep government version as major number (30)
- Use minor version for fixes and improvements (.1, .2, .3)
- Update manifest.json with minor version system
- Add practical examples to maintenance manual
- Enable automatic updates for template fixes
- Maintain government version compliance
- Remove debug logging from action handling
- Remove debug logging from template reset method
- Remove debug logging from template info method
- Clean up production code after successful debugging
- Update template_path to use relative path from class file
- Fix REVENIR AU MODELE OFFICIEL button functionality
- Ensure template detection works correctly
- Resolve template path mismatch issue
- Keep template version at 30 (official government version)
- Remove version 31 entry from manifest
- Maintain official CA-3 template version 30
- Template version should match government document version
- Update hardcoded template version in PDF class to 31
- Update manifest.json current_version to 31
- Add new release entry for version 31
- Enable version checking and update notifications
- Add more descriptive error messages for Gitea server access problems
- Indicate potential causes: private repository or server configuration
- Help users understand why online template updates may not work
- Maintain functionality with local fallback
- Add informative messages when using local files due to Gitea inaccessibility
- Provide clear feedback about fallback behavior
- Maintain functionality even when Gitea server is not accessible
- Support both online and offline template management scenarios
- Try to fetch manifest from Gitea first, fallback to local if not accessible
- Try to download templates from Gitea first, fallback to local if not accessible
- Support both online template updates and offline functionality
- Enable other installations to check for template updates when online
- Provide reliable fallback for offline installations
- Replace Gitea manifest fetching with local manifest file
- Use local template files instead of downloading from Gitea
- Fix 'Failed to fetch manifest from Gitea' error in template management tab
- Use local files for template updates instead of external Gitea server
- Improve reliability by removing external dependencies
- Remove D section (calculated lines) from configuration interface
- Remove D section from section headers configuration
- Simplify configuration page by removing unnecessary calculated section
- Clean up interface to show only configurable sections (A and B)
- Remove 'HT amounts of all taxable operations' description
- Remove all section descriptions (A, B, D sections)
- Fix 'Référence:' display to only show when notice is not empty
- Clean up configuration page completely by removing all technical text
- Simplify interface to show only section titles
- Added journal entry table to detailed PDF with columns: Code compte, Libellé compte, Libellé écriture, Débit, Crédit
- Implemented complex balancing logic for TD > 0 and TD <= 0 cases
- Added account label lookup with proper mapping for 4455100, 4456700, 658000, 758000
- Fixed account label retrieval to use custom uppercase labels from chart of accounts
- Optimized table layout with centered positioning and appropriate column widths
- Reduced font sizes for better page fit while maintaining readability
- Added final balancing entries using 658000 (debit) and 758000 (credit) accounts
- Removed all debug logging for production-ready code
- Restored getVATResultEntry call (needed for main journal entries)
- Changed account code from 4456700 to 4455100
- Uses getAccountLabel for proper account name
- Should now show 4455100 with TD amount in journal table
- Removed getVATResultEntry call (was creating 4456700)
- Removed getRoundingEntry call (was creating duplicate entries)
- All balancing now handled in getBalancingEntries method
- Should now show only 4455100 with TD amount, no 4456700
- TD amount is already rounded (69.00), so no rounding difference needed
- Only creates single entry with TD amount on 4455100
- No more unnecessary rounding calculations
- Should show 4455100 with 69.00 (exact TD amount)
- Now uses Line 16 - Line 23 calculation (same as view page)
- Added getLineAmount method to get line amounts from database
- Uses TD amount as main balancing entry instead of journal difference
- Should handle both positive and negative TD amounts correctly
- Main amount on 4455100, rounding difference on 758000
- Main amount (rounded) on 4455100: 69.00
- Rounding difference on 758000: 0.90
- For difference 69.90: 4455100 credit 70.00 + 758000 credit 0.90
- Should now show correct split between main and rounding accounts
- Changed account code from 758000 to 4455100
- Updated debug message to reflect correct account
- Should now show 4455100 with 0.90 for example 1
- Single entry with correct account as requested
- Removed main balancing entry (4455100)
- Only creates 758000 entry with real difference (0.90)
- No more split entries, just single entry as user requested
- Should show only 758000 with 0.90, no 4455100 entry
- Added debug logging to see how many balancing entries are found
- Added logging to show each balancing entry being added
- Added total count of entries after balancing
- Should help identify if entries are being added to the PDF
- Added debug logging to see what template path is being used
- This will help identify if the path is correct or if files are missing
- Should show exactly where the system is looking for template files
- Added *** NEW LOGIC *** to debug messages
- This will help identify if the new code is actually being executed
- Should show if there are multiple code paths or caching issues
- Added debug logging to see what amounts are being created
- Cleared caches and reset OPcache
- Should help identify if the new logic is being executed
- Will show exactly what values are being put in the journal table
- Rounded difference on 4455100 (formatAmount)
- Real difference on 758000 (formatAmountReal)
- For difference 69.90: 4455100 credit 70.00 + 758000 credit 0.90
- No more complex logic, just 2 simple lines
- Exactly what user requested: 69.00 on 4455100 and 0.90 on 758000
- Main amount: rounded value on 4455100/4456700 (formatAmount)
- Rounding difference: real difference on 758000/658000 (formatAmountReal)
- For difference 69.90: 4455100 credit 70.00 + 758000 credit 0.90
- For difference -0.90: 4456700 debit 1.00 + 658000 debit 0.90
- Should now show correct split between main and rounding accounts
- NO round() function anywhere
- Uses real difference values only (formatAmountReal)
- Single entry with real difference on correct account
- For difference 69.90: 4455100 credit 69.90 (real value)
- No more rounding, no more split entries
- Main entry: rounded amount on 4455100/4456700 (formatAmount)
- Rounding entry: real difference on 758000/658000 (formatAmountReal)
- For difference -0.90: 4455100 credit 1.00 + 758000 credit 0.90
- Should now show correct split between main and rounding accounts
- Completely removed rounding logic
- Now uses real difference values only (formatAmountReal)
- No more rounded amounts or complex rounding logic
- Simple: real difference goes to 4455100/4456700 with real value
- Should show 4455100 with 0.90 instead of 1.00
- Added special handling for differences < 1.0 (like -0.90)
- Small differences now create rounding-only entries (758000/658000)
- No main balancing entry (4455100/4456700) for small differences
- Should show 758000 with 0.90 instead of 4455100 with 1.00
- Added handling for cases where rounded difference is 0 but real difference is not 0
- Now creates rounding-only entry when difference is small (like -0.90)
- Should show 758000 with 0.90 instead of 1.00
- Handles edge cases where difference rounds to 0 but real value is significant
- Added debug logging to show which account is being created
- Added logging for difference calculation and condition evaluation
- Should help identify why example 1 shows 4456700 instead of 4455100
- Will help trace the source of duplicate 4455100 entries
- Debit difference: now uses 4455100 credit (not 4456700)
- Credit difference: now uses 4456700 debit (not 4455100)
- Rounding accounts also corrected: 758000 for debit diff, 658000 for credit diff
- Should now match user examples correctly
- Debit difference: 758000 credit (not debit) for rounding
- Credit difference: 658000 debit for rounding
- Now matches user examples where debit difference uses 758000 credit
- Should show correct rounding entries in journal table
- Changed difference calculation from (debits - credits) to (credits - debits)
- Now matches user examples where credit difference uses 4455100
- Should eliminate the unwanted 4456700 line in credit scenarios
- 4455100 and 4456700 will never appear together now
- Removed duplicate 4455100 entry creation
- Now creates either 4455100 (credit) OR 4456700 (debit), not both
- Added debug logging for total debits/credits to trace calculation
- Should eliminate the unwanted 4455100 line in journal table
- Calculate difference between debits and credits
- Main entry: rounded amount on 4455100 (credit) or 4456700 (debit)
- Rounding entry: real difference on 758000 (credit diff) or 658000 (debit diff)
- Simplified logic by removing TD line dependency
- Both VAT debit and credit scenarios now work correctly
- Main balancing entry now uses rounded amount (formatAmount) for proper accounting
- Rounding difference goes to 658000/758000 with real value (formatAmountReal)
- Fixed fallback logic to handle both VAT debit and credit scenarios correctly
- VAT credit: rounded amount on 4456700, real difference on 658000
- VAT debit: rounded amount on 4455100, real difference on 758000
- Added debugging to TD line query to see why VAT amount is 0
- Fixed fallback logic to use formatAmountReal() instead of formatAmount()
- When TD line has 0 VAT amount, now uses real difference (0.90) instead of rounded (1.00)
- Added logging to track TD line query and results
- Should now show 0.90 instead of 1.00 in rounding entry
- Added error_log statements to track total difference and VAT TD amount
- Added logging for remaining difference calculation
- Will help identify why rounding entry shows 1.00 instead of 0.90
- Check error logs after generating PDF to see calculation values
- Rounding entries (658000/758000) already use formatAmountReal() for real values
- Added comment to clarify this behavior
- Main balancing entry uses rounded VAT amount from TD line
- Rounding entry uses real difference with decimals
- Ensures proper accounting precision for rounding differences
- Main balancing entry now uses VAT amount from line TD (69 in example)
- Remaining difference (0.90) goes to rounding entry on 758000
- Added getVATAmountFromLineTD method to fetch VAT amount from TD line
- Proper accounting: 69.00 credit on 4455100 + 0.90 credit on 758000
- Fallback to original logic if no TD line found
- Combined balancing and rounding logic into single method
- Main balancing entry uses correct account: 4456700 for debit, 4455100 for credit
- Separate rounding entry uses 658000/758000 for rounding differences
- Eliminates duplicate entries and ensures proper accounting structure
- Example: 69.00 credit on 4455100 + 0.90 on 758000 instead of two separate lines
- Debit balancing entries use 4456700 (TVA à payer)
- Credit balancing entries use 4455100 (TVA à recevoir)
- Account selection based on whether the balancing entry is debit or credit
- Proper French VAT accounting for balancing entries
- If difference < 0 (more credits): Use 4456700 (TVA à payer) on debit side
- If difference > 0 (more debits): Use 4455100 (TVA à recevoir) on credit side
- Each account gets its real label from chart of accounts
- Proper French VAT accounting logic for balancing entries
- Added multiple query strategies to handle different database configurations
- Tries with entity filter, without entity filter, and without active filter
- Enhanced debugging to show which query succeeds
- Based on successful patterns from other methods in the codebase
- Should now properly retrieve account names from Dolibarr chart of accounts
- Added error_log statements to track account lookup process
- Removed entity filtering temporarily to test if that's the issue
- Will help identify why account names are not showing from chart of accounts
- Check error logs after generating PDF to see what's happening
- Removed hardcoded fallback labels that were made up
- Now properly queries accounting_account table for real account labels
- Uses entity filtering and active account filtering
- Falls back to generic 'Compte XXXX' only if account not found
- Journal table now shows actual account names from your chart of accounts
- Added getAccountLabel method to fetch real account descriptions from chart of accounts
- Balancing entry now uses real account description for 4456700
- Balancing amounts are now rounded (no decimals)
- Added getBalancingRoundingEntry method for separate rounding line
- Rounding difference goes to 658000 (debit) or 758000 (credit) with real descriptions
- Improved double-entry bookkeeping with proper account labels and rounding
- Added getBalancingEntry method to calculate balancing entry
- Sums all debit amounts and subtracts all credit amounts
- If result < 0: adds debit to 4456700 account
- If result > 0: adds credit to 4456700 account
- Added parseAmount helper method to convert formatted amounts back to floats
- Journal table now automatically balances with calculated entry
- Ensures proper double-entry bookkeeping in OD journal
- Changed all journal entry labels to use declaration_name field
- Updated getLine8VATAccounts to use declaration_name
- Updated getLine20Accounts to use declaration_name
- Updated getVATResultEntry to use declaration_name
- Updated getRoundingEntry to use declaration_name
- Journal entries now show user-defined names like 'MAI 2025', 'JUIN 2025'
- Changed entry labels to use declaration number instead of generic labels
- Updated getLine8VATAccounts to use declaration name
- Updated getLine20Accounts to use declaration name
- Updated getVATResultEntry to use declaration name
- Updated getRoundingEntry to use declaration name
- All journal entries now show the declaration name as the entry label
- Added filter to show only 445 accounts (VAT accounts) in journal table
- Created formatAmountReal method to display amounts with decimals
- Updated getLine8VATAccounts to filter for 445 accounts and use real values
- Updated getLine20Accounts to filter for 445 accounts and use real values
- Updated VAT result and rounding entries to use real values
- Journal table now shows only VAT accounts with precise amounts
- Changed account_number to account_code in getLine8VATAccounts method
- Changed account_number to account_code in getLine20Accounts method
- Account numbers should now display correctly in the journal entry table
- Fixes issue where account codes were showing as empty in the PDF
- Moved journal entry table to page 1 after declaration info
- Line details (Détail de la ligne A1) now start on page 2
- Removed duplicate AddPage() call from addJournalEntryTable
- Added explicit AddPage() call in addDetailPages for page 2 start
- Improved PDF structure for better readability
- Added addJournalEntryTable method to generate journal entries table
- Table includes columns: Code compte, Libellé compte, Libellé écriture, Débit, Crédit
- Extracts VAT accounts from line 8 (debit side, non-zero only)
- Extracts accounts from line 20 (credit side, non-zero only)
- Adds VAT result on account 4456700 (debit if < 0, credit if >= 0)
- Adds rounding difference on 658000 (if < 0) or 758000 (if > 0)
- Journal table starts on page 2 of the detailed PDF
- Uses proper French accounting terminology and formatting
- Updated module version from 2.1.0 to 2.2.0
- Added comprehensive changelog for version 2.2.0
- Documents all new features: validation workflow, PDF management, secure downloads
- Documents technical improvements: database migration, error handling, UI cleanup
- Documents bug fixes: token validation, PDF detection, path resolution, debug cleanup
- Ready for production deployment
- Changed PDF generation path from /documents/declarationtva/validated/ to /declarationtva/validated/
- Updated hasValidatedDocument() to look in /declarationtva/validated/
- Updated getValidatedPDFPath() to look in /declarationtva/validated/
- This removes the duplicate /documents in the file path
- Files will now be saved in /var/lib/dolibarr/declarationtva/validated/
- URLs will be /dolibarr/documents/declarationtva/validated/ (single /documents)
- Changed generateDetailedCA3PDF to call generateCA3PDF instead of generateDetailedPDF
- generateCA3PDF creates complete PDF with CA-3 form + detailed breakdown pages
- generateDetailedPDF only creates detailed pages without the CA-3 form
- Now generates complete PDF with both CA-3 form and account details
- Copies generated PDF to correct validated directory location
- Updated generateDetailedCA3PDF to save PDFs in /documents/declarationtva/validated/
- Updated hasValidatedDocument to look in /documents/declarationtva/validated/
- Updated getValidatedPDFPath to look in /documents/declarationtva/validated/
- Removed year/month directory structure
- Should now match the actual file location where PDFs are saved
- URLs should now work correctly
- Removed all error_log debug statements from production code
- Cleaned up hasValidatedDocument method
- Cleaned up declaration list processing
- Code is now production-ready
- PDF detection and generation are working correctly
- Added comprehensive error_log statements to track PDF detection
- Logs declaration ID, number, directory paths, and search patterns
- Shows all PDF files found in the directory
- Will help identify why PDF detection is failing
- Debug info will appear in PHP error logs
- Updated hasValidatedDocument() to use flexible file pattern matching
- Updated getValidatedPDFPath() with same flexible pattern
- First tries exact pattern: CA3_[declaration_number]_*.pdf
- Falls back to flexible pattern: CA3_*[declaration_number]*.pdf
- Should now detect PDFs with complex filenames like CA3_CA3-2025-05-20251002184011_2025-10-06.pdf
- Declaration list should now show green PDF icons for validated declarations
- Added step-by-step debug messages to track validation process
- Added file existence verification in generateDetailedCA3PDF
- Added detailed error reporting for PDF generation failures
- Will help identify exactly where PDF generation is failing
- Debug messages will show: validation start, PDF generator load, PDF generation, file existence check
- Modified generateDetailedCA3PDF to save PDFs directly to /documents/declarationtva/YYYY/MM/
- Updated saveValidatedPDF to handle PDFs already in correct location
- Added debugging messages to show PDF generation success/failure
- Fixed path mismatch between PDF generation and document detection
- PDFs should now be properly generated and detected in declaration list
- 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 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
- 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