From 7672722701c8b5e51113a0d697511e3f52c74047 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 8 May 2018 19:32:38 +0200 Subject: [PATCH 1/9] Missing class : missing class for acc_ledger --- include/class/acc_ledger.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/include/class/acc_ledger.class.php b/include/class/acc_ledger.class.php index f6254b13a..91dc186fb 100644 --- a/include/class/acc_ledger.class.php +++ b/include/class/acc_ledger.class.php @@ -47,6 +47,7 @@ require_once NOALYSS_INCLUDE.'/class/acc_payment.class.php'; require_once NOALYSS_INCLUDE.'/class/acc_ledger_history.class.php'; //require_once NOALYSS_INCLUDE.'/class/print_ledger.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; +require_once NOALYSS_INCLUDE.'/class/pre_op_ods.class.php'; /** \file * @brief Class for jrn, class acc_ledger for manipulating the ledger From 4f9be5373f14ff8672d49502705278f0df053fdb Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 8 May 2018 22:40:31 +0200 Subject: [PATCH 2/9] Bug 1600 : alphanumeric accounting must be case insensitive --- include/class/acc_account.class.php | 3 ++- include/class/fiche.class.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/class/acc_account.class.php b/include/class/acc_account.class.php index 68cb964a8..4a41f6915 100644 --- a/include/class/acc_account.class.php +++ b/include/class/acc_account.class.php @@ -53,6 +53,7 @@ class Acc_Account $this->db=$p_cn; $id=-1; if ( trim($pcm_val) != "" ) { + $pcm_val=mb_strtoupper($pcm_val); $pcm_val=$this->db->get_value("select format_account($1)", array($pcm_val)); $id=$p_cn->get_value("select id from tmp_pcmn where pcm_val=$1",[$pcm_val]); @@ -128,7 +129,7 @@ class Acc_Account function verify() { // check for Duplicate key, parent ... see Acc_Plan_MTable $count=$this->data_sql->count(" where pcm_val =$1 and id <> $2", - [$this->data_sql->pcm_val,$this->data_sql->id]); + [mb_strtoupper($this->data_sql->pcm_val),$this->data_sql->id]); if ( $count > 0) throw new Exception (_("Poste en double"),EXC_DUPLICATE); diff --git a/include/class/fiche.class.php b/include/class/fiche.class.php index c67ac0fc0..a69db88b2 100644 --- a/include/class/fiche.class.php +++ b/include/class/fiche.class.php @@ -805,7 +805,7 @@ class Fiche // account if ($id==ATTR_DEF_ACCOUNT) { - $v=sql_string($value); + $v=mb_strtoupper(sql_string($value)); try { @@ -973,7 +973,7 @@ class Fiche // account if ($id==ATTR_DEF_ACCOUNT) { - $v=sql_string($value); + $v=mb_strtoupper(sql_string($value)); if (trim($v)!='') { if (strpos($v, ',')!=0) From ff98ba8064efe86315ccc95a56dd71cc9db9140f Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 22 Apr 2018 11:00:00 +0200 Subject: [PATCH 3/9] html_page_start : protect query, improve code --- include/lib/ac_common.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index 6a910e4ef..9ace668a1 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -270,9 +270,11 @@ function html_page_start($p_theme="", $p_script="", $p_script2="") if ($p_theme != "") { $Res = $cn->exec_sql("select the_filestyle from theme - where the_name='" . $p_theme . "'"); + where the_name=$1" ,[$p_theme]); if (Database::num_row($Res) == 0) - $style = "style-classic.css"; + { + $style = "style-classic7.css"; + } else { $s = Database::fetch_array($Res, 0); @@ -281,7 +283,7 @@ function html_page_start($p_theme="", $p_script="", $p_script2="") } else { - $style = "style-classic.css"; + $style = "style-classic7.css"; } // end if $title="NOALYSS"; From 03497b90478bc0f7aca21351ea4e20a816c6fca2 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 28 Apr 2018 15:39:36 +0200 Subject: [PATCH 4/9] Action_Code : add validate, cancel and modify icon --- include/lib/icon_action.class.php | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/include/lib/icon_action.class.php b/include/lib/icon_action.class.php index 68fec5ed7..ad9a30bb9 100644 --- a/include/lib/icon_action.class.php +++ b/include/lib/icon_action.class.php @@ -193,4 +193,40 @@ class Icon_Action $r=''; return $r; } + /** + * Display the icon to modify a idem + * @param type $p_id + * @param type $p_javascript + * @return string + */ + static function modify($p_id,$p_javascript) + { + $r=''; + + return $r; + } + /** + * Display the icon to modify a idem + * @param type $p_id + * @param type $p_javascript + * @return string + */ + static function validate($p_id,$p_javascript) + { + $r=''; + + return $r; + } + /** + * Display the icon to modify a idem + * @param type $p_id + * @param type $p_javascript + * @return string + */ + static function cancel($p_id,$p_javascript) + { + $r=''; + + return $r; + } } From fc84867210892b2e4b5f617aa20e1beb75ff4f81 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 10 May 2018 23:02:23 +0200 Subject: [PATCH 5/9] Display the balance difference --- include/class/acc_operation.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/class/acc_operation.class.php b/include/class/acc_operation.class.php index 014404941..793fb7327 100644 --- a/include/class/acc_operation.class.php +++ b/include/class/acc_operation.class.php @@ -278,7 +278,7 @@ class Acc_Operation if ( $diff != 0 ) { - printf (_("Erreur : balance incorrecte :diff = %d"),$diff); + printf (_("Erreur : balance incorrecte :diff = %s"),$diff); return false; } From 64749aa738e780adae581ffd3454b655b5281759 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 12 May 2018 12:56:12 +0200 Subject: [PATCH 6/9] Bug in QUANT_PURCHASE , dp_dep_priv is not saved Conflicts: sql/upgrade.sql --- sql/upgrade.sql | 64 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/sql/upgrade.sql b/sql/upgrade.sql index f3ed35a1d..f3340f58e 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -1,9 +1,55 @@ -create view v_tva_rate as select - tva_id, - tva_rate, - tva_label, - tva_comment, - split_part(tva_poste,',',1) as tva_purchase, - split_part(tva_poste,',',2) as tva_sale, - tva_both_side -from tva_rate; +CREATE OR REPLACE FUNCTION comptaproc.insert_quant_purchase(p_internal text, p_j_id numeric, p_fiche character varying, p_quant numeric, p_price numeric, p_vat numeric, p_vat_code integer, p_nd_amount numeric, p_nd_tva numeric, p_nd_tva_recup numeric, p_dep_priv numeric, p_client character varying, p_tva_sided numeric, p_price_unit numeric) + RETURNS void + LANGUAGE plpgsql +AS $function$ +declare + fid_client integer; + fid_good integer; + account_priv account_type; + fid_good_account account_type; + n_dep_priv numeric; +begin + n_dep_priv := p_dep_priv; + select p_value into account_priv from parm_code where p_code='DEP_PRIV'; + select f_id into fid_client from + fiche_detail where ad_id=23 and ad_value=upper(trim(p_client)); + select f_id into fid_good from + fiche_detail where ad_id=23 and ad_value=upper(trim(p_fiche)); + select ad_value into fid_good_account from fiche_detail where ad_id=5 and f_id=fid_good; + if strpos( fid_good_account , account_priv ) = 1 then + n_dep_priv=p_price; + end if; + + insert into quant_purchase + (qp_internal, + j_id, + qp_fiche, + qp_quantite, + qp_price, + qp_vat, + qp_vat_code, + qp_nd_amount, + qp_nd_tva, + qp_nd_tva_recup, + qp_supplier, + qp_dep_priv, + qp_vat_sided, + qp_unit) + values + (p_internal, + p_j_id, + fid_good, + p_quant, + p_price, + p_vat, + p_vat_code, + p_nd_amount, + p_nd_tva, + p_nd_tva_recup, + fid_client, + n_dep_priv, + p_tva_sided, + p_price_unit); + return; +end; + $function$ \ No newline at end of file From 6eb2e07f8e712c4f4e31bb5b6b0d6d998c4b8a1a Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 12 May 2018 13:55:09 +0200 Subject: [PATCH 7/9] integrate fix for bug in insert_quant_purchase which cannot save private fee Conflicts: include/sql/patch/upgrade128.sql --- include/sql/patch/upgrade128.sql | 161 +++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 include/sql/patch/upgrade128.sql diff --git a/include/sql/patch/upgrade128.sql b/include/sql/patch/upgrade128.sql new file mode 100644 index 000000000..b219fedd3 --- /dev/null +++ b/include/sql/patch/upgrade128.sql @@ -0,0 +1,161 @@ +begin; +INSERT INTO public.menu_ref +(me_code, me_menu, me_file, me_url, me_description, me_parameter, me_javascript, me_type, me_description_etendue) +VALUES('CFGCURRENCY', 'Devises', 'acc_currency_cfg.inc.php', NULL, 'Configuration des devises', NULL,NULL,'ME','Permet de configurer les devises'); + +INSERT INTO public.profile_menu +(pm_id, me_code, me_code_dep, p_id, p_order, p_type_display, pm_default, pm_id_dep) +VALUES(nextval('profile_menu_pm_id_seq'), 'CFGCURRENCY', 'PARAM', 1, 50, 'E', 0, 45); + +-- Drop table + +-- DROP TABLE public.currency + +CREATE TABLE public.currency ( + id serial NOT NULL, + cr_code_iso varchar(10) NULL, + CONSTRAINT currency_pk PRIMARY KEY (id), + CONSTRAINT currency_un UNIQUE (cr_code_iso) +); + + +-- Drop table + +-- DROP TABLE public.currency_history + +CREATE TABLE public.currency_history ( + id serial NOT NULL, + ch_value numeric(20,6) NOT NULL, + ch_from date NOT NULL, + currency_id int4 NOT NULL, + CONSTRAINT currency_history_pk PRIMARY KEY (id), + CONSTRAINT currency_history_currency_fk FOREIGN KEY (currency_id) REFERENCES currency(id) + ON DELETE RESTRICT ON UPDATE CASCADE +) +; + +-- Ajouter commentaire sur colonne + +ALTER TABLE public.currency ADD cr_name varchar(80) NULL; +insert into currency (id,cr_code_iso,cr_name) values (0,'EUR','EUR'); +insert into currency_history (ch_value,ch_from,currency_id) values (1,to_date('01.01.2000','DD.MM.YYYY'),0); + +ALTER TABLE public.currency_history ADD CONSTRAINT currency_history_check CHECK (ch_value > 0) ; + +-- Create view to manage the table +create view v_currency_last_value as +with recent_rate as +( select + currency_id,max(ch_from) as rc_from + from + currency_history + group by currency_id + ) +select + cr1.id as currency_id, + cr1.cr_name, + cr1.cr_code_iso, + ch1.id as currency_history_id, + ch1.ch_value as ch_value, + to_char(rc_from,'DD.MM.YYYY') as str_from +from +currency as cr1 +join recent_rate on (currency_id=cr1.id) +join currency_history as ch1 on (recent_rate.currency_id=ch1.currency_id and rc_from=ch1.ch_from); + +COMMENT ON COLUMN public.currency_history.id IS 'pk' ; +COMMENT ON COLUMN public.currency_history.ch_value IS 'rate of currency depending of currency of the folder' ; +COMMENT ON COLUMN public.currency_history.ch_from IS 'Date when the rate is available' ; +COMMENT ON COLUMN public.currency_history.currency_id IS 'FK to currency' ; +COMMENT ON COLUMN public.currency.cr_code_iso IS 'Code ISO' ; +COMMENT ON COLUMN public.currency.cr_name IS 'Name of the currency' ; + + + +-- Drop table + +-- DROP TABLE public.operation_currency + +CREATE TABLE public.operation_currency ( + id bigserial NOT NULL, + oc_amount numeric(20,6) NOT NULL, -- amount in currency + oc_vat_amount numeric(20,6) NULL DEFAULT 0, -- vat amount in currency + oc_price_unit numeric(20,6) NULL, -- unit price in currency + j_id int8 NOT NULL, -- fk to jrnx + CONSTRAINT operation_currency_pk PRIMARY KEY (id) +); + +ALTER TABLE public.operation_currency ADD CONSTRAINT operation_currency_jrnx_fk FOREIGN KEY (j_id) REFERENCES public.jrnx(j_id) ON DELETE CASCADE ON UPDATE CASCADE; + +-- Column comments + +COMMENT ON COLUMN public.operation_currency.oc_amount IS 'amount in currency' ; +COMMENT ON COLUMN public.operation_currency.oc_vat_amount IS 'vat amount in currency' ; +COMMENT ON COLUMN public.operation_currency.oc_price_unit IS 'unit price in currency' ; +COMMENT ON COLUMN public.operation_currency.j_id IS 'fk to jrnx' ; +alter table jrn add currency_id bigint default 0; +update jrn set currency_id=0; +alter table jrn add currency_rate numeric (20,6) default 1; +update jrn set currency_rate=1; +alter table jrn add currency_rate_ref numeric(20,6) default 1; +update jrn set currency_rate_ref=1; +ALTER TABLE public.jrn ADD CONSTRAINT jrn_currency_fk FOREIGN KEY (currency_id) REFERENCES public.currency(id) ON DELETE RESTRICT ON UPDATE RESTRICT; + +CREATE OR REPLACE FUNCTION comptaproc.insert_quant_purchase(p_internal text, p_j_id numeric, p_fiche character varying, p_quant numeric, p_price numeric, p_vat numeric, p_vat_code integer, p_nd_amount numeric, p_nd_tva numeric, p_nd_tva_recup numeric, p_dep_priv numeric, p_client character varying, p_tva_sided numeric, p_price_unit numeric) + RETURNS void +AS $function$ +declare + fid_client integer; + fid_good integer; + account_priv account_type; + fid_good_account account_type; + n_dep_priv numeric; +begin + n_dep_priv := p_dep_priv; + select p_value into account_priv from parm_code where p_code='DEP_PRIV'; + select f_id into fid_client from + fiche_detail where ad_id=23 and ad_value=upper(trim(p_client)); + select f_id into fid_good from + fiche_detail where ad_id=23 and ad_value=upper(trim(p_fiche)); + select ad_value into fid_good_account from fiche_detail where ad_id=5 and f_id=fid_good; + if strpos( fid_good_account , account_priv ) = 1 then + n_dep_priv=p_price; + end if; + + insert into quant_purchase + (qp_internal, + j_id, + qp_fiche, + qp_quantite, + qp_price, + qp_vat, + qp_vat_code, + qp_nd_amount, + qp_nd_tva, + qp_nd_tva_recup, + qp_supplier, + qp_dep_priv, + qp_vat_sided, + qp_unit) + values + (p_internal, + p_j_id, + fid_good, + p_quant, + p_price, + p_vat, + p_vat_code, + p_nd_amount, + p_nd_tva, + p_nd_tva_recup, + fid_client, + n_dep_priv, + p_tva_sided, + p_price_unit); + return; +end; +$function$ +LANGUAGE plpgsql; + +insert into version (val,v_description) values (129,'Currency : create view , create tables '); +commit; \ No newline at end of file From 3fcfd114f70755bcdfe6557fcceba5fd03e937ac Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 17 May 2018 21:23:03 +0200 Subject: [PATCH 8/9] Add upgrade128.sql --- include/constant.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constant.php b/include/constant.php index 67f0da304..cce784f4b 100644 --- a/include/constant.php +++ b/include/constant.php @@ -110,7 +110,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) { if ( ! defined ("SYSINFO_DISPLAY")) { define ("SYSINFO_DISPLAY",TRUE); } -define ("DBVERSION",128); +define ("DBVERSION",129); define ("MONO_DATABASE",25); define ("DBVERSIONREPO",18); define ('NOTFOUND','--not found--'); From 5feb8f2e477ca13926dc3e070ed654059d605c71 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 17 May 2018 21:25:22 +0200 Subject: [PATCH 9/9] Upgrade 128.sql --- include/sql/patch/upgrade128.sql | 106 +------------------------------ 1 file changed, 2 insertions(+), 104 deletions(-) diff --git a/include/sql/patch/upgrade128.sql b/include/sql/patch/upgrade128.sql index b219fedd3..7a2b06643 100644 --- a/include/sql/patch/upgrade128.sql +++ b/include/sql/patch/upgrade128.sql @@ -1,106 +1,4 @@ begin; -INSERT INTO public.menu_ref -(me_code, me_menu, me_file, me_url, me_description, me_parameter, me_javascript, me_type, me_description_etendue) -VALUES('CFGCURRENCY', 'Devises', 'acc_currency_cfg.inc.php', NULL, 'Configuration des devises', NULL,NULL,'ME','Permet de configurer les devises'); - -INSERT INTO public.profile_menu -(pm_id, me_code, me_code_dep, p_id, p_order, p_type_display, pm_default, pm_id_dep) -VALUES(nextval('profile_menu_pm_id_seq'), 'CFGCURRENCY', 'PARAM', 1, 50, 'E', 0, 45); - --- Drop table - --- DROP TABLE public.currency - -CREATE TABLE public.currency ( - id serial NOT NULL, - cr_code_iso varchar(10) NULL, - CONSTRAINT currency_pk PRIMARY KEY (id), - CONSTRAINT currency_un UNIQUE (cr_code_iso) -); - - --- Drop table - --- DROP TABLE public.currency_history - -CREATE TABLE public.currency_history ( - id serial NOT NULL, - ch_value numeric(20,6) NOT NULL, - ch_from date NOT NULL, - currency_id int4 NOT NULL, - CONSTRAINT currency_history_pk PRIMARY KEY (id), - CONSTRAINT currency_history_currency_fk FOREIGN KEY (currency_id) REFERENCES currency(id) - ON DELETE RESTRICT ON UPDATE CASCADE -) -; - --- Ajouter commentaire sur colonne - -ALTER TABLE public.currency ADD cr_name varchar(80) NULL; -insert into currency (id,cr_code_iso,cr_name) values (0,'EUR','EUR'); -insert into currency_history (ch_value,ch_from,currency_id) values (1,to_date('01.01.2000','DD.MM.YYYY'),0); - -ALTER TABLE public.currency_history ADD CONSTRAINT currency_history_check CHECK (ch_value > 0) ; - --- Create view to manage the table -create view v_currency_last_value as -with recent_rate as -( select - currency_id,max(ch_from) as rc_from - from - currency_history - group by currency_id - ) -select - cr1.id as currency_id, - cr1.cr_name, - cr1.cr_code_iso, - ch1.id as currency_history_id, - ch1.ch_value as ch_value, - to_char(rc_from,'DD.MM.YYYY') as str_from -from -currency as cr1 -join recent_rate on (currency_id=cr1.id) -join currency_history as ch1 on (recent_rate.currency_id=ch1.currency_id and rc_from=ch1.ch_from); - -COMMENT ON COLUMN public.currency_history.id IS 'pk' ; -COMMENT ON COLUMN public.currency_history.ch_value IS 'rate of currency depending of currency of the folder' ; -COMMENT ON COLUMN public.currency_history.ch_from IS 'Date when the rate is available' ; -COMMENT ON COLUMN public.currency_history.currency_id IS 'FK to currency' ; -COMMENT ON COLUMN public.currency.cr_code_iso IS 'Code ISO' ; -COMMENT ON COLUMN public.currency.cr_name IS 'Name of the currency' ; - - - --- Drop table - --- DROP TABLE public.operation_currency - -CREATE TABLE public.operation_currency ( - id bigserial NOT NULL, - oc_amount numeric(20,6) NOT NULL, -- amount in currency - oc_vat_amount numeric(20,6) NULL DEFAULT 0, -- vat amount in currency - oc_price_unit numeric(20,6) NULL, -- unit price in currency - j_id int8 NOT NULL, -- fk to jrnx - CONSTRAINT operation_currency_pk PRIMARY KEY (id) -); - -ALTER TABLE public.operation_currency ADD CONSTRAINT operation_currency_jrnx_fk FOREIGN KEY (j_id) REFERENCES public.jrnx(j_id) ON DELETE CASCADE ON UPDATE CASCADE; - --- Column comments - -COMMENT ON COLUMN public.operation_currency.oc_amount IS 'amount in currency' ; -COMMENT ON COLUMN public.operation_currency.oc_vat_amount IS 'vat amount in currency' ; -COMMENT ON COLUMN public.operation_currency.oc_price_unit IS 'unit price in currency' ; -COMMENT ON COLUMN public.operation_currency.j_id IS 'fk to jrnx' ; -alter table jrn add currency_id bigint default 0; -update jrn set currency_id=0; -alter table jrn add currency_rate numeric (20,6) default 1; -update jrn set currency_rate=1; -alter table jrn add currency_rate_ref numeric(20,6) default 1; -update jrn set currency_rate_ref=1; -ALTER TABLE public.jrn ADD CONSTRAINT jrn_currency_fk FOREIGN KEY (currency_id) REFERENCES public.currency(id) ON DELETE RESTRICT ON UPDATE RESTRICT; - CREATE OR REPLACE FUNCTION comptaproc.insert_quant_purchase(p_internal text, p_j_id numeric, p_fiche character varying, p_quant numeric, p_price numeric, p_vat numeric, p_vat_code integer, p_nd_amount numeric, p_nd_tva numeric, p_nd_tva_recup numeric, p_dep_priv numeric, p_client character varying, p_tva_sided numeric, p_price_unit numeric) RETURNS void AS $function$ @@ -157,5 +55,5 @@ end; $function$ LANGUAGE plpgsql; -insert into version (val,v_description) values (129,'Currency : create view , create tables '); -commit; \ No newline at end of file +insert into version (val,v_description) values (129,'Fix bug in QUANT_PURCHASE'); +commit;