From 5b94dc1e68e652c247bb6b0e2cd67fdb75da13a7 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 22 Jul 2014 23:13:23 +0200 Subject: [PATCH] =?UTF-8?q?Probl=C3=A8me=20de=20mise=20=C3=A0=20jour=20de?= =?UTF-8?q?=20la=20version=20mono?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/admin/sql/patch/ac-upgrade14.sql | 19 ++++++++- sql/upgrade.sql | 61 +++++++-------------------- 2 files changed, 33 insertions(+), 47 deletions(-) diff --git a/html/admin/sql/patch/ac-upgrade14.sql b/html/admin/sql/patch/ac-upgrade14.sql index c7cf70445..599cb177c 100644 --- a/html/admin/sql/patch/ac-upgrade14.sql +++ b/html/admin/sql/patch/ac-upgrade14.sql @@ -4,5 +4,22 @@ update theme set the_name='Mobile' ,the_filestyle='style-mobile.css' where the_n update user_global_pref set parameter_value='Mandarine' where parameter_value='Colored'; update user_global_pref set parameter_value='Mobile' where parameter_value='EPad'; update theme set the_filestyle='style-classic.css' where the_filestyle='style.css'; -update version set val=15; + +CREATE OR REPLACE FUNCTION public.upgrade_repo(p_version integer) + RETURNS void +AS $function$ +declare + is_mono integer; +begin + select count (*) into is_mono from information_schema.tables where table_name='repo_version'; + if is_mono = 1 then + update repo_version set val=p_version; + else + update repo_version set val=p_version; + end if; +end; +$function$ + language plpgsql; +select upgrade_repo(15); + commit; diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 27bd799be..7c433b2e2 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -1,48 +1,17 @@ insert into fiche_def_ref(frd_id,frd_text) values (26,'Projet'); insert into attr_min (frd_id,ad_id) values (26,1),(26,9); - -DROP VIEW v_detail_purchase; - -CREATE OR REPLACE VIEW v_detail_purchase AS - WITH m AS ( - SELECT sum(quant_purchase.qp_price) AS htva, sum(quant_purchase.qp_vat) AS tot_vat, 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,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 - 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; - -DROP VIEW v_detail_sale; - -CREATE OR REPLACE VIEW v_detail_sale AS - WITH m AS ( - SELECT sum(quant_sold.qs_price) AS htva, sum(quant_sold.qs_vat) AS tot_vat, 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,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 - 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; \ No newline at end of file +CREATE OR REPLACE FUNCTION public.upgrade_repo(p_version integer) + RETURNS void +AS $function$ +declare + is_mono integer; +begin + select count (*) into is_mono from information_schema.tables where table_name='repo_version'; + if is_mono = 1 then + update repo_version set val=p_version; + else + update repo_version set val=p_version; + end if; +end; +$function$ + language plpgsql; \ No newline at end of file