From 9f76747aff8a7bfb20de357e4c50e395bed48b98 Mon Sep 17 00:00:00 2001 From: lvessiller-opendsi Date: Thu, 7 Nov 2024 20:55:50 +0100 Subject: [PATCH] NEW VAT by state (SQL) (#31627) * NEW VAT by state (SQL) * Revert fk_tva column in department table * NEW department in vat rates dict --- htdocs/install/mysql/migration/20.0.0-21.0.0.sql | 5 +++++ htdocs/install/mysql/tables/llx_c_tva.key.sql | 3 +++ htdocs/install/mysql/tables/llx_c_tva.sql | 1 + 3 files changed, 9 insertions(+) diff --git a/htdocs/install/mysql/migration/20.0.0-21.0.0.sql b/htdocs/install/mysql/migration/20.0.0-21.0.0.sql index 598b29a5bc45f..719a824d019fc 100644 --- a/htdocs/install/mysql/migration/20.0.0-21.0.0.sql +++ b/htdocs/install/mysql/migration/20.0.0-21.0.0.sql @@ -310,3 +310,8 @@ ALTER TABLE llx_propaldet ADD COLUMN subprice_ttc double(24,8) DEFAULT 0 after s ALTER TABLE llx_propaldet ADD COLUMN multicurrency_subprice_ttc double(24,8) DEFAULT 0 after multicurrency_subprice; ALTER TABLE llx_supplier_proposaldet ADD COLUMN subprice_ttc double(24,8) DEFAULT 0 after subprice; ALTER TABLE llx_supplier_proposaldet ADD COLUMN multicurrency_subprice_ttc double(24,8) DEFAULT 0 after multicurrency_subprice; + +-- Add VAT by department +ALTER TABLE llx_c_tva ADD COLUMN fk_department_buyer integer DEFAULT NULL AFTER fk_pays; +ALTER TABLE llx_c_tva ADD INDEX idx_tva_fk_department_buyer (fk_department_buyer); +ALTER TABLE llx_c_tva ADD CONSTRAINT fk_tva_fk_department_buyer FOREIGN KEY (fk_department_buyer) REFERENCES llx_c_departements (rowid); diff --git a/htdocs/install/mysql/tables/llx_c_tva.key.sql b/htdocs/install/mysql/tables/llx_c_tva.key.sql index fbdd89e1b0299..dd64a5f219d7e 100644 --- a/htdocs/install/mysql/tables/llx_c_tva.key.sql +++ b/htdocs/install/mysql/tables/llx_c_tva.key.sql @@ -20,3 +20,6 @@ ALTER TABLE llx_c_tva ADD UNIQUE INDEX uk_c_tva_id (entity, fk_pays, code, taux, recuperableonly); -- ALTER TABLE llx_c_tva ADD UNIQUE INDEX uk_c_tva_id (fk_pays, code, recuperableonly); -- Not yet possible for compatibility reason, where old code is '' + +ALTER TABLE llx_c_tva ADD INDEX idx_tva_fk_department_buyer (fk_department_buyer); +ALTER TABLE llx_c_tva ADD CONSTRAINT fk_tva_fk_department_buyer FOREIGN KEY (fk_department_buyer) REFERENCES llx_c_departements (rowid); diff --git a/htdocs/install/mysql/tables/llx_c_tva.sql b/htdocs/install/mysql/tables/llx_c_tva.sql index ac10520fc0189..d4fee71c2ec77 100644 --- a/htdocs/install/mysql/tables/llx_c_tva.sql +++ b/htdocs/install/mysql/tables/llx_c_tva.sql @@ -23,6 +23,7 @@ create table llx_c_tva rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, fk_pays integer NOT NULL, + fk_department_buyer integer DEFAULT NULL, -- Id of department for VAT rule or NULL to keep rule on country code varchar(10) DEFAULT '', -- a key to describe vat entry, for example FR20 type_vat smallint NOT NULL DEFAULT 0, -- 0: all, 1: sell, 2: purchase taux double NOT NULL,