BSSC#85523 Rap/Toevoegen kolommen

svn path=/Customer/trunk/; revision=67076
This commit is contained in:
Maarten van der Heide
2024-11-18 17:02:19 +00:00
parent 95e67fb5d9
commit f2140b21c6

View File

@@ -2734,7 +2734,7 @@ BEGIN
rec.vvo_toeslag, -- n4/vvo_toeslag
rec.regel_key, -- n5/regel_key
rec.refid, -- c1/contract_id
NULL, -- c2
NULL, -- c2/reservering_id=NULL
NULL, -- c3
NULL, -- c4
NULL, -- c5
@@ -2810,7 +2810,7 @@ EXCEPTION
fac.writelog (p_applname, 'E', v_errormsg, 'FACT-export afgebroken!');
END;
/
/*
-- 30 Vergadering/2,00 Ruimte
-- 50 Events/8,00 Ruimte
-- 90 Roomservice/0,50 Voorzieningen
@@ -3825,7 +3825,7 @@ AS
AND mkp.prs_kostenplaats_key = kp.prs_kostenplaats_key(+)
AND kp.prs_kostenplaatsgrp_key = kpg.prs_kostenplaatsgrp_key(+)
AND m.mld_melding_key = ks.mld_melding_key;
*/
CREATE OR REPLACE VIEW bssc_v_addd_actual
AS
SELECT DECODE (
@@ -3837,7 +3837,7 @@ AS
NULL,
'*OPEN* R' || x.res_id,
'*CONCEPT* R'
|| DECODE (dres.aantal, 1, x.res_id, SUBSTR (x.res_id, 1, INSTR (x.res_id, '/') - 1) || ' [' || TO_CHAR (dres.aantal) || ' deelreserveringen]')))
|| DECODE (dres.aantal, 1, x.res_id, SUBSTR (x.res_id, 1, INSTR (x.res_id, '/') - 1))))
fin_verkoopfactuur_id,
MIN ('CMD' || TRIM (COALESCE (x.en, '-'))) po_nr,
TO_CHAR (x.reslev, 'yyyymmdd') || SUBSTR ('0000' || TO_CHAR (x.res_rsv_ruimte_key), -7) || TO_CHAR (x.volgnr) sortering, -- TODO
@@ -3845,7 +3845,7 @@ AS
--'Meeting ' || x.res_id regel, -- Factureren per deelreservering!
'Meeting ' || SUBSTR (x.res_id, 1, INSTR (x.res_id, '/') - 1) regel, -- Factureren per reservering (delen zover vrijgegeven)!
x.prs_perslid_naam_full aanvrager,
DECODE (x.volgnr, 0, x.res_voorziening || ' [' || TO_CHAR (ROUND (x.aantal, 2)) || ' uur]', 2, TO_CHAR (x.aantal) || 'x ' || x.res_voorziening, x.res_voorziening) regel_oms,
DECODE (x.volgnr, 0, x.res_voorziening || ' [' || TO_CHAR (ROUND (x.aantal, 2), 'fm99990.0') || ' uur]', 2, TO_CHAR (x.aantal) || 'x ' || x.res_voorziening, x.res_voorziening) regel_oms,
TO_CHAR (SYSDATE, 'dd-mm-yyyy') factuurdatum, TO_CHAR (SYSDATE + 30, 'dd-mm-yyyy') vervaldatum,
'reservering' xmlnode,
x.res_rsv_ruimte_key refkey,
@@ -4282,13 +4282,13 @@ AS
NULL,
'*OPEN* R' || x.res_id,
'*CONCEPT* R'
|| DECODE (dres.aantal, 1, x.res_id, SUBSTR (x.res_id, 1, INSTR (x.res_id, '/') - 1) || ' [' || TO_CHAR (dres.aantal) || ' deelreserveringen]'))),
|| DECODE (dres.aantal, 1, x.res_id, SUBSTR (x.res_id, 1, INSTR (x.res_id, '/') - 1)))),
TO_CHAR (x.reslev, 'yyyymmdd') || SUBSTR ('0000' || TO_CHAR (res_rsv_ruimte_key), -7) || TO_CHAR (volgnr),
--DECODE (x.res_activiteit_key, 30, 'Vergadering ', 50, 'Event ', 'Roomservice ') || x.res_id,
--'Meeting ' || x.res_id,
'Meeting ' || SUBSTR (x.res_id, 1, INSTR (x.res_id, '/') - 1),
x.prs_perslid_naam_full,
DECODE (x.volgnr, 0, x.res_voorziening || ' [' || TO_CHAR (ROUND (x.aantal, 2)) || ' uur]', 2, TO_CHAR (x.aantal) || 'x ' || x.res_voorziening, x.res_voorziening),
DECODE (x.volgnr, 0, x.res_voorziening || ' [' || TO_CHAR (ROUND (x.aantal, 2), 'fm99990.0') || ' uur]', 2, TO_CHAR (x.aantal) || 'x ' || x.res_voorziening, x.res_voorziening),
TO_CHAR (SYSDATE, 'dd-mm-yyyy'), TO_CHAR (SYSDATE + 30, 'dd-mm-yyyy'),
'reservering',
x.res_rsv_ruimte_key,
@@ -4639,7 +4639,7 @@ BEGIN
TO_NUMBER (NULL), -- n4
TO_NUMBER (NULL), -- n5
NULL, -- c1/contract_id=NULL
NULL, -- c2
rec.refid, -- c2/reservering_id
NULL, -- c3
rec.contactpersoon, -- c4
rec.aanvrager, -- c5
@@ -4910,7 +4910,7 @@ BEGIN
TO_NUMBER (NULL), -- n4
TO_NUMBER (NULL), -- n5
DECODE (rec.xmlnode, 'contract', rec.refid, NULL), -- c1/contract_id
NULL, -- c2
NULL, -- c2/reservering_id=NULL
NULL, -- c3
rec.contactpersoon, -- c4
rec.aanvrager, -- c5
@@ -5080,7 +5080,7 @@ BEGIN
TO_NUMBER (NULL), -- n4
TO_NUMBER (NULL), -- n5
DECODE (rec.xmlnode, 'contract', rec.refid, NULL), -- c1/contract_id
NULL, -- c2
NULL, -- c2/reservering_id=NULL
NULL, -- c3
rec.contactpersoon, -- c4
rec.aanvrager, -- c5
@@ -6847,7 +6847,7 @@ SELECT UPPER (SUBSTR (xmlnode, 1, 1)) factuurstroom, -- R of M!
FROM bssc_v_addd_actual
WHERE maand >= TO_CHAR (ADD_MONTHS (SYSDATE, -12), 'yyyy') || '01';
-- BSSC#65731
-- BSSC#65731+BSSC#85523
CREATE OR REPLACE VIEW bssc_v_rap_resprice
(
res_rsv_ruimte_key,
@@ -6858,15 +6858,20 @@ CREATE OR REPLACE VIEW bssc_v_rap_resprice
tot_tijd, -- Tijd tot
bedrijfsnaam,
res_rsv_ruimte_omschrijving, -- Reserveringsomschrijving
aanvrager,
organisator,
adm_stat, -- Administratieve status
res_stat,
project_code,
res_type, -- Type
aantal,
res_extra,
res_omschrijving, -- Omschrijving
res_stuk_prijs2,
res_stuk_prijs,
res_line_totaal, -- Bedrag
deelresprijs -- Totaal
deelresprijs, -- Totaal
btw,
kostensoort
)
AS
SELECT rrr.res_rsv_ruimte_key,
@@ -6875,29 +6880,39 @@ AS
rrr.res_rsv_ruimte_van van_tijd,
rrr.res_rsv_ruimte_tot,
rrr.res_rsv_ruimte_tot tot_tijd,
kw.res_kenmerkreservering_waarde,
rel.res_kenmerkreservering_waarde bedrijfsnaam,
rrr.res_rsv_ruimte_omschrijving,
pfc.prs_perslid_naam_full aanvrager,
pfh.prs_perslid_naam_full organisator,
(SELECT res_status_bo_omschrijving FROM res_status_bo WHERE res_status_bo_key = rrr.res_status_bo_key)
adm_stat,
(SELECT res_status_fo_omschrijving FROM res_status_fo WHERE res_status_fo_key = rrr.res_status_fo_key)
res_stat,
pc.res_kenmerkreservering_waarde project_code,
x.res_type,
x.aantal,
x.res_extra,
x.res_omschrijving,
x.stuksprijs,
x.aantal * x.stuksprijs,
res.getdeelresprijs (rrr.res_rsv_ruimte_key) deelresprijs
res.getdeelresprijs (rrr.res_rsv_ruimte_key) deelresprijs,
x.btw,
x.prs_kostensoort_oms || ' - ' || prs_kostensoort_opmerking kostensoort
FROM (SELECT 'Artikel' res_type,
rra.res_rsv_ruimte_key,
rra.res_rsv_artikel_aantal aantal,
ra.res_artikel_nr res_extra,
ra.res_artikel_omschrijving res_omschrijving,
DECODE (rra.res_rsv_artikel_prijs, NULL, ra.res_artikel_prijs, rra.res_rsv_artikel_prijs / DECODE (COALESCE (rra.res_rsv_artikel_aantal, 0), 0, 1, rra.res_rsv_artikel_aantal))
stuksprijs
FROM res_v_aanwezigrsv_artikel rra, res_artikel ra
stuksprijs,
COALESCE (rra.res_rsv_artikel_btw, ra.res_artikel_btw) btw,
ks.prs_kostensoort_oms,
ks.prs_kostensoort_opmerking
FROM res_v_aanwezigrsv_artikel rra, res_artikel ra, res_discipline disc, prs_kostensoort ks
WHERE rra.res_rsv_artikel_dirtlevel = 0
AND rra.res_artikel_key = ra.res_artikel_key
AND ra.res_discipline_key = disc.ins_discipline_key
AND disc.prs_kostensoort_key = ks.prs_kostensoort_key(+)
UNION ALL
SELECT 'Object' res_type,
rrd.res_rsv_ruimte_key,
@@ -6905,10 +6920,16 @@ AS
NULL res_extra,
rd.res_deel_omschrijving res_omschrijving,
--DECODE (rrd.res_rsv_deel_prijs, NULL, rd.res_deel_prijs, rrd.res_rsv_deel_prijs / DECODE (COALESCE (rrd.res_rsv_deel_aantal, 0), 0, 1, rrd.res_rsv_deel_aantal))
COALESCE (rrd.res_rsv_deel_prijs, 0) stuksprijs
FROM res_v_aanwezigrsv_deel rrd, res_deel rd
COALESCE (rrd.res_rsv_deel_prijs, 0) stuksprijs,
21 btw,
ks.prs_kostensoort_oms,
ks.prs_kostensoort_opmerking
FROM res_v_aanwezigrsv_deel rrd, res_deel rd, res_discipline disc, prs_kostensoort ks
WHERE rrd.res_rsv_deel_dirtlevel = 0
--AND rrd.res_rsv_ruimte_key IS NOT NULL -- Geen parkeerplaatsen bij niet reservering-gebonden afspraken?
AND rrd.res_deel_key = rd.res_deel_key
AND rd.res_discipline_key = disc.ins_discipline_key
AND disc.prs_kostensoort_key = ks.prs_kostensoort_key(+)
UNION ALL
SELECT 'Ruimte' res_type,
rrr.res_rsv_ruimte_key,
@@ -6916,26 +6937,53 @@ AS
ro.res_opstelling_omschrijving res_extra,
rr.res_ruimte_nr res_omschrijving,
res.getruimteprijs (rrr.res_rsv_ruimte_key) / DECODE ((rrr.res_rsv_ruimte_tot - rrr.res_rsv_ruimte_van), 0, 1, (rrr.res_rsv_ruimte_tot - rrr.res_rsv_ruimte_van) * 24)
stuksprijs
FROM res_v_aanwezigrsv_ruimte rrr, res_ruimte_opstelling rro, res_ruimte rr, res_opstelling ro
stuksprijs,
21 btw,
ks.prs_kostensoort_oms,
ks.prs_kostensoort_opmerking
FROM res_v_aanwezigrsv_ruimte rrr, res_ruimte_opstelling rro, res_ruimte rr, res_opstelling ro, res_discipline disc, prs_kostensoort ks
WHERE rrr.res_rsv_ruimte_dirtlevel = 0
AND rrr.res_ruimte_opstel_key = rro.res_ruimte_opstel_key
AND rro.res_ruimte_key = rr.res_ruimte_key
AND rro.res_opstelling_key = ro.res_opstelling_key
AND rr.res_discipline_key = disc.ins_discipline_key
AND disc.prs_kostensoort_key = ks.prs_kostensoort_key(+)
UNION ALL
SELECT 'Korting' res_type,
res_rsv_ruimte_key,
-1 aantal,
NULL res_extra,
'Korting' res_omschrijving,
res_rsv_ruimte_korting stuksprijs
FROM res_v_aanwezigrsv_ruimte
WHERE res_rsv_ruimte_dirtlevel = 0
AND res_rsv_ruimte_korting IS NOT NULL) x,
res_rsv_ruimte_korting stuksprijs,
21 btw,
ks.prs_kostensoort_oms,
ks.prs_kostensoort_opmerking
FROM res_v_aanwezigrsv_ruimte rrr, res_ruimte_opstelling rro, res_ruimte rr, res_opstelling ro, res_discipline disc, prs_kostensoort ks
WHERE rrr.res_rsv_ruimte_dirtlevel = 0
AND rrr.res_rsv_ruimte_korting IS NOT NULL
AND rrr.res_ruimte_opstel_key = rro.res_ruimte_opstel_key
AND rro.res_ruimte_key = rr.res_ruimte_key
AND rro.res_opstelling_key = ro.res_opstelling_key
AND rr.res_discipline_key = disc.ins_discipline_key
AND disc.prs_kostensoort_key = ks.prs_kostensoort_key(+)) x,
res_rsv_ruimte rrr,
(SELECT * FROM res_v_aanwezigkenmerkwaarde WHERE res_kenmerk_key IN (248, 254, 264, 325)) kw -- Relatie
prs_v_perslid_fullnames_all pfh,
prs_v_perslid_fullnames_all pfc,
(SELECT *
FROM res_v_aanwezigkenmerkwaarde
WHERE res_kenmerk_key IN (248, 254, 264, 325)) rel, -- Relatie
(SELECT *
FROM res_v_aanwezigkenmerkwaarde kr
WHERE EXISTS
(SELECT 1
FROM res_kenmerk
WHERE res_srtkenmerk_key = 401 -- Projectcode
AND res_kenmerk_key = kr.res_kenmerk_key)) pc
WHERE x.res_rsv_ruimte_key = rrr.res_rsv_ruimte_key
AND x.res_rsv_ruimte_key = kw.res_rsv_ruimte_key(+);
AND rrr.res_rsv_ruimte_contact_key = pfc.prs_perslid_key
AND rrr.res_rsv_ruimte_host_key = pfh.prs_perslid_key
AND x.res_rsv_ruimte_key = rel.res_rsv_ruimte_key(+)
AND x.res_rsv_ruimte_key = pc.res_rsv_ruimte_key(+);
-- Rapportage ter controle facturatie van contracten per maand (of niet).
CREATE OR REPLACE VIEW BSSC_V_RAP_CNT_FIN_MND