rel8100
Merge branch 'master' into entreprise
This commit is contained in:
commit
3867346d28
297 changed files with 22561 additions and 7418 deletions
7
include/sql/patch/ac-upgrade18.sql
Normal file
7
include/sql/patch/ac-upgrade18.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
begin;
|
||||
|
||||
ALTER TABLE public.audit_connect DROP CONSTRAINT valid_state ;
|
||||
ALTER TABLE public.audit_connect ADD CONSTRAINT valid_state CHECK ( ac_state in ('FAIL','SUCCESS','AUDIT','ADMIN'));
|
||||
|
||||
select upgrade_repo(19);
|
||||
commit;
|
||||
188
include/sql/patch/upgrade144.sql
Normal file
188
include/sql/patch/upgrade144.sql
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
begin;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION comptaproc.jrn_check_periode()
|
||||
RETURNS trigger
|
||||
AS $function$
|
||||
declare
|
||||
bClosed bool;
|
||||
str_status text;
|
||||
ljr_tech_per jrn.jr_tech_per%TYPE;
|
||||
ljr_def_id jrn.jr_def_id%TYPE;
|
||||
lreturn jrn%ROWTYPE;
|
||||
begin
|
||||
if TG_OP='UPDATE' then
|
||||
ljr_tech_per :=OLD.jr_tech_per ;
|
||||
NEW.jr_tech_per := comptaproc.find_periode(to_char(NEW.jr_date,'DD.MM.YYYY'));
|
||||
ljr_def_id :=OLD.jr_def_id;
|
||||
lreturn :=NEW;
|
||||
if NEW.jr_date = OLD.jr_date then
|
||||
return NEW;
|
||||
end if;
|
||||
if comptaproc.is_closed(NEW.jr_tech_per,NEW.jr_def_id) = true then
|
||||
raise exception 'Periode fermee';
|
||||
end if;
|
||||
end if;
|
||||
|
||||
if TG_OP='INSERT' then
|
||||
NEW.jr_tech_per := comptaproc.find_periode(to_char(NEW.jr_date,'DD.MM.YYYY'));
|
||||
ljr_tech_per :=NEW.jr_tech_per ;
|
||||
ljr_def_id :=NEW.jr_def_id;
|
||||
lreturn :=NEW;
|
||||
end if;
|
||||
|
||||
if TG_OP='DELETE' then
|
||||
ljr_tech_per :=OLD.jr_tech_per;
|
||||
ljr_def_id :=OLD.jr_def_id;
|
||||
lreturn :=OLD;
|
||||
end if;
|
||||
|
||||
if comptaproc.is_closed (ljr_tech_per,ljr_def_id) = true then
|
||||
raise exception 'Periode fermee';
|
||||
end if;
|
||||
|
||||
return lreturn;
|
||||
end;
|
||||
$function$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
|
||||
-- New right for action : delete
|
||||
ALTER TABLE public.user_sec_action_profile drop CONSTRAINT user_sec_action_profile_ua_right_check;
|
||||
ALTER TABLE public.user_sec_action_profile ADD CONSTRAINT user_sec_action_profile_ua_right_check check (ua_right in ('R','W','X','O'));
|
||||
|
||||
-- extension CRM : definition des options qu'on peut ajouter
|
||||
-- public.document_option_ref definition
|
||||
|
||||
-- Drop table
|
||||
|
||||
-- DROP TABLE public.document_option_ref;
|
||||
|
||||
|
||||
CREATE TABLE public.contact_option_ref (
|
||||
cor_id bigserial NOT NULL,
|
||||
cor_label varchar NOT NULL, -- Label de l'option
|
||||
cor_type int4 NOT NULL DEFAULT 0, -- 0 text , 1 select ,2 nombre , 3 date
|
||||
cor_value_select varchar NULL, -- Select values
|
||||
CONSTRAINT contact_option_ref_pk PRIMARY KEY (cor_id)
|
||||
);
|
||||
COMMENT ON TABLE public.contact_option_ref IS 'Option for the contact';
|
||||
|
||||
-- Column comments
|
||||
|
||||
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';
|
||||
|
||||
|
||||
|
||||
|
||||
-- renomme le menu
|
||||
update menu_ref set me_description = 'Configuration des documents dans le suivi' ,me_file='cfg_action.inc.php' ,
|
||||
me_description_etendue ='Vous permet d''ajouter de nouveaux type de documents pour le suivi (bordereau de livraison, devis..)',me_code='CFGACTION',
|
||||
me_menu='Document Suivi'
|
||||
where me_code='CFGCATDOC';
|
||||
|
||||
|
||||
-- ajoute un menu pour les options de contacts
|
||||
INSERT INTO public.menu_ref (me_code,me_menu,me_file,me_url,me_description,me_parameter,me_javascript,me_type,me_description_etendue) VALUES
|
||||
('CFGCONTACT','Contact','contact_option_ref.inc.php',NULL,'Configure les options pours les contacts multiples',NULL,NULL,'ME',NULL)
|
||||
;
|
||||
|
||||
INSERT INTO public.profile_menu (me_code,me_code_dep,p_id,p_order,p_type_display,pm_default,pm_id_dep) VALUES
|
||||
('CFGCONTACT','DIVPARM',1,85,'E',0,56)
|
||||
;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE public.tag_group (
|
||||
tg_id bigserial NOT NULL,
|
||||
tg_name varchar NOT NULL
|
||||
);
|
||||
COMMENT ON TABLE public.tag_group IS 'Group of tags';
|
||||
|
||||
-- Column comments
|
||||
|
||||
COMMENT ON COLUMN public.tag_group.tg_name IS 'Nom du groupe';
|
||||
ALTER TABLE public.tag_group ADD CONSTRAINT tag_group_pk PRIMARY KEY (tg_id);
|
||||
|
||||
-- public.jnt_tag_group_tag definition
|
||||
|
||||
-- Drop table
|
||||
|
||||
-- DROP TABLE public.jnt_tag_group_tag;
|
||||
|
||||
CREATE TABLE public.jnt_tag_group_tag (
|
||||
tag_group_id int8 NOT NULL,
|
||||
tag_id int8 NOT NULL,
|
||||
jt_id serial NOT NULL,
|
||||
CONSTRAINT jnt_tag_group_tag_pkey PRIMARY KEY (jt_id),
|
||||
CONSTRAINT jnt_tag_group_tag_un UNIQUE (tag_id, tag_group_id)
|
||||
);
|
||||
COMMENT ON TABLE public.jnt_tag_group_tag IS 'Many to Many table betwwen tag and tag group';
|
||||
|
||||
|
||||
-- public.jnt_tag_group_tag foreign keys
|
||||
|
||||
ALTER TABLE public.jnt_tag_group_tag ADD CONSTRAINT jnt_tag_group_tag_fk FOREIGN KEY (tag_id) REFERENCES tags(t_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
ALTER TABLE public.jnt_tag_group_tag ADD CONSTRAINT jnt_tag_group_tag_fk_1 FOREIGN KEY (tag_group_id) REFERENCES tag_group(tg_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
|
||||
insert into action values (1025,'Ajout d''étiquette','followup','TAGADD');
|
||||
|
||||
-- public.action_person_option definition
|
||||
|
||||
-- Drop table
|
||||
|
||||
-- DROP TABLE public.action_person_option;
|
||||
|
||||
CREATE TABLE public.action_person_option (
|
||||
ap_id bigserial NOT NULL,
|
||||
ap_value varchar NULL, -- Value of the option
|
||||
contact_option_ref_id int8 NOT NULL, -- FK to contact_option
|
||||
action_person_id int8 NOT NULL, -- FK to action_person
|
||||
CONSTRAINT action_person_option_pk PRIMARY KEY (ap_id)
|
||||
);
|
||||
COMMENT ON TABLE public.action_person_option IS 'option for each contact';
|
||||
|
||||
-- Column comments
|
||||
|
||||
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';
|
||||
|
||||
|
||||
-- public.action_person_option foreign keys
|
||||
|
||||
ALTER TABLE public.action_person_option ADD CONSTRAINT action_person_option_fk FOREIGN KEY (action_person_id) REFERENCES action_person(ap_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
ALTER TABLE public.action_person_option ADD CONSTRAINT contact_option_ref_fk FOREIGN KEY (contact_option_ref_id) REFERENCES contact_option_ref(cor_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
-- public.document_option definition
|
||||
|
||||
-- Drop table
|
||||
|
||||
-- DROP TABLE public.document_option;
|
||||
|
||||
CREATE TABLE public.document_option (
|
||||
do_id bigserial NOT NULL,
|
||||
do_code varchar(20) NOT NULL, -- Code of the option to add
|
||||
document_type_id int8 NULL, -- FK to document_type
|
||||
do_enable int4 NOT NULL DEFAULT 1, -- 1 the option is activated, 0 is inativated
|
||||
CONSTRAINT document_option_ref_pk PRIMARY KEY (do_id),
|
||||
CONSTRAINT document_option_un UNIQUE (do_code, document_type_id)
|
||||
);
|
||||
COMMENT ON TABLE public.document_option IS 'Reference of option addable to document_type';
|
||||
|
||||
-- Column comments
|
||||
|
||||
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';
|
||||
|
||||
|
||||
-- public.document_option foreign keys
|
||||
|
||||
ALTER TABLE public.document_option ADD CONSTRAINT document_option_ref_fk FOREIGN KEY (document_type_id) REFERENCES document_type(dt_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||
|
||||
insert into version (val,v_description) values (145,'Improve tags , add multiple contacts with options');
|
||||
commit;
|
||||
33
include/sql/patch/upgrade145.sql
Normal file
33
include/sql/patch/upgrade145.sql
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
begin;
|
||||
|
||||
ALTER TABLE public.document_option ADD do_option varchar NULL;
|
||||
COMMENT ON COLUMN public.document_option.do_option IS 'Option for the detail';
|
||||
|
||||
alter table attr_def add column ad_search_followup int;
|
||||
alter table attr_def alter column ad_search_followup set default 1;
|
||||
update attr_def set ad_search_followup=1;
|
||||
comment on column attr_def.ad_search_followup is '1 : search available from followup , 0 : search not available in followup';
|
||||
|
||||
|
||||
create table jnt_document_option_contact
|
||||
(
|
||||
jdoc_id bigserial primary key,
|
||||
jdoc_enable int not null,
|
||||
document_type_id bigint references document_type (dt_id) on delete cascade on update cascade,
|
||||
contact_option_ref_id bigint references contact_option_ref(cor_id) on delete cascade on update cascade
|
||||
);
|
||||
ALTER TABLE public.jnt_document_option_contact ADD CONSTRAINT jnt_document_option_contact_un UNIQUE (document_type_id,contact_option_ref_id);
|
||||
ALTER TABLE public.jnt_document_option_contact ADD CONSTRAINT jnt_document_option_contact_check CHECK (jdoc_enable in (0,1));
|
||||
|
||||
insert into attr_def(ad_id,ad_text,ad_type,ad_size) values (54,'Actif','check','1');
|
||||
insert into attr_min(frd_id,ad_id) select frd_id , 54 from fiche_def_ref ;
|
||||
insert into jnt_fic_attr (fd_id,ad_id,jnt_order) select fd_id,54,30 from fiche_def;
|
||||
insert into fiche_detail (f_id,ad_id,ad_value) select f_id, 54,1 from fiche_detail where ad_id=1 and f_id not in (select f_id from fiche_detail where ad_id=54);
|
||||
update fiche_detail set ad_value='1' where ad_id=54;
|
||||
insert into menu_ref(me_code,me_menu,me_file,me_type) values ('CSV:FollowUpContactOption','Export action suivi','export_follow_up_contact_csv.php','PR');
|
||||
insert into profile_menu (me_code,p_id,p_type_display) select 'CSV:FollowUpContactOption',p_id,'P' from profile;
|
||||
|
||||
|
||||
|
||||
insert into version (val,v_description) values (146,'Export CSV for Multiple card, contact option by document type');
|
||||
commit;
|
||||
7
include/sql/patch/upgrade146.sql
Normal file
7
include/sql/patch/upgrade146.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
begin;
|
||||
|
||||
ALTER TABLE public.action_person drop CONSTRAINT action_gestion_ag_id_fk2 ;
|
||||
ALTER TABLE public.action_person ADD CONSTRAINT action_gestion_ag_id_fk2 FOREIGN KEY (ag_id) REFERENCES action_gestion(ag_id) on delete cascade on update cascade;
|
||||
|
||||
insert into version (val,v_description) values (147,'Cascade delete on action_gestion');
|
||||
commit;
|
||||
22
include/sql/patch/upgrade147.sql
Normal file
22
include/sql/patch/upgrade147.sql
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
begin;
|
||||
INSERT INTO public.document_option (do_code, document_type_id, do_enable, do_option) select 'detail_operation', dt_id, 1,
|
||||
case when dt_id in (2,3,4,5,21) then 'VEN' else 'ACH' end do_option
|
||||
from document_type
|
||||
where
|
||||
not exists (select 1 from document_option where document_type_id in (2,3,4,5,10,20) and do_code='detail_operation' )
|
||||
and dt_id in (2,3,4,5,10,20,21);
|
||||
|
||||
|
||||
INSERT INTO public.document_option (do_code, document_type_id, do_enable, do_option) select 'contact_multiple',dt_id , 1, NULL
|
||||
from document_type where
|
||||
not exists (select 1 from document_option where document_type_id in (2,3,4,5,10,20) and do_code='contact_multiple' )
|
||||
and dt_id in (2,3,4,5,10,20) ;
|
||||
|
||||
INSERT INTO public.document_option (do_code, document_type_id, do_enable, do_option) select 'make_invoice', dt_id, 1, NULL
|
||||
from document_type
|
||||
where
|
||||
not exists (select 1 from document_option where document_type_id in (2,4) and do_code='make_invoice' )
|
||||
and dt_id in (2,4);
|
||||
|
||||
insert into version (val,v_description) values (148,'Default values for document_option');
|
||||
commit;
|
||||
6
include/sql/patch/upgrade148.sql
Normal file
6
include/sql/patch/upgrade148.sql
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
begin;
|
||||
INSERT INTO public.document_option (do_code, document_type_id, do_enable, do_option) select 'followup_comment', dt_id, 1, 'SOME_FIXED'
|
||||
from document_type ;
|
||||
|
||||
insert into version (val,v_description) values (149,'Default values for document_option,comment on followup');
|
||||
commit;
|
||||
6
include/sql/patch/upgrade149.sql
Normal file
6
include/sql/patch/upgrade149.sql
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
begin;
|
||||
update menu_ref set me_code='CFGOPT1',me_menu='Option Fiches', me_description = 'configure les options pour les fiches dans le suivi' where me_code='CFGCONTACT';
|
||||
update bookmark set b_action=replace(b_action,'CFGCONTACT','CFGOPT1');
|
||||
|
||||
insert into version (val,v_description) values (150,'Change name default action');
|
||||
commit;
|
||||
15
include/sql/patch/upgrade150.sql
Normal file
15
include/sql/patch/upgrade150.sql
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
begin;
|
||||
alter table tags add column t_color int;
|
||||
alter table tags alter t_color set default 1;
|
||||
update tags set t_color=1;
|
||||
create table operation_tag (opt_id bigserial primary key, jrn_id bigint , tag_id int);
|
||||
alter table operation_tag add constraint opt_jrnx foreign key (jrn_id) references jrn (jr_id) on update cascade on delete cascade;
|
||||
alter table operation_tag add constraint opt_tag_id foreign key (tag_id) references tags (t_id) on update cascade on delete cascade;
|
||||
comment on table operation_tag is 'Tag attached to an operation';
|
||||
ALTER TABLE public.user_filter ADD uf_tag text ;
|
||||
alter table user_filter add uf_tag_option int;
|
||||
|
||||
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';
|
||||
insert into version (val,v_description) values (151,'Tag with color and operation');
|
||||
commit;
|
||||
253
include/sql/patch/upgrade151.sql
Normal file
253
include/sql/patch/upgrade151.sql
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
begin;
|
||||
-- improve vw_fiche_attr
|
||||
alter table fiche add column f_enable char(1);
|
||||
update fiche set f_enable=ad_value from fiche_detail as fd1 where fd1.f_id=fiche.f_id and ad_id=54;
|
||||
update fiche set f_enable='1' where f_enable is null;
|
||||
alter table fiche alter f_enable set not null;
|
||||
alter table fiche add constraint f_enable_ck check (f_enable in ('0','1'));
|
||||
comment on column fiche.f_enable is 'value = 1 if card enable , otherwise 0 ';
|
||||
|
||||
-- improve performance on this view
|
||||
drop index if exists fiche_detail_attr_ix;
|
||||
create index fiche_detail_attr_ix on fiche_detail (ad_id);
|
||||
|
||||
drop view vw_fiche_attr cascade;
|
||||
|
||||
-- add "fiche.f_enable" in the view
|
||||
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,
|
||||
f_enable
|
||||
FROM ( SELECT fiche.f_id,
|
||||
fiche.fd_id,
|
||||
fiche.f_enable,
|
||||
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 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 quant_sold quant_sold_1
|
||||
JOIN jrnx jrnx_1 USING (j_id)
|
||||
JOIN jrn jrn_1 ON jrnx_1.j_grpt = jrn_1.jr_grpt_id
|
||||
GROUP BY jrn_1.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,
|
||||
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,
|
||||
oc.oc_amount,
|
||||
oc.oc_vat_amount,
|
||||
( SELECT currency.cr_code_iso
|
||||
FROM currency
|
||||
WHERE jrn.currency_id = currency.id) AS cr_code_iso
|
||||
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
|
||||
LEFT JOIN operation_currency oc ON oc.j_id = jrnx.j_id;
|
||||
|
||||
create view 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 quant_purchase quant_purchase_1
|
||||
JOIN jrnx jrnx_1 USING (j_id)
|
||||
JOIN jrn jrn_1 ON jrnx_1.j_grpt = jrn_1.jr_grpt_id
|
||||
GROUP BY jrn_1.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,
|
||||
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,
|
||||
oc.oc_amount,
|
||||
oc.oc_vat_amount,
|
||||
( SELECT currency.cr_code_iso
|
||||
FROM currency
|
||||
WHERE jrn.currency_id = currency.id) AS cr_code_iso
|
||||
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
|
||||
LEFT JOIN operation_currency oc ON oc.j_id = jrnx.j_id;
|
||||
|
||||
|
||||
COMMENT ON VIEW vw_fiche_attr IS 'Some attribute for all cards';
|
||||
comment on view v_detail_sale is 'Summary one row by sale ';
|
||||
comment on view v_detail_purchase is 'Summary one row by purchase';
|
||||
|
||||
-- remove
|
||||
delete from fiche_detail where ad_id=54;
|
||||
delete from attr_min where ad_id=54;
|
||||
delete from attr_def where ad_id=54;
|
||||
delete from jnt_fic_attr where ad_id =54;
|
||||
|
||||
|
||||
-- open COMPANY when PARAM is choosen for profile 1
|
||||
update profile_menu set pm_default=1,p_order=1 where pm_id=54;
|
||||
|
||||
update menu_ref set me_menu ='Nouvel achat' where me_code in ('ACH');
|
||||
update menu_ref set me_menu ='Nouvelle vente' where me_code in ('VEN');
|
||||
update menu_ref set me_menu ='Nouvelle opération' where me_code in ('ODS');
|
||||
COMMENT ON TABLE public.action_gestion_comment IS 'comment on action management';
|
||||
COMMENT ON TABLE public.action_gestion_operation IS 'Operation linked on action';
|
||||
COMMENT ON TABLE public.action_gestion_related IS 'link between action';
|
||||
COMMENT ON TABLE public.action_tags IS 'Tags link to action';
|
||||
|
||||
COMMENT ON TABLE public.currency IS 'currency';
|
||||
COMMENT ON TABLE public.currency_history IS 'currency values history';
|
||||
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.forecast_cat IS 'Category of forecast';
|
||||
COMMENT ON TABLE public.forecast_item IS 'items of forecast';
|
||||
COMMENT ON TABLE public.formdef IS 'Simple Report name';
|
||||
COMMENT ON TABLE public.form IS 'Simple report definition';
|
||||
COMMENT ON TABLE public.groupe_analytique IS 'Group of analytic accountancy';
|
||||
COMMENT ON TABLE public.jnt_document_option_contact IS 'Many to many table between document and contact option';
|
||||
COMMENT ON TABLE public.jnt_letter IS 'm2m tables for lettering';
|
||||
COMMENT ON TABLE public.jrn_info IS 'extra info for operation';
|
||||
COMMENT ON TABLE public.jrn_periode IS 'Period by ledger';
|
||||
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 TABLE public.operation_currency IS 'Information about currency';
|
||||
COMMENT ON TABLE public.operation_tag IS 'Tag for operation';
|
||||
COMMENT ON TABLE public.parm_code IS 'Parameter code and accountancy';
|
||||
COMMENT ON TABLE public.profile_menu_type IS 'Type of menu';
|
||||
COMMENT ON TABLE public.quant_purchase IS 'Supplemental info for purchase';
|
||||
COMMENT ON TABLE public.stock_change IS 'Change of stock';
|
||||
COMMENT ON TABLE public.tags IS 'Tags name';
|
||||
COMMENT ON TABLE public.user_filter IS 'Filter for the search';
|
||||
COMMENT ON TABLE public.user_active_security IS 'Security for user';
|
||||
COMMENT ON TABLE public.user_sec_act IS 'Security on actions for user';
|
||||
COMMENT ON TABLE public.user_sec_jrn IS 'Security on ledger for users';
|
||||
COMMENT ON TABLE public."version" IS 'DB version';
|
||||
insert into version (val,v_description) values (152,'Comment on tables,card structure change');
|
||||
commit;
|
||||
7
include/sql/patch/upgrade152.sql
Normal file
7
include/sql/patch/upgrade152.sql
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
begin;
|
||||
insert into document_option (do_code,document_type_id,do_enable,do_option)
|
||||
select 'videoconf_server',dt_id,'1','https://www.free-solutions.org/'
|
||||
from
|
||||
document_type;
|
||||
insert into version (val,v_description) values (153,'Add videoconf server');
|
||||
commit;
|
||||
Loading…
Add table
Add a link
Reference in a new issue