diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index c64ede9953a..3cc09c24193 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -59,15 +59,15 @@ class AccountancySystem function create($user) { $now=dol_now(); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."accountingsystem"; + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system"; $sql.= " (date_creation, fk_user_author, numero,intitule)"; $sql.= " VALUES (".$this->db->idate($now).",".$user->id.",'".$this->numero."','".$this->intitule."')"; $resql = $this->db->query($sql); if ($resql) { - $id = $this->db->last_insert_id(MAIN_DB_PREFIX."accountingsystem"); + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."accounting_system"); if ($id > 0) { diff --git a/htdocs/admin/accounting.php b/htdocs/admin/accounting.php index 571fc5a5672..6f2cd2e51e6 100644 --- a/htdocs/admin/accounting.php +++ b/htdocs/admin/accounting.php @@ -41,9 +41,9 @@ $compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES'; if ($action == 'setcomptamode') { $compta_mode = GETPOST('compta_mode','alpha'); - + $res = dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode,'chaine',0,'',$conf->entity); - + if (! $res > 0) $error++; if (! $error) @@ -60,9 +60,9 @@ if ($action == 'setcomptamode') if ($action == 'setchart') { $chartofaccounts = GETPOST('chartofaccounts','alpha'); - + $res = dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts,'chaine',0,'',$conf->entity); - + if (! $res > 0) $error++; if (! $error) @@ -81,9 +81,9 @@ if ($action == 'update' || $action == 'add') $constvalue = GETPOST('constvalue','alpha'); $consttype = GETPOST('consttype','alpha'); $constnote = GETPOST('constnote','alpha'); - + $res = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity); - + if (! $res > 0) $error++; if (! $error) @@ -157,13 +157,13 @@ if (! empty($conf->global->ACCOUNTING_SELECTCHART) && ! empty($conf->accounting- { print '
'; print_titre($langs->trans("Definechartofaccounts")); - + print '
'; print ''; - + print ''; $var=True; - + print ''; print ''; // Param - $libelle = $langs->trans($key); + $libelle = $langs->trans($key); print '\n"; @@ -266,7 +266,7 @@ foreach ($list as $key) print '   '; print "\n"; print ''; - + $i++; } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index e18420285c0..7a9b9c3ff18 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -99,7 +99,7 @@ $tabname[20]= MAIN_DB_PREFIX."c_input_method"; $tabname[21]= MAIN_DB_PREFIX."c_availability"; $tabname[22]= MAIN_DB_PREFIX."c_input_reason"; $tabname[23]= MAIN_DB_PREFIX."accountingaccount"; -$tabname[24]= MAIN_DB_PREFIX."accountingsystem"; +$tabname[24]= MAIN_DB_PREFIX."accounting_system"; // Dictionary labels $tablib=array(); @@ -153,7 +153,7 @@ $tabsql[20]= "SELECT rowid as rowid, code, libelle, active FROM ".MAIN_DB_PREF $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c"; $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; $tabsql[23]= "SELECT rowid as rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number as accountancy_code, account_parent, label, active FROM ".MAIN_DB_PREFIX."accountingaccount"; -$tabsql[24]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as pays_id, p.code as pays_code, p.libelle as pays, s.label, s.active FROM ".MAIN_DB_PREFIX."accountingsystem as s, ".MAIN_DB_PREFIX."c_pays as p WHERE s.fk_pays=p.rowid and p.active=1"; +$tabsql[24]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as pays_id, p.code as pays_code, p.libelle as pays, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_pays as p WHERE s.fk_pays=p.rowid and p.active=1"; // Critere de tri du dictionnaire $tabsqlsort=array(); diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index ef1e43b17df..f580acf7e8f 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -46,21 +46,21 @@ * @param int $info_bits Miscellanous informations on line * @param int $type 0/1=Product/service * @param string $seller Thirdparty seller (we need $seller->country_code property). Provided only if seller is the supplier. - * @return result[ 0=total_ht, - * 1=total_vat, - * 2=total_ttc, - * 3=pu_ht, - * 4=pu_tva, - * 5=pu_ttc, - * 6=total_ht_without_discount, - * 7=total_vat_without_discount, - * 8=total_ttc_without_discount, - * 9=amount tax1 for total_ht, - * 10=amount tax2 for total_ht, - * 11=amount tax1 for pu_ht, - * 12=amount tax2 for pu_ht, - * 13=not used???, - * 14=amount tax1 for total_ht_without_discount, + * @return result[ 0=total_ht, + * 1=total_vat, + * 2=total_ttc, + * 3=pu_ht, + * 4=pu_tva, + * 5=pu_ttc, + * 6=total_ht_without_discount, + * 7=total_vat_without_discount, + * 8=total_ttc_without_discount, + * 9=amount tax1 for total_ht, + * 10=amount tax2 for total_ht, + * 11=amount tax1 for pu_ht, + * 12=amount tax2 for pu_ht, + * 13=not used???, + * 14=amount tax1 for total_ht_without_discount, * 15=amount tax1 for total_ht_without_discount] */ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '') @@ -69,7 +69,17 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $result=array(); - if (empty($seller) || ! is_object($seller)) $seller=$mysoc; // If seller is a customer, $seller is not provided, we use $mysoc + if (empty($seller) || ! is_object($seller)) + { + if (! is_object($mysoc)) // mysoc may be not defined (during migration process) + { + $mysoc=new Societe($db); + $mysoc->getMysoc($conf); + } + $seller=$mysoc; // If seller is a customer, $seller is not provided, we use $mysoc + //var_dump($seller->country_id);exit; + } + $countryid=$seller->country_id; if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj; if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj; @@ -192,7 +202,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } // if there's some localtax without vat, we calculate localtaxes (we will add them at end) - + //If price is 'TTC' we need to have the totals without VAT for a correct calculation if ($price_base_type=='TTC') { diff --git a/htdocs/install/mysql/data/llx_accounting.sql b/htdocs/install/mysql/data/llx_accounting.sql index cac46f77a51..f5ab745bba7 100644 --- a/htdocs/install/mysql/data/llx_accounting.sql +++ b/htdocs/install/mysql/data/llx_accounting.sql @@ -28,13 +28,13 @@ -- delete from llx_accountingaccount; -delete from llx_accountingsystem; +delete from llx_accounting_system; -- -- Descriptif des plans comptables FR PCG99-ABREGE -- -insert into llx_accountingsystem (rowid, pcg_version, fk_pays, label, active) VALUES (1,'PCG99-ABREGE', 1, 'The simple accountancy french plan', 1); +insert into llx_accounting_system (rowid, pcg_version, fk_pays, label, active) VALUES (1,'PCG99-ABREGE', 1, 'The simple accountancy french plan', 1); insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES ( 1,'PCG99-ABREGE','CAPIT', 'CAPITAL', '101', '1', 'Capital', '1'); insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES ( 2,'PCG99-ABREGE','CAPIT', 'XXXXXX', '105', '1', 'Ecarts de réévaluation', '1'); @@ -143,7 +143,7 @@ insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, -- Descriptif des plans comptables FR PCG99-BASE -- -insert into llx_accountingsystem (rowid, pcg_version, fk_pays, label, active) VALUES (2,'PCG99-BASE', 1, 'The base accountancy french plan', 1); +insert into llx_accounting_system (rowid, pcg_version, fk_pays, label, active) VALUES (2,'PCG99-BASE', 1, 'The base accountancy french plan', 1); insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (103,'PCG99-BASE','CAPIT', 'XXXXXX', '10', '1', 'Capital et réserves', '1'); insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (104,'PCG99-BASE','CAPIT', 'CAPITAL', '101', '10', 'Capital', '1'); diff --git a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql index a7add395e4c..a4048115593 100755 --- a/htdocs/install/mysql/migration/3.1.0-3.2.0.sql +++ b/htdocs/install/mysql/migration/3.1.0-3.2.0.sql @@ -464,3 +464,8 @@ UPDATE llx_product SET canvas = NULL where canvas = 'service@product'; DELETE FROM llx_const WHERE __DECRYPT('name')__ = 'SOCIETE_CODECOMPTA_ADDON' AND __DECRYPT('value')__ = 'mod_codecompta_digitaria'; ALTER TABLE llx_c_barcode_type ADD UNIQUE INDEX uk_c_barcode_type(code, entity); + +-- To make migration script with version >= 3.3 working correctly +ALTER TABLE llx_c_tva ADD COLUMN localtax1_type varchar(1) default '0' after localtax1; +ALTER TABLE llx_c_tva ADD COLUMN localtax2_type varchar(1) default '0' after localtax2; + diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index e81a3275532..8b51f95f176 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -212,8 +212,8 @@ ALTER TABLE llx_boxes ADD UNIQUE INDEX uk_boxes (entity, box_id, position, fk_us UPDATE llx_boxes as b SET b.entity = (SELECT bd.entity FROM llx_boxes_def as bd WHERE bd.rowid = b.box_id); -- TASK #204 -alter table llx_c_tva add column localtax1_type varchar(1) default '0' after localtax1; -alter table llx_c_tva add column localtax2_type varchar(1) default '0' after localtax2; +ALTER TABLE llx_c_tva ADD COLUMN localtax1_type varchar(1) default '0' after localtax1; +ALTER TABLE llx_c_tva ADD COLUMN localtax2_type varchar(1) default '0' after localtax2; ALTER TABLE llx_c_tva MODIFY COLUMN localtax1_type varchar(1); ALTER TABLE llx_c_tva MODIFY COLUMN localtax2_type varchar(1); @@ -289,8 +289,9 @@ ALTER TABLE llx_c_chargessociales ADD COLUMN accountancy_code varchar(15) DEFAUL -- Tables for accountancy expert DROP TABLE llx_accountingaccount; DROP TABLE llx_accountingsystem; +DROP TABLE llx_accounting_system; -create table llx_accountingsystem +create table llx_accounting_system ( rowid integer AUTO_INCREMENT PRIMARY KEY, pcg_version varchar(12) NOT NULL, @@ -299,7 +300,7 @@ create table llx_accountingsystem active smallint DEFAULT 0 )ENGINE=innodb; -ALTER TABLE llx_accountingsystem ADD INDEX idx_accountingsystem_pcg_version (pcg_version); +ALTER TABLE llx_accounting_system ADD INDEX idx_accounting_system_pcg_version (pcg_version); create table llx_accountingaccount ( @@ -314,12 +315,12 @@ create table llx_accountingaccount )ENGINE=innodb; ALTER TABLE llx_accountingaccount ADD INDEX idx_accountingaccount_fk_pcg_version (fk_pcg_version); -ALTER TABLE llx_accountingaccount ADD CONSTRAINT fk_accountingaccount_fk_pcg_version FOREIGN KEY (fk_pcg_version) REFERENCES llx_accountingsystem (pcg_version); +ALTER TABLE llx_accountingaccount ADD CONSTRAINT fk_accountingaccount_fk_pcg_version FOREIGN KEY (fk_pcg_version) REFERENCES llx_accounting_system (pcg_version); -- Data for accountancy expert -insert into llx_accountingsystem (rowid, pcg_version, fk_pays, label, active) VALUES (1,'PCG99-ABREGE', 1, 'The simple accountancy french plan', 1); +insert into llx_accounting_system (rowid, pcg_version, fk_pays, label, active) VALUES (1,'PCG99-ABREGE', 1, 'The simple accountancy french plan', 1); insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES ( 1,'PCG99-ABREGE','CAPIT', 'CAPITAL', '101', '1', 'Capital', '1'); insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES ( 2,'PCG99-ABREGE','CAPIT', 'XXXXXX', '105', '1', 'Ecarts de réévaluation', '1'); @@ -424,7 +425,7 @@ insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (101,'PCG99-ABREGE','PROD', 'XXXXXX', '787', '7', 'Reprises sur provisions', '1'); insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (102,'PCG99-ABREGE','PROD', 'XXXXXX', '79', '7', 'Transferts de charges', '1'); -insert into llx_accountingsystem (rowid, pcg_version, fk_pays, label, active) VALUES (2,'PCG99-BASE', 1, 'The base accountancy french plan', 1); +insert into llx_accounting_system (rowid, pcg_version, fk_pays, label, active) VALUES (2,'PCG99-BASE', 1, 'The base accountancy french plan', 1); insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (103,'PCG99-BASE','CAPIT', 'XXXXXX', '10', '1', 'Capital et réserves', '1'); insert into llx_accountingaccount (rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, label, active) VALUES (104,'PCG99-BASE','CAPIT', 'CAPITAL', '101', '10', 'Capital', '1'); diff --git a/htdocs/install/mysql/tables/llx_accountingsystem.key.sql b/htdocs/install/mysql/tables/llx_accounting_system.key.sql similarity index 91% rename from htdocs/install/mysql/tables/llx_accountingsystem.key.sql rename to htdocs/install/mysql/tables/llx_accounting_system.key.sql index 07a60a29054..f67852a8a6a 100644 --- a/htdocs/install/mysql/tables/llx_accountingsystem.key.sql +++ b/htdocs/install/mysql/tables/llx_accounting_system.key.sql @@ -18,5 +18,5 @@ -- =========================================================================== -ALTER TABLE llx_accountingsystem ADD INDEX idx_accountingsystem_pcg_version (pcg_version); +ALTER TABLE llx_accounting_system ADD INDEX idx_accounting_system_pcg_version (pcg_version); diff --git a/htdocs/install/mysql/tables/llx_accountingsystem.sql b/htdocs/install/mysql/tables/llx_accounting_system.sql similarity index 97% rename from htdocs/install/mysql/tables/llx_accountingsystem.sql rename to htdocs/install/mysql/tables/llx_accounting_system.sql index 33f3557b19a..0761ce40a75 100644 --- a/htdocs/install/mysql/tables/llx_accountingsystem.sql +++ b/htdocs/install/mysql/tables/llx_accounting_system.sql @@ -18,7 +18,7 @@ -- Table of "Plan de comptes" for accountancy expert module -- ============================================================================ -create table llx_accountingsystem +create table llx_accounting_system ( rowid integer AUTO_INCREMENT PRIMARY KEY, pcg_version varchar(12) NOT NULL, diff --git a/htdocs/install/mysql/tables/llx_accountingaccount.key.sql b/htdocs/install/mysql/tables/llx_accountingaccount.key.sql index 53e134c34c2..fde16ec9a3f 100644 --- a/htdocs/install/mysql/tables/llx_accountingaccount.key.sql +++ b/htdocs/install/mysql/tables/llx_accountingaccount.key.sql @@ -21,4 +21,4 @@ ALTER TABLE llx_accountingaccount ADD INDEX idx_accountingaccount_fk_pcg_version (fk_pcg_version); -ALTER TABLE llx_accountingaccount ADD CONSTRAINT fk_accountingaccount_fk_pcg_version FOREIGN KEY (fk_pcg_version) REFERENCES llx_accountingsystem (pcg_version); +ALTER TABLE llx_accountingaccount ADD CONSTRAINT fk_accountingaccount_fk_pcg_version FOREIGN KEY (fk_pcg_version) REFERENCES llx_accounting_system (pcg_version); diff --git a/htdocs/install/mysql/tables/llx_livraison.key.sql b/htdocs/install/mysql/tables/llx_livraison.key.sql index b493749bb92..70992cafc68 100644 --- a/htdocs/install/mysql/tables/llx_livraison.key.sql +++ b/htdocs/install/mysql/tables/llx_livraison.key.sql @@ -26,4 +26,4 @@ ALTER TABLE llx_livraison ADD INDEX idx_livraison_fk_user_valid (fk_user_valid); ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); -ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); +ALTER TABLE llx_livraison ADD CONSTRAINT fk_livraison_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index ede2a5145d0..a3720e910db 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -57,7 +57,7 @@ CREATE OR REPLACE FUNCTION dol_util_triggerall(DoEnable boolean) RETURNS integer -- Add triggers -CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_accountingsystem FOR EACH ROW EXECUTE PROCEDURE update_modified_column(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_accounting_system FOR EACH ROW EXECUTE PROCEDURE update_modified_column(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_accountingtransaction FOR EACH ROW EXECUTE PROCEDURE update_modified_column(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_actioncomm FOR EACH ROW EXECUTE PROCEDURE update_modified_column(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_adherent_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column();
'; print ''; @@ -176,9 +176,9 @@ if (! empty($conf->global->ACCOUNTING_SELECTCHART) && ! empty($conf->accounting- print ""; print ''; print ''; print ''; - + print '
'.$libelle; //print ' ('.$key.')'; print "