diff --git a/include/constant.php b/include/constant.php index 819f8b528..ce5670ec1 100644 --- a/include/constant.php +++ b/include/constant.php @@ -116,7 +116,7 @@ if ( !defined ("NOALYSS_PACKAGE_REPOSITORY")) { if ( ! defined ("SYSINFO_DISPLAY")) { define ("SYSINFO_DISPLAY",TRUE); } -define ("DBVERSION",168); +define ("DBVERSION",169); define ("MONO_DATABASE",25); define ("DBVERSIONREPO",20); define ('NOTFOUND','--not found--'); diff --git a/include/sql/patch/upgrade168.sql b/include/sql/patch/upgrade168.sql new file mode 100644 index 000000000..9d884bf09 --- /dev/null +++ b/include/sql/patch/upgrade168.sql @@ -0,0 +1,34 @@ +begin; + +update jrn set currency_id = 0,currency_rate=1,currency_rate_ref = 1 where currency_id is null or currency_rate is null or currency_rate_ref is null; + + + + +CREATE OR REPLACE FUNCTION comptaproc.jrn_currency() + RETURNS trigger + AS $function$ +begin + if new.currency_id is null then + new.currency_id := 0; + new.currency_rate := 1; + new.currency_rate_ref := 1; + end if; + return new; +end; +$function$ +LANGUAGE plpgsql; + +create trigger t_jrn_currency before +insert or update + on + public.jrn for each row execute procedure comptaproc.jrn_currency(); + + +ALTER TABLE public.jrn ALTER COLUMN currency_id SET NOT NULL; +ALTER TABLE public.jrn ALTER COLUMN currency_rate SET NOT NULL; +ALTER TABLE public.jrn ALTER COLUMN currency_rate_ref SET NOT NULL; + + +insert into version (val,v_description) values (169,'Fix bug currency_id is null, from IMPORTBANK'); +commit ;