- Add comprehensive accounting integration with OD and bank journal entries
- Create configurable accounting entries toggle in setup
- Implement submission workflow with accounting entry creation
- Add proper error handling and validation
- Support VAT refund threshold logic for account selection
- Integrate with Dolibarr's AccountingBookkeeping class
- Add French language strings for new features
- PDF export button now only shows for draft declarations
- Validated declarations should use the PDF download link from the list
- Prevents confusion between export and download functionality
- Maintains clear separation between draft (export) and validated (download) workflows
- Removed 'Export Detailed PDF' button from view page
- Removed export_pdf_detailed action handler
- Detailed export is now integrated into main 'Export PDF' button
- Simplifies UI by having single PDF export option
- Main export now includes both CA-3 form and detailed breakdown pages
- 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
- Collect all debug messages in an array instead of showing them individually
- Display all debug info in a single message with line breaks
- Added checkmarks (✓) for success and X marks (✗) for failures
- Messages now persist longer and are easier to read
- All validation steps are now visible in one consolidated message
- 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
- 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
- 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
- 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:
✅ 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:
- 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.
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.
Improved:
- All amounts now display as whole numbers without decimals (e.g., 124 instead of 124.00)
- Zero values show as empty fields to avoid confusion
- Original amounts in brackets still show with 2 decimals for precision
- Cleaner display: 124 (123.67) or just 124 or empty field
- Added formatAmount() helper for simple amounts
- Updated formatAmountWithOriginal() to handle zero values
- Much cleaner and less confusing for users
Fixed:
- Line 16: Subtotal TVA due - no original amounts (just user reference)
- Line 23: Subtotal TVA déductible - no original amounts (just user reference)
- Section D lines (25, 26, TD, 28, 29): No original amounts (calculated from rounded values)
- Only actual data lines (A1-A5, 08, 09, 9B, 17, 20-22) show original amounts in brackets
- Section D uses rounded values for calculations as required
Fixed:
- Line 16: Subtotal TVA due (08 + 09 + 9B) now shows original amounts in brackets
- Line 17: Manual entry line now shows original amounts in brackets
- Line 23: Subtotal TVA déductible (20 + 21 + 22) now shows original amounts in brackets
- All subtotal and manual entry lines now have consistent formatting
- Original amounts visible for transparency in all calculated lines
Fixed:
- Store original amounts in line_label with special format
- Parse original amounts in view page helper function
- Display original amounts in brackets: 124 (123.67)
- Handle both base and VAT amounts separately
- Original amounts now visible in amount columns
- Clear transparency for rounding decisions
Removed:
- TotalVATCollected from page header
- TotalVATDeductible from page header
- NetVATDue from page header
- VATCredit from page header
The totals are now only shown in the CA-3 table sections where they belong
Fixed:
- Line 25: Only shows value if net_vat_due < 0 (VAT credit - we receive money)
- Line TD: Only shows value if net_vat_due > 0 (VAT due - we pay money)
- Clear separation between payment (TD) and receipt (25) scenarios
- Line TD description: 'TVA due (montant à payer)'
- This clearly separates when we need to pay vs receive VAT
Fixed:
- Line 25: TVA brute due (Total VAT collected) - always positive
- Line TD: TVA due (absolute value) - never negative, shows abs(net_vat_due)
- Line TD appears between lines 26 and 28 in Section D
- Line TD shows 'TVA due (valeur absolue)' as description
- This ensures VAT due is never negative, even with VAT credits
Added:
- Line 23: Subtotal of lines 20, 21, 22 (for user reference)
- calculateLine23() method that sums VAT amounts from lines 20, 21, 22
- Line 23 display in Section C between lines 22 and Section D
- Line 23 shows as 'Sous-total TVA déductible (20 + 21 + 22)' with bold formatting
- Provides subtotal for Section C just like line 16 for Section B
Fixed:
- Line 16 now appears in Section B between lines 9B and 17
- Line 16 shows as 'Sous-total TVA due (08 + 09 + 9B)' with bold formatting
- Line 16 displays the calculated subtotal amount
- Proper positioning in the CA-3 form structure
Fixed:
- Removed extra header line above section A
- Right-aligned all value column titles (Amount, Base Amount, VAT Amount)
- Professional look with consistent alignment
- Table now starts directly with section A header
Fixed:
- Description column now spans 2 columns (colspan='2') for normal rows
- All section headers span 4 columns (colspan='4')
- Table headers properly aligned with data rows
- Lines 08, 09, 9B: 4 columns (Line | Description | Base HT | VAT)
- All other lines: 3 columns (Line | Description spanning 2 | Amount)
- Table should now be properly aligned and readable
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
Fixed:
- Added CA-3 line definitions lookup
- Use proper descriptions from configuration
- Fallback to database line_label if definition missing
- All CA-3 lines now show proper descriptions:
A1: Montant hors TVA des opérations imposables
A2: Opérations imposables mais ne relevant pas du CA courant
etc.
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
Fixed:
- Moved object initialization before action processing
- Prevents 'Call to a member function on null' error
- recalculateCA3Amounts() now works properly
- Objects are available when action handlers run
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
View Page Updates:
- Use declaration's own start_date and end_date instead of period dates
- Show dates in Period field: 'Start Date - End Date'
- Remove separate DateRange line (redundant)
- Fix created_date property in fetch() method
- Cleaner, more accurate display of declaration information
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!