357 lines
14 KiB
Plaintext
357 lines
14 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 ();
|
|
|
|
/* ROOT VIEWS for User defined Reports (UDR) */
|
|
CREATE_VIEW(bes_v_udr_bestelling, 1)
|
|
(
|
|
bestelling_key,
|
|
bestelaanvraagnr,
|
|
besteldatum,
|
|
leverancier,
|
|
besteller,
|
|
invoerder,
|
|
kostensoortgroep,
|
|
kostensoort,
|
|
kpn,
|
|
kpn_omschrijving,
|
|
fclt_3d_afdeling_key,
|
|
afdeling_code,
|
|
afdeling_omschrijving,
|
|
fclt_3d_locatie_key,
|
|
locatie_code,
|
|
regio_omschrijving,
|
|
district_omschrijving,
|
|
afleveradres,
|
|
afleverplaats,
|
|
mandaat,
|
|
fclt_3d_discipline_key,
|
|
catalogus,
|
|
groep,
|
|
productomschrijving,
|
|
productcode,
|
|
afleverdatum,
|
|
doorlooptijd_werkdgn,
|
|
sla_tijd,
|
|
prijs,
|
|
inkoopprijs,
|
|
status,
|
|
gefiatteerddoor,
|
|
bestelopdrachtnummer,
|
|
aantal,
|
|
itemprijs,
|
|
iteminkoopprijs,
|
|
itemposnr
|
|
)
|
|
AS
|
|
SELECT bes_bestelling_key,
|
|
bestelaanvraagnr,
|
|
besteldatum,
|
|
bedrijf_naam,
|
|
besteller,
|
|
invoerder,
|
|
kostensoortgroep,
|
|
kostensoort,
|
|
kpn,
|
|
kpn_omschrijving,
|
|
prs_afdeling_key,
|
|
afdeling_code,
|
|
afdeling_omschrijving,
|
|
alg_locatie_key,
|
|
locatie_code,
|
|
regio_omschrijving,
|
|
district_omschijving,
|
|
afleveradres,
|
|
afleverplaats,
|
|
mandaat,
|
|
ins_discipline_key,
|
|
catalogus,
|
|
groep,
|
|
productomschrijving,
|
|
productcode,
|
|
afleverdatum,
|
|
doorlooptijd_werkdgn,
|
|
sla_tijd,
|
|
prijs,
|
|
inkoopprijs,
|
|
status,
|
|
gefiatteerddoor,
|
|
bestelopdrachtnummer,
|
|
aantal,
|
|
itemprijs,
|
|
iteminkoopprijs,
|
|
itemposnr
|
|
FROM (SELECT b.bes_bestelling_key bes_bestelling_key,
|
|
'A-' || b.bes_bestelling_key bestelaanvraagnr,
|
|
b.bes_bestelling_datum 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 =
|
|
COALESCE (fac.gettrackinguserkey ('BESNEW', b.bes_bestelling_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 MAX(COALESCE (bsg.prs_kostensoort_key,
|
|
disc.prs_kostensoort_key))
|
|
FROM bes_discipline disc, bes_srtgroep bsg
|
|
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 MAX(COALESCE (bsg.prs_kostensoort_key,
|
|
disc.prs_kostensoort_key))
|
|
FROM bes_discipline disc, bes_srtgroep bsg
|
|
WHERE disc.ins_discipline_key = bsg.ins_discipline_key
|
|
AND disc.ins_discipline_key = d.ins_discipline_key))
|
|
kostensoort,
|
|
k.prs_kostenplaats_nr kpn,
|
|
k.prs_kostenplaats_omschrijving kpn_omschrijving,
|
|
(SELECT b.prs_bedrijf_naam
|
|
FROM prs_bedrijf b
|
|
WHERE b.prs_bedrijf_key = sd.prs_bedrijf_key)
|
|
bedrijf_naam,
|
|
a.prs_afdeling_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_regio_omschrijving
|
|
FROM alg_locatie l, alg_district d, alg_regio r
|
|
WHERE r.alg_regio_key = d.alg_regio_key
|
|
AND l.alg_district_key = d.alg_district_key
|
|
AND l.alg_locatie_key = ma.alg_locatie_key)
|
|
regio_omschrijving,
|
|
(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,
|
|
b.bes_bestelling_plaats afleverplaats,
|
|
NVL ( (SELECT pr.fac_profiel_limiet
|
|
FROM fac_profiel pr
|
|
WHERE p.fac_profiel_key = pr.fac_profiel_key), 0)
|
|
mandaat,
|
|
d.ins_discipline_key ins_discipline_key,
|
|
d.ins_discipline_omschrijving catalogus,
|
|
sg.bes_srtgroep_omschrijving groep,
|
|
b.bes_bestelling_leverdatum afleverdatum,
|
|
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,
|
|
bi.bes_bestelling_item_prijs * bi.bes_bestelling_item_aantal prijs,
|
|
NVL (bes.getsrtdeelinkprijs (sd.bes_srtdeel_key, bes_bestelling_datum),
|
|
bi.bes_bestelling_item_prijs)
|
|
* bi.bes_bestelling_item_aantal
|
|
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,
|
|
bi.bes_bestelling_item_prijs itemprijs,
|
|
NVL (bes.getsrtdeelinkprijs (sd.bes_srtdeel_key, bes_bestelling_datum),
|
|
bi.bes_bestelling_item_prijs)
|
|
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,
|
|
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 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);
|
|
|
|
CREATE_VIEW(bes_v_allsrtinstallatie, 0)
|
|
(
|
|
NIVEAU,
|
|
BES_SRTINSTALLATIE_KEY,
|
|
DISCIPLINE_OMS,
|
|
SRTGROEP_OMS,
|
|
SRTDEEL_OMS,
|
|
BES_DISCIPLINE_KEY,
|
|
BES_SRTGROEP_KEY,
|
|
BES_SRTDEEL_KEY,
|
|
BES_DISCIPLINE_VERWIJDER,
|
|
BES_SRTGROEP_VERWIJDER,
|
|
BES_SRTDEEL_VERWIJDER
|
|
)
|
|
AS
|
|
SELECT 'D',
|
|
bes_ID.ins_discipline_key,
|
|
bes_ID.ins_discipline_omschrijving discipline_oms,
|
|
NULL srtgroep_oms,
|
|
NULL srtdeel_oms,
|
|
bes_ID.ins_discipline_key,
|
|
NULL bes_srtgroep_key,
|
|
NULL bes_srtdeel_key,
|
|
bes_ID.ins_discipline_verwijder bes_discipline_verwijder,
|
|
NULL bes_srtgroep_verwijder,
|
|
NULL bes_srtdeel_verwijder
|
|
FROM bes_discipline bes_ID
|
|
UNION
|
|
SELECT 'G',
|
|
bes_SG.bes_srtgroep_key,
|
|
bes_ID.ins_discipline_omschrijving,
|
|
bes_SG.bes_srtgroep_omschrijving,
|
|
NULL srtdeel_oms,
|
|
bes_ID.ins_discipline_key,
|
|
bes_SG.bes_srtgroep_key,
|
|
NULL bes_srtdeel_key,
|
|
bes_ID.ins_discipline_verwijder bes_discipline_verwijder,
|
|
bes_SG.bes_srtgroep_verwijder,
|
|
NULL bes_srtdeel_verwijder
|
|
FROM bes_discipline bes_ID, bes_srtgroep bes_SG
|
|
WHERE bes_ID.ins_discipline_key = bes_SG.ins_discipline_key
|
|
UNION
|
|
SELECT 'S',
|
|
bes_SD.bes_srtdeel_key,
|
|
bes_ID.ins_discipline_omschrijving,
|
|
bes_SG.bes_srtgroep_omschrijving,
|
|
bes_SD.bes_srtdeel_omschrijving,
|
|
bes_ID.ins_discipline_key,
|
|
bes_SG.bes_srtgroep_key,
|
|
bes_SD.bes_srtdeel_key,
|
|
bes_ID.ins_discipline_verwijder bes_discipline_verwijder,
|
|
bes_SG.bes_srtgroep_verwijder,
|
|
bes_SD.bes_srtdeel_verwijder
|
|
FROM bes_discipline bes_ID, bes_srtgroep bes_SG, bes_srtdeel bes_SD
|
|
WHERE bes_SG.bes_srtgroep_key = bes_SD.bes_srtgroep_key
|
|
AND bes_ID.ins_discipline_key = bes_SG.ins_discipline_key;
|
|
|
|
CREATE_VIEW(bes_v_rap_sync_catalogus, 0)
|
|
(
|
|
CATALOGUS_NAAM,
|
|
LEVERANCIER,
|
|
CAT_DATUM,
|
|
ARTIKELNR,
|
|
GROEP,
|
|
OMSCHRIJVING,
|
|
PRIJS,
|
|
EENHEID,
|
|
PICTURE,
|
|
ORDERAANTAL,
|
|
TAX,
|
|
DUEDATE,
|
|
INKOOPPRIJS,
|
|
MINIMUM,
|
|
STAFFELTABEL,
|
|
WIJZIGDAGEN,
|
|
ANNULEERDAGEN,
|
|
OPMERKING
|
|
)
|
|
AS
|
|
SELECT bd.ins_discipline_omschrijving,
|
|
b.prs_bedrijf_naam,
|
|
NULL,
|
|
sd.bes_srtdeel_nr,
|
|
sg.bes_srtgroep_omschrijving,
|
|
sd.bes_srtdeel_omschrijving,
|
|
REPLACE (TO_CHAR (bes.getsrtdeelprijs (sd.bes_srtdeel_key, NULL)), ',', '.'),
|
|
sd.bes_srtdeel_eenheid,
|
|
sd.bes_srtdeel_image,
|
|
TO_CHAR (sd.bes_srtdeel_veelvoud),
|
|
TO_CHAR (sd.bes_srtdeel_btw),
|
|
TO_CHAR (sd.bes_srtdeel_vervaldatum, 'yyyymmdd'),
|
|
REPLACE (TO_CHAR (bes.getsrtdeelinkprijs (sd.bes_srtdeel_key, NULL)), ',', '.'),
|
|
TO_CHAR (sd.bes_srtdeel_minimum),
|
|
bs.bes_staffeltabel_naam,
|
|
TO_CHAR (sd.bes_srtdeel_wijzigdagen),
|
|
TO_CHAR (sd.bes_srtdeel_annuleerdagen),
|
|
sd.bes_srtdeel_opmerking
|
|
FROM bes_discipline bd,
|
|
bes_srtgroep sg,
|
|
bes_srtdeel sd,
|
|
prs_bedrijf b,
|
|
bes_staffeltabel bs
|
|
WHERE bd.ins_discipline_module = 'BES'
|
|
AND bd.ins_discipline_verwijder IS NULL
|
|
AND bd.ins_discipline_key = sg.ins_discipline_key
|
|
AND sg.bes_srtgroep_verwijder IS NULL
|
|
AND sg.bes_srtgroep_key = sd.bes_srtgroep_key
|
|
AND sd.bes_srtdeel_verwijder IS NULL
|
|
AND sd.prs_bedrijf_key = b.prs_bedrijf_key
|
|
AND sd.bes_staffeltabel_key = bs.bes_staffeltabel_key;
|
|
|
|
REGISTERRUN('$Id$')
|
|
|
|
#endif // BES
|