diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index ba786a0..99e918b 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -263,6 +263,12 @@ class DeclarationTVA ); $combined_label = !empty($account_labels) ? implode(', ', $account_labels) : 'No accounts mapped'; + + // Truncate label if too long to prevent database issues (keep some buffer) + if (strlen($combined_label) > 1000) { + $combined_label = substr($combined_label, 0, 997) . '...'; + } + $this->createCA3Line($declaration_id, $ca3_line, $combined_label, $combined_amounts); // Log the final amounts for debugging diff --git a/sql/migration_fix_line_label_length.sql b/sql/migration_fix_line_label_length.sql new file mode 100644 index 0000000..448ff28 --- /dev/null +++ b/sql/migration_fix_line_label_length.sql @@ -0,0 +1,11 @@ +-- Migration to fix line_label field length issue +-- The varchar(255) limit was causing problems with many account mappings +-- This increases it to TEXT to handle long account label combinations + +-- Update the line_label field to TEXT to handle long account combinations +ALTER TABLE `llx_declarationtva_ca3_lines` +MODIFY COLUMN `line_label` TEXT DEFAULT NULL; + +-- Add comment to document the change +ALTER TABLE `llx_declarationtva_ca3_lines` +MODIFY COLUMN `line_label` TEXT DEFAULT NULL COMMENT 'Combined account labels for this CA-3 line (can be long with many accounts)';