Database : correct the scripts for creating DB and adapt to postgreSQL 12

This commit is contained in:
sparkyx 2024-08-24 11:59:55 +02:00
parent 81fde67755
commit 062ed82feb
21 changed files with 10193 additions and 5432 deletions

View file

@ -404,6 +404,8 @@ echo "<li>";
echo "</li>";
}
//---------------------------------------------------------------------------------------
// Check php modules
//---------------------------------------------------------------------------------------
@ -484,17 +486,20 @@ if ( (defined("MULTI") && MULTI==1)|| !defined("MULTI"))
?>
<h2><?php echo _('Base de données')?></h2>
<?php
// Verify Psql version
//--
//-------------------------------------------------------------------------------------------
// Verify Psql version
//
//-------------------------------------------------------------------------------------------
$sql="select setting from pg_settings where name='server_version'";
$version=$cn->get_value($sql);
echo _("Version base de données :"),$version;
$majeur=explode(".",$version);
if ( $majeur[0] < 10 )
if ( $majeur[0] < 12 )
{
?>
<p><?php echo $failed . _(" Vous devez absolument utiliser au minimum une version 10 de PostGresql, si votre distribution n'en
<p><?php echo $failed . _(" Vous devez utiliser au minimum une version 12 de PostGresql, si votre distribution n'en
offre pas, installez-en une en la compilant. Lisez attentivement la notice sur postgresql.org pour migrer
vos bases de données")?>
</p>
@ -594,19 +599,48 @@ if ($account == 0 ) {
echo "Creation of ".domaine."account_repository";
if ( DEBUGNOALYSS == 0 ) ob_start();
$cn->exec_sql("create database ".domaine."account_repository encoding='utf8'");
$cn=new Database();
$cn->start();
$cn->execute_script(NOALYSS_INCLUDE."/sql/account_repository/schema.sql");
$cn->execute_script(NOALYSS_INCLUDE."/sql/account_repository/data.sql");
$cn->execute_script(NOALYSS_INCLUDE."/sql/account_repository/constraint.sql");
$repo=new Database();
$sql_trigger_activate="
create or replace procedure public.trigger_activate(to_enable bool)
language plpgsql
as
$$
declare
rec1 record;
cmd text;
begin
for rec1 in (select relname,nspname
from pg_catalog.pg_class pc join pg_catalog.pg_namespace pn on (pn.oid=pc.relnamespace)
where pn.nspname in ('public','comptaproc') and relhastriggers is true) loop
if to_enable is false then
cmd=format('alter table %s.%s disable trigger all',rec1.nspname,rec1.relname);
else
cmd=format('alter table %s.%s enable trigger all',rec1.nspname,rec1.relname);
end if;
execute cmd;
raise notice '%',cmd;
end loop;
end
$$;
";
$repo->exec_sql($sql_trigger_activate);
$repo->start();
$repo->execute_script(NOALYSS_INCLUDE."/sql/account_repository/schema.sql");
$repo->exec_sql("call public.trigger_activate(false) ");
$repo->execute_script(NOALYSS_INCLUDE."/sql/account_repository/data.sql");
$repo->commit($cn);
/* update name administrator */
$cadmin=NOALYSS_ADMINISTRATOR;
$cpassword_admin=NOALYSS_ADMIN_PASSWORD;
$cn->exec_sql("update ac_users set use_login=$1,use_pass=md5($2),use_active=1 where use_id=1",
$repo->exec_sql("update public.ac_users set use_login=$1,use_pass=md5($2),use_active=1 where use_id=1",
array(strtolower($cadmin),$cpassword_admin));
$cn->commit($cn);
$repo->exec_sql("call public.trigger_activate(true) ");
$repo->exec_sql("drop procedure public.trigger_activate ");
if ( DEBUGNOALYSS == 0 )
{
ob_end_clean();
@ -620,27 +654,35 @@ if ($account == 0 ) {
$cn->exec_sql("create database ".domaine."mod1 encoding='utf8'");
$cn=new Database(1,'mod');
$cn->exec_sql($sql_trigger_activate);
$cn->start();
$cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/schema.sql');
$cn->exec_sql("call public.trigger_activate(false) ");
$cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/data.sql');
$cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/constraint.sql');
$cn->commit();
$cn->commit();
$cn->exec_sql("call public.trigger_activate(true) ");
$cn->exec_sql("drop procedure public.trigger_activate");
if ( DEBUGNOALYSS == 0 )
{
ob_end_clean();
}
echo _("Creation of Modele 2");
echo _("Creation of Modele 2");
$cn->exec_sql("create database ".domaine."mod2 encoding='utf8'");
$cn=new Database(2,'mod');
$cn->exec_sql($sql_trigger_activate);
$cn->start();
if ( DEBUGNOALYSS == 0 ) { ob_start(); }
$cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/schema.sql');
$cn->execute_script(NOALYSS_INCLUDE.'/sql/mod2/data.sql');
$cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/constraint.sql');
$cn->commit();
$cn->execute_script(NOALYSS_INCLUDE.'/sql/mod1/schema.sql');
$cn->exec_sql("call public.trigger_activate(false) ");
$cn->execute_script(NOALYSS_INCLUDE.'/sql/mod2/data.sql');
$cn->commit();
$cn->exec_sql("call public.trigger_activate(true) ");
$cn->exec_sql("drop procedure public.trigger_activate");
if ( DEBUGNOALYSS == 0 ) ob_end_clean();
echo '<h1>'._('Important').'</h1>';
echo '<p>'._('Utilisateur administrateur'),' ',NOALYSS_ADMINISTRATOR,'</p>';
@ -725,7 +767,7 @@ define ('ALLOWED_ADMIN',1);
$rep=new Database();
if (defined("NOALYSS_ADMINISTRATOR") && defined ("NOALYSS_ADMIN_PASSWORD"))
{
$rep->exec_sql("update ac_users set use_login=$1 ,use_pass=md5($2)
$rep->exec_sql("update public.ac_users set use_login=$1 ,use_pass=md5($2)
where use_id=1",
array(strtolower(NOALYSS_ADMINISTRATOR),
NOALYSS_ADMIN_PASSWORD));

View file

@ -63,12 +63,39 @@ class Package_Template extends Package_Noalyss
$cn->exec_sql($sql);
$newdb=new Database($seq, 'mod');
$sql_trigger_activate="
create or replace procedure public.trigger_activate(to_enable bool)
language plpgsql
as
$$
declare
rec1 record;
cmd text;
begin
for rec1 in (select relname,nspname
from pg_catalog.pg_class pc join pg_catalog.pg_namespace pn on (pn.oid=pc.relnamespace)
where pn.nspname in ('public','comptaproc') and relhastriggers is true) loop
if to_enable is false then
cmd=format('alter table %s.%s disable trigger all',rec1.nspname,rec1.relname);
else
cmd=format('alter table %s.%s enable trigger all',rec1.nspname,rec1.relname);
end if;
execute cmd;
raise notice '%',cmd;
end loop;
end
$$;
";
$newdb->exec_sql($sql_trigger_activate);
// Execute SQL Script
$newdb->execute_script($tmpdir.'/schema.sql');
$newdb->exec_sql("call public.trigger_activate(false) ");
$newdb->execute_script($tmpdir.'/data.sql');
$newdb->execute_script($tmpdir.'/constraint.sql');
$newdb->exec_sql("call public.trigger_activate(true) ");
$newdb->exec_sql("drop procedure public.trigger_activate ");
// Register into account_repository, we add the seq number for avoiding duplicate
$description = sprintf(_("Installé le %s"),date("d-m-Y h:i:s"));
$cn->exec_sql(" insert into modeledef (mod_id,mod_name,mod_desc) values ($1,$2,$3)",

View file

@ -2,44 +2,3 @@
SET check_function_bodies = false;
SET client_min_messages = warning;
SET search_path = public, pg_catalog;
ALTER TABLE ONLY audit_connect ALTER COLUMN ac_id SET DEFAULT nextval('audit_connect_ac_id_seq'::regclass);
ALTER TABLE ONLY dossier_sent_email ALTER COLUMN id SET DEFAULT nextval('dossier_sent_email_id_seq'::regclass);
ALTER TABLE ONLY ac_dossier
ADD CONSTRAINT ac_dossier_dos_name_key UNIQUE (dos_name);
ALTER TABLE ONLY ac_dossier
ADD CONSTRAINT ac_dossier_pkey PRIMARY KEY (dos_id);
ALTER TABLE ONLY ac_users
ADD CONSTRAINT ac_users_pkey PRIMARY KEY (use_id);
ALTER TABLE ONLY ac_users
ADD CONSTRAINT ac_users_use_login_key UNIQUE (use_login);
ALTER TABLE ONLY audit_connect
ADD CONSTRAINT audit_connect_pkey PRIMARY KEY (ac_id);
ALTER TABLE ONLY dossier_sent_email
ADD CONSTRAINT de_date_dos_id_ux UNIQUE (de_date, dos_id);
ALTER TABLE ONLY dossier_sent_email
ADD CONSTRAINT dossier_sent_email_pkey PRIMARY KEY (id);
ALTER TABLE ONLY jnt_use_dos
ADD CONSTRAINT jnt_use_dos_pkey PRIMARY KEY (jnt_id);
ALTER TABLE ONLY modeledef
ADD CONSTRAINT modeledef_pkey PRIMARY KEY (mod_id);
ALTER TABLE ONLY user_global_pref
ADD CONSTRAINT pk_user_global_pref PRIMARY KEY (user_id, parameter_type);
ALTER TABLE ONLY progress
ADD CONSTRAINT progress_pkey PRIMARY KEY (p_id);
ALTER TABLE ONLY recover_pass
ADD CONSTRAINT recover_pass_pkey PRIMARY KEY (request);
ALTER TABLE ONLY jnt_use_dos
ADD CONSTRAINT use_id_dos_id_uniq UNIQUE (use_id, dos_id);
ALTER TABLE ONLY version
ADD CONSTRAINT version_pkey PRIMARY KEY (val);
ALTER TABLE ONLY recover_pass
ADD CONSTRAINT ac_users_recover_pass_fk FOREIGN KEY (use_id) REFERENCES ac_users(use_id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY dossier_sent_email
ADD CONSTRAINT de_ac_dossier_fk FOREIGN KEY (dos_id) REFERENCES ac_dossier(dos_id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY user_global_pref
ADD CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES ac_users(use_login) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY jnt_use_dos
ADD CONSTRAINT jnt_use_dos_dos_id_fkey FOREIGN KEY (dos_id) REFERENCES ac_dossier(dos_id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY jnt_use_dos
ADD CONSTRAINT jnt_use_dos_use_id_fkey FOREIGN KEY (use_id) REFERENCES ac_users(use_id);
CREATE TRIGGER limit_user_trg BEFORE INSERT OR UPDATE ON audit_connect FOR EACH ROW EXECUTE PROCEDURE limit_user();

View file

@ -1,43 +1,23 @@
set search_path = public,comptaproc,pg_catalog ;
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin, use_email) VALUES (4, 'demo', 'demo', 'demo', 0, 'fe01ce2a7fbac8fafaed7c982a04e229', 0, NULL);
INSERT INTO ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin, use_email) VALUES (1, NULL, NULL, 'admin', 1, 'b1cc88e1907cde80cb2595fa793b3da9', 1, NULL);
SELECT pg_catalog.setval('audit_connect_ac_id_seq', 1, false);
SELECT pg_catalog.setval('dossier_id', 24, true);
SELECT pg_catalog.setval('dossier_sent_email_id_seq', 1, false);
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (1, '(BE) Basique', 'Comptabilité Belge, à adapter');
INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (2, '(FR) Basique', 'Comptabilité Française, à adapter');
INSERT INTO public.ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin, use_email) VALUES (4, 'demo', 'demo', 'demo', 0, 'fe01ce2a7fbac8fafaed7c982a04e229', 0, NULL);
INSERT INTO public.ac_users (use_id, use_first_name, use_name, use_login, use_active, use_pass, use_admin, use_email) VALUES (1, NULL, NULL, 'admin', 1, '04cd7fc709122459e51c439171c43209', 1, NULL);
@ -47,39 +27,65 @@ INSERT INTO modeledef (mod_id, mod_name, mod_desc) VALUES (2, '(FR) Basique', 'C
SELECT pg_catalog.setval('s_modid', 8, true);
SELECT pg_catalog.setval('seq_jnt_use_dos', 28, true);
INSERT INTO public.modeledef (mod_id, mod_name, mod_desc) VALUES (1, '(BE) Basique', 'Comptabilité Belge, à adapter');
INSERT INTO public.modeledef (mod_id, mod_name, mod_desc) VALUES (2, '(FR) Basique', 'Comptabilité Française, à adapter');
SELECT pg_catalog.setval('seq_priv_user', 12, true);
INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('Light', 'style-light.css', NULL);
INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('Classique', 'style-classic.css', NULL);
INSERT INTO theme (the_name, the_filestyle, the_filebutton) VALUES ('Classic7', 'style-classic7.css', NULL);
INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('demo', 'PAGESIZE', '50');
INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('demo', 'LANG', 'fr_FR.utf8');
INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'PAGESIZE', '50');
INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'LANG', 'fr_FR.utf8');
INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'TOPMENU', 'TEXT');
INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('demo', 'THEME', 'Classic7');
INSERT INTO user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'THEME', 'Classic7');
INSERT INTO public.theme (the_name, the_filestyle, the_filebutton) VALUES ('Light', 'style-light.css', NULL);
INSERT INTO public.theme (the_name, the_filestyle, the_filebutton) VALUES ('Classique', 'style-classic.css', NULL);
INSERT INTO public.theme (the_name, the_filestyle, the_filebutton) VALUES ('Classic7', 'style-classic7.css', NULL);
SELECT pg_catalog.setval('users_id', 5, true);
INSERT INTO public.user_global_pref (user_id, parameter_type, parameter_value) VALUES ('demo', 'PAGESIZE', '50');
INSERT INTO public.user_global_pref (user_id, parameter_type, parameter_value) VALUES ('demo', 'LANG', 'fr_FR.utf8');
INSERT INTO public.user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'PAGESIZE', '50');
INSERT INTO public.user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'LANG', 'fr_FR.utf8');
INSERT INTO public.user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'TOPMENU', 'TEXT');
INSERT INTO public.user_global_pref (user_id, parameter_type, parameter_value) VALUES ('demo', 'THEME', 'Classic7');
INSERT INTO public.user_global_pref (user_id, parameter_type, parameter_value) VALUES ('admin', 'THEME', 'Classic7');
INSERT INTO version (val) VALUES (18);
INSERT INTO public.version (val) VALUES (18);
SELECT pg_catalog.setval('public.audit_connect_ac_id_seq', 1, false);
SELECT pg_catalog.setval('public.dossier_id', 24, true);
SELECT pg_catalog.setval('public.dossier_sent_email_id_seq', 1, false);
SELECT pg_catalog.setval('public.s_modid', 8, true);
SELECT pg_catalog.setval('public.seq_jnt_use_dos', 28, true);
SELECT pg_catalog.setval('public.seq_priv_user', 12, true);
SELECT pg_catalog.setval('public.users_id', 5, true);

View file

@ -1,4 +1,4 @@
CREATE INDEX audit_connect_ac_user ON audit_connect USING btree (ac_user);
CREATE INDEX fk_jnt_dos_id ON jnt_use_dos USING btree (dos_id);
CREATE INDEX fk_jnt_use_dos ON jnt_use_dos USING btree (use_id);
CREATE INDEX fki_ac_users_recover_pass_fk ON recover_pass USING btree (use_id);
CREATE INDEX audit_connect_ac_user ON public.audit_connect USING btree (ac_user);
CREATE INDEX fk_jnt_dos_id ON public.jnt_use_dos USING btree (dos_id);
CREATE INDEX fk_jnt_use_dos ON public.jnt_use_dos USING btree (use_id);
CREATE INDEX fki_ac_users_recover_pass_fk ON public.recover_pass USING btree (use_id);

View file

@ -4,39 +4,15 @@
# under GPL license
#
export TEMPLATE=${DOMAIN}account_repository
#export TEMPLATE=${DOMAIN}account_repository
export TEMPLATE=account_repository
pg_dump -O -U dany -s $TEMPLATE|grep -v "COMMENT ON SCHEMA public IS 'Standard public schema';" |sed "/^--/d" > schema.sql
sed -i -e "/COMMENT ON EXTENSION/d" schema.sql
sed -i -e "/CREATE EXTENSION/d" schema.sql
awk '/SEQUENCE/,/;/ { print $0;}' < schema.sql > sequence.sql
awk '/CREATE DOMAIN/,/;/ { print $0;}' < schema.sql > table.sql
awk '/CREATE TABLE/,/;/ { print $0;}' < schema.sql >> table.sql
awk '/CREATE VIEW/,/;/ { print $0;}' < schema.sql > view.sql
awk '/INDEX/,/;/ { print $0;}' < schema.sql > index.sql
(
echo " SET client_encoding = 'utf8';"
echo " SET check_function_bodies = false;"
echo " SET client_min_messages = warning;"
echo "SET search_path = public, pg_catalog;"
)> constraint.sql
awk '/ALTER TABLE/,/;/ { print $0;}' < schema.sql >> constraint.sql
awk '/CREATE TRIGGER/,/;/ { print $0;}' < schema.sql >> constraint.sql
awk '/COMMENT ON CONSTRAINT/,/;/ { print $0;}' < schema.sql >> constraint.sql
awk '/COMMENT ON TRIGGER/,/;/ { print $0;}' < schema.sql >> constraint.sql
# function in XML
## awk 'BEGIN{print "<PROCEDURES>";} /CREATE FUNCTION/,/\$\$;/ { if (/CREATE FUNCTION/) {print "<procedure>";} if (/\$\$;/) {print "</procedure>";} print $0;} END { print "</PROCEDURES>";}' < schema.sql
awk '/CREATE FUNCTION/,/\$\$;/ { print $0;}' < schema.sql > function.sql
awk '/COMMENT/,/;/ {print $0;}' < schema.sql > comment.sql
sed -i -e "/REVOKE /d" -e "/GRANT /d" -e "/ALTER TABLE.*/d" -e "/ADD CONSTRAINT/d" -e "/CREATE PROCEDURAL/d" -e "/CREATE TRIGGER/d" -e "/COMMENT ON CONSTRAINT/d" -e "/COMMENT ON TRIGGER/d" schema.sql
grep setval schema.sql >> sequence.sql
pg_dump -O -U dany --data-only --column-inserts -O ${TEMPLATE}|sed "/^--/d" | sed -e "/SET search_path/d" > data.sql
echo "set search_path = public,comptaproc,pg_catalog ;" > data.sql
pg_dump -O -U dany --data-only --column-inserts -O ${TEMPLATE}|sed "/^--/d" | sed -e "/SET search_path/d" >> data.sql

View file

@ -1,20 +1,18 @@
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
SET search_path = public, pg_catalog;
CREATE FUNCTION limit_user() RETURNS trigger
CREATE FUNCTION public.limit_user() RETURNS trigger
LANGUAGE plpgsql
AS $$
@ -25,7 +23,7 @@ end; $$;
CREATE FUNCTION upgrade_repo(p_version integer) RETURNS void
CREATE FUNCTION public.upgrade_repo(p_version integer) RETURNS void
LANGUAGE plpgsql
AS $$
declare
@ -43,22 +41,23 @@ $$;
SET default_tablespace = '';
SET default_table_access_method = heap;
CREATE TABLE ac_dossier (
CREATE TABLE public.ac_dossier (
dos_id integer DEFAULT nextval(('dossier_id'::text)::regclass) NOT NULL,
dos_name text NOT NULL,
dos_description text,
dos_email integer DEFAULT (-1)
dos_email integer DEFAULT '-1'::integer
);
COMMENT ON COLUMN ac_dossier.dos_email IS 'Max emails per day : 0 none , -1 unlimited or max value';
COMMENT ON COLUMN public.ac_dossier.dos_email IS 'Max emails per day : 0 none , -1 unlimited or max value';
CREATE TABLE ac_users (
CREATE TABLE public.ac_users (
use_id integer DEFAULT nextval(('users_id'::text)::regclass) NOT NULL,
use_first_name text,
use_name text,
@ -72,11 +71,11 @@ CREATE TABLE ac_users (
COMMENT ON COLUMN ac_users.use_email IS 'Email of the user';
COMMENT ON COLUMN public.ac_users.use_email IS 'Email of the user';
CREATE TABLE audit_connect (
CREATE TABLE public.audit_connect (
ac_id integer NOT NULL,
ac_user text,
ac_date timestamp without time zone DEFAULT now(),
@ -84,12 +83,12 @@ CREATE TABLE audit_connect (
ac_state text,
ac_module text,
ac_url text,
CONSTRAINT valid_state CHECK ((((ac_state = 'FAIL'::text) OR (ac_state = 'SUCCESS'::text)) OR (ac_state = 'AUDIT'::text)))
CONSTRAINT valid_state CHECK (((ac_state = 'FAIL'::text) OR (ac_state = 'SUCCESS'::text) OR (ac_state = 'AUDIT'::text)))
);
CREATE SEQUENCE audit_connect_ac_id_seq
CREATE SEQUENCE public.audit_connect_ac_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
@ -98,11 +97,11 @@ CREATE SEQUENCE audit_connect_ac_id_seq
ALTER SEQUENCE audit_connect_ac_id_seq OWNED BY audit_connect.ac_id;
ALTER SEQUENCE public.audit_connect_ac_id_seq OWNED BY public.audit_connect.ac_id;
CREATE SEQUENCE dossier_id
CREATE SEQUENCE public.dossier_id
START WITH 1
INCREMENT BY 1
NO MINVALUE
@ -111,7 +110,7 @@ CREATE SEQUENCE dossier_id
CREATE TABLE dossier_sent_email (
CREATE TABLE public.dossier_sent_email (
id integer NOT NULL,
de_date character varying(8) NOT NULL,
de_sent_email integer NOT NULL,
@ -120,27 +119,27 @@ CREATE TABLE dossier_sent_email (
COMMENT ON TABLE dossier_sent_email IS 'Count the sent email by folder';
COMMENT ON TABLE public.dossier_sent_email IS 'Count the sent email by folder';
COMMENT ON COLUMN dossier_sent_email.id IS 'primary key';
COMMENT ON COLUMN public.dossier_sent_email.id IS 'primary key';
COMMENT ON COLUMN dossier_sent_email.de_date IS 'Date YYYYMMDD';
COMMENT ON COLUMN public.dossier_sent_email.de_date IS 'Date YYYYMMDD';
COMMENT ON COLUMN dossier_sent_email.de_sent_email IS 'Number of sent emails';
COMMENT ON COLUMN public.dossier_sent_email.de_sent_email IS 'Number of sent emails';
COMMENT ON COLUMN dossier_sent_email.dos_id IS 'Link to ac_dossier';
COMMENT ON COLUMN public.dossier_sent_email.dos_id IS 'Link to ac_dossier';
CREATE SEQUENCE dossier_sent_email_id_seq
CREATE SEQUENCE public.dossier_sent_email_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
@ -149,11 +148,11 @@ CREATE SEQUENCE dossier_sent_email_id_seq
ALTER SEQUENCE dossier_sent_email_id_seq OWNED BY dossier_sent_email.id;
ALTER SEQUENCE public.dossier_sent_email_id_seq OWNED BY public.dossier_sent_email.id;
CREATE TABLE jnt_use_dos (
CREATE TABLE public.jnt_use_dos (
jnt_id integer DEFAULT nextval(('seq_jnt_use_dos'::text)::regclass) NOT NULL,
use_id integer NOT NULL,
dos_id integer NOT NULL
@ -161,7 +160,7 @@ CREATE TABLE jnt_use_dos (
CREATE TABLE modeledef (
CREATE TABLE public.modeledef (
mod_id integer DEFAULT nextval(('s_modid'::text)::regclass) NOT NULL,
mod_name text NOT NULL,
mod_desc text
@ -169,7 +168,7 @@ CREATE TABLE modeledef (
CREATE TABLE progress (
CREATE TABLE public.progress (
p_id character varying(16) NOT NULL,
p_value numeric(5,2) NOT NULL,
p_created timestamp without time zone DEFAULT now()
@ -177,7 +176,7 @@ CREATE TABLE progress (
CREATE TABLE recover_pass (
CREATE TABLE public.recover_pass (
use_id bigint NOT NULL,
request text NOT NULL,
password text NOT NULL,
@ -189,7 +188,7 @@ CREATE TABLE recover_pass (
CREATE SEQUENCE s_modid
CREATE SEQUENCE public.s_modid
START WITH 1
INCREMENT BY 1
NO MINVALUE
@ -198,7 +197,7 @@ CREATE SEQUENCE s_modid
CREATE SEQUENCE seq_jnt_use_dos
CREATE SEQUENCE public.seq_jnt_use_dos
START WITH 1
INCREMENT BY 1
NO MINVALUE
@ -207,7 +206,7 @@ CREATE SEQUENCE seq_jnt_use_dos
CREATE SEQUENCE seq_priv_user
CREATE SEQUENCE public.seq_priv_user
START WITH 1
INCREMENT BY 1
NO MINVALUE
@ -216,7 +215,7 @@ CREATE SEQUENCE seq_priv_user
CREATE TABLE theme (
CREATE TABLE public.theme (
the_name text NOT NULL,
the_filestyle text,
the_filebutton text
@ -224,7 +223,7 @@ CREATE TABLE theme (
CREATE TABLE user_global_pref (
CREATE TABLE public.user_global_pref (
user_id text NOT NULL,
parameter_type text NOT NULL,
parameter_value text
@ -232,23 +231,23 @@ CREATE TABLE user_global_pref (
COMMENT ON TABLE user_global_pref IS 'The user''s global parameter ';
COMMENT ON TABLE public.user_global_pref IS 'The user''s global parameter ';
COMMENT ON COLUMN user_global_pref.user_id IS 'user''s login ';
COMMENT ON COLUMN public.user_global_pref.user_id IS 'user''s login ';
COMMENT ON COLUMN user_global_pref.parameter_type IS 'the type of parameter ';
COMMENT ON COLUMN public.user_global_pref.parameter_type IS 'the type of parameter ';
COMMENT ON COLUMN user_global_pref.parameter_value IS 'the value of parameter ';
COMMENT ON COLUMN public.user_global_pref.parameter_value IS 'the value of parameter ';
CREATE SEQUENCE users_id
CREATE SEQUENCE public.users_id
START WITH 1
INCREMENT BY 1
NO MINVALUE
@ -257,94 +256,132 @@ CREATE SEQUENCE users_id
CREATE TABLE version (
CREATE TABLE public.version (
val integer NOT NULL
);
ALTER TABLE ONLY public.audit_connect ALTER COLUMN ac_id SET DEFAULT nextval('public.audit_connect_ac_id_seq'::regclass);
ALTER TABLE ONLY public.dossier_sent_email ALTER COLUMN id SET DEFAULT nextval('public.dossier_sent_email_id_seq'::regclass);
ALTER TABLE ONLY public.ac_dossier
ADD CONSTRAINT ac_dossier_dos_name_key UNIQUE (dos_name);
ALTER TABLE ONLY public.ac_dossier
ADD CONSTRAINT ac_dossier_pkey PRIMARY KEY (dos_id);
ALTER TABLE ONLY public.ac_users
ADD CONSTRAINT ac_users_pkey PRIMARY KEY (use_id);
ALTER TABLE ONLY public.ac_users
ADD CONSTRAINT ac_users_use_login_key UNIQUE (use_login);
ALTER TABLE ONLY public.audit_connect
ADD CONSTRAINT audit_connect_pkey PRIMARY KEY (ac_id);
ALTER TABLE ONLY public.dossier_sent_email
ADD CONSTRAINT de_date_dos_id_ux UNIQUE (de_date, dos_id);
ALTER TABLE ONLY public.dossier_sent_email
ADD CONSTRAINT dossier_sent_email_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.jnt_use_dos
ADD CONSTRAINT jnt_use_dos_pkey PRIMARY KEY (jnt_id);
ALTER TABLE ONLY public.modeledef
ADD CONSTRAINT modeledef_pkey PRIMARY KEY (mod_id);
ALTER TABLE ONLY public.user_global_pref
ADD CONSTRAINT pk_user_global_pref PRIMARY KEY (user_id, parameter_type);
ALTER TABLE ONLY public.progress
ADD CONSTRAINT progress_pkey PRIMARY KEY (p_id);
ALTER TABLE ONLY public.recover_pass
ADD CONSTRAINT recover_pass_pkey PRIMARY KEY (request);
ALTER TABLE ONLY public.jnt_use_dos
ADD CONSTRAINT use_id_dos_id_uniq UNIQUE (use_id, dos_id);
ALTER TABLE ONLY public.version
ADD CONSTRAINT version_pkey PRIMARY KEY (val);
CREATE INDEX audit_connect_ac_user ON audit_connect USING btree (ac_user);
CREATE INDEX audit_connect_ac_user ON public.audit_connect USING btree (ac_user);
CREATE INDEX fk_jnt_dos_id ON jnt_use_dos USING btree (dos_id);
CREATE INDEX fk_jnt_dos_id ON public.jnt_use_dos USING btree (dos_id);
CREATE INDEX fk_jnt_use_dos ON jnt_use_dos USING btree (use_id);
CREATE INDEX fki_ac_users_recover_pass_fk ON recover_pass USING btree (use_id);
CREATE INDEX fk_jnt_use_dos ON public.jnt_use_dos USING btree (use_id);
CREATE INDEX fki_ac_users_recover_pass_fk ON public.recover_pass USING btree (use_id);
CREATE TRIGGER limit_user_trg BEFORE INSERT OR UPDATE ON public.audit_connect FOR EACH ROW EXECUTE FUNCTION public.limit_user();
ALTER TABLE ONLY public.recover_pass
ADD CONSTRAINT ac_users_recover_pass_fk FOREIGN KEY (use_id) REFERENCES public.ac_users(use_id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.dossier_sent_email
ADD CONSTRAINT de_ac_dossier_fk FOREIGN KEY (dos_id) REFERENCES public.ac_dossier(dos_id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.user_global_pref
ADD CONSTRAINT fk_user_id FOREIGN KEY (user_id) REFERENCES public.ac_users(use_login) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.jnt_use_dos
ADD CONSTRAINT jnt_use_dos_dos_id_fkey FOREIGN KEY (dos_id) REFERENCES public.ac_dossier(dos_id) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE ONLY public.jnt_use_dos
ADD CONSTRAINT jnt_use_dos_use_id_fkey FOREIGN KEY (use_id) REFERENCES public.ac_users(use_id);

View file

@ -1,42 +1,42 @@
CREATE SEQUENCE audit_connect_ac_id_seq
CREATE SEQUENCE public.audit_connect_ac_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE audit_connect_ac_id_seq OWNED BY audit_connect.ac_id;
CREATE SEQUENCE dossier_id
ALTER SEQUENCE public.audit_connect_ac_id_seq OWNED BY public.audit_connect.ac_id;
CREATE SEQUENCE public.dossier_id
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE SEQUENCE dossier_sent_email_id_seq
CREATE SEQUENCE public.dossier_sent_email_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE dossier_sent_email_id_seq OWNED BY dossier_sent_email.id;
CREATE SEQUENCE s_modid
ALTER SEQUENCE public.dossier_sent_email_id_seq OWNED BY public.dossier_sent_email.id;
CREATE SEQUENCE public.s_modid
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE SEQUENCE seq_jnt_use_dos
CREATE SEQUENCE public.seq_jnt_use_dos
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE SEQUENCE seq_priv_user
CREATE SEQUENCE public.seq_priv_user
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE SEQUENCE users_id
CREATE SEQUENCE public.users_id
START WITH 1
INCREMENT BY 1
NO MINVALUE

View file

@ -1,10 +1,10 @@
CREATE TABLE ac_dossier (
CREATE TABLE public.ac_dossier (
dos_id integer DEFAULT nextval(('dossier_id'::text)::regclass) NOT NULL,
dos_name text NOT NULL,
dos_description text,
dos_email integer DEFAULT (-1)
dos_email integer DEFAULT '-1'::integer
);
CREATE TABLE ac_users (
CREATE TABLE public.ac_users (
use_id integer DEFAULT nextval(('users_id'::text)::regclass) NOT NULL,
use_first_name text,
use_name text,
@ -15,7 +15,7 @@ CREATE TABLE ac_users (
use_email text,
CONSTRAINT ac_users_use_active_check CHECK (((use_active = 0) OR (use_active = 1)))
);
CREATE TABLE audit_connect (
CREATE TABLE public.audit_connect (
ac_id integer NOT NULL,
ac_user text,
ac_date timestamp without time zone DEFAULT now(),
@ -23,30 +23,30 @@ CREATE TABLE audit_connect (
ac_state text,
ac_module text,
ac_url text,
CONSTRAINT valid_state CHECK ((((ac_state = 'FAIL'::text) OR (ac_state = 'SUCCESS'::text)) OR (ac_state = 'AUDIT'::text)))
CONSTRAINT valid_state CHECK (((ac_state = 'FAIL'::text) OR (ac_state = 'SUCCESS'::text) OR (ac_state = 'AUDIT'::text)))
);
CREATE TABLE dossier_sent_email (
CREATE TABLE public.dossier_sent_email (
id integer NOT NULL,
de_date character varying(8) NOT NULL,
de_sent_email integer NOT NULL,
dos_id integer NOT NULL
);
CREATE TABLE jnt_use_dos (
CREATE TABLE public.jnt_use_dos (
jnt_id integer DEFAULT nextval(('seq_jnt_use_dos'::text)::regclass) NOT NULL,
use_id integer NOT NULL,
dos_id integer NOT NULL
);
CREATE TABLE modeledef (
CREATE TABLE public.modeledef (
mod_id integer DEFAULT nextval(('s_modid'::text)::regclass) NOT NULL,
mod_name text NOT NULL,
mod_desc text
);
CREATE TABLE progress (
CREATE TABLE public.progress (
p_id character varying(16) NOT NULL,
p_value numeric(5,2) NOT NULL,
p_created timestamp without time zone DEFAULT now()
);
CREATE TABLE recover_pass (
CREATE TABLE public.recover_pass (
use_id bigint NOT NULL,
request text NOT NULL,
password text NOT NULL,
@ -55,16 +55,16 @@ CREATE TABLE recover_pass (
recover_on timestamp with time zone,
recover_by text
);
CREATE TABLE theme (
CREATE TABLE public.theme (
the_name text NOT NULL,
the_filestyle text,
the_filebutton text
);
CREATE TABLE user_global_pref (
CREATE TABLE public.user_global_pref (
user_id text NOT NULL,
parameter_type text NOT NULL,
parameter_value text
);
CREATE TABLE version (
CREATE TABLE public.version (
val integer NOT NULL
);

View file

@ -1,203 +1,308 @@
COMMENT ON FUNCTION correct_sequence(p_sequence text, p_col text, p_table text) IS ' Often the primary key is a sequence number and sometimes the value of the sequence is not synchronized with the primary key ( p_sequence : sequence name, p_col : col of the pk,p_table : concerned table';
COMMENT ON FUNCTION format_account(p_account public.account_type) IS 'format the accounting :
COMMENT ON FUNCTION comptaproc.correct_sequence(p_sequence text, p_col text, p_table text) IS ' Often the primary key is a sequence number and sometimes the value of the sequence is not synchronized with the primary key ( p_sequence : sequence name, p_col : col of the pk,p_table : concerned table';
COMMENT ON FUNCTION comptaproc.format_account(p_account public.account_type) IS 'format the accounting :
- upper case
- remove space and special char.
';
COMMENT ON FUNCTION html_quote(p_string text) IS 'remove harmfull HTML char';
COMMENT ON TABLE action IS 'The different privileges';
COMMENT ON COLUMN action.ac_code IS 'this code will be used in the code with the function User::check_action ';
COMMENT ON TABLE action_detail IS 'Detail of action_gestion, see class Action_Detail';
COMMENT ON COLUMN action_detail.f_id IS 'the concerned card';
COMMENT ON COLUMN action_detail.ad_text IS ' Description ';
COMMENT ON COLUMN action_detail.ad_pu IS ' price per unit ';
COMMENT ON COLUMN action_detail.ad_quant IS 'quantity ';
COMMENT ON COLUMN action_detail.ad_tva_id IS ' tva_id ';
COMMENT ON COLUMN action_detail.ad_tva_amount IS ' tva_amount ';
COMMENT ON COLUMN action_detail.ad_total_amount IS ' total amount';
COMMENT ON TABLE action_gestion IS 'Contains the details for the follow-up of customer, supplier, administration';
COMMENT ON COLUMN action_gestion.ag_type IS ' type of action: see document_type ';
COMMENT ON COLUMN action_gestion.f_id_dest IS ' third party ';
COMMENT ON COLUMN action_gestion.ag_title IS ' title ';
COMMENT ON COLUMN action_gestion.ag_timestamp IS ' ';
COMMENT ON COLUMN action_gestion.ag_ref IS 'its reference ';
COMMENT ON COLUMN action_gestion.ag_priority IS 'Low, medium, important ';
COMMENT ON COLUMN action_gestion.ag_dest IS ' is the profile which has to take care of this action ';
COMMENT ON COLUMN action_gestion.ag_owner IS ' is the owner of this action ';
COMMENT ON COLUMN action_gestion.ag_contact IS ' contact of the third part ';
COMMENT ON COLUMN action_gestion.ag_state IS 'state of the action same as document_state ';
COMMENT ON COLUMN action_gestion_comment.agc_id IS 'PK';
COMMENT ON COLUMN action_gestion_comment.ag_id IS 'FK to action_gestion';
COMMENT ON COLUMN action_gestion_comment.agc_comment IS 'comment';
COMMENT ON COLUMN action_gestion_comment.tech_user IS 'user_login';
COMMENT ON COLUMN action_gestion_operation.ago_id IS 'pk';
COMMENT ON COLUMN action_gestion_operation.ag_id IS 'fk to action_gestion';
COMMENT ON COLUMN action_gestion_operation.jr_id IS 'fk to jrn';
COMMENT ON COLUMN action_gestion_related.aga_id IS 'pk';
COMMENT ON COLUMN action_gestion_related.aga_least IS 'fk to action_gestion, smallest ag_id';
COMMENT ON COLUMN action_gestion_related.aga_greatest IS 'fk to action_gestion greatest ag_id';
COMMENT ON COLUMN action_gestion_related.aga_type IS 'Type de liens';
COMMENT ON TABLE action_person IS 'Person involved in the action';
COMMENT ON COLUMN action_person.ap_id IS 'pk';
COMMENT ON COLUMN action_person.ag_id IS 'fk to fiche';
COMMENT ON TABLE attr_def IS 'The available attributs for the cards';
COMMENT ON TABLE attr_min IS 'The value of attributs for the cards';
COMMENT ON TABLE bilan IS 'contains the template and the data for generating different documents ';
COMMENT ON COLUMN bilan.b_id IS 'primary key';
COMMENT ON COLUMN bilan.b_name IS 'Name of the document';
COMMENT ON COLUMN bilan.b_file_template IS 'path of the template (document/...)';
COMMENT ON COLUMN bilan.b_file_form IS 'path of the file with forms';
COMMENT ON COLUMN bilan.b_type IS 'type = ODS, RTF...';
COMMENT ON TABLE bookmark IS 'Bookmark of the connected user';
COMMENT ON TABLE centralized IS 'The centralized journal';
COMMENT ON TABLE document IS 'This table contains all the documents : summary and lob files';
COMMENT ON TABLE document_modele IS ' contains all the template for the documents';
COMMENT ON SEQUENCE document_seq IS 'Sequence for the sequence bound to the document modele';
COMMENT ON TABLE document_state IS 'State of the document';
COMMENT ON TABLE document_type IS 'Type of document : meeting, invoice,...';
COMMENT ON COLUMN document_type.dt_prefix IS 'Prefix for ag_ref';
COMMENT ON TABLE extension IS 'Content the needed information for the extension';
COMMENT ON COLUMN extension.ex_id IS 'Primary key';
COMMENT ON COLUMN extension.ex_name IS 'code of the extension ';
COMMENT ON COLUMN extension.ex_code IS 'code of the extension ';
COMMENT ON COLUMN extension.ex_desc IS 'Description of the extension ';
COMMENT ON COLUMN extension.ex_file IS 'path to the extension to include';
COMMENT ON COLUMN extension.ex_enable IS 'Y : enabled N : disabled ';
COMMENT ON TABLE fiche IS 'Cards';
COMMENT ON TABLE fiche_def IS 'Cards definition';
COMMENT ON TABLE fiche_def_ref IS 'Family Cards definition';
COMMENT ON TABLE fiche_detail IS 'join between the card and the attribut definition';
COMMENT ON TABLE forecast IS 'contains the name of the forecast';
COMMENT ON COLUMN forecast_cat.fc_id IS 'primary key';
COMMENT ON COLUMN forecast_cat.fc_desc IS 'text of the category';
COMMENT ON COLUMN forecast_cat.f_id IS 'Foreign key, it is the parent from the table forecast';
COMMENT ON COLUMN forecast_cat.fc_order IS 'Order of the category, used when displaid';
COMMENT ON COLUMN forecast_item.fi_id IS 'Primary key';
COMMENT ON COLUMN forecast_item.fi_text IS 'Label of the i tem';
COMMENT ON COLUMN forecast_item.fi_account IS 'Accountancy entry';
COMMENT ON COLUMN forecast_item.fi_card IS 'Card (fiche.f_id)';
COMMENT ON COLUMN forecast_item.fi_order IS 'Order of showing (not used)';
COMMENT ON COLUMN forecast_item.fi_amount IS 'Amount';
COMMENT ON COLUMN forecast_item.fi_debit IS 'possible values are D or C';
COMMENT ON COLUMN forecast_item.fi_pid IS '0 for every month, or the value parm_periode.p_id ';
COMMENT ON TABLE form IS 'Forms content';
COMMENT ON TABLE info_def IS 'Contains the types of additionnal info we can add to a operation';
COMMENT ON TABLE jnt_fic_attr IS 'join between the family card and the attribut definition';
COMMENT ON TABLE jrn IS 'Journal: content one line for a group of accountancy writing';
COMMENT ON COLUMN jrn.jr_optype IS 'Type of operation , NOR = NORMAL , OPE opening , EXT extourne, CLO closing';
COMMENT ON TABLE jrn_def IS 'Definition of a journal, his properties';
COMMENT ON COLUMN jrn_def.jrn_enable IS 'Set to 1 if the ledger is enable ';
COMMENT ON TABLE jrn_note IS 'Note about operation';
COMMENT ON TABLE jrn_rapt IS 'Rapprochement between operation';
COMMENT ON TABLE jrn_type IS 'Type of journal (Sell, Buy, Financial...)';
COMMENT ON TABLE jrnx IS 'Journal: content one line for each accountancy writing';
COMMENT ON TABLE key_distribution IS 'Distribution key for analytic';
COMMENT ON COLUMN key_distribution.kd_id IS 'PK';
COMMENT ON COLUMN key_distribution.kd_name IS 'Name of the key';
COMMENT ON COLUMN key_distribution.kd_description IS 'Description of the key';
COMMENT ON TABLE key_distribution_activity IS 'Contains the analytic account';
COMMENT ON COLUMN key_distribution_activity.ka_id IS 'pk';
COMMENT ON COLUMN key_distribution_activity.ke_id IS 'fk to key_distribution_detail';
COMMENT ON COLUMN key_distribution_activity.po_id IS 'fk to poste_analytique';
COMMENT ON COLUMN key_distribution_activity.pa_id IS 'fk to plan_analytique';
COMMENT ON TABLE key_distribution_detail IS 'Row of activity and percent';
COMMENT ON COLUMN key_distribution_detail.ke_id IS 'pk';
COMMENT ON COLUMN key_distribution_detail.kd_id IS 'fk to key_distribution';
COMMENT ON COLUMN key_distribution_detail.ke_row IS 'group order';
COMMENT ON TABLE key_distribution_ledger IS 'Legder where the distribution key can be used';
COMMENT ON COLUMN key_distribution_ledger.kl_id IS 'pk';
COMMENT ON COLUMN key_distribution_ledger.kd_id IS 'fk to key_distribution';
COMMENT ON COLUMN key_distribution_ledger.jrn_def_id IS 'fk to jrnd_def, ledger where this key is available';
COMMENT ON COLUMN menu_ref.me_code IS 'Menu Code ';
COMMENT ON COLUMN menu_ref.me_menu IS 'Label to display';
COMMENT ON COLUMN menu_ref.me_file IS 'if not empty file to include';
COMMENT ON COLUMN menu_ref.me_url IS 'url ';
COMMENT ON COLUMN menu_ref.me_type IS 'ME for menu
COMMENT ON FUNCTION comptaproc.format_quickcode(p_qcode text) IS 'Put in upper case and remove invalid char';
COMMENT ON FUNCTION comptaproc.four_upper_letter() IS 'Cut to the 4 first letter in uppercase';
COMMENT ON FUNCTION comptaproc.html_quote(p_string text) IS 'remove harmfull HTML char';
COMMENT ON FUNCTION comptaproc.update_quick_code(njft_id integer, tav_text text) IS 'update the qcode + related columns in other cards';
COMMENT ON TABLE public.acc_other_tax IS 'Additional tax for Sale or Purchase ';
COMMENT ON COLUMN public.acc_other_tax.ac_label IS 'Label of the tax';
COMMENT ON COLUMN public.acc_other_tax.ac_rate IS 'rate of the tax in percent';
COMMENT ON COLUMN public.acc_other_tax.ajrn_def_id IS 'array of to FK jrn_def (jrn_def_id)';
COMMENT ON COLUMN public.acc_other_tax.ac_accounting IS 'FK tmp_pcmn (pcm_val)';
COMMENT ON TABLE public.action IS 'The different privileges';
COMMENT ON COLUMN public.action.ac_code IS 'this code will be used in the code with the function User::check_action ';
COMMENT ON TABLE public.action_detail IS 'Detail of action_gestion, see class Action_Detail';
COMMENT ON COLUMN public.action_detail.f_id IS 'the concerned card';
COMMENT ON COLUMN public.action_detail.ad_text IS ' Description ';
COMMENT ON COLUMN public.action_detail.ad_pu IS ' price per unit ';
COMMENT ON COLUMN public.action_detail.ad_quant IS 'quantity ';
COMMENT ON COLUMN public.action_detail.ad_tva_id IS ' tva_id ';
COMMENT ON COLUMN public.action_detail.ad_tva_amount IS ' tva_amount ';
COMMENT ON COLUMN public.action_detail.ad_total_amount IS ' total amount';
COMMENT ON TABLE public.action_gestion IS 'Contains the details for the follow-up of customer, supplier, administration';
COMMENT ON COLUMN public.action_gestion.ag_type IS ' type of action: see document_type ';
COMMENT ON COLUMN public.action_gestion.f_id_dest IS 'third party';
COMMENT ON COLUMN public.action_gestion.ag_title IS 'title';
COMMENT ON COLUMN public.action_gestion.ag_ref IS 'its reference';
COMMENT ON COLUMN public.action_gestion.ag_priority IS 'Low, medium, important';
COMMENT ON COLUMN public.action_gestion.ag_dest IS 'is the profile which has to take care of this action';
COMMENT ON COLUMN public.action_gestion.ag_owner IS 'is the owner of this action';
COMMENT ON COLUMN public.action_gestion.ag_contact IS 'contact of the third part';
COMMENT ON COLUMN public.action_gestion.ag_state IS 'state of the action same as document_state';
COMMENT ON TABLE public.action_gestion_comment IS 'comment on action management';
COMMENT ON COLUMN public.action_gestion_comment.agc_id IS 'PK';
COMMENT ON COLUMN public.action_gestion_comment.ag_id IS 'FK to action_gestion';
COMMENT ON COLUMN public.action_gestion_comment.agc_comment IS 'comment';
COMMENT ON COLUMN public.action_gestion_comment.tech_user IS 'user_login';
COMMENT ON TABLE public.action_gestion_operation IS 'Operation linked on action';
COMMENT ON COLUMN public.action_gestion_operation.ago_id IS 'pk';
COMMENT ON COLUMN public.action_gestion_operation.ag_id IS 'fk to action_gestion';
COMMENT ON COLUMN public.action_gestion_operation.jr_id IS 'fk to jrn';
COMMENT ON TABLE public.action_gestion_related IS 'link between action';
COMMENT ON COLUMN public.action_gestion_related.aga_id IS 'pk';
COMMENT ON COLUMN public.action_gestion_related.aga_least IS 'fk to action_gestion, smallest ag_id';
COMMENT ON COLUMN public.action_gestion_related.aga_greatest IS 'fk to action_gestion greatest ag_id';
COMMENT ON COLUMN public.action_gestion_related.aga_type IS 'Type de liens';
COMMENT ON TABLE public.action_person IS 'Person involved in the action';
COMMENT ON COLUMN public.action_person.ap_id IS 'pk';
COMMENT ON COLUMN public.action_person.ag_id IS 'fk to fiche';
COMMENT ON TABLE public.action_person_option IS 'option for each contact';
COMMENT ON COLUMN public.action_person_option.ap_value IS 'Value of the option';
COMMENT ON COLUMN public.action_person_option.contact_option_ref_id IS 'FK to contact_option';
COMMENT ON COLUMN public.action_person_option.action_person_id IS 'FK to action_person';
COMMENT ON TABLE public.action_tags IS 'Tags link to action';
COMMENT ON TABLE public.attr_def IS 'The available attributs for the cards';
COMMENT ON COLUMN public.attr_def.ad_search_followup IS '1 : search available from followup , 0 : search not available in followup';
COMMENT ON COLUMN public.attr_def.ad_default_order IS 'Default order of the attribute';
COMMENT ON TABLE public.attr_min IS 'The value of attributs for the cards';
COMMENT ON TABLE public.bilan IS 'contains the template and the data for generating different documents ';
COMMENT ON COLUMN public.bilan.b_id IS 'primary key';
COMMENT ON COLUMN public.bilan.b_name IS 'Name of the document';
COMMENT ON COLUMN public.bilan.b_file_template IS 'path of the template (document/...)';
COMMENT ON COLUMN public.bilan.b_file_form IS 'path of the file with forms';
COMMENT ON COLUMN public.bilan.b_type IS 'type = ODS, RTF...';
COMMENT ON TABLE public.bookmark IS 'Bookmark of the connected user';
COMMENT ON TABLE public.centralized IS 'The centralized journal';
COMMENT ON TABLE public.contact_option_ref IS 'Option for the contact';
COMMENT ON COLUMN public.contact_option_ref.cor_label IS 'Label de l''option';
COMMENT ON COLUMN public.contact_option_ref.cor_type IS '0 text , 1 select ,2 nombre , 3 date';
COMMENT ON COLUMN public.contact_option_ref.cor_value_select IS 'Select values';
COMMENT ON TABLE public.currency IS 'currency';
COMMENT ON COLUMN public.currency.cr_code_iso IS 'Code ISO';
COMMENT ON COLUMN public.currency.cr_name IS 'Name of the currency';
COMMENT ON TABLE public.currency_history IS 'currency values history';
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 TABLE public.del_action IS 'deleted actions';
COMMENT ON TABLE public.del_jrn IS 'deleted operation';
COMMENT ON TABLE public.del_jrnx IS 'delete operation details';
COMMENT ON TABLE public.document IS 'This table contains all the documents : summary and lob files';
COMMENT ON TABLE public.document_component IS 'Give the component of NOALYSS that is using is';
COMMENT ON COLUMN public.document_component.dc_id IS 'PK';
COMMENT ON COLUMN public.document_component.dc_code IS 'Code used in document_modele';
COMMENT ON COLUMN public.document_component.dc_comment IS 'Code used in document_modele';
COMMENT ON TABLE public.document_modele IS ' contains all the template for the documents';
COMMENT ON TABLE public.document_option IS 'Reference of option addable to document_type';
COMMENT ON COLUMN public.document_option.do_code IS 'Code of the option to add';
COMMENT ON COLUMN public.document_option.document_type_id IS 'FK to document_type';
COMMENT ON COLUMN public.document_option.do_enable IS '1 the option is activated, 0 is inativated';
COMMENT ON COLUMN public.document_option.do_option IS 'Option for the detail';
COMMENT ON SEQUENCE public.document_seq IS 'Sequence for the sequence bound to the document modele';
COMMENT ON TABLE public.document_state IS 'State of the document';
COMMENT ON TABLE public.document_type IS 'Type of document : meeting, invoice,...';
COMMENT ON COLUMN public.document_type.dt_prefix IS 'Prefix for ag_ref';
COMMENT ON TABLE public.extension IS 'Content the needed information for the extension';
COMMENT ON COLUMN public.extension.ex_id IS 'Primary key';
COMMENT ON COLUMN public.extension.ex_name IS 'code of the extension ';
COMMENT ON COLUMN public.extension.ex_code IS 'code of the extension ';
COMMENT ON COLUMN public.extension.ex_desc IS 'Description of the extension ';
COMMENT ON COLUMN public.extension.ex_file IS 'path to the extension to include';
COMMENT ON COLUMN public.extension.ex_enable IS 'Y : enabled N : disabled ';
COMMENT ON TABLE public.fiche IS 'Cards';
COMMENT ON COLUMN public.fiche.f_enable IS 'value = 1 if card enable , otherwise 0 ';
COMMENT ON TABLE public.fiche_def IS 'Cards definition';
COMMENT ON TABLE public.fiche_def_ref IS 'Family Cards definition';
COMMENT ON TABLE public.fiche_detail IS 'join between the card and the attribut definition';
COMMENT ON TABLE public.forecast IS 'contains the name of the forecast';
COMMENT ON TABLE public.forecast_category IS 'Category of forecast';
COMMENT ON COLUMN public.forecast_category.fc_id IS 'primary key';
COMMENT ON COLUMN public.forecast_category.fc_desc IS 'text of the category';
COMMENT ON COLUMN public.forecast_category.f_id IS 'Foreign key, it is the parent from the table forecast';
COMMENT ON COLUMN public.forecast_category.fc_order IS 'Order of the category, used when displaid';
COMMENT ON TABLE public.forecast_item IS 'items of forecast';
COMMENT ON COLUMN public.forecast_item.fi_id IS 'Primary key';
COMMENT ON COLUMN public.forecast_item.fi_text IS 'Label of the i tem';
COMMENT ON COLUMN public.forecast_item.fi_account IS 'Accountancy entry';
COMMENT ON COLUMN public.forecast_item.fi_order IS 'Order of showing (not used)';
COMMENT ON COLUMN public.forecast_item.fi_amount IS 'Amount';
COMMENT ON COLUMN public.forecast_item.fi_pid IS '0 for every month, or the value parm_periode.p_id ';
COMMENT ON TABLE public.form_definition IS 'Simple Report name';
COMMENT ON TABLE public.form_detail IS 'Simple report details with formula';
COMMENT ON TABLE public.groupe_analytique IS 'Group of analytic accountancy';
COMMENT ON TABLE public.info_def IS 'Contains the types of additionnal info we can add to a operation';
COMMENT ON TABLE public.jnt_document_option_contact IS 'Many to many table between document and contact option';
COMMENT ON TABLE public.jnt_fic_attr IS 'join between the family card and the attribut definition';
COMMENT ON TABLE public.jnt_letter IS 'm2m tables for lettering';
COMMENT ON TABLE public.jnt_tag_group_tag IS 'Many to Many table betwwen tag and tag group';
COMMENT ON TABLE public.jrn IS 'Journal: content one line for a group of accountancy writing';
COMMENT ON COLUMN public.jrn.jr_optype IS 'Type of operation , NOR = NORMAL , OPE opening , EXT extourne, CLO closing';
COMMENT ON TABLE public.jrn_def IS 'Definition of a journal, his properties';
COMMENT ON COLUMN public.jrn_def.jrn_enable IS 'Set to 1 if the ledger is enable ';
COMMENT ON COLUMN public.jrn_def.currency_id IS 'Default currency for financial ledger';
COMMENT ON COLUMN public.jrn_def.jrn_def_negative_amount IS '1 echo a warning if you are not using an negative amount, default 0 for no warning';
COMMENT ON COLUMN public.jrn_def.jrn_def_negative_warning IS 'Yell a warning if the amount if not negative , in the case of jrn_def_negative_amount is Y';
COMMENT ON COLUMN public.jrn_def.jrn_def_quantity IS 'Use the quantity column, 0->disable,1->enable,used only with Sale and Purchase otherwise ignored';
COMMENT ON TABLE public.jrn_info IS 'extra info for operation';
COMMENT ON TABLE public.jrn_note IS 'Note about operation';
COMMENT ON TABLE public.jrn_periode IS 'Period by ledger';
COMMENT ON TABLE public.jrn_rapt IS 'Rapprochement between operation';
COMMENT ON COLUMN public.jrn_tax.j_id IS 'fk jrnx';
COMMENT ON COLUMN public.jrn_tax.pcm_val IS 'FK tmp_pcmn';
COMMENT ON COLUMN public.jrn_tax.ac_id IS 'FK to acc_other_tax';
COMMENT ON TABLE public.jrn_type IS 'Type of journal (Sell, Buy, Financial...)';
COMMENT ON TABLE public.jrnx IS 'Journal: content one line for each accountancy writing';
COMMENT ON TABLE public.key_distribution IS 'Distribution key for analytic';
COMMENT ON COLUMN public.key_distribution.kd_id IS 'PK';
COMMENT ON COLUMN public.key_distribution.kd_name IS 'Name of the key';
COMMENT ON COLUMN public.key_distribution.kd_description IS 'Description of the key';
COMMENT ON TABLE public.key_distribution_activity IS 'Contains the analytic account';
COMMENT ON COLUMN public.key_distribution_activity.ka_id IS 'pk';
COMMENT ON COLUMN public.key_distribution_activity.ke_id IS 'fk to key_distribution_detail';
COMMENT ON COLUMN public.key_distribution_activity.po_id IS 'fk to poste_analytique';
COMMENT ON COLUMN public.key_distribution_activity.pa_id IS 'fk to plan_analytique';
COMMENT ON TABLE public.key_distribution_detail IS 'Row of activity and percent';
COMMENT ON COLUMN public.key_distribution_detail.ke_id IS 'pk';
COMMENT ON COLUMN public.key_distribution_detail.kd_id IS 'fk to key_distribution';
COMMENT ON COLUMN public.key_distribution_detail.ke_row IS 'group order';
COMMENT ON TABLE public.key_distribution_ledger IS 'Legder where the distribution key can be used';
COMMENT ON COLUMN public.key_distribution_ledger.kl_id IS 'pk';
COMMENT ON COLUMN public.key_distribution_ledger.kd_id IS 'fk to key_distribution';
COMMENT ON COLUMN public.key_distribution_ledger.jrn_def_id IS 'fk to jrnd_def, ledger where this key is available';
COMMENT ON TABLE public.letter_cred IS 'Letter cred';
COMMENT ON TABLE public.letter_deb IS 'letter deb';
COMMENT ON TABLE public.menu_default IS 'default menu for certains actions';
COMMENT ON TABLE public.menu_ref IS 'Definition of all the menu';
COMMENT ON COLUMN public.menu_ref.me_code IS 'Menu Code ';
COMMENT ON COLUMN public.menu_ref.me_menu IS 'Label to display';
COMMENT ON COLUMN public.menu_ref.me_file IS 'if not empty file to include';
COMMENT ON COLUMN public.menu_ref.me_url IS 'url ';
COMMENT ON COLUMN public.menu_ref.me_type IS 'ME for menu
PR for Printing
SP for special meaning (ex: return to line)
PL for plugin';
COMMENT ON TABLE mod_payment IS 'Contains the different media of payment and the corresponding ledger';
COMMENT ON COLUMN mod_payment.jrn_def_id IS 'Ledger using this payment method';
COMMENT ON TABLE op_predef IS 'predefined operation';
COMMENT ON COLUMN op_predef.jrn_def_id IS 'jrn_id';
COMMENT ON COLUMN op_predef.od_name IS 'name of the operation';
COMMENT ON TABLE op_predef_detail IS 'contains the detail of predefined operations';
COMMENT ON TABLE operation_analytique IS 'History of the analytic account';
COMMENT ON COLUMN operation_analytique.oa_jrnx_id_source IS 'jrnx.j_id source of this amount, this amount is computed from an amount giving a ND VAT.Normally NULL is there is no ND VAT.';
COMMENT ON COLUMN operation_analytique.oa_positive IS 'Sign of the amount';
COMMENT ON COLUMN operation_analytique.f_id IS 'FK to fiche.f_id , used only with ODS';
COMMENT ON TABLE parameter IS 'parameter of the company';
COMMENT ON TABLE parm_money IS 'Currency conversion';
COMMENT ON TABLE parm_periode IS 'Periode definition';
COMMENT ON TABLE parm_poste IS 'Contains data for finding is the type of the account (asset)';
COMMENT ON TABLE plan_analytique IS 'Plan Analytique (max 5)';
COMMENT ON TABLE poste_analytique IS 'Poste Analytique';
COMMENT ON TABLE profile IS 'Available profile ';
COMMENT ON COLUMN profile.p_name IS 'Name of the profile';
COMMENT ON COLUMN profile.p_desc IS 'description of the profile';
COMMENT ON COLUMN profile.with_calc IS 'show the calculator';
COMMENT ON COLUMN profile.with_direct_form IS 'show the direct form';
COMMENT ON TABLE profile_menu IS 'Join between the profile and the menu ';
COMMENT ON COLUMN profile_menu.me_code_dep IS 'menu code dependency';
COMMENT ON COLUMN profile_menu.p_id IS 'link to profile';
COMMENT ON COLUMN profile_menu.p_order IS 'order of displaying menu';
COMMENT ON COLUMN profile_menu.p_type_display IS 'M is a module
COMMENT ON TABLE public.payment_method IS 'Contains the different media of payment and the corresponding ledger';
COMMENT ON COLUMN public.payment_method.jrn_def_id IS 'Ledger using this payment method';
COMMENT ON TABLE public.op_predef IS 'predefined operation';
COMMENT ON COLUMN public.op_predef.jrn_def_id IS 'jrn_id';
COMMENT ON COLUMN public.op_predef.od_name IS 'name of the operation';
COMMENT ON TABLE public.op_predef_detail IS 'contains the detail of predefined operations';
COMMENT ON TABLE public.operation_analytique IS 'History of the analytic account';
COMMENT ON COLUMN public.operation_analytique.oa_jrnx_id_source IS 'jrnx.j_id source of this amount, this amount is computed from an amount giving a ND VAT.Normally NULL is there is no ND VAT.';
COMMENT ON COLUMN public.operation_analytique.oa_positive IS 'Sign of the amount';
COMMENT ON COLUMN public.operation_analytique.f_id IS 'FK to fiche.f_id , used only with ODS';
COMMENT ON TABLE public.operation_currency IS 'Information about currency';
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';
COMMENT ON TABLE public.operation_tag IS 'Tag for operation';
COMMENT ON TABLE public.parameter IS 'parameter of the company';
COMMENT ON TABLE public.parameter_extra IS 'Extra parameter for the folder';
COMMENT ON COLUMN public.parameter_extra.pe_code IS 'Code used in the Document:generate';
COMMENT ON COLUMN public.parameter_extra.pe_label IS 'Label description';
COMMENT ON COLUMN public.parameter_extra.pe_value IS 'Value which will replace the tag in Document:generate';
COMMENT ON TABLE public.parm_code IS 'Parameter code and accountancy';
COMMENT ON TABLE public.parm_money IS 'Currency conversion';
COMMENT ON TABLE public.parm_periode IS 'Periode definition';
COMMENT ON COLUMN public.parm_periode.p_start IS 'Start date of periode';
COMMENT ON COLUMN public.parm_periode.p_end IS 'End date of periode';
COMMENT ON COLUMN public.parm_periode.p_exercice IS 'Exercice';
COMMENT ON COLUMN public.parm_periode.p_closed IS 'is closed';
COMMENT ON COLUMN public.parm_periode.p_central IS 'is centralized (obsolete)';
COMMENT ON COLUMN public.parm_periode.p_exercice_label IS 'label of the exercice';
COMMENT ON TABLE public.parm_poste IS 'Contains data for finding is the type of the account (asset)';
COMMENT ON TABLE public.plan_analytique IS 'Plan Analytique (max 5)';
COMMENT ON TABLE public.poste_analytique IS 'Poste Analytique';
COMMENT ON COLUMN public.poste_analytique.po_state IS 'Analytic Account state : 0 disabled 0 enabled ';
COMMENT ON TABLE public.profile IS 'Available profile ';
COMMENT ON COLUMN public.profile.p_name IS 'Name of the profile';
COMMENT ON COLUMN public.profile.p_desc IS 'description of the profile';
COMMENT ON COLUMN public.profile.with_calc IS 'show the calculator';
COMMENT ON COLUMN public.profile.with_direct_form IS 'show the direct form';
COMMENT ON COLUMN public.profile.with_search_card IS 'Display a icon for searching card : 1 display, 0 not displaid';
COMMENT ON TABLE public.profile_menu IS 'Join between the profile and the menu ';
COMMENT ON COLUMN public.profile_menu.me_code_dep IS 'menu code dependency';
COMMENT ON COLUMN public.profile_menu.p_id IS 'link to profile';
COMMENT ON COLUMN public.profile_menu.p_order IS 'order of displaying menu';
COMMENT ON COLUMN public.profile_menu.p_type_display IS 'M is a module
E is a menu
S is a select (for plugin)';
COMMENT ON COLUMN profile_menu.pm_default IS 'default menu';
COMMENT ON COLUMN profile_menu.pm_id_dep IS 'parent of this menu item';
COMMENT ON TABLE profile_sec_repository IS 'Available profile for user';
COMMENT ON COLUMN profile_sec_repository.ur_id IS 'pk';
COMMENT ON COLUMN profile_sec_repository.p_id IS 'fk to profile';
COMMENT ON COLUMN profile_sec_repository.r_id IS 'fk to stock_repository';
COMMENT ON COLUMN profile_sec_repository.ur_right IS 'Type of right : R for readonly W for write';
COMMENT ON TABLE profile_user IS 'Contains the available profile for users';
COMMENT ON COLUMN profile_user.user_name IS 'fk to available_user : login';
COMMENT ON COLUMN profile_user.p_id IS 'fk to profile';
COMMENT ON TABLE quant_fin IS 'Simple operation for financial';
COMMENT ON COLUMN quant_purchase.qp_vat_sided IS 'amount of the VAT which avoid VAT, case of the VAT which add the same amount at the deb and cred';
COMMENT ON TABLE quant_sold IS 'Contains about invoice for customer';
COMMENT ON TABLE stock_goods IS 'About the goods';
COMMENT ON TABLE stock_repository IS 'stock repository';
COMMENT ON COLUMN stock_repository.r_id IS 'pk';
COMMENT ON COLUMN stock_repository.r_name IS 'name of the stock';
COMMENT ON COLUMN stock_repository.r_adress IS 'adress of the stock';
COMMENT ON COLUMN stock_repository.r_country IS 'country of the stock';
COMMENT ON COLUMN stock_repository.r_city IS 'City of the stock';
COMMENT ON COLUMN stock_repository.r_phone IS 'Phone number';
COMMENT ON COLUMN tags.t_actif IS 'Y if the tag is activate and can be used ';
COMMENT ON TABLE tmp_pcmn IS 'Plan comptable minimum normalisé';
COMMENT ON COLUMN tmp_pcmn.id IS 'allow to identify the row, it is unique and not null (pseudo pk)';
COMMENT ON COLUMN tmp_pcmn.pcm_direct_use IS 'Value are N or Y , N cannot be used directly , not even through a card';
COMMENT ON TABLE todo_list IS 'Todo list';
COMMENT ON COLUMN todo_list.is_public IS 'Flag for the public parameter';
COMMENT ON TABLE todo_list_shared IS 'Note of todo list shared with other users';
COMMENT ON COLUMN todo_list_shared.todo_list_id IS 'fk to todo_list';
COMMENT ON COLUMN todo_list_shared.use_login IS 'user login';
COMMENT ON TABLE tva_rate IS 'Rate of vat';
COMMENT ON COLUMN user_active_security.us_login IS 'user''s login';
COMMENT ON COLUMN user_active_security.us_ledger IS 'Flag Security for ledger';
COMMENT ON COLUMN user_active_security.us_action IS 'Security for action';
COMMENT ON TABLE user_local_pref IS 'The user''s local parameter ';
COMMENT ON COLUMN user_local_pref.user_id IS 'user''s login ';
COMMENT ON COLUMN user_local_pref.parameter_type IS 'the type of parameter ';
COMMENT ON COLUMN user_local_pref.parameter_value IS 'the value of parameter ';
COMMENT ON TABLE user_sec_action_profile IS 'Available profile for user';
COMMENT ON COLUMN user_sec_action_profile.ua_id IS 'pk';
COMMENT ON COLUMN user_sec_action_profile.p_id IS 'fk to profile';
COMMENT ON COLUMN user_sec_action_profile.ua_right IS 'Type of right : R for readonly W for write';
COMMENT ON VIEW v_menu_description IS 'Description des menus';
COMMENT ON VIEW v_menu_profile IS 'Give the profile and the menu + dependencies';
COMMENT ON VIEW v_tva_rate IS 'Show this table to be easily used by Tva_Rate_MTable';
COMMENT ON COLUMN v_tva_rate.tva_purchase IS ' VAT used for purchase';
COMMENT ON COLUMN v_tva_rate.tva_sale IS ' VAT used for sale';
COMMENT ON COLUMN v_tva_rate.tva_both_side IS 'if 1 , VAT avoided ';
COMMENT ON VIEW vw_fiche_def IS 'all the attributs for card family';
COMMENT ON CONSTRAINT uniq_user_ledger ON user_sec_jrn IS 'Create an unique combination user / ledger';
COMMENT ON TRIGGER action_gestion_t_insert_update ON action_gestion IS 'Truncate the column ag_title to 70 char';
COMMENT ON TRIGGER profile_user_ins_upd ON profile_user IS 'Force the column user_name to lowercase';
COMMENT ON TRIGGER t_jrnx_ins ON jrnx IS 'check that the qcode used by the card exists and format it : uppercase and trim the space';
COMMENT ON TRIGGER t_letter_del ON jrnx IS 'Delete the lettering for this row';
COMMENT ON TRIGGER todo_list_ins_upd ON todo_list IS 'Force the column use_login to lowercase';
COMMENT ON TRIGGER todo_list_shared_ins_upd ON todo_list_shared IS 'Force the column ua_login to lowercase';
COMMENT ON TRIGGER user_sec_act_ins_upd ON user_sec_act IS 'Force the column ua_login to lowercase';
COMMENT ON TRIGGER user_sec_jrn_after_ins_upd ON user_sec_jrn IS 'Force the column uj_login to lowercase';
COMMENT ON COLUMN public.profile_menu.pm_default IS 'default menu';
COMMENT ON COLUMN public.profile_menu.pm_id_dep IS 'parent of this menu item';
COMMENT ON TABLE public.profile_menu_type IS 'Type of menu';
COMMENT ON TABLE public.profile_mobile IS 'Menu for mobile device';
COMMENT ON COLUMN public.profile_mobile.pmo_id IS 'primary key';
COMMENT ON COLUMN public.profile_mobile.me_code IS 'Code of menu_ref to execute';
COMMENT ON COLUMN public.profile_mobile.pmo_order IS 'item order in menu';
COMMENT ON COLUMN public.profile_mobile.p_id IS 'Profile id ';
COMMENT ON COLUMN public.profile_mobile.pmo_default IS 'possible values are 1 , the default HTML header (javascript,CSS,...) is loaded , 0 nothing is loaded from noalyss ';
COMMENT ON TABLE public.profile_sec_repository IS 'Available profile for user';
COMMENT ON COLUMN public.profile_sec_repository.ur_id IS 'pk';
COMMENT ON COLUMN public.profile_sec_repository.p_id IS 'fk to profile';
COMMENT ON COLUMN public.profile_sec_repository.r_id IS 'fk to stock_repository';
COMMENT ON COLUMN public.profile_sec_repository.ur_right IS 'Type of right : R for readonly W for write';
COMMENT ON TABLE public.profile_user IS 'Contains the available profile for users';
COMMENT ON COLUMN public.profile_user.user_name IS 'fk to available_user : login';
COMMENT ON COLUMN public.profile_user.p_id IS 'fk to profile';
COMMENT ON TABLE public.quant_fin IS 'Simple operation for financial';
COMMENT ON TABLE public.quant_purchase IS 'Supplemental info for purchase';
COMMENT ON COLUMN public.quant_purchase.qp_vat_sided IS 'amount of the VAT which avoid VAT, case of the VAT which add the same amount at the deb and cred';
COMMENT ON TABLE public.quant_sold IS 'Contains about invoice for customer';
COMMENT ON TABLE public.stock_change IS 'Change of stock';
COMMENT ON TABLE public.stock_goods IS 'About the goods';
COMMENT ON TABLE public.stock_repository IS 'stock repository';
COMMENT ON COLUMN public.stock_repository.r_id IS 'pk';
COMMENT ON COLUMN public.stock_repository.r_name IS 'name of the stock';
COMMENT ON COLUMN public.stock_repository.r_adress IS 'adress of the stock';
COMMENT ON COLUMN public.stock_repository.r_country IS 'country of the stock';
COMMENT ON COLUMN public.stock_repository.r_city IS 'City of the stock';
COMMENT ON COLUMN public.stock_repository.r_phone IS 'Phone number';
COMMENT ON TABLE public.tag_group IS 'Group of tags';
COMMENT ON COLUMN public.tag_group.tg_name IS 'Nom du groupe';
COMMENT ON TABLE public.tags IS 'Tags name';
COMMENT ON COLUMN public.tags.t_actif IS 'Y if the tag is activate and can be used ';
COMMENT ON TABLE public.tmp_pcmn IS 'Plan comptable minimum normalisé';
COMMENT ON COLUMN public.tmp_pcmn.id IS 'allow to identify the row, it is unique and not null (pseudo pk)';
COMMENT ON COLUMN public.tmp_pcmn.pcm_direct_use IS 'Value are N or Y , N cannot be used directly , not even through a card';
COMMENT ON TABLE public.todo_list IS 'Todo list';
COMMENT ON COLUMN public.todo_list.is_public IS 'Flag for the public parameter';
COMMENT ON TABLE public.todo_list_shared IS 'Note of todo list shared with other users';
COMMENT ON COLUMN public.todo_list_shared.todo_list_id IS 'fk to todo_list';
COMMENT ON COLUMN public.todo_list_shared.use_login IS 'user login';
COMMENT ON TABLE public.tva_rate IS 'Rate of vat';
COMMENT ON COLUMN public.tva_rate.tva_label IS 'Label';
COMMENT ON COLUMN public.tva_rate.tva_rate IS 'Rate';
COMMENT ON COLUMN public.tva_rate.tva_comment IS 'Description of VAT';
COMMENT ON COLUMN public.tva_rate.tva_poste IS 'accounting';
COMMENT ON COLUMN public.tva_rate.tva_both_side IS 'If set to 1 , the amount VAT will be reversed (autoliquidation)';
COMMENT ON COLUMN public.tva_rate.tva_payment_sale IS 'Check if the VAT on Sale must be declared when at the date of payment (P) or the date of operation (O)';
COMMENT ON COLUMN public.tva_rate.tva_payment_purchase IS 'Check if the VAT on Purchase must be declared when at the date of payment (P) or the date of operation (O)';
COMMENT ON TABLE public.user_active_security IS 'Security for user';
COMMENT ON COLUMN public.user_active_security.us_login IS 'user''s login';
COMMENT ON COLUMN public.user_active_security.us_ledger IS 'Flag Security for ledger';
COMMENT ON COLUMN public.user_active_security.us_action IS 'Security for action';
COMMENT ON TABLE public.user_filter IS 'Filter for the search';
COMMENT ON COLUMN public.user_filter.operation_filter IS 'Status of the operation : paid, unpaid or all operation';
COMMENT ON COLUMN public.user_filter.uf_tag IS 'Tag list';
COMMENT ON COLUMN public.user_filter.uf_tag_option IS '0 : all tags must be present, 1: at least one';
COMMENT ON COLUMN public.user_filter.uf_currency_code IS 'correspond to currency.id';
COMMENT ON COLUMN public.user_filter.tva_id_search IS 'VAT id ';
COMMENT ON TABLE public.user_local_pref IS 'The user''s local parameter ';
COMMENT ON COLUMN public.user_local_pref.user_id IS 'user''s login ';
COMMENT ON COLUMN public.user_local_pref.parameter_type IS 'the type of parameter ';
COMMENT ON COLUMN public.user_local_pref.parameter_value IS 'the value of parameter ';
COMMENT ON TABLE public.user_sec_act IS 'Security on actions for user';
COMMENT ON TABLE public.user_sec_action_profile IS 'Available profile for user';
COMMENT ON COLUMN public.user_sec_action_profile.ua_id IS 'pk';
COMMENT ON COLUMN public.user_sec_action_profile.p_id IS 'fk to profile';
COMMENT ON COLUMN public.user_sec_action_profile.ua_right IS 'Type of right : R for readonly W for write';
COMMENT ON TABLE public.user_sec_jrn IS 'Security on ledger for users';
COMMENT ON VIEW public.vw_fiche_attr IS 'Some attribute for all cards';
COMMENT ON VIEW public.v_menu_description IS 'Description des menus';
COMMENT ON VIEW public.v_menu_profile IS 'Give the profile and the menu + dependencies';
COMMENT ON TABLE public.version IS 'DB version';
COMMENT ON VIEW public.vw_fiche_def IS 'all the attributs for card family';
COMMENT ON CONSTRAINT uniq_user_ledger ON public.user_sec_jrn IS 'Create an unique combination user / ledger';
COMMENT ON TRIGGER action_gestion_t_insert_update ON public.action_gestion IS 'Truncate the column ag_title to 70 char';
COMMENT ON TRIGGER profile_user_ins_upd ON public.profile_user IS 'Force the column user_name to lowercase';
COMMENT ON TRIGGER t_jrnx_ins ON public.jrnx IS 'check that the qcode used by the card exists and format it : uppercase and trim the space';
COMMENT ON TRIGGER t_letter_del ON public.jrnx IS 'Delete the lettering for this row';
COMMENT ON TRIGGER todo_list_ins_upd ON public.todo_list IS 'Force the column use_login to lowercase';
COMMENT ON TRIGGER todo_list_shared_ins_upd ON public.todo_list_shared IS 'Force the column ua_login to lowercase';
COMMENT ON TRIGGER user_sec_act_ins_upd ON public.user_sec_act IS 'Force the column ua_login to lowercase';
COMMENT ON TRIGGER user_sec_jrn_after_ins_upd ON public.user_sec_jrn IS 'Force the column uj_login to lowercase';

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,33 +1,34 @@
CREATE UNIQUE INDEX fd_id_ad_id_x ON jnt_fic_attr USING btree (fd_id, ad_id);
CREATE UNIQUE INDEX fiche_detail_f_id_ad_id ON fiche_detail USING btree (f_id, ad_id);
CREATE INDEX fk_action_person_action_gestion ON action_person USING btree (ag_id);
CREATE INDEX fk_action_person_fiche ON action_person USING btree (f_id);
CREATE INDEX fk_stock_good_repository_r_id ON stock_goods USING btree (r_id);
CREATE INDEX fk_stock_goods_f_id ON stock_goods USING btree (f_id);
CREATE INDEX fk_stock_goods_j_id ON stock_goods USING btree (j_id);
CREATE INDEX fki_f_end_date ON forecast USING btree (f_end_date);
CREATE INDEX fki_f_start_date ON forecast USING btree (f_start_date);
CREATE INDEX fki_jrn_jr_grpt_id ON jrn USING btree (jr_grpt_id);
CREATE INDEX fki_jrnx_f_id ON jrnx USING btree (f_id);
CREATE INDEX fki_jrnx_j_grpt ON jrnx USING btree (j_grpt);
CREATE INDEX fki_profile_menu_me_code ON profile_menu USING btree (me_code);
CREATE INDEX fki_profile_menu_profile ON profile_menu USING btree (p_id);
CREATE INDEX fki_profile_menu_type_fkey ON profile_menu USING btree (p_type_display);
CREATE INDEX idx_qs_internal ON quant_sold USING btree (qs_internal);
CREATE INDEX jnt_fic_att_value_fd_id_idx ON fiche_detail USING btree (f_id);
CREATE INDEX jnt_fic_attr_fd_id_idx ON jnt_fic_attr USING btree (fd_id);
CREATE INDEX jrnx_j_qcode_ix ON jrnx USING btree (j_qcode);
CREATE UNIQUE INDEX k_ag_ref ON action_gestion USING btree (ag_ref);
CREATE INDEX link_action_type_fki ON action_gestion_related USING btree (aga_type);
CREATE UNIQUE INDEX qcode_idx ON fiche_detail USING btree (ad_value) WHERE (ad_id = 23);
CREATE UNIQUE INDEX qf_jr_id ON quant_fin USING btree (jr_id);
CREATE UNIQUE INDEX qp_j_id ON quant_purchase USING btree (j_id);
CREATE UNIQUE INDEX qs_j_id ON quant_sold USING btree (j_id);
CREATE INDEX quant_purchase_jrn_fki ON quant_purchase USING btree (qp_internal);
CREATE INDEX quant_sold_jrn_fki ON quant_sold USING btree (qs_internal);
CREATE UNIQUE INDEX uj_login_uj_jrn_id ON user_sec_jrn USING btree (uj_login, uj_jrn_id);
CREATE UNIQUE INDEX ux_po_name ON poste_analytique USING btree (po_name);
CREATE UNIQUE INDEX x_jrn_jr_id ON jrn USING btree (jr_id);
CREATE INDEX x_mt ON jrn USING btree (jr_mt);
CREATE UNIQUE INDEX x_periode ON parm_periode USING btree (p_start, p_end);
CREATE INDEX x_poste ON jrnx USING btree (j_poste);
CREATE UNIQUE INDEX fd_id_ad_id_x ON public.jnt_fic_attr USING btree (fd_id, ad_id);
CREATE INDEX fiche_detail_attr_ix ON public.fiche_detail USING btree (ad_id);
CREATE UNIQUE INDEX fiche_detail_f_id_ad_id ON public.fiche_detail USING btree (f_id, ad_id);
CREATE INDEX fk_action_person_action_gestion ON public.action_person USING btree (ag_id);
CREATE INDEX fk_action_person_fiche ON public.action_person USING btree (f_id);
CREATE INDEX fk_stock_good_repository_r_id ON public.stock_goods USING btree (r_id);
CREATE INDEX fk_stock_goods_f_id ON public.stock_goods USING btree (f_id);
CREATE INDEX fk_stock_goods_j_id ON public.stock_goods USING btree (j_id);
CREATE INDEX fki_f_end_date ON public.forecast USING btree (f_end_date);
CREATE INDEX fki_f_start_date ON public.forecast USING btree (f_start_date);
CREATE INDEX fki_jrn_jr_grpt_id ON public.jrn USING btree (jr_grpt_id);
CREATE INDEX fki_jrnx_f_id ON public.jrnx USING btree (f_id);
CREATE INDEX fki_jrnx_j_grpt ON public.jrnx USING btree (j_grpt);
CREATE INDEX fki_profile_menu_me_code ON public.profile_menu USING btree (me_code);
CREATE INDEX fki_profile_menu_profile ON public.profile_menu USING btree (p_id);
CREATE INDEX fki_profile_menu_type_fkey ON public.profile_menu USING btree (p_type_display);
CREATE INDEX idx_qs_internal ON public.quant_sold USING btree (qs_internal);
CREATE INDEX jnt_fic_att_value_fd_id_idx ON public.fiche_detail USING btree (f_id);
CREATE INDEX jnt_fic_attr_fd_id_idx ON public.jnt_fic_attr USING btree (fd_id);
CREATE INDEX jrnx_j_qcode_ix ON public.jrnx USING btree (j_qcode);
CREATE UNIQUE INDEX k_ag_ref ON public.action_gestion USING btree (ag_ref);
CREATE INDEX link_action_type_fki ON public.action_gestion_related USING btree (aga_type);
CREATE UNIQUE INDEX qcode_idx ON public.fiche_detail USING btree (ad_value) WHERE (ad_id = 23);
CREATE UNIQUE INDEX qf_jr_id ON public.quant_fin USING btree (jr_id);
CREATE UNIQUE INDEX qp_j_id ON public.quant_purchase USING btree (j_id);
CREATE UNIQUE INDEX qs_j_id ON public.quant_sold USING btree (j_id);
CREATE INDEX quant_purchase_jrn_fki ON public.quant_purchase USING btree (qp_internal);
CREATE INDEX quant_sold_jrn_fki ON public.quant_sold USING btree (qs_internal);
CREATE UNIQUE INDEX uj_login_uj_jrn_id ON public.user_sec_jrn USING btree (uj_login, uj_jrn_id);
CREATE UNIQUE INDEX ux_po_name ON public.poste_analytique USING btree (po_name);
CREATE UNIQUE INDEX x_jrn_jr_id ON public.jrn USING btree (jr_id);
CREATE INDEX x_mt ON public.jrn USING btree (jr_mt);
CREATE UNIQUE INDEX x_periode ON public.parm_periode USING btree (p_start, p_end);
CREATE INDEX x_poste ON public.jrnx USING btree (j_poste);

View file

@ -12,33 +12,7 @@ psql -X $TEMPLATE -c "delete from user_local_pref"
pg_dump -O -U dany -s $TEMPLATE|grep -v "COMMENT ON SCHEMA public IS 'Standard public schema';" |sed "/^--/d" > schema.sql
sed -i -e "/COMMENT ON EXTENSION/d" schema.sql
sed -i -e "/CREATE EXTENSION/d" schema.sql
awk '/SEQUENCE/,/;/ { print $0;}' < schema.sql > sequence.sql
awk '/CREATE DOMAIN/,/;/ { print $0;}' < schema.sql > table.sql
awk '/CREATE TABLE/,/;/ { print $0;}' < schema.sql >> table.sql
awk '/CREATE VIEW/,/;/ { print $0;}' < schema.sql > view.sql
awk '/INDEX/,/;/ { print $0;}' < schema.sql > index.sql
(
echo " SET client_encoding = 'utf8';"
echo " SET check_function_bodies = false;"
echo " SET client_min_messages = warning;"
echo "SET search_path = public, pg_catalog;"
)> constraint.sql
awk '/ALTER TABLE/,/;/ { print $0;}' < schema.sql >> constraint.sql
awk '/CREATE TRIGGER/,/;/ { print $0;}' < schema.sql >> constraint.sql
awk '/COMMENT ON CONSTRAINT/,/;/ { print $0;}' < schema.sql >> constraint.sql
awk '/COMMENT ON TRIGGER/,/;/ { print $0;}' < schema.sql >> constraint.sql
# function in XML
## awk 'BEGIN{print "<PROCEDURES>";} /CREATE FUNCTION/,/\$\$;/ { if (/CREATE FUNCTION/) {print "<procedure>";} if (/\$\$;/) {print "</procedure>";} print $0;} END { print "</PROCEDURES>";}' < schema.sql
awk '/CREATE FUNCTION/,/\$\$;/ { print $0;}' < schema.sql > function.sql
awk '/COMMENT/,/;/ {print $0;}' < schema.sql > comment.sql
sed -i -e "/REVOKE /d" -e "/GRANT /d" -e "/ALTER TABLE.*/d" -e "/ADD CONSTRAINT/d" -e "/CREATE PROCEDURAL/d" -e "/CREATE TRIGGER/d" -e "/COMMENT ON CONSTRAINT/d" -e "/COMMENT ON TRIGGER/d" schema.sql
grep setval schema.sql >> sequence.sql
echo "set search_path = public,comptaproc,pg_catalog ;" > data.sql
pg_dump -O -U dany --data-only --column-inserts -O ${TEMPLATE}|sed "/^--/d" | sed -e "/SET search_path/d" >> data.sql

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,23 @@
CREATE DOMAIN account_type AS character varying(40);
CREATE TABLE action (
CREATE DOMAIN public.account_type AS character varying(40);
CREATE TABLE public.acc_other_tax (
ac_id integer NOT NULL,
ac_label text NOT NULL,
ac_rate numeric(5,2) NOT NULL,
ajrn_def_id integer[],
ac_accounting public.account_type NOT NULL
);
CREATE TABLE public.action (
ac_id integer NOT NULL,
ac_description text NOT NULL,
ac_module text,
ac_code character varying(30)
);
CREATE TABLE action_detail (
CREATE TABLE public.action_comment_document (
acd_id bigint NOT NULL,
document_id bigint,
action_gestion_comment_id bigint
);
CREATE TABLE public.action_detail (
ad_id integer NOT NULL,
f_id bigint,
ad_text text,
@ -16,8 +28,8 @@ CREATE TABLE action_detail (
ad_total_amount numeric(20,4) DEFAULT 0,
ag_id integer DEFAULT 0 NOT NULL
);
CREATE TABLE action_gestion (
ag_id integer DEFAULT nextval('action_gestion_ag_id_seq'::regclass) NOT NULL,
CREATE TABLE public.action_gestion (
ag_id integer DEFAULT nextval('public.action_gestion_ag_id_seq'::regclass) NOT NULL,
ag_type integer,
f_id_dest integer,
ag_title text,
@ -25,65 +37,80 @@ CREATE TABLE action_gestion (
ag_ref text,
ag_hour text,
ag_priority integer DEFAULT 2,
ag_dest bigint DEFAULT (-1) NOT NULL,
ag_dest bigint DEFAULT '-1'::integer NOT NULL,
ag_owner text,
ag_contact bigint,
ag_state integer,
ag_remind_date date
);
CREATE TABLE action_gestion_comment (
CREATE TABLE public.action_gestion_comment (
agc_id bigint NOT NULL,
ag_id bigint,
agc_date timestamp with time zone DEFAULT now(),
agc_comment text,
tech_user text
tech_user text,
agc_comment_raw text
);
CREATE TABLE action_gestion_operation (
CREATE TABLE public.action_gestion_filter (
af_id bigint NOT NULL,
af_user text NOT NULL,
af_name text NOT NULL,
af_search text NOT NULL
);
CREATE TABLE public.action_gestion_operation (
ago_id bigint NOT NULL,
ag_id bigint,
jr_id bigint
);
CREATE TABLE action_gestion_related (
CREATE TABLE public.action_gestion_related (
aga_id bigint NOT NULL,
aga_least bigint NOT NULL,
aga_greatest bigint NOT NULL,
aga_type bigint
);
CREATE TABLE action_person (
CREATE TABLE public.action_person (
ap_id integer NOT NULL,
ag_id integer NOT NULL,
f_id integer NOT NULL
);
CREATE TABLE action_tags (
CREATE TABLE public.action_person_option (
ap_id bigint NOT NULL,
ap_value character varying,
contact_option_ref_id bigint NOT NULL,
action_person_id bigint NOT NULL
);
CREATE TABLE public.action_tags (
at_id integer NOT NULL,
t_id integer,
ag_id integer
);
CREATE TABLE attr_def (
CREATE TABLE public.attr_def (
ad_id integer DEFAULT nextval(('s_attr_def'::text)::regclass) NOT NULL,
ad_text text,
ad_type text,
ad_size text NOT NULL,
ad_extra text
ad_extra text,
ad_search_followup integer DEFAULT 1,
ad_default_order integer
);
CREATE TABLE attr_min (
CREATE TABLE public.attr_min (
frd_id integer NOT NULL,
ad_id integer NOT NULL
);
CREATE TABLE bilan (
b_id integer DEFAULT nextval('bilan_b_id_seq'::regclass) NOT NULL,
CREATE TABLE public.bilan (
b_id integer DEFAULT nextval('public.bilan_b_id_seq'::regclass) NOT NULL,
b_name text NOT NULL,
b_file_template text NOT NULL,
b_file_form text,
b_type text NOT NULL
);
CREATE TABLE bookmark (
CREATE TABLE public.bookmark (
b_id integer NOT NULL,
b_order integer DEFAULT 1,
b_action text,
login text
);
CREATE TABLE centralized (
CREATE TABLE public.centralized (
c_id integer DEFAULT nextval(('s_centralized'::text)::regclass) NOT NULL,
c_j_id integer,
c_date date NOT NULL,
@ -91,7 +118,7 @@ CREATE TABLE centralized (
c_montant numeric(20,4) NOT NULL,
c_debit boolean DEFAULT true,
c_jrn_def integer NOT NULL,
c_poste account_type,
c_poste public.account_type,
c_description text,
c_grp integer NOT NULL,
c_comment text,
@ -99,12 +126,30 @@ CREATE TABLE centralized (
c_periode integer,
c_order integer
);
CREATE TABLE del_action (
CREATE TABLE public.contact_option_ref (
cor_id bigint NOT NULL,
cor_label character varying NOT NULL,
cor_type integer DEFAULT 0 NOT NULL,
cor_value_select character varying
);
CREATE TABLE public.currency (
id integer NOT NULL,
cr_code_iso character varying(10),
cr_name character varying(80)
);
CREATE TABLE public.currency_history (
id integer NOT NULL,
ch_value numeric(20,8) NOT NULL,
ch_from date NOT NULL,
currency_id integer NOT NULL,
CONSTRAINT currency_history_check CHECK ((ch_value > (0)::numeric))
);
CREATE TABLE public.del_action (
del_id integer NOT NULL,
del_name text NOT NULL,
del_time timestamp without time zone
);
CREATE TABLE del_jrn (
CREATE TABLE public.del_jrn (
jr_id integer NOT NULL,
jr_def_id integer,
jr_montant numeric(20,4),
@ -127,11 +172,11 @@ CREATE TABLE del_jrn (
jr_pj_number text,
dj_id integer NOT NULL
);
CREATE TABLE del_jrnx (
CREATE TABLE public.del_jrnx (
j_id integer NOT NULL,
j_date date,
j_montant numeric(20,4),
j_poste account_type,
j_poste public.account_type,
j_grpt integer,
j_rapt text,
j_jrn_def integer,
@ -146,8 +191,8 @@ CREATE TABLE del_jrnx (
djx_id integer NOT NULL,
f_id bigint
);
CREATE TABLE document (
d_id integer DEFAULT nextval('document_d_id_seq'::regclass) NOT NULL,
CREATE TABLE public.document (
d_id integer DEFAULT nextval('public.document_d_id_seq'::regclass) NOT NULL,
ag_id integer NOT NULL,
d_lob oid,
d_number bigint NOT NULL,
@ -155,8 +200,13 @@ CREATE TABLE document (
d_mimetype text,
d_description text
);
CREATE TABLE document_modele (
md_id integer DEFAULT nextval('document_modele_md_id_seq'::regclass) NOT NULL,
CREATE TABLE public.document_component (
dc_id integer NOT NULL,
dc_code text NOT NULL,
dc_comment text NOT NULL
);
CREATE TABLE public.document_modele (
md_id integer DEFAULT nextval('public.document_modele_md_id_seq'::regclass) NOT NULL,
md_name text NOT NULL,
md_lob oid,
md_type integer NOT NULL,
@ -164,17 +214,24 @@ CREATE TABLE document_modele (
md_mimetype text,
md_affect character varying(3) NOT NULL
);
CREATE TABLE document_state (
s_id integer DEFAULT nextval('document_state_s_id_seq'::regclass) NOT NULL,
CREATE TABLE public.document_option (
do_id bigint NOT NULL,
do_code character varying(20) NOT NULL,
document_type_id bigint,
do_enable integer DEFAULT 1 NOT NULL,
do_option character varying
);
CREATE TABLE public.document_state (
s_id integer DEFAULT nextval('public.document_state_s_id_seq'::regclass) NOT NULL,
s_value character varying(50) NOT NULL,
s_status character(1)
);
CREATE TABLE document_type (
dt_id integer DEFAULT nextval('document_type_dt_id_seq'::regclass) NOT NULL,
CREATE TABLE public.document_type (
dt_id integer DEFAULT nextval('public.document_type_dt_id_seq'::regclass) NOT NULL,
dt_value character varying(80),
dt_prefix text
);
CREATE TABLE extension (
CREATE TABLE public.extension (
ex_id integer NOT NULL,
ex_name character varying(30) NOT NULL,
ex_code character varying(15) NOT NULL,
@ -182,11 +239,13 @@ CREATE TABLE extension (
ex_file character varying NOT NULL,
ex_enable "char" DEFAULT 'Y'::"char" NOT NULL
);
CREATE TABLE fiche (
CREATE TABLE public.fiche (
f_id integer DEFAULT nextval(('s_fiche'::text)::regclass) NOT NULL,
fd_id integer
fd_id integer,
f_enable character(1) NOT NULL,
CONSTRAINT f_enable_ck CHECK ((f_enable = ANY (ARRAY['0'::bpchar, '1'::bpchar])))
);
CREATE TABLE fiche_def (
CREATE TABLE public.fiche_def (
fd_id integer DEFAULT nextval(('s_fdef'::text)::regclass) NOT NULL,
fd_class_base text,
fd_label text NOT NULL,
@ -194,70 +253,81 @@ CREATE TABLE fiche_def (
frd_id integer NOT NULL,
fd_description text
);
CREATE TABLE fiche_def_ref (
CREATE TABLE public.fiche_def_ref (
frd_id integer DEFAULT nextval(('s_fiche_def_ref'::text)::regclass) NOT NULL,
frd_text text,
frd_class_base account_type
frd_class_base public.account_type
);
CREATE TABLE fiche_detail (
CREATE TABLE public.fiche_detail (
jft_id integer DEFAULT nextval(('s_jnt_fic_att_value'::text)::regclass) NOT NULL,
f_id integer,
ad_id integer,
ad_value text
);
CREATE TABLE forecast (
CREATE TABLE public.forecast (
f_id integer NOT NULL,
f_name text NOT NULL,
f_start_date bigint,
f_end_date bigint
);
CREATE TABLE forecast_cat (
CREATE TABLE public.forecast_category (
fc_id integer NOT NULL,
fc_desc text NOT NULL,
f_id bigint,
f_id bigint NOT NULL,
fc_order integer DEFAULT 0 NOT NULL
);
CREATE TABLE forecast_item (
CREATE TABLE public.forecast_item (
fi_id integer NOT NULL,
fi_text text,
fi_account text,
fi_card integer,
fi_order integer,
fc_id integer,
fi_amount numeric(20,4) DEFAULT 0,
fi_debit "char" DEFAULT 'd'::"char" NOT NULL,
fi_pid integer
fi_pid integer,
fi_amount_initial numeric(20,4) DEFAULT 0
);
CREATE TABLE form (
CREATE TABLE public.form_definition (
fr_id integer DEFAULT nextval(('s_formdef'::text)::regclass) NOT NULL,
fr_label text
);
CREATE TABLE public.form_detail (
fo_id integer DEFAULT nextval(('s_form'::text)::regclass) NOT NULL,
fo_fr_id integer,
fo_fr_id integer NOT NULL,
fo_pos integer,
fo_label text,
fo_formula text
);
CREATE TABLE formdef (
fr_id integer DEFAULT nextval(('s_formdef'::text)::regclass) NOT NULL,
fr_label text
);
CREATE TABLE groupe_analytique (
CREATE TABLE public.groupe_analytique (
ga_id character varying(10) NOT NULL,
pa_id integer,
ga_description text
);
CREATE TABLE info_def (
CREATE TABLE public.info_def (
id_type text NOT NULL,
id_description text
);
CREATE TABLE jnt_fic_attr (
CREATE TABLE public.jnt_document_option_contact (
jdoc_id bigint NOT NULL,
jdoc_enable integer NOT NULL,
document_type_id bigint,
contact_option_ref_id bigint,
CONSTRAINT jnt_document_option_contact_check CHECK ((jdoc_enable = ANY (ARRAY[0, 1])))
);
CREATE TABLE public.jnt_fic_attr (
fd_id integer,
ad_id integer,
jnt_id bigint DEFAULT nextval('s_jnt_id'::regclass) NOT NULL,
jnt_id bigint DEFAULT nextval('public.s_jnt_id'::regclass) NOT NULL,
jnt_order integer NOT NULL
);
CREATE TABLE jnt_letter (
CREATE TABLE public.jnt_letter (
jl_id integer NOT NULL
);
CREATE TABLE jrn (
CREATE TABLE public.jnt_tag_group_tag (
tag_group_id bigint NOT NULL,
tag_id bigint NOT NULL,
jt_id integer NOT NULL
);
CREATE TABLE public.jrn (
jr_id integer DEFAULT nextval(('s_jrn'::text)::regclass) NOT NULL,
jr_def_id integer NOT NULL,
jr_montant numeric(20,4) NOT NULL,
@ -279,9 +349,12 @@ CREATE TABLE jrn (
jr_pj_number text,
jr_mt text,
jr_date_paid date,
jr_optype character varying(3) DEFAULT 'NOR'::character varying
jr_optype character varying(3) DEFAULT 'NOR'::character varying,
currency_id bigint DEFAULT 0 NOT NULL,
currency_rate numeric(20,6) DEFAULT 1 NOT NULL,
currency_rate_ref numeric(20,6) DEFAULT 1 NOT NULL
);
CREATE TABLE jrn_def (
CREATE TABLE public.jrn_def (
jrn_def_id integer DEFAULT nextval(('s_jrn_def'::text)::regclass) NOT NULL,
jrn_def_name text NOT NULL,
jrn_def_class_deb text,
@ -298,39 +371,50 @@ CREATE TABLE jrn_def (
jrn_def_bank bigint,
jrn_def_num_op integer,
jrn_def_description text,
jrn_enable integer DEFAULT 1
jrn_enable integer DEFAULT 1,
currency_id integer DEFAULT 0 NOT NULL,
jrn_def_negative_amount character(1) DEFAULT '0'::bpchar NOT NULL,
jrn_def_negative_warning text,
jrn_def_quantity smallint DEFAULT 1 NOT NULL,
CONSTRAINT negative_amount_ck CHECK ((jrn_def_negative_amount = ANY (ARRAY['1'::bpchar, '0'::bpchar])))
);
CREATE TABLE jrn_info (
CREATE TABLE public.jrn_info (
ji_id integer NOT NULL,
jr_id integer NOT NULL,
id_type text NOT NULL,
ji_value text
);
CREATE TABLE jrn_note (
CREATE TABLE public.jrn_note (
n_id integer NOT NULL,
n_text text,
jr_id bigint NOT NULL
);
CREATE TABLE jrn_periode (
CREATE TABLE public.jrn_periode (
jrn_def_id integer NOT NULL,
p_id integer NOT NULL,
status text,
id bigint DEFAULT nextval('jrn_periode_id_seq'::regclass) NOT NULL
id bigint DEFAULT nextval('public.jrn_periode_id_seq'::regclass) NOT NULL
);
CREATE TABLE jrn_rapt (
CREATE TABLE public.jrn_rapt (
jra_id integer DEFAULT nextval(('s_jrn_rapt'::text)::regclass) NOT NULL,
jr_id integer NOT NULL,
jra_concerned integer NOT NULL
);
CREATE TABLE jrn_type (
CREATE TABLE public.jrn_tax (
jt_id integer NOT NULL,
j_id bigint NOT NULL,
pcm_val public.account_type NOT NULL,
ac_id integer NOT NULL
);
CREATE TABLE public.jrn_type (
jrn_type_id character(3) NOT NULL,
jrn_desc text
);
CREATE TABLE jrnx (
CREATE TABLE public.jrnx (
j_id integer DEFAULT nextval(('s_jrn_op'::text)::regclass) NOT NULL,
j_date date DEFAULT now(),
j_montant numeric(20,4) DEFAULT 0,
j_poste account_type NOT NULL,
j_poste public.account_type NOT NULL,
j_grpt integer NOT NULL,
j_rapt text,
j_jrn_def integer NOT NULL,
@ -344,48 +428,48 @@ CREATE TABLE jrnx (
j_qcode text,
f_id bigint
);
CREATE TABLE key_distribution (
CREATE TABLE public.key_distribution (
kd_id integer NOT NULL,
kd_name text,
kd_description text
);
CREATE TABLE key_distribution_activity (
CREATE TABLE public.key_distribution_activity (
ka_id integer NOT NULL,
ke_id bigint NOT NULL,
po_id bigint,
pa_id bigint NOT NULL
);
CREATE TABLE key_distribution_detail (
CREATE TABLE public.key_distribution_detail (
ke_id integer NOT NULL,
kd_id bigint NOT NULL,
ke_row integer NOT NULL,
ke_percent numeric(20,4) NOT NULL
);
CREATE TABLE key_distribution_ledger (
CREATE TABLE public.key_distribution_ledger (
kl_id integer NOT NULL,
kd_id bigint NOT NULL,
jrn_def_id bigint NOT NULL
);
CREATE TABLE letter_cred (
CREATE TABLE public.letter_cred (
lc_id integer NOT NULL,
j_id bigint NOT NULL,
jl_id bigint NOT NULL
);
CREATE TABLE letter_deb (
CREATE TABLE public.letter_deb (
ld_id integer NOT NULL,
j_id bigint NOT NULL,
jl_id bigint NOT NULL
);
CREATE TABLE link_action_type (
CREATE TABLE public.link_action_type (
l_id bigint NOT NULL,
l_desc character varying
);
CREATE TABLE menu_default (
CREATE TABLE public.menu_default (
md_id integer NOT NULL,
md_code text NOT NULL,
me_code text NOT NULL
);
CREATE TABLE menu_ref (
CREATE TABLE public.menu_ref (
me_code text NOT NULL,
me_menu text,
me_file text,
@ -396,7 +480,7 @@ CREATE TABLE menu_ref (
me_type character varying(2),
me_description_etendue text
);
CREATE TABLE mod_payment (
CREATE TABLE public.payment_method (
mp_id integer NOT NULL,
mp_lib text NOT NULL,
mp_jrn_def_id integer NOT NULL,
@ -404,8 +488,8 @@ CREATE TABLE mod_payment (
mp_qcode text,
jrn_def_id bigint
);
CREATE TABLE op_predef (
od_id integer DEFAULT nextval('op_def_op_seq'::regclass) NOT NULL,
CREATE TABLE public.op_predef (
od_id integer DEFAULT nextval('public.op_def_op_seq'::regclass) NOT NULL,
jrn_def_id integer NOT NULL,
od_name text NOT NULL,
od_item integer NOT NULL,
@ -413,26 +497,26 @@ CREATE TABLE op_predef (
od_direct boolean NOT NULL,
od_description text
);
CREATE TABLE op_predef_detail (
opd_id integer DEFAULT nextval('op_predef_detail_opd_id_seq'::regclass) NOT NULL,
CREATE TABLE public.op_predef_detail (
opd_id integer DEFAULT nextval('public.op_predef_detail_opd_id_seq'::regclass) NOT NULL,
od_id integer NOT NULL,
opd_poste text NOT NULL,
opd_amount numeric(20,4),
opd_tva_id integer,
opd_tva_id text,
opd_quantity numeric(20,4),
opd_debit boolean NOT NULL,
opd_tva_amount numeric(20,4),
opd_comment text,
opd_qc boolean
);
CREATE TABLE operation_analytique (
oa_id integer DEFAULT nextval('historique_analytique_ha_id_seq'::regclass) NOT NULL,
CREATE TABLE public.operation_analytique (
oa_id integer DEFAULT nextval('public.historique_analytique_ha_id_seq'::regclass) NOT NULL,
po_id integer NOT NULL,
oa_amount numeric(20,4) NOT NULL,
oa_description text,
oa_debit boolean DEFAULT true NOT NULL,
j_id integer,
oa_group integer DEFAULT nextval('s_oa_group'::regclass) NOT NULL,
oa_group integer DEFAULT nextval('public.s_oa_group'::regclass) NOT NULL,
oa_date date NOT NULL,
oa_row integer,
oa_jrnx_id_source bigint,
@ -440,54 +524,101 @@ CREATE TABLE operation_analytique (
f_id bigint,
CONSTRAINT operation_analytique_oa_amount_check CHECK ((oa_amount >= (0)::numeric))
);
CREATE TABLE parameter (
CREATE TABLE public.operation_currency (
id bigint NOT NULL,
oc_amount numeric(20,6) NOT NULL,
oc_vat_amount numeric(20,6) DEFAULT 0,
oc_price_unit numeric(20,6),
j_id bigint NOT NULL
);
CREATE TABLE public.operation_exercice (
oe_id bigint NOT NULL,
oe_date date,
oe_type text NOT NULL,
oe_text text,
oe_dossier_id integer NOT NULL,
oe_exercice integer NOT NULL,
jr_internal text,
oe_transfer_date timestamp without time zone,
tech_user text,
tech_date timestamp without time zone DEFAULT now(),
CONSTRAINT operation_exercice_oe_type_check CHECK (((oe_type = 'opening'::text) OR (oe_type = 'closing'::text)))
);
CREATE TABLE public.operation_exercice_detail (
oed_id bigint NOT NULL,
oe_id bigint NOT NULL,
oed_poste public.account_type,
oed_qcode text,
oed_label text,
oed_amount numeric(20,4),
oed_debit boolean
);
CREATE TABLE public.operation_tag (
opt_id bigint NOT NULL,
jrn_id bigint,
tag_id integer
);
CREATE TABLE public.parameter (
pr_id text NOT NULL,
pr_value text
);
CREATE TABLE parm_code (
CREATE TABLE public.parameter_extra (
id integer NOT NULL,
pe_code text,
pe_label text,
pe_value text
);
CREATE TABLE public.parm_appearance (
a_code text NOT NULL,
a_value text NOT NULL
);
CREATE TABLE public.parm_code (
p_code text NOT NULL,
p_value text,
p_comment text
);
CREATE TABLE parm_money (
CREATE TABLE public.parm_money (
pm_id integer DEFAULT nextval(('s_currency'::text)::regclass),
pm_code character(3) NOT NULL,
pm_rate numeric(20,4)
);
CREATE TABLE parm_periode (
CREATE TABLE public.parm_periode (
p_id integer DEFAULT nextval(('s_periode'::text)::regclass) NOT NULL,
p_start date NOT NULL,
p_end date NOT NULL,
p_exercice text DEFAULT to_char(now(), 'YYYY'::text) NOT NULL,
p_closed boolean DEFAULT false,
p_central boolean DEFAULT false,
p_exercice_label text NOT NULL,
CONSTRAINT parm_periode_check CHECK ((p_end >= p_start))
);
CREATE TABLE parm_poste (
p_value account_type NOT NULL,
CREATE TABLE public.parm_poste (
p_value public.account_type NOT NULL,
p_type text NOT NULL
);
CREATE TABLE plan_analytique (
pa_id integer DEFAULT nextval('plan_analytique_pa_id_seq'::regclass) NOT NULL,
CREATE TABLE public.plan_analytique (
pa_id integer DEFAULT nextval('public.plan_analytique_pa_id_seq'::regclass) NOT NULL,
pa_name text DEFAULT 'Sans Nom'::text NOT NULL,
pa_description text
);
CREATE TABLE poste_analytique (
po_id integer DEFAULT nextval('poste_analytique_po_id_seq'::regclass) NOT NULL,
CREATE TABLE public.poste_analytique (
po_id integer DEFAULT nextval('public.poste_analytique_po_id_seq'::regclass) NOT NULL,
po_name text NOT NULL,
pa_id integer NOT NULL,
po_amount numeric(20,4) DEFAULT 0.0 NOT NULL,
po_description text,
ga_id character varying(10)
ga_id character varying(10),
po_state integer DEFAULT 1 NOT NULL
);
CREATE TABLE profile (
CREATE TABLE public.profile (
p_name text NOT NULL,
p_id integer NOT NULL,
p_desc text,
with_calc boolean DEFAULT true,
with_direct_form boolean DEFAULT true
with_direct_form boolean DEFAULT true,
with_search_card integer
);
CREATE TABLE profile_menu (
CREATE TABLE public.profile_menu (
pm_id integer NOT NULL,
me_code text,
me_code_dep text,
@ -497,30 +628,38 @@ CREATE TABLE profile_menu (
pm_default integer,
pm_id_dep bigint
);
CREATE TABLE profile_menu_type (
CREATE TABLE public.profile_menu_type (
pm_type text NOT NULL,
pm_desc text
);
CREATE TABLE profile_sec_repository (
CREATE TABLE public.profile_mobile (
pmo_id integer NOT NULL,
me_code text NOT NULL,
pmo_order integer NOT NULL,
p_id integer NOT NULL,
pmo_default character(1) DEFAULT '1'::bpchar
);
CREATE TABLE public.profile_sec_repository (
ur_id bigint NOT NULL,
p_id bigint,
r_id bigint,
ur_right character(1),
CONSTRAINT user_sec_profile_ur_right_check CHECK ((ur_right = ANY (ARRAY['R'::bpchar, 'W'::bpchar])))
);
CREATE TABLE profile_user (
CREATE TABLE public.profile_user (
user_name text NOT NULL,
pu_id integer NOT NULL,
p_id integer
);
CREATE TABLE quant_fin (
CREATE TABLE public.quant_fin (
qf_id bigint NOT NULL,
qf_bank bigint,
jr_id bigint,
qf_other bigint,
qf_amount numeric(20,4) DEFAULT 0
qf_amount numeric(20,4) DEFAULT 0,
j_id bigint
);
CREATE TABLE quant_purchase (
CREATE TABLE public.quant_purchase (
qp_id integer DEFAULT nextval(('s_quantity'::text)::regclass) NOT NULL,
qp_internal text,
j_id integer NOT NULL,
@ -538,7 +677,7 @@ CREATE TABLE quant_purchase (
qp_vat_sided numeric(20,4) DEFAULT 0.0,
qp_unit numeric(20,4) DEFAULT 0
);
CREATE TABLE quant_sold (
CREATE TABLE public.quant_sold (
qs_id integer DEFAULT nextval(('s_quantity'::text)::regclass) NOT NULL,
qs_internal text,
qs_fiche integer NOT NULL,
@ -552,7 +691,7 @@ CREATE TABLE quant_sold (
qs_vat_sided numeric(20,4) DEFAULT 0.0,
qs_unit numeric(20,4) DEFAULT 0
);
CREATE TABLE stock_change (
CREATE TABLE public.stock_change (
c_id bigint NOT NULL,
c_comment text,
c_date date,
@ -560,7 +699,7 @@ CREATE TABLE stock_change (
r_id bigint,
tech_date time without time zone DEFAULT now() NOT NULL
);
CREATE TABLE stock_goods (
CREATE TABLE public.stock_goods (
sg_id integer DEFAULT nextval(('s_stock_goods'::text)::regclass) NOT NULL,
j_id integer,
f_id integer,
@ -576,7 +715,7 @@ CREATE TABLE stock_goods (
c_id bigint,
CONSTRAINT stock_goods_sg_type CHECK (((sg_type = 'c'::bpchar) OR (sg_type = 'd'::bpchar)))
);
CREATE TABLE stock_repository (
CREATE TABLE public.stock_repository (
r_id bigint NOT NULL,
r_name text,
r_adress text,
@ -584,27 +723,32 @@ CREATE TABLE stock_repository (
r_city text,
r_phone text
);
CREATE TABLE tags (
CREATE TABLE public.tag_group (
tg_id bigint NOT NULL,
tg_name character varying NOT NULL
);
CREATE TABLE public.tags (
t_id integer NOT NULL,
t_tag text NOT NULL,
t_description text,
t_actif character(1) DEFAULT 'Y'::bpchar,
t_color integer DEFAULT 1,
CONSTRAINT tags_check CHECK ((t_actif = ANY (ARRAY['N'::bpchar, 'Y'::bpchar])))
);
CREATE TABLE tmp_pcmn (
pcm_val account_type NOT NULL,
CREATE TABLE public.tmp_pcmn (
pcm_val public.account_type NOT NULL,
pcm_lib text,
pcm_val_parent account_type DEFAULT 0,
pcm_val_parent public.account_type DEFAULT 0,
pcm_type text,
id bigint DEFAULT nextval('tmp_pcmn_id_seq'::regclass) NOT NULL,
id bigint DEFAULT nextval('public.tmp_pcmn_id_seq'::regclass) NOT NULL,
pcm_direct_use character varying(1) DEFAULT 'Y'::character varying NOT NULL,
CONSTRAINT pcm_direct_use_ck CHECK (((pcm_direct_use)::text = ANY ((ARRAY['Y'::character varying, 'N'::character varying])::text[])))
CONSTRAINT pcm_direct_use_ck CHECK (((pcm_direct_use)::text = ANY (ARRAY[('Y'::character varying)::text, ('N'::character varying)::text])))
);
CREATE TABLE tmp_stockgood (
CREATE TABLE public.tmp_stockgood (
s_id bigint NOT NULL,
s_date timestamp without time zone DEFAULT now()
);
CREATE TABLE tmp_stockgood_detail (
CREATE TABLE public.tmp_stockgood_detail (
d_id bigint NOT NULL,
s_id bigint,
sg_code text,
@ -613,8 +757,8 @@ CREATE TABLE tmp_stockgood_detail (
r_id bigint,
f_id bigint
);
CREATE TABLE todo_list (
tl_id integer DEFAULT nextval('todo_list_tl_id_seq'::regclass) NOT NULL,
CREATE TABLE public.todo_list (
tl_id integer DEFAULT nextval('public.todo_list_tl_id_seq'::regclass) NOT NULL,
tl_date date NOT NULL,
tl_title text NOT NULL,
tl_desc text,
@ -622,31 +766,37 @@ CREATE TABLE todo_list (
is_public character(1) DEFAULT 'N'::bpchar NOT NULL,
CONSTRAINT ck_is_public CHECK ((is_public = ANY (ARRAY['Y'::bpchar, 'N'::bpchar])))
);
CREATE TABLE todo_list_shared (
CREATE TABLE public.todo_list_shared (
id integer NOT NULL,
todo_list_id integer NOT NULL,
use_login text NOT NULL
);
CREATE TABLE tool_uos (
uos_value bigint DEFAULT nextval('uos_pk_seq'::regclass) NOT NULL
CREATE TABLE public.tool_uos (
uos_value bigint DEFAULT nextval('public.uos_pk_seq'::regclass) NOT NULL
);
CREATE TABLE tva_rate (
tva_id integer DEFAULT nextval('s_tva'::regclass) NOT NULL,
CREATE TABLE public.tva_rate (
tva_id integer DEFAULT nextval('public.s_tva'::regclass) NOT NULL,
tva_label text NOT NULL,
tva_rate numeric(8,4) DEFAULT 0.0 NOT NULL,
tva_comment text,
tva_poste text,
tva_both_side integer DEFAULT 0
tva_both_side integer DEFAULT 0,
tva_payment_sale character(1) DEFAULT 'O'::bpchar,
tva_payment_purchase character(1) DEFAULT 'O'::bpchar,
tva_code text NOT NULL,
CONSTRAINT tva_code_number_check CHECK ((tva_code !~ '^([0-9]+)$'::text)),
CONSTRAINT tva_rate_purchase_check CHECK ((tva_payment_purchase = ANY (ARRAY['O'::bpchar, 'P'::bpchar]))),
CONSTRAINT tva_rate_sale_check CHECK ((tva_payment_sale = ANY (ARRAY['O'::bpchar, 'P'::bpchar])))
);
CREATE TABLE user_active_security (
CREATE TABLE public.user_active_security (
id integer NOT NULL,
us_login text NOT NULL,
us_ledger character varying(1) NOT NULL,
us_action character varying(1) NOT NULL,
CONSTRAINT user_active_security_action_check CHECK (((us_action)::text = ANY ((ARRAY['Y'::character varying, 'N'::character varying])::text[]))),
CONSTRAINT user_active_security_ledger_check CHECK (((us_ledger)::text = ANY ((ARRAY['Y'::character varying, 'N'::character varying])::text[])))
CONSTRAINT user_active_security_action_check CHECK (((us_action)::text = ANY (ARRAY[('Y'::character varying)::text, ('N'::character varying)::text]))),
CONSTRAINT user_active_security_ledger_check CHECK (((us_ledger)::text = ANY (ARRAY[('Y'::character varying)::text, ('N'::character varying)::text])))
);
CREATE TABLE user_filter (
CREATE TABLE public.user_filter (
id bigint NOT NULL,
login text,
nb_jrn integer,
@ -663,32 +813,36 @@ CREATE TABLE user_filter (
ledger_type character varying(5),
all_ledger integer,
filter_name text NOT NULL,
unpaid character varying
operation_filter text NOT NULL,
uf_tag text,
uf_tag_option integer,
uf_currency_code integer,
tva_id_search integer
);
CREATE TABLE user_local_pref (
CREATE TABLE public.user_local_pref (
user_id text NOT NULL,
parameter_type text NOT NULL,
parameter_value text
);
CREATE TABLE user_sec_act (
CREATE TABLE public.user_sec_act (
ua_id integer DEFAULT nextval(('s_user_act'::text)::regclass) NOT NULL,
ua_login text,
ua_act_id integer
);
CREATE TABLE user_sec_action_profile (
CREATE TABLE public.user_sec_action_profile (
ua_id bigint NOT NULL,
p_id bigint,
p_granted bigint,
ua_right character(1),
CONSTRAINT user_sec_action_profile_ua_right_check CHECK ((ua_right = ANY (ARRAY['R'::bpchar, 'W'::bpchar])))
CONSTRAINT user_sec_action_profile_ua_right_check CHECK ((ua_right = ANY (ARRAY['R'::bpchar, 'W'::bpchar, 'X'::bpchar, 'O'::bpchar])))
);
CREATE TABLE user_sec_jrn (
CREATE TABLE public.user_sec_jrn (
uj_id integer DEFAULT nextval(('s_user_jrn'::text)::regclass) NOT NULL,
uj_login text,
uj_jrn_id integer,
uj_priv text
);
CREATE TABLE version (
CREATE TABLE public.version (
val integer NOT NULL,
v_description text,
v_date timestamp without time zone DEFAULT now()

View file

@ -1,32 +1,725 @@
CREATE VIEW v_all_menu AS
SELECT pm.me_code, pm.pm_id, pm.me_code_dep, pm.p_order, pm.p_type_display, p.p_name, p.p_desc, mr.me_menu, mr.me_file, mr.me_url, mr.me_parameter, mr.me_javascript, mr.me_type, pm.p_id, mr.me_description FROM ((profile_menu pm JOIN profile p ON ((p.p_id = pm.p_id))) JOIN menu_ref mr USING (me_code)) ORDER BY pm.p_order;
CREATE VIEW vw_fiche_attr AS
SELECT a.f_id, a.fd_id, a.ad_value AS vw_name, k.ad_value AS vw_first_name, b.ad_value AS vw_sell, c.ad_value AS vw_buy, d.ad_value AS tva_code, tva_rate.tva_id, tva_rate.tva_rate, tva_rate.tva_label, e.ad_value AS vw_addr, f.ad_value AS vw_cp, j.ad_value AS quick_code, h.ad_value AS vw_description, i.ad_value AS tva_num, fiche_def.frd_id, l.ad_value AS accounting FROM (((((((((((((SELECT fiche.f_id, fiche.fd_id, fiche_detail.ad_value FROM (fiche LEFT JOIN fiche_detail USING (f_id)) WHERE (fiche_detail.ad_id = 1)) a LEFT JOIN (SELECT fiche_detail.f_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 6)) b ON ((a.f_id = b.f_id))) LEFT JOIN (SELECT fiche_detail.f_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 7)) c ON ((a.f_id = c.f_id))) LEFT JOIN (SELECT fiche_detail.f_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 2)) d ON ((a.f_id = d.f_id))) LEFT JOIN (SELECT fiche_detail.f_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 14)) e ON ((a.f_id = e.f_id))) LEFT JOIN (SELECT fiche_detail.f_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 15)) f ON ((a.f_id = f.f_id))) LEFT JOIN (SELECT fiche_detail.f_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 23)) j ON ((a.f_id = j.f_id))) LEFT JOIN (SELECT fiche_detail.f_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 9)) h ON ((a.f_id = h.f_id))) LEFT JOIN (SELECT fiche_detail.f_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 13)) i ON ((a.f_id = i.f_id))) LEFT JOIN (SELECT fiche_detail.f_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 32)) k ON ((a.f_id = k.f_id))) LEFT JOIN tva_rate ON ((d.ad_value = (tva_rate.tva_id)::text))) JOIN fiche_def USING (fd_id)) LEFT JOIN (SELECT fiche_detail.f_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 5)) l ON ((a.f_id = l.f_id)));
CREATE VIEW vw_fiche_name AS
SELECT fiche_detail.f_id, fiche_detail.ad_value AS name FROM fiche_detail WHERE (fiche_detail.ad_id = 1);
CREATE VIEW v_detail_purchase AS
WITH m AS (SELECT sum(quant_purchase.qp_price) AS htva, sum(quant_purchase.qp_vat) AS tot_vat, sum(quant_purchase.qp_vat_sided) AS tot_tva_np, jrn.jr_id FROM ((quant_purchase JOIN jrnx USING (j_id)) JOIN jrn ON ((jrnx.j_grpt = jrn.jr_grpt_id))) GROUP BY jrn.jr_id) SELECT jrn.jr_id, jrn.jr_date, jrn.jr_date_paid, jrn.jr_ech, jrn.jr_tech_per, jrn.jr_comment, jrn.jr_pj_number, jrn.jr_internal, jrn.jr_def_id, jrnx.j_poste, jrnx.j_text, jrnx.j_qcode, quant_purchase.qp_fiche AS item_card, a.name AS item_name, quant_purchase.qp_supplier, b.vw_name AS tiers_name, b.quick_code, tva_rate.tva_label, tva_rate.tva_comment, tva_rate.tva_both_side, quant_purchase.qp_vat_sided AS vat_sided, quant_purchase.qp_vat_code AS vat_code, quant_purchase.qp_vat AS vat, quant_purchase.qp_price AS price, quant_purchase.qp_quantite AS quantity, (quant_purchase.qp_price / quant_purchase.qp_quantite) AS price_per_unit, quant_purchase.qp_nd_amount AS non_ded_amount, quant_purchase.qp_nd_tva AS non_ded_tva, quant_purchase.qp_nd_tva_recup AS non_ded_tva_recup, m.htva, m.tot_vat, m.tot_tva_np FROM ((((((jrn JOIN jrnx ON ((jrn.jr_grpt_id = jrnx.j_grpt))) JOIN quant_purchase USING (j_id)) JOIN vw_fiche_name a ON ((quant_purchase.qp_fiche = a.f_id))) JOIN vw_fiche_attr b ON ((quant_purchase.qp_supplier = b.f_id))) JOIN tva_rate ON ((quant_purchase.qp_vat_code = tva_rate.tva_id))) JOIN m ON ((m.jr_id = jrn.jr_id)));
CREATE VIEW v_detail_sale AS
WITH m AS (SELECT sum(quant_sold.qs_price) AS htva, sum(quant_sold.qs_vat) AS tot_vat, sum(quant_sold.qs_vat_sided) AS tot_tva_np, jrn.jr_id FROM ((quant_sold JOIN jrnx USING (j_id)) JOIN jrn ON ((jrnx.j_grpt = jrn.jr_grpt_id))) GROUP BY jrn.jr_id) SELECT jrn.jr_id, jrn.jr_date, jrn.jr_date_paid, jrn.jr_ech, jrn.jr_tech_per, jrn.jr_comment, jrn.jr_pj_number, jrn.jr_internal, jrn.jr_def_id, jrnx.j_poste, jrnx.j_text, jrnx.j_qcode, quant_sold.qs_fiche AS item_card, a.name AS item_name, quant_sold.qs_client, b.vw_name AS tiers_name, b.quick_code, tva_rate.tva_label, tva_rate.tva_comment, tva_rate.tva_both_side, quant_sold.qs_vat_sided AS vat_sided, quant_sold.qs_vat_code AS vat_code, quant_sold.qs_vat AS vat, quant_sold.qs_price AS price, quant_sold.qs_quantite AS quantity, (quant_sold.qs_price / quant_sold.qs_quantite) AS price_per_unit, m.htva, m.tot_vat, m.tot_tva_np FROM ((((((jrn JOIN jrnx ON ((jrn.jr_grpt_id = jrnx.j_grpt))) JOIN quant_sold USING (j_id)) JOIN vw_fiche_name a ON ((quant_sold.qs_fiche = a.f_id))) JOIN vw_fiche_attr b ON ((quant_sold.qs_client = b.f_id))) JOIN tva_rate ON ((quant_sold.qs_vat_code = tva_rate.tva_id))) JOIN m ON ((m.jr_id = jrn.jr_id)));
CREATE VIEW v_menu_dependency AS
WITH t_menu AS (SELECT pm.pm_id, mr.me_menu, pm.me_code, pm.me_code_dep, pm.p_type_display, mr.me_file, mr.me_javascript, mr.me_description, mr.me_description_etendue, p.p_id FROM ((profile_menu pm JOIN profile p ON ((p.p_id = pm.p_id))) JOIN menu_ref mr USING (me_code))) SELECT DISTINCT ((COALESCE((v3.me_code || '/'::text), ''::text) || COALESCE(v2.me_code, ''::text)) || CASE WHEN (v2.me_code IS NULL) THEN COALESCE(v1.me_code, ''::text) WHEN (v2.me_code IS NOT NULL) THEN COALESCE(('/'::text || v1.me_code), ''::text) ELSE NULL::text END) AS code, v1.pm_id, v1.me_code, v1.me_description, v1.me_description_etendue, v1.me_file, ('> '::text || v1.me_menu) AS v1menu, CASE WHEN (v2.pm_id IS NOT NULL) THEN v2.pm_id WHEN (v3.pm_id IS NOT NULL) THEN v3.pm_id ELSE NULL::integer END AS higher_dep, CASE WHEN (COALESCE(v3.me_menu, ''::text) <> ''::text) THEN (' > '::text || v2.me_menu) ELSE v2.me_menu END AS v2menu, v3.me_menu AS v3menu, v3.p_type_display, COALESCE(v1.me_javascript, COALESCE(v2.me_javascript, v3.me_javascript)) AS javascript, v1.p_id, v2.p_id AS v2pid, v3.p_id AS v3pid FROM ((t_menu v1 LEFT JOIN t_menu v2 ON ((v1.me_code_dep = v2.me_code))) LEFT JOIN t_menu v3 ON ((v2.me_code_dep = v3.me_code))) WHERE (((COALESCE(v2.p_id, v1.p_id) = v1.p_id) AND (COALESCE(v3.p_id, v1.p_id) = v1.p_id)) AND (v1.p_type_display <> 'P'::text)) ORDER BY v1.pm_id;
CREATE VIEW v_menu_description AS
WITH t_menu AS (SELECT pm.pm_id, pm.pm_id_dep, pm.p_id, mr.me_menu, pm.me_code, pm.me_code_dep, pm.p_type_display, pu.user_name, mr.me_file, mr.me_javascript, mr.me_description, mr.me_description_etendue FROM (((profile_menu pm JOIN profile_user pu ON ((pu.p_id = pm.p_id))) JOIN profile p ON ((p.p_id = pm.p_id))) JOIN menu_ref mr USING (me_code))) SELECT DISTINCT ((COALESCE((v3.me_code || '/'::text), ''::text) || COALESCE(v2.me_code, ''::text)) || CASE WHEN (v2.me_code IS NULL) THEN COALESCE(v1.me_code, ''::text) WHEN (v2.me_code IS NOT NULL) THEN COALESCE(('/'::text || v1.me_code), ''::text) ELSE NULL::text END) AS code, v1.me_code, v1.me_description, v1.me_description_etendue, v1.me_file, v1.user_name, ('> '::text || v1.me_menu) AS v1menu, CASE WHEN (COALESCE(v3.me_menu, ''::text) <> ''::text) THEN (' > '::text || v2.me_menu) ELSE v2.me_menu END AS v2menu, v3.me_menu AS v3menu, v3.p_type_display, COALESCE(v1.me_javascript, COALESCE(v2.me_javascript, v3.me_javascript)) AS javascript, v1.pm_id, v1.pm_id_dep, v1.p_id FROM ((t_menu v1 LEFT JOIN t_menu v2 ON ((v1.me_code_dep = v2.me_code))) LEFT JOIN t_menu v3 ON ((v2.me_code_dep = v3.me_code))) WHERE ((v1.p_type_display <> 'P'::text) AND ((COALESCE(v1.me_file, ''::text) <> ''::text) OR (COALESCE(v1.me_javascript, ''::text) <> ''::text)));
CREATE VIEW v_menu_description_favori AS
WITH t_menu AS (SELECT mr.me_menu, pm.me_code, pm.me_code_dep, pm.p_type_display, pu.user_name, mr.me_file, mr.me_javascript, mr.me_description, mr.me_description_etendue FROM (((profile_menu pm JOIN profile_user pu ON ((pu.p_id = pm.p_id))) JOIN profile p ON ((p.p_id = pm.p_id))) JOIN menu_ref mr USING (me_code))) SELECT DISTINCT ((COALESCE((v3.me_code || '/'::text), ''::text) || COALESCE(v2.me_code, ''::text)) || CASE WHEN (v2.me_code IS NULL) THEN COALESCE(v1.me_code, ''::text) WHEN (v2.me_code IS NOT NULL) THEN COALESCE(('/'::text || v1.me_code), ''::text) ELSE NULL::text END) AS code, v1.me_code, v1.me_description, v1.me_description_etendue, v1.me_file, v1.user_name, ('> '::text || v1.me_menu) AS v1menu, CASE WHEN (COALESCE(v3.me_menu, ''::text) <> ''::text) THEN (' > '::text || v2.me_menu) ELSE v2.me_menu END AS v2menu, v3.me_menu AS v3menu, v3.p_type_display, COALESCE(v1.me_javascript, COALESCE(v2.me_javascript, v3.me_javascript)) AS javascript FROM ((t_menu v1 LEFT JOIN t_menu v2 ON ((v1.me_code_dep = v2.me_code))) LEFT JOIN t_menu v3 ON ((v2.me_code_dep = v3.me_code))) WHERE (v1.p_type_display <> 'P'::text);
CREATE VIEW v_menu_profile AS
WITH t_menu AS (SELECT pm.pm_id, pm.pm_id_dep, pm.me_code, pm.me_code_dep, pm.p_type_display, pm.p_id FROM (profile_menu pm JOIN profile p ON ((p.p_id = pm.p_id)))) SELECT DISTINCT ((COALESCE((v3.me_code || '/'::text), ''::text) || COALESCE(v2.me_code, ''::text)) || CASE WHEN (v2.me_code IS NULL) THEN COALESCE(v1.me_code, ''::text) WHEN (v2.me_code IS NOT NULL) THEN COALESCE(('/'::text || v1.me_code), ''::text) ELSE NULL::text END) AS code, v3.p_type_display, COALESCE(v3.pm_id, 0) AS pm_id_v3, COALESCE(v2.pm_id, 0) AS pm_id_v2, v1.pm_id AS pm_id_v1, v1.p_id FROM ((t_menu v1 LEFT JOIN t_menu v2 ON ((v1.pm_id_dep = v2.pm_id))) LEFT JOIN t_menu v3 ON ((v2.pm_id_dep = v3.pm_id))) WHERE (v1.p_type_display <> 'P'::text);
CREATE VIEW v_quant_detail AS
WITH quant AS (SELECT quant_purchase.j_id, quant_purchase.qp_fiche AS fiche_id, quant_purchase.qp_supplier AS tiers, quant_purchase.qp_vat AS vat_amount, quant_purchase.qp_price AS price, quant_purchase.qp_vat_code AS vat_code, quant_purchase.qp_dep_priv AS dep_priv, quant_purchase.qp_nd_tva AS nd_tva, quant_purchase.qp_nd_tva_recup AS nd_tva_recup, quant_purchase.qp_nd_amount AS nd_amount, quant_purchase.qp_vat_sided AS vat_sided FROM quant_purchase UNION ALL SELECT quant_sold.j_id, quant_sold.qs_fiche, quant_sold.qs_client, quant_sold.qs_vat, quant_sold.qs_price, quant_sold.qs_vat_code, 0, 0, 0, 0, quant_sold.qs_vat_sided FROM quant_sold) SELECT jrn.jr_id, quant.tiers, jrn_def.jrn_def_name, jrn_def.jrn_def_type, vw_fiche_name.name, jrn.jr_comment, jrn.jr_montant, sum(quant.price) AS price, quant.vat_code, sum(quant.vat_amount) AS vat_amount, sum(quant.dep_priv) AS dep_priv, sum(quant.nd_tva) AS nd_tva, sum(quant.nd_tva_recup) AS nd_tva_recup, sum(quant.nd_amount) AS nd_amount, quant.vat_sided, tva_rate.tva_label FROM (((((jrn JOIN jrnx ON ((jrnx.j_grpt = jrn.jr_grpt_id))) JOIN quant USING (j_id)) LEFT JOIN vw_fiche_name ON ((quant.tiers = vw_fiche_name.f_id))) JOIN jrn_def ON ((jrn_def.jrn_def_id = jrn.jr_def_id))) JOIN tva_rate ON ((tva_rate.tva_id = quant.vat_code))) GROUP BY jrn.jr_id, quant.tiers, jrn.jr_comment, jrn.jr_montant, quant.vat_code, quant.vat_sided, vw_fiche_name.name, jrn_def.jrn_def_name, jrn_def.jrn_def_type, tva_rate.tva_label;
CREATE VIEW v_tva_rate AS
SELECT tva_rate.tva_id, tva_rate.tva_rate, tva_rate.tva_label, tva_rate.tva_comment, split_part(tva_rate.tva_poste, ','::text, 1) AS tva_purchase, split_part(tva_rate.tva_poste, ','::text, 2) AS tva_sale, tva_rate.tva_both_side FROM tva_rate;
CREATE VIEW vw_client AS
SELECT fiche.f_id, a1.ad_value AS name, a.ad_value AS quick_code, b.ad_value AS tva_num, c.ad_value AS poste_comptable, d.ad_value AS rue, e.ad_value AS code_postal, f.ad_value AS pays, g.ad_value AS telephone, h.ad_value AS email FROM (((((((((((fiche JOIN fiche_def USING (fd_id)) JOIN fiche_def_ref USING (frd_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 1)) a1 USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 13)) b USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 23)) a USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 5)) c USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 14)) d USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 15)) e USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 16)) f USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 17)) g USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 18)) h USING (f_id)) WHERE (fiche_def_ref.frd_id = 9);
CREATE VIEW vw_fiche_def AS
SELECT jnt_fic_attr.fd_id, jnt_fic_attr.ad_id, attr_def.ad_text, fiche_def.fd_class_base, fiche_def.fd_label, fiche_def.fd_create_account, fiche_def.frd_id FROM ((fiche_def JOIN jnt_fic_attr USING (fd_id)) JOIN attr_def ON ((attr_def.ad_id = jnt_fic_attr.ad_id)));
CREATE VIEW vw_fiche_min AS
SELECT attr_min.frd_id, attr_min.ad_id, attr_def.ad_text, fiche_def_ref.frd_text, fiche_def_ref.frd_class_base FROM ((attr_min JOIN attr_def USING (ad_id)) JOIN fiche_def_ref USING (frd_id));
CREATE VIEW vw_poste_qcode AS
SELECT c.f_id, a.ad_value AS j_poste, b.ad_value AS j_qcode FROM ((fiche c LEFT JOIN (SELECT fiche_detail.f_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 5)) a USING (f_id)) LEFT JOIN (SELECT fiche_detail.f_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 23)) b USING (f_id));
CREATE VIEW vw_supplier AS
SELECT fiche.f_id, a1.ad_value AS name, a.ad_value AS quick_code, b.ad_value AS tva_num, c.ad_value AS poste_comptable, d.ad_value AS rue, e.ad_value AS code_postal, f.ad_value AS pays, g.ad_value AS telephone, h.ad_value AS email FROM (((((((((((fiche JOIN fiche_def USING (fd_id)) JOIN fiche_def_ref USING (frd_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 1)) a1 USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 13)) b USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 23)) a USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 5)) c USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 14)) d USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 15)) e USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 16)) f USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 17)) g USING (f_id)) LEFT JOIN (SELECT fiche_detail.jft_id, fiche_detail.f_id, fiche_detail.ad_id, fiche_detail.ad_value FROM fiche_detail WHERE (fiche_detail.ad_id = 18)) h USING (f_id)) WHERE (fiche_def_ref.frd_id = 8);
CREATE VIEW public.v_all_account_currency AS
SELECT sum(oc.oc_amount) AS sum_oc_amount,
sum(oc.oc_vat_amount) AS sum_oc_vat_amount,
x.j_poste,
x.j_id
FROM ((public.quant_fin q1
JOIN ( SELECT j1.j_id,
j.jr_id,
j1.f_id,
j1.j_poste
FROM (public.jrnx j1
JOIN public.jrn j ON ((j1.j_grpt = j.jr_grpt_id)))) x ON ((q1.jr_id = x.jr_id)))
JOIN public.operation_currency oc ON ((oc.j_id = q1.j_id)))
GROUP BY x.j_poste, x.j_id
UNION ALL
SELECT sum(oc.oc_amount) AS sum_oc_amount,
sum(oc.oc_vat_amount) AS sum_oc_vat_amount,
x.j_poste,
x.j_id
FROM ((public.quant_purchase q1
JOIN ( SELECT j1.j_id,
j.jr_id,
j1.f_id,
j1.j_poste,
j.jr_internal
FROM (public.jrnx j1
JOIN public.jrn j ON ((j1.j_grpt = j.jr_grpt_id)))) x ON (((q1.qp_internal = x.jr_internal) AND ((x.f_id = q1.qp_fiche) OR (x.f_id = q1.qp_supplier)))))
JOIN public.operation_currency oc ON ((oc.j_id = q1.j_id)))
GROUP BY x.j_poste, x.j_id
UNION ALL
SELECT sum(oc.oc_amount) AS sum_oc_amount,
sum(oc.oc_vat_amount) AS sum_oc_vat_amount,
x.j_poste,
x.j_id
FROM ((public.quant_sold q1
JOIN ( SELECT j1.j_id,
j.jr_id,
j1.f_id,
j1.j_poste,
j.jr_internal
FROM (public.jrnx j1
JOIN public.jrn j ON ((j1.j_grpt = j.jr_grpt_id)))) x ON (((q1.qs_internal = x.jr_internal) AND ((x.f_id = q1.qs_fiche) OR (x.f_id = q1.qs_client)))))
JOIN public.operation_currency oc ON ((oc.j_id = q1.j_id)))
GROUP BY x.j_poste, x.j_id;
CREATE VIEW public.v_all_card_currency AS
SELECT sum(operation_currency.oc_amount) AS sum_oc_amount,
sum(operation_currency.oc_vat_amount) AS sum_oc_vat_amount,
jrnx.f_id,
operation_currency.j_id
FROM (public.operation_currency
JOIN public.jrnx USING (j_id))
GROUP BY jrnx.f_id, operation_currency.j_id;
CREATE VIEW public.v_all_menu AS
SELECT pm.me_code,
pm.pm_id,
pm.me_code_dep,
pm.p_order,
pm.p_type_display,
p.p_name,
p.p_desc,
mr.me_menu,
mr.me_file,
mr.me_url,
mr.me_parameter,
mr.me_javascript,
mr.me_type,
pm.p_id,
mr.me_description
FROM ((public.profile_menu pm
JOIN public.profile p ON ((p.p_id = pm.p_id)))
JOIN public.menu_ref mr USING (me_code))
ORDER BY pm.p_order;
CREATE VIEW public.v_contact AS
WITH contact_data AS (
SELECT f.f_id,
f.f_enable,
f.fd_id
FROM (public.fiche f
JOIN public.fiche_def fd ON ((f.fd_id = fd.fd_id)))
WHERE (fd.frd_id = 16)
)
SELECT cd.f_id,
cd.f_enable,
( SELECT fiche_detail.ad_value
FROM public.fiche_detail
WHERE ((fiche_detail.ad_id = 32) AND (fiche_detail.f_id = cd.f_id))) AS contact_fname,
( SELECT fiche_detail.ad_value
FROM public.fiche_detail
WHERE ((fiche_detail.ad_id = 1) AND (fiche_detail.f_id = cd.f_id))) AS contact_name,
( SELECT fiche_detail.ad_value
FROM public.fiche_detail
WHERE ((fiche_detail.ad_id = 23) AND (fiche_detail.f_id = cd.f_id))) AS contact_qcode,
( SELECT fiche_detail.ad_value
FROM public.fiche_detail
WHERE ((fiche_detail.ad_id = 25) AND (fiche_detail.f_id = cd.f_id))) AS contact_company,
( SELECT fiche_detail.ad_value
FROM public.fiche_detail
WHERE ((fiche_detail.ad_id = 27) AND (fiche_detail.f_id = cd.f_id))) AS contact_mobile,
( SELECT fiche_detail.ad_value
FROM public.fiche_detail
WHERE ((fiche_detail.ad_id = 17) AND (fiche_detail.f_id = cd.f_id))) AS contact_phone,
( SELECT fiche_detail.ad_value
FROM public.fiche_detail
WHERE ((fiche_detail.ad_id = 18) AND (fiche_detail.f_id = cd.f_id))) AS contact_email,
( SELECT fiche_detail.ad_value
FROM public.fiche_detail
WHERE ((fiche_detail.ad_id = 26) AND (fiche_detail.f_id = cd.f_id))) AS contact_fax,
cd.fd_id AS card_category
FROM contact_data cd;
CREATE VIEW public.v_currency_last_value AS
WITH recent_rate AS (
SELECT currency_history.currency_id,
max(currency_history.ch_from) AS rc_from
FROM public.currency_history
GROUP BY currency_history.currency_id
)
SELECT cr1.id AS currency_id,
cr1.cr_name,
cr1.cr_code_iso,
ch1.id AS currency_history_id,
ch1.ch_value,
to_char((recent_rate.rc_from)::timestamp with time zone, 'DD.MM.YYYY'::text) AS str_from
FROM ((public.currency cr1
JOIN recent_rate ON ((recent_rate.currency_id = cr1.id)))
JOIN public.currency_history ch1 ON (((recent_rate.currency_id = ch1.currency_id) AND (recent_rate.rc_from = ch1.ch_from))));
CREATE VIEW public.vw_fiche_attr AS
SELECT a.f_id,
a.fd_id,
a.ad_value AS vw_name,
k.ad_value AS vw_first_name,
b.ad_value AS vw_sell,
c.ad_value AS vw_buy,
d.ad_value AS tva_code,
tva_rate.tva_id,
tva_rate.tva_rate,
tva_rate.tva_label,
e.ad_value AS vw_addr,
f.ad_value AS vw_cp,
j.ad_value AS quick_code,
h.ad_value AS vw_description,
i.ad_value AS tva_num,
fiche_def.frd_id,
l.ad_value AS accounting,
a.f_enable
FROM ((((((((((((( SELECT fiche.f_id,
fiche.fd_id,
fiche.f_enable,
fiche_detail.ad_value
FROM (public.fiche
LEFT JOIN public.fiche_detail USING (f_id))
WHERE (fiche_detail.ad_id = 1)) a
LEFT JOIN ( SELECT fiche_detail.f_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 6)) b ON ((a.f_id = b.f_id)))
LEFT JOIN ( SELECT fiche_detail.f_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 7)) c ON ((a.f_id = c.f_id)))
LEFT JOIN ( SELECT fiche_detail.f_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 2)) d ON ((a.f_id = d.f_id)))
LEFT JOIN ( SELECT fiche_detail.f_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 14)) e ON ((a.f_id = e.f_id)))
LEFT JOIN ( SELECT fiche_detail.f_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 15)) f ON ((a.f_id = f.f_id)))
LEFT JOIN ( SELECT fiche_detail.f_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 23)) j ON ((a.f_id = j.f_id)))
LEFT JOIN ( SELECT fiche_detail.f_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 9)) h ON ((a.f_id = h.f_id)))
LEFT JOIN ( SELECT fiche_detail.f_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 13)) i ON ((a.f_id = i.f_id)))
LEFT JOIN ( SELECT fiche_detail.f_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 32)) k ON ((a.f_id = k.f_id)))
LEFT JOIN public.tva_rate ON ((d.ad_value = (tva_rate.tva_id)::text)))
JOIN public.fiche_def USING (fd_id))
LEFT JOIN ( SELECT fiche_detail.f_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 5)) l ON ((a.f_id = l.f_id)));
CREATE VIEW public.vw_fiche_name AS
SELECT fiche_detail.f_id,
fiche_detail.ad_value AS name
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 1);
CREATE VIEW public.v_detail_purchase AS
WITH m AS (
SELECT sum(quant_purchase_1.qp_price) AS htva,
sum(quant_purchase_1.qp_vat) AS tot_vat,
sum(quant_purchase_1.qp_vat_sided) AS tot_tva_np,
jrn_1.jr_id
FROM ((public.quant_purchase quant_purchase_1
JOIN public.jrnx jrnx_1 USING (j_id))
JOIN public.jrn jrn_1 ON ((jrnx_1.j_grpt = jrn_1.jr_grpt_id)))
GROUP BY jrn_1.jr_id
), other_tax AS (
SELECT jrnx_1.j_grpt,
sum(
CASE
WHEN (jrnx_1.j_debit IS FALSE) THEN ((0)::numeric - jrnx_1.j_montant)
ELSE jrnx_1.j_montant
END) AS other_tax_amount
FROM (public.jrnx jrnx_1
JOIN public.jrn_tax USING (j_id))
GROUP BY jrnx_1.j_grpt
)
SELECT jrn.jr_id,
jrn.jr_date,
jrn.jr_date_paid,
jrn.jr_ech,
jrn.jr_tech_per,
jrn.jr_comment,
jrn.jr_pj_number,
jrn.jr_internal,
jrn.jr_def_id,
jrnx.j_poste,
jrnx.j_text,
jrnx.j_qcode,
jrn.jr_rapt,
quant_purchase.qp_fiche AS item_card,
a.name AS item_name,
quant_purchase.qp_supplier,
b.vw_name AS tiers_name,
b.quick_code,
tva_rate.tva_label,
tva_rate.tva_comment,
tva_rate.tva_both_side,
quant_purchase.qp_vat_sided AS vat_sided,
quant_purchase.qp_vat_code AS vat_code,
quant_purchase.qp_vat AS vat,
quant_purchase.qp_price AS price,
quant_purchase.qp_quantite AS quantity,
(quant_purchase.qp_price / quant_purchase.qp_quantite) AS price_per_unit,
quant_purchase.qp_nd_amount AS non_ded_amount,
quant_purchase.qp_nd_tva AS non_ded_tva,
quant_purchase.qp_nd_tva_recup AS non_ded_tva_recup,
m.htva,
m.tot_vat,
m.tot_tva_np,
ot.other_tax_amount,
oc.oc_amount,
oc.oc_vat_amount,
( SELECT currency.cr_code_iso
FROM public.currency
WHERE (jrn.currency_id = currency.id)) AS cr_code_iso
FROM ((((((((public.jrn
JOIN public.jrnx ON ((jrn.jr_grpt_id = jrnx.j_grpt)))
JOIN public.quant_purchase USING (j_id))
JOIN public.vw_fiche_name a ON ((quant_purchase.qp_fiche = a.f_id)))
JOIN public.vw_fiche_attr b ON ((quant_purchase.qp_supplier = b.f_id)))
LEFT JOIN public.tva_rate ON ((quant_purchase.qp_vat_code = tva_rate.tva_id)))
JOIN m ON ((m.jr_id = jrn.jr_id)))
LEFT JOIN public.operation_currency oc ON ((oc.j_id = jrnx.j_id)))
LEFT JOIN other_tax ot ON ((ot.j_grpt = jrn.jr_grpt_id)));
CREATE VIEW public.v_detail_sale AS
WITH m AS (
SELECT sum(quant_sold_1.qs_price) AS htva,
sum(quant_sold_1.qs_vat) AS tot_vat,
sum(quant_sold_1.qs_vat_sided) AS tot_tva_np,
jrn_1.jr_id
FROM ((public.quant_sold quant_sold_1
JOIN public.jrnx jrnx_1 USING (j_id))
JOIN public.jrn jrn_1 ON ((jrnx_1.j_grpt = jrn_1.jr_grpt_id)))
GROUP BY jrn_1.jr_id
), other_tax AS (
SELECT jrnx_1.j_grpt,
sum(
CASE
WHEN (jrnx_1.j_debit IS TRUE) THEN ((0)::numeric - jrnx_1.j_montant)
ELSE jrnx_1.j_montant
END) AS other_tax_amount
FROM (public.jrnx jrnx_1
JOIN public.jrn_tax USING (j_id))
GROUP BY jrnx_1.j_grpt
)
SELECT jrn.jr_id,
jrn.jr_date,
jrn.jr_date_paid,
jrn.jr_ech,
jrn.jr_tech_per,
jrn.jr_comment,
jrn.jr_pj_number,
jrn.jr_internal,
jrn.jr_def_id,
jrnx.j_poste,
jrnx.j_text,
jrnx.j_qcode,
jrn.jr_rapt,
quant_sold.qs_fiche AS item_card,
a.name AS item_name,
quant_sold.qs_client,
b.vw_name AS tiers_name,
b.quick_code,
tva_rate.tva_label,
tva_rate.tva_comment,
tva_rate.tva_both_side,
quant_sold.qs_vat_sided AS vat_sided,
quant_sold.qs_vat_code AS vat_code,
quant_sold.qs_vat AS vat,
quant_sold.qs_price AS price,
quant_sold.qs_quantite AS quantity,
(quant_sold.qs_price / quant_sold.qs_quantite) AS price_per_unit,
m.htva,
m.tot_vat,
m.tot_tva_np,
ot.other_tax_amount,
oc.oc_amount,
oc.oc_vat_amount,
( SELECT currency.cr_code_iso
FROM public.currency
WHERE (jrn.currency_id = currency.id)) AS cr_code_iso
FROM ((((((((public.jrn
JOIN public.jrnx ON ((jrn.jr_grpt_id = jrnx.j_grpt)))
JOIN public.quant_sold USING (j_id))
JOIN public.vw_fiche_name a ON ((quant_sold.qs_fiche = a.f_id)))
JOIN public.vw_fiche_attr b ON ((quant_sold.qs_client = b.f_id)))
LEFT JOIN public.tva_rate ON ((quant_sold.qs_vat_code = tva_rate.tva_id)))
JOIN m ON ((m.jr_id = jrn.jr_id)))
LEFT JOIN public.operation_currency oc ON ((oc.j_id = jrnx.j_id)))
LEFT JOIN other_tax ot ON ((ot.j_grpt = jrn.jr_grpt_id)));
CREATE VIEW public.v_menu_dependency AS
WITH t_menu AS (
SELECT pm.pm_id,
mr.me_menu,
pm.me_code,
pm.me_code_dep,
pm.p_type_display,
mr.me_file,
mr.me_javascript,
mr.me_description,
mr.me_description_etendue,
p.p_id
FROM ((public.profile_menu pm
JOIN public.profile p ON ((p.p_id = pm.p_id)))
JOIN public.menu_ref mr USING (me_code))
)
SELECT DISTINCT ((COALESCE((v3.me_code || '/'::text), ''::text) || COALESCE(v2.me_code, ''::text)) ||
CASE
WHEN (v2.me_code IS NULL) THEN COALESCE(v1.me_code, ''::text)
WHEN (v2.me_code IS NOT NULL) THEN COALESCE(('/'::text || v1.me_code), ''::text)
ELSE NULL::text
END) AS code,
v1.pm_id,
v1.me_code,
v1.me_description,
v1.me_description_etendue,
v1.me_file,
('> '::text || v1.me_menu) AS v1menu,
CASE
WHEN (v2.pm_id IS NOT NULL) THEN v2.pm_id
WHEN (v3.pm_id IS NOT NULL) THEN v3.pm_id
ELSE NULL::integer
END AS higher_dep,
CASE
WHEN (COALESCE(v3.me_menu, ''::text) <> ''::text) THEN (' > '::text || v2.me_menu)
ELSE v2.me_menu
END AS v2menu,
v3.me_menu AS v3menu,
v3.p_type_display,
COALESCE(v1.me_javascript, COALESCE(v2.me_javascript, v3.me_javascript)) AS javascript,
v1.p_id,
v2.p_id AS v2pid,
v3.p_id AS v3pid
FROM ((t_menu v1
LEFT JOIN t_menu v2 ON ((v1.me_code_dep = v2.me_code)))
LEFT JOIN t_menu v3 ON ((v2.me_code_dep = v3.me_code)))
WHERE ((COALESCE(v2.p_id, v1.p_id) = v1.p_id) AND (COALESCE(v3.p_id, v1.p_id) = v1.p_id) AND (v1.p_type_display <> 'P'::text))
ORDER BY v1.pm_id;
CREATE VIEW public.v_menu_description AS
WITH t_menu AS (
SELECT pm.pm_id,
pm.pm_id_dep,
pm.p_id,
mr.me_menu,
pm.me_code,
pm.me_code_dep,
pm.p_type_display,
pu.user_name,
mr.me_file,
mr.me_javascript,
mr.me_description,
mr.me_description_etendue
FROM (((public.profile_menu pm
JOIN public.profile_user pu ON ((pu.p_id = pm.p_id)))
JOIN public.profile p ON ((p.p_id = pm.p_id)))
JOIN public.menu_ref mr USING (me_code))
)
SELECT DISTINCT ((COALESCE((v3.me_code || '/'::text), ''::text) || COALESCE(v2.me_code, ''::text)) ||
CASE
WHEN (v2.me_code IS NULL) THEN COALESCE(v1.me_code, ''::text)
WHEN (v2.me_code IS NOT NULL) THEN COALESCE(('/'::text || v1.me_code), ''::text)
ELSE NULL::text
END) AS code,
v1.me_code,
v1.me_description,
v1.me_description_etendue,
v1.me_file,
v1.user_name,
('> '::text || v1.me_menu) AS v1menu,
CASE
WHEN (COALESCE(v3.me_menu, ''::text) <> ''::text) THEN (' > '::text || v2.me_menu)
ELSE v2.me_menu
END AS v2menu,
v3.me_menu AS v3menu,
v3.p_type_display,
COALESCE(v1.me_javascript, COALESCE(v2.me_javascript, v3.me_javascript)) AS javascript,
v1.pm_id,
v1.pm_id_dep,
v1.p_id
FROM ((t_menu v1
LEFT JOIN t_menu v2 ON ((v1.me_code_dep = v2.me_code)))
LEFT JOIN t_menu v3 ON ((v2.me_code_dep = v3.me_code)))
WHERE ((v1.p_type_display <> 'P'::text) AND ((COALESCE(v1.me_file, ''::text) <> ''::text) OR (COALESCE(v1.me_javascript, ''::text) <> ''::text)));
CREATE VIEW public.v_menu_description_favori AS
WITH t_menu AS (
SELECT mr.me_menu,
pm.me_code,
pm.me_code_dep,
pm.p_type_display,
pu.user_name,
mr.me_file,
mr.me_javascript,
mr.me_description,
mr.me_description_etendue
FROM (((public.profile_menu pm
JOIN public.profile_user pu ON ((pu.p_id = pm.p_id)))
JOIN public.profile p ON ((p.p_id = pm.p_id)))
JOIN public.menu_ref mr USING (me_code))
)
SELECT DISTINCT ((COALESCE((v3.me_code || '/'::text), ''::text) || COALESCE(v2.me_code, ''::text)) ||
CASE
WHEN (v2.me_code IS NULL) THEN COALESCE(v1.me_code, ''::text)
WHEN (v2.me_code IS NOT NULL) THEN COALESCE(('/'::text || v1.me_code), ''::text)
ELSE NULL::text
END) AS code,
v1.me_code,
v1.me_description,
v1.me_description_etendue,
v1.me_file,
v1.user_name,
('> '::text || v1.me_menu) AS v1menu,
CASE
WHEN (COALESCE(v3.me_menu, ''::text) <> ''::text) THEN (' > '::text || v2.me_menu)
ELSE v2.me_menu
END AS v2menu,
v3.me_menu AS v3menu,
v3.p_type_display,
COALESCE(v1.me_javascript, COALESCE(v2.me_javascript, v3.me_javascript)) AS javascript
FROM ((t_menu v1
LEFT JOIN t_menu v2 ON ((v1.me_code_dep = v2.me_code)))
LEFT JOIN t_menu v3 ON ((v2.me_code_dep = v3.me_code)))
WHERE (v1.p_type_display <> 'P'::text);
CREATE VIEW public.v_menu_profile AS
WITH t_menu AS (
SELECT pm.pm_id,
pm.pm_id_dep,
pm.me_code,
pm.me_code_dep,
pm.p_type_display,
pm.p_id
FROM (public.profile_menu pm
JOIN public.profile p ON ((p.p_id = pm.p_id)))
)
SELECT DISTINCT ((COALESCE((v3.me_code || '/'::text), ''::text) || COALESCE(v2.me_code, ''::text)) ||
CASE
WHEN (v2.me_code IS NULL) THEN COALESCE(v1.me_code, ''::text)
WHEN (v2.me_code IS NOT NULL) THEN COALESCE(('/'::text || v1.me_code), ''::text)
ELSE NULL::text
END) AS code,
v3.p_type_display,
COALESCE(v3.pm_id, 0) AS pm_id_v3,
COALESCE(v2.pm_id, 0) AS pm_id_v2,
v1.pm_id AS pm_id_v1,
v1.p_id
FROM ((t_menu v1
LEFT JOIN t_menu v2 ON ((v1.pm_id_dep = v2.pm_id)))
LEFT JOIN t_menu v3 ON ((v2.pm_id_dep = v3.pm_id)))
WHERE (v1.p_type_display <> 'P'::text);
CREATE VIEW public.v_quant_detail AS
WITH quant AS (
SELECT quant_purchase.j_id,
quant_purchase.qp_fiche AS fiche_id,
quant_purchase.qp_supplier AS tiers,
quant_purchase.qp_vat AS vat_amount,
quant_purchase.qp_price AS price,
quant_purchase.qp_vat_code AS vat_code,
quant_purchase.qp_dep_priv AS dep_priv,
quant_purchase.qp_nd_tva AS nd_tva,
quant_purchase.qp_nd_tva_recup AS nd_tva_recup,
quant_purchase.qp_nd_amount AS nd_amount,
quant_purchase.qp_vat_sided AS vat_sided
FROM public.quant_purchase
UNION ALL
SELECT quant_sold.j_id,
quant_sold.qs_fiche,
quant_sold.qs_client,
quant_sold.qs_vat,
quant_sold.qs_price,
quant_sold.qs_vat_code,
0,
0,
0,
0,
quant_sold.qs_vat_sided
FROM public.quant_sold
)
SELECT jrn.jr_id,
quant.tiers,
jrn_def.jrn_def_name,
jrn_def.jrn_def_type,
vw_fiche_name.name,
jrn.jr_comment,
jrn.jr_montant,
sum(quant.price) AS price,
quant.vat_code,
sum(quant.vat_amount) AS vat_amount,
sum(quant.dep_priv) AS dep_priv,
sum(quant.nd_tva) AS nd_tva,
sum(quant.nd_tva_recup) AS nd_tva_recup,
sum(quant.nd_amount) AS nd_amount,
quant.vat_sided,
tva_rate.tva_label
FROM (((((public.jrn
JOIN public.jrnx ON ((jrnx.j_grpt = jrn.jr_grpt_id)))
JOIN quant USING (j_id))
LEFT JOIN public.vw_fiche_name ON ((quant.tiers = vw_fiche_name.f_id)))
JOIN public.jrn_def ON ((jrn_def.jrn_def_id = jrn.jr_def_id)))
JOIN public.tva_rate ON ((tva_rate.tva_id = quant.vat_code)))
GROUP BY jrn.jr_id, quant.tiers, jrn.jr_comment, jrn.jr_montant, quant.vat_code, quant.vat_sided, vw_fiche_name.name, jrn_def.jrn_def_name, jrn_def.jrn_def_type, tva_rate.tva_label;
CREATE VIEW public.v_tva_rate AS
SELECT tva_rate.tva_id,
tva_rate.tva_rate,
tva_rate.tva_code,
tva_rate.tva_label,
tva_rate.tva_comment,
split_part(tva_rate.tva_poste, ','::text, 1) AS tva_purchase,
split_part(tva_rate.tva_poste, ','::text, 2) AS tva_sale,
tva_rate.tva_both_side,
tva_rate.tva_payment_purchase,
tva_rate.tva_payment_sale
FROM public.tva_rate;
CREATE VIEW public.vw_client AS
SELECT fiche.f_id,
a1.ad_value AS name,
a.ad_value AS quick_code,
b.ad_value AS tva_num,
c.ad_value AS poste_comptable,
d.ad_value AS rue,
e.ad_value AS code_postal,
f.ad_value AS pays,
g.ad_value AS telephone,
h.ad_value AS email
FROM (((((((((((public.fiche
JOIN public.fiche_def USING (fd_id))
JOIN public.fiche_def_ref USING (frd_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 1)) a1 USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 13)) b USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 23)) a USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 5)) c USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 14)) d USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 15)) e USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 16)) f USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 17)) g USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 18)) h USING (f_id))
WHERE (fiche_def_ref.frd_id = 9);
CREATE VIEW public.vw_fiche_def AS
SELECT jnt_fic_attr.fd_id,
jnt_fic_attr.ad_id,
attr_def.ad_text,
fiche_def.fd_class_base,
fiche_def.fd_label,
fiche_def.fd_create_account,
fiche_def.frd_id
FROM ((public.fiche_def
JOIN public.jnt_fic_attr USING (fd_id))
JOIN public.attr_def ON ((attr_def.ad_id = jnt_fic_attr.ad_id)));
CREATE VIEW public.vw_fiche_min AS
SELECT attr_min.frd_id,
attr_min.ad_id,
attr_def.ad_text,
fiche_def_ref.frd_text,
fiche_def_ref.frd_class_base
FROM ((public.attr_min
JOIN public.attr_def USING (ad_id))
JOIN public.fiche_def_ref USING (frd_id));
CREATE VIEW public.vw_poste_qcode AS
SELECT c.f_id,
a.ad_value AS j_poste,
b.ad_value AS j_qcode
FROM ((public.fiche c
LEFT JOIN ( SELECT fiche_detail.f_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 5)) a USING (f_id))
LEFT JOIN ( SELECT fiche_detail.f_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 23)) b USING (f_id));
CREATE VIEW public.vw_supplier AS
SELECT fiche.f_id,
a1.ad_value AS name,
a.ad_value AS quick_code,
b.ad_value AS tva_num,
c.ad_value AS poste_comptable,
d.ad_value AS rue,
e.ad_value AS code_postal,
f.ad_value AS pays,
g.ad_value AS telephone,
h.ad_value AS email
FROM (((((((((((public.fiche
JOIN public.fiche_def USING (fd_id))
JOIN public.fiche_def_ref USING (frd_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 1)) a1 USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 13)) b USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 23)) a USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 5)) c USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 14)) d USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 15)) e USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 16)) f USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 17)) g USING (f_id))
LEFT JOIN ( SELECT fiche_detail.jft_id,
fiche_detail.f_id,
fiche_detail.ad_id,
fiche_detail.ad_value
FROM public.fiche_detail
WHERE (fiche_detail.ad_id = 18)) h USING (f_id))
WHERE (fiche_def_ref.frd_id = 8);

File diff suppressed because it is too large Load diff

View file

@ -6,38 +6,13 @@
export TEMPLATE=${DOMAIN}mod2
psql -X $TEMPLATE -c "delete from user_local_pref"
psql -X $TEMPLATE -c "delete from user_local_pref"
pg_dump -O -U dany -s $TEMPLATE|grep -v "COMMENT ON SCHEMA public IS 'Standard public schema';" |sed "/^--/d" > schema.sql
sed -i -e "/COMMENT ON EXTENSION/d" schema.sql
sed -i -e "/CREATE EXTENSION/d" schema.sql
awk '/SEQUENCE/,/;/ { print $0;}' < schema.sql > sequence.sql
awk '/CREATE DOMAIN/,/;/ { print $0;}' < schema.sql > table.sql
awk '/CREATE TABLE/,/;/ { print $0;}' < schema.sql >> table.sql
awk '/CREATE VIEW/,/;/ { print $0;}' < schema.sql > view.sql
awk '/INDEX/,/;/ { print $0;}' < schema.sql > index.sql
(
echo " SET client_encoding = 'utf8';"
echo " SET check_function_bodies = false;"
echo " SET client_min_messages = warning;"
echo "SET search_path = public, pg_catalog;"
)> constraint.sql
awk '/ALTER TABLE/,/;/ { print $0;}' < schema.sql >> constraint.sql
awk '/CREATE TRIGGER/,/;/ { print $0;}' < schema.sql >> constraint.sql
awk '/COMMENT ON CONSTRAINT/,/;/ { print $0;}' < schema.sql >> constraint.sql
awk '/COMMENT ON TRIGGER/,/;/ { print $0;}' < schema.sql >> constraint.sql
# function in XML
## awk 'BEGIN{print "<PROCEDURES>";} /CREATE FUNCTION/,/\$\$;/ { if (/CREATE FUNCTION/) {print "<procedure>";} if (/\$\$;/) {print "</procedure>";} print $0;} END { print "</PROCEDURES>";}' < schema.sql
awk '/CREATE FUNCTION/,/\$\$;/ { print $0;}' < schema.sql > function.sql
awk '/COMMENT/,/;/ {print $0;}' < schema.sql > comment.sql
sed -i -e "/REVOKE /d" -e "/GRANT /d" -e "/ALTER TABLE.*/d" -e "/ADD CONSTRAINT/d" -e "/CREATE PROCEDURAL/d" -e "/CREATE TRIGGER/d" -e "/COMMENT ON CONSTRAINT/d" -e "/COMMENT ON TRIGGER/d" schema.sql
grep setval schema.sql >> sequence.sql
echo "set search_path = public,comptaproc,pg_catalog ;" > data.sql
pg_dump -O -U dany --data-only --column-inserts -O ${TEMPLATE}|sed "/^--/d" | sed -e "/SET search_path/d" >> data.sql