-- Fix missing declarationtva_config table
-- Run this SQL in your database to create the missing table

USE dolibarrdebian;

CREATE TABLE IF NOT EXISTS `llx_declarationtva_config` (
  `rowid` int(11) NOT NULL AUTO_INCREMENT,
  `entity` int(11) NOT NULL DEFAULT 1,
  `config_key` varchar(64) NOT NULL,
  `config_value` text,
  `created_date` datetime DEFAULT NULL,
  PRIMARY KEY (`rowid`),
  UNIQUE KEY `uk_config_entity_key` (`entity`, `config_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Insert some default configuration values
INSERT IGNORE INTO `llx_declarationtva_config` (`entity`, `config_key`, `config_value`, `created_date`) VALUES
(1, 'module_version', '2.4.0', NOW()),
(1, 'amount_calc_amount_calculation_method', 'truncate', NOW()),
(1, 'auto_create_auto_create_accounting', '0', NOW()),
(1, 'bank_bank_account', '0', NOW()),
(1, 'journal_vat_to_pay', '44551', NOW()),
(1, 'journal_vat_to_receive', '44567', NOW()),
(1, 'journal_other_charges', '658', NOW()),
(1, 'journal_other_products', '758', NOW());
