From 3df7aca4e2af6410e4fb059a806393e8f12a4a2a Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 12 Oct 2013 20:05:47 +0000 Subject: [PATCH] =?UTF-8?q?task=20#0000891:=20Impression=20des=20op=C3=A9r?= =?UTF-8?q?ations=20ainsi=20que=20les=20op=C3=A9rations=20rapproch=C3=A9es?= =?UTF-8?q?=20Cr=C3=A9ation=20de=20la=20vue=20:=20=C3=A0=20integrer=20dans?= =?UTF-8?q?=20le=20patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/detail-operation-rapprochement.sql | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 sql/detail-operation-rapprochement.sql diff --git a/sql/detail-operation-rapprochement.sql b/sql/detail-operation-rapprochement.sql new file mode 100644 index 000000000..d029b2bea --- /dev/null +++ b/sql/detail-operation-rapprochement.sql @@ -0,0 +1,43 @@ +drop view v_quant_detail; +create or replace view v_quant_detail as +with quant as + (select + j_id, + qp_fiche as fiche_id, + qp_supplier as tiers, + qp_vat as vat_amount, + qp_price as price, + qp_vat_code as vat_code, + qp_dep_priv as dep_priv, + qp_nd_tva as nd_tva, + qp_nd_tva_recup as nd_tva_recup, + qp_nd_amount as nd_amount, + qp_vat_sided as vat_sided + from quant_purchase + union all + select + j_id, + qs_fiche, + qs_client, + qs_vat, + qs_price, + qs_vat_code, + 0, + 0, + 0, + 0, + qs_vat_sided + from + quant_sold +) +select + jr_id,quant.tiers,jrn_def_name,jrn_def_type,name,jr_comment,jr_montant,sum(price) as price,vat_code,sum(vat_amount) as vat_amount,sum(dep_priv) as dep_priv,sum(nd_tva) as nd_tva,sum(nd_tva_recup) as nd_tva_recup,sum(nd_amount) as nd_amount,vat_sided,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 (tiers=vw_fiche_name.f_id) +join jrn_def on (jrn_def_id=jr_def_id) +join tva_rate on (tva_id=vat_code) +group by +jr_id,quant.tiers,jr_comment,jr_montant,vat_code,vat_sided,name,jrn_def_name,jrn_def_type,tva_label; \ No newline at end of file