AADS#39888 Aanpassing Exact inkoop interface (DSM)

svn path=/Customer/trunk/; revision=33282
This commit is contained in:
Ruud Lipper
2017-03-28 09:46:32 +00:00
parent 95e91d8ac7
commit 4affcf8907

View File

@@ -131,6 +131,20 @@ SELECT alg_onrgoed_key alg_gebouw_key,
'SABIC', 1120,
'SITECH', 1200,
1020);
-- View om de exact code van een district te bepalen.
-- Dit kenmerk heeft potentieel voor verschillende klanten een andere key. Voor nu alleen nog DSM.
CREATE OR REPLACE VIEW aaxx_v_exact_code_district
(
alg_district_key,
exact_code
)
AS
SELECT alg_onrgoed_key alg_district_key,
alg_onrgoedkenmerk_waarde exact_code
FROM alg_onrgoedkenmerk
WHERE alg_onrgoed_niveau = 'D'
AND alg_kenmerk_key = DECODE (aaxx_get_user, 'DSM', 1100, 1100);
-- View om de exact code van een gebouw te bepalen op basis van een factuurkey
-- Op dit moment ondersteunen we dit alleen bij opdrachten en contracten
@@ -168,6 +182,62 @@ SELECT DISTINCT fin_factuur_key, exact_code
AND ma.mld_adres_gebouw_ruimte = g.alg_gebouw_code(+)
AND g.alg_gebouw_key = eg.alg_gebouw_key(+);
-- View om de exact code van een district te bepalen op basis van een factuurkey
-- Op dit moment alleen nog voor DSM
CREATE OR REPLACE VIEW aaxx_v_exact_code_district_fac
(
fin_factuur_key,
exact_code
)
AS
SELECT fin_factuur_key, exact_code
FROM fin_factuur f,
mld_opdr o,
mld_melding m,
alg_v_allonrgoed_gegevens og,
alg_locatie l,
aaxx_v_exact_code_district aed
WHERE f.mld_opdr_key = o.mld_opdr_key
AND o.mld_melding_key = m.mld_melding_key
AND m.mld_alg_onroerendgoed_keys = og.alg_onroerendgoed_keys
AND og.alg_locatie_key = l.alg_locatie_key
AND l.alg_district_key = aed.alg_district_key
UNION ALL
SELECT fin_factuur_key, exact_code
FROM fin_factuur f,
cnt_contract_plaats cp,
alg_gebouw g,
alg_locatie l,
aaxx_v_exact_code_district aed
WHERE f.cnt_contract_key = cp.cnt_contract_key
AND cp.cnt_alg_plaats_key = g.alg_gebouw_key
AND g.alg_locatie_key = l.alg_locatie_key
AND l.alg_district_key = aed.alg_district_key
AND cp.cnt_alg_plaats_code = 'G'
UNION ALL
SELECT fin_factuur_key, exact_code
FROM fin_factuur f,
cnt_contract_plaats cp,
alg_locatie l,
aaxx_v_exact_code_district aed
WHERE f.cnt_contract_key = cp.cnt_contract_key
AND cp.cnt_alg_plaats_key = l.alg_locatie_key
AND l.alg_district_key = aed.alg_district_key
AND cp.cnt_alg_plaats_code = 'L'
UNION ALL
SELECT DISTINCT fin_factuur_key, exact_code
FROM fin_factuur f,
aaxx_v_bestelgegevens bg,
mld_adres ma,
aaxx_v_exact_code_district aed,
(SELECT g.alg_gebouw_key, g.alg_gebouw_code, l.alg_district_key
FROM alg_gebouw g, alg_locatie l
WHERE g.alg_locatie_key = l.alg_locatie_key) vg
WHERE f.bes_bestelopdr_key = bg.bes_bestelopdr_key
AND bg.mld_adres_key_lev = ma.mld_adres_key(+)
AND ma.mld_adres_gebouw_ruimte = vg.alg_gebouw_code(+)
AND vg.alg_district_key = aed.alg_district_key(+);
-- Functie om bij facturen met een btw tarief dat verlegd is, voor de verkoopfactuur toch een geldige
-- btw code te genereren. De klant moet namelijk wel BTW betalen.
CREATE OR REPLACE FUNCTION aaxx_get_verkoop_btw_code (p_btwtabelwaarde_key IN NUMBER) RETURN VARCHAR2
@@ -2086,6 +2156,8 @@ AS
DECODE (cnt_contract_key, NULL,
(select exact_code from aaxx_v_exact_code_gebouw_fac ecgf where ecgf.fin_factuur_key = fg.fin_factuur_key),
'999999'),
'DSM',
(select exact_code from aaxx_v_exact_code_district_fac ecgf where ecgf.fin_factuur_key = fg.fin_factuur_key),
'999999'
) kstplcode,
( SELECT prs_kostenplaats_nr