From 1e3e53ffb52cf8b723a44d431b39eefe0c1ea547 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Thu, 12 Oct 2023 16:35:41 +0300 Subject: [PATCH] SQL for invoice subtype (#26198) * Add more subtypes for Greece * Update llx_c_invoice_subtype.key.sql * Update llx_c_invoice_subtype.sql * Update llx_facture_fourn.sql * Update 18.0.0-19.0.0.sql --- htdocs/install/mysql/data/llx_c_invoice_subtype.sql | 3 +++ htdocs/install/mysql/migration/18.0.0-19.0.0.sql | 9 +++++++++ .../install/mysql/tables/llx_c_invoice_subtype.key.sql | 2 +- htdocs/install/mysql/tables/llx_c_invoice_subtype.sql | 2 +- htdocs/install/mysql/tables/llx_facture_fourn.sql | 1 + 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_invoice_subtype.sql b/htdocs/install/mysql/data/llx_c_invoice_subtype.sql index d17097e592e..ba40f026e51 100644 --- a/htdocs/install/mysql/data/llx_c_invoice_subtype.sql +++ b/htdocs/install/mysql/data/llx_c_invoice_subtype.sql @@ -41,3 +41,6 @@ insert into llx_c_invoice_subtype (fk_country, code, label, active) VALUES (102, insert into llx_c_invoice_subtype (fk_country, code, label, active) VALUES (102, '11.2', 'ΑΠΥ', 1); insert into llx_c_invoice_subtype (fk_country, code, label, active) VALUES (102, '11.3', 'Απλοποιημένο Τιμολόγιο', 0); insert into llx_c_invoice_subtype (fk_country, code, label, active) VALUES (102, '11.5', 'Απόδειξη Λιανικής Πώλησης για Λογ/σμό Τρίτων', 0); +insert into llx_c_invoice_subtype (fk_country, code, label, active) VALUES (102, '5.1', 'Πιστωτικό Τιμολόγιο / Συσχετιζόμενο', 0); +insert into llx_c_invoice_subtype (fk_country, code, label, active) VALUES (102, '5.2', 'Πιστωτικό Τιμολόγιο / Μη Συσχετιζόμενο', 1); +insert into llx_c_invoice_subtype (fk_country, code, label, active) VALUES (102, '11.4', 'Πιστωτικό Στοιχείο Λιανικής', 1); diff --git a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql index 36d655e486b..3149dda123e 100644 --- a/htdocs/install/mysql/migration/18.0.0-19.0.0.sql +++ b/htdocs/install/mysql/migration/18.0.0-19.0.0.sql @@ -121,6 +121,15 @@ ALTER TABLE llx_accounting_account MODIFY COLUMN pcg_type varchar(32); -- VPGSQL8.2 DROP INDEX uk_links; ALTER TABLE llx_links ADD UNIQUE INDEX uk_links (objectid, objecttype,label); +ALTER TABLE llx_facture_fourn ADD COLUMN subtype smallint DEFAULT NULL; + +ALTER TABLE llx_c_invoice_subtype DROP INDEX uk_c_invoice_subtype; +ALTER TABLE llx_c_invoice_subtype ADD UNIQUE INDEX uk_c_invoice_subtype (entity, code, fk_country); ALTER TABLE llx_c_invoice_subtype MODIFY COLUMN entity integer DEFAULT 1 NOT NULL; +ALTER TABLE llx_c_invoice_subtype MODIFY COLUMN code varchar(5) NOT NULL; + +insert into llx_c_invoice_subtype (entity, fk_country, code, label, active) VALUES (1, 102, '5.1', 'Πιστωτικό Τιμολόγιο / Συσχετιζόμενο', 0); +insert into llx_c_invoice_subtype (entity, fk_country, code, label, active) VALUES (1, 102, '5.2', 'Πιστωτικό Τιμολόγιο / Μη Συσχετιζόμενο', 1); +insert into llx_c_invoice_subtype (entity, fk_country, code, label, active) VALUES (1, 102, '11.4', 'Πιστωτικό Στοιχ. Λιανικής', 1); ALTER TABLE llx_prelevement_lignes ADD COLUMN fk_user integer NULL; diff --git a/htdocs/install/mysql/tables/llx_c_invoice_subtype.key.sql b/htdocs/install/mysql/tables/llx_c_invoice_subtype.key.sql index a362755358a..3c6d5ef273e 100644 --- a/htdocs/install/mysql/tables/llx_c_invoice_subtype.key.sql +++ b/htdocs/install/mysql/tables/llx_c_invoice_subtype.key.sql @@ -16,4 +16,4 @@ -- -- ======================================================================== -ALTER TABLE llx_c_invoice_subtype ADD UNIQUE INDEX uk_c_invoice_subtype (entity, code); +ALTER TABLE llx_c_invoice_subtype ADD UNIQUE INDEX uk_c_invoice_subtype (entity, code, fk_country); diff --git a/htdocs/install/mysql/tables/llx_c_invoice_subtype.sql b/htdocs/install/mysql/tables/llx_c_invoice_subtype.sql index 741f8bd2766..201df19923c 100644 --- a/htdocs/install/mysql/tables/llx_c_invoice_subtype.sql +++ b/htdocs/install/mysql/tables/llx_c_invoice_subtype.sql @@ -21,7 +21,7 @@ CREATE TABLE llx_c_invoice_subtype rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, -- multi company id fk_country integer NOT NULL, - code varchar(4) NOT NULL, + code varchar(5) NOT NULL, label varchar(100), active tinyint DEFAULT 1 NOT NULL diff --git a/htdocs/install/mysql/tables/llx_facture_fourn.sql b/htdocs/install/mysql/tables/llx_facture_fourn.sql index c7a29146536..9408254db7e 100644 --- a/htdocs/install/mysql/tables/llx_facture_fourn.sql +++ b/htdocs/install/mysql/tables/llx_facture_fourn.sql @@ -30,6 +30,7 @@ create table llx_facture_fourn ref_ext varchar(255), -- reference into an external system (not used by dolibarr) type smallint DEFAULT 0 NOT NULL, + subtype smallint DEFAULT NULL, -- subtype of invoice (some countries need a subtype to classify invoices) fk_soc integer NOT NULL, datec datetime, -- date de creation de la facture