Files
Database/BES/BES_VIE.SRC
2012-05-06 12:54:48 +00:00

181 lines
10 KiB
Plaintext

#ifdef BES // 03-11-2000 PF
/*
* $Revision$
* $Id$
*/
CREATE_VIEW(bes_discipline, 0)
AS
SELECT * FROM ins_tab_discipline WHERE ins_discipline_module = 'BES';
DEFINIEER_VIEW_AANWEZIG(bes_discipline, ins_discipline_verwijder,
bes_v_aanwezigdiscipline,0);
CREATE_VIEW(bes_v_aanwezigsrtgroep, 0)
AS
SELECT * FROM bes_srtgroep WHERE bes_srtgroep_verwijder IS NULL;
CREATE_VIEW(bes_v_aanwezigsrtdeel, 0)
AS
SELECT * FROM bes_srtdeel WHERE bes_srtdeel_verwijder IS NULL;
/* LET OP (FSN#21553)
* Deze twee views lijkt qua naam een tabel, maar is het technisch niet
* Hij levert de statustekst in de juiste taal op, van een specifieke statuscode
* Voorheen was dit een tabel met deze naam, en werd deze initieel gevuld. Dit is
* hiermee dus vanwege de i18n veranderd.
*/
CREATE_VIEW(bes_bestellingstatuses, 0)
AS
SELECT fac_code2label_code bes_bestellingstatuses_key,
COALESCE (fac_locale_xsl_cust, fac_locale_xsl_tekst) bes_bestellingstatuses_omschr
FROM fac_locale_xsl fl, fac_code2label fs
WHERE fl.fac_locale_xsl_label = fac_code2label_label
AND fac_code2label_domein = 'bestelling'
AND fac_locale_xsl_lang = lcl.getuserlanguage ();
CREATE_VIEW(bes_bestelopdrstatuses, 0)
AS
SELECT fac_code2label_code bes_bestelopdrstatuses_key,
COALESCE (fac_locale_xsl_cust, fac_locale_xsl_tekst) bes_bestelopdrstatuses_omschr
FROM fac_locale_xsl fl, fac_code2label fs
WHERE fl.fac_locale_xsl_label = fac_code2label_label
AND fac_code2label_domein = 'bestelopdr'
AND fac_locale_xsl_lang = lcl.getuserlanguage ();
CREATE_VIEW(bes_v_qvw_algemeen, 0) (bes_bestelling_key,
bestelaanvraagnr,
besteldatum,
besteller,
invoerder,
kostensoortgroep,
kostensoort,
kpn,
kpn_omschrijving,
prs_bedrijf_key,
afdeling_code,
afdeling_omschrijving,
alg_locatie_key,
locatie_code,
district_omschijving,
afleveradres,
mandaat,
personeelsnr,
werkplek,
ins_discipline_key,
catalogus,
groep,
afleverdatum,
doorlooptijd_werkdgn,
sla_tijd,
productcode,
prijs,
inkoopprijs,
status,
gefiatteerddoor,
bestelopdrachtnummer,
aantal,
itemprijs,
iteminkoopprijs,
productomschrijving,
itemposnr
)
AS
SELECT bes_bestelling_key, bestelaanvraagnr, besteldatum, besteller, invoerder, kostensoortgroep,kostensoort, kpn, kpn_omschrijving, prs_bedrijf_key,
afdeling_code, afdeling_omschrijving, alg_locatie_key, locatie_code, district_omschijving, afleveradres, mandaat,
personeelsnr, werkplek, ins_discipline_key, catalogus, groep, afleverdatum, doorlooptijd_werkdgn, sla_tijd,
productcode, prijs, inkoopprijs, status, gefiatteerddoor, bestelopdrachtnummer, aantal, itemprijs, iteminkoopprijs, productomschrijving, itemposnr
FROM (SELECT b.bes_bestelling_key bes_bestelling_key, 'A-' || b.bes_bestelling_key bestelaanvraagnr,
TO_CHAR (b.bes_bestelling_datum, 'YYYY-MM-DD') besteldatum,
(SELECT prs_perslid_naam_full
FROM prs_v_perslid_fullnames_all pf
WHERE pf.prs_perslid_key = p.prs_perslid_key) besteller,
(SELECT prs_perslid_naam_full
FROM prs_v_perslid_fullnames_all pf
WHERE pf.prs_perslid_key = fac.gettrackinguserkey ('BESAP2', b.bes_bestelling_key)) invoerder,
(select ksg.prs_kostensoortgrp_oms
from prs_kostensoortgrp ksg, prs_kostensoort ks
where ksg.PRS_KOSTENSOORTGRP_KEY = ks.PRS_KOSTENSOORTGRP_KEY
and ks.PRS_KOSTENSOORT_KEY = (select disc.PRS_KOSTENSOORT_KEY
from bes_discipline disc
where disc.ins_DISCIPLINE_KEY = d.ins_discipline_key)) kostensoortgroep,
(select ks.prs_kostensoort_oms
from prs_kostensoort ks
where ks.PRS_KOSTENSOORT_KEY = (select disc.PRS_KOSTENSOORT_KEY
from bes_discipline disc
where disc.ins_DISCIPLINE_KEY = d.ins_discipline_key)) kostensoort,
k.prs_kostenplaats_nr kpn,
k.prs_kostenplaats_omschrijving kpn_omschrijving,
(SELECT prs_bedrijf_key
FROM prs_v_afdeling pva
WHERE pva.prs_afdeling_key = a.prs_afdeling_key) prs_bedrijf_key,
a.prs_afdeling_naam afdeling_code,
a.prs_afdeling_omschrijving afdeling_omschrijving,
ma.alg_locatie_key alg_locatie_key,
(SELECT alg_locatie_code
FROM alg_locatie l
WHERE l.alg_locatie_key = ma.alg_locatie_key) locatie_code,
(SELECT alg_district_omschrijving
FROM alg_locatie l, alg_district d
WHERE l.alg_district_key = d.alg_district_key
AND l.alg_locatie_key = ma.alg_locatie_key) district_omschijving,
ma.mld_adres_naam afleveradres, NVL ((SELECT pr.fac_profiel_limiet
FROM fac_profiel pr
WHERE p.fac_profiel_key = pr.fac_profiel_key), 0) mandaat,
prs_perslid_nr personeelsnr, wp2.prs_werkplek_aanduiding werkplek,
d.ins_discipline_key ins_discipline_key,
d.ins_discipline_omschrijving catalogus,
sg.bes_srtgroep_omschrijving groep,
TO_CHAR (b.bes_bestelling_leverdatum, 'YYYY-MM-DD') afleverdatum,
TO_CHAR (fac.count_work_days (b.bes_bestelling_datum, NVL (fac.gettrackingdate ('BESOTV', b.bes_bestelling_key), SYSDATE))
) doorlooptijd_werkdgn,
NVL ((SELECT bdp.bes_disc_params_leverdagen
FROM bes_disc_params bdp
WHERE d.ins_discipline_key = bdp.bes_ins_discipline_key), 0) sla_tijd,
sd.bes_srtdeel_nr productcode,
REPLACE (TO_CHAR (bi.bes_bestelling_item_prijs * bi.bes_bestelling_item_aantal, '9999990.99'), '.', ',') prijs,
REPLACE (TO_CHAR (NVL(bes.getsrtdeelinkprijs(sd.bes_srtdeel_key, bes_bestelling_datum), bi.bes_bestelling_item_prijs) * bi.bes_bestelling_item_aantal, '9999990.99'), '.', ',') inkoopprijs,
(SELECT bes_bestellingstatuses_omschr
FROM bes_bestellingstatuses bs
WHERE bs.bes_bestellingstatuses_key = b.bes_bestelling_status) status,
(SELECT prs_perslid_naam_full
FROM prs_v_perslid_fullnames_all pf
WHERE pf.prs_perslid_key = b.bes_bestelling_fiat_user) gefiatteerddoor,
'O-' || bo.bes_bestelopdr_id bestelopdrachtnummer, bi.bes_bestelling_item_aantal aantal,
REPLACE (TO_CHAR (bi.bes_bestelling_item_prijs, '9999990.99'), '.', ',') itemprijs,
REPLACE (TO_CHAR (NVL(bes.getsrtdeelinkprijs(sd.bes_srtdeel_key, bes_bestelling_datum), bi.bes_bestelling_item_prijs), '9999990.99'), '.', ',') iteminkoopprijs,
sd.bes_srtdeel_omschrijving productomschrijving,
boi.bes_bestelopdr_item_posnr itemposnr
FROM bes_bestelling b,
prs_perslid p,
prs_kostenplaats k,
prs_afdeling a,
mld_adres ma,
(SELECT pw.prs_perslid_key,
MIN (prs_werkplek_aanduiding) || DECODE (COUNT (*), 1, '', '...') prs_werkplek_aanduiding
FROM prs_v_werkplek_gegevens wp, prs_perslidwerkplek pw
WHERE wp.prs_werkplek_key = pw.prs_werkplek_key
GROUP BY pw.prs_perslid_key) wp2,
bes_bestelling_item bi,
bes_bestelopdr_item boi,
bes_bestelopdr bo,
bes_srtdeel sd,
bes_srtgroep sg,
ins_tab_discipline d
WHERE b.prs_perslid_key = p.prs_perslid_key
AND b.prs_kostenplaats_key = k.prs_kostenplaats_key
AND p.prs_afdeling_key = a.prs_afdeling_key
AND b.mld_adres_key_lev = ma.mld_adres_key
AND wp2.prs_perslid_key(+) = p.prs_perslid_key
AND b.bes_bestelling_key = bi.bes_bestelling_key
AND bi.bes_bestelopdr_item_key = boi.bes_bestelopdr_item_key(+)
AND boi.bes_bestelopdr_key = bo.bes_bestelopdr_key(+)
AND bi.bes_srtdeel_key = sd.bes_srtdeel_key
AND sd.bes_srtgroep_key = sg.bes_srtgroep_key
AND sg.ins_discipline_key = d.ins_discipline_key);
REGISTERRUN('$Workfile: BES_VIE.SRC $','$Revision$')
#endif // BES