UWVA#26378 FACTUUR-import/verbeteren robuustheid
svn path=/Customer/trunk/; revision=18115
This commit is contained in:
@@ -11,6 +11,22 @@ SET DEFINE OFF
|
||||
SET ECHO ON
|
||||
spool xuwva_fin.lst
|
||||
|
||||
/* Formatted on 3-6-2013 20:42:53 (QP5 v5.115.810.9015) */
|
||||
CREATE OR REPLACE PROCEDURE uwva_imp_writelog (p_import_key IN NUMBER,
|
||||
p_severity IN VARCHAR2,
|
||||
p_errormsg IN VARCHAR2,
|
||||
p_errorhint IN VARCHAR2)
|
||||
AS
|
||||
PRAGMA AUTONOMOUS_TRANSACTION;
|
||||
BEGIN
|
||||
fac.imp_writelog (p_import_key,
|
||||
p_severity,
|
||||
p_errormsg,
|
||||
p_errorhint);
|
||||
COMMIT;
|
||||
END;
|
||||
/
|
||||
|
||||
/* Formatted on 8-3-2012 14:30:15 (QP5 v5.115.810.9015) */
|
||||
CREATE OR REPLACE VIEW uwva_v_rap_cat_factuur
|
||||
AS
|
||||
@@ -5792,46 +5808,45 @@ AS
|
||||
|
||||
-- UWVA#16763
|
||||
-- Procedure voor de import van facturen (van leverancier)
|
||||
/* Formatted on 12-2-2010 13:14:42 (QP5 v5.136.908.31019) */
|
||||
/* Formatted on 10-6-2013 13:24:42 (QP5 v5.115.810.9015) */
|
||||
CREATE OR REPLACE PROCEDURE uwva_import_factuur (p_import_key IN NUMBER)
|
||||
AS
|
||||
v_newline fac_imp_file.fac_imp_file_line%TYPE;
|
||||
v_field VARCHAR2 (100);
|
||||
v_fielddelimitor VARCHAR2 (1);
|
||||
v_errormsg VARCHAR (200);
|
||||
oracle_err_num NUMBER;
|
||||
oracle_err_mes VARCHAR2 (200);
|
||||
header_is_valid NUMBER;
|
||||
c_delim VARCHAR2 (1) := ';';
|
||||
v_newline fac_imp_file.fac_imp_file_line%TYPE;
|
||||
v_errormsg VARCHAR2 (1000);
|
||||
oracle_err_num NUMBER;
|
||||
oracle_err_mes VARCHAR2 (200);
|
||||
header_is_valid NUMBER;
|
||||
-- De importvelden
|
||||
v_bestelnummer VARCHAR2 (100);
|
||||
v_regelnummer VARCHAR2 (100);
|
||||
v_besteldatum VARCHAR2 (100);
|
||||
v_omschrijving VARCHAR2 (1000);
|
||||
v_nrbesteld VARCHAR2 (100);
|
||||
v_stukexcl VARCHAR2 (100);
|
||||
v_stukincl VARCHAR2 (100);
|
||||
v_eenheid VARCHAR2 (100);
|
||||
v_afleverdatum VARCHAR2 (100);
|
||||
v_nrgeleverd VARCHAR2 (100);
|
||||
v_kostenplaats VARCHAR2 (100);
|
||||
v_totaalexcl VARCHAR2 (100);
|
||||
v_btwcode VARCHAR2 (100);
|
||||
v_totaalbtw VARCHAR2 (100);
|
||||
v_totaalincl VARCHAR2 (100);
|
||||
v_factuurnr VARCHAR2 (100);
|
||||
v_check_dec_sign NUMBER (5, 2);
|
||||
v_bestelnummer VARCHAR2 (100);
|
||||
v_regelnummer VARCHAR2 (100);
|
||||
v_besteldatum VARCHAR2 (100);
|
||||
v_omschrijving VARCHAR2 (1000);
|
||||
v_nrbesteld VARCHAR2 (100);
|
||||
v_stukexcl VARCHAR2 (100);
|
||||
v_stukincl VARCHAR2 (100);
|
||||
v_eenheid VARCHAR2 (100);
|
||||
v_afleverdatum VARCHAR2 (100);
|
||||
v_nrgeleverd VARCHAR2 (100);
|
||||
v_kostenplaats VARCHAR2 (100);
|
||||
v_totaalexcl VARCHAR2 (100);
|
||||
v_btwcode VARCHAR2 (100);
|
||||
v_totaalbtw VARCHAR2 (100);
|
||||
v_totaalincl VARCHAR2 (100);
|
||||
v_factuurnr VARCHAR2 (100);
|
||||
v_check_dec_sign NUMBER (5, 2);
|
||||
|
||||
CURSOR cfactuur
|
||||
IS
|
||||
SELECT *
|
||||
SELECT fac_imp_file_line,
|
||||
LENGTH (TRIM (REPLACE (fac_imp_file_line, c_delim, '')))
|
||||
regellengte
|
||||
FROM fac_imp_file
|
||||
WHERE fac_import_key = p_import_key
|
||||
ORDER BY fac_imp_file_index;
|
||||
|
||||
v_rec cfactuur%ROWTYPE;
|
||||
v_rec cfactuur%ROWTYPE;
|
||||
BEGIN
|
||||
-- Init
|
||||
v_fielddelimitor := ';';
|
||||
header_is_valid := 0;
|
||||
|
||||
DELETE FROM uwva_imp_factuur;
|
||||
@@ -5839,121 +5854,119 @@ BEGIN
|
||||
DELETE imp_log
|
||||
WHERE imp_log_applicatie = 'FACTUUR';
|
||||
|
||||
-- check the client decimal settings
|
||||
-- we do not convert the , to a . if the client decimal separator is a ,
|
||||
-- Check the client decimal settings.
|
||||
-- Do not convert the ',' to a '.' if the client decimal separator is a ','!
|
||||
SELECT fac.safe_to_number ('2,5') INTO v_check_dec_sign FROM DUAL;
|
||||
|
||||
FOR v_rec IN cfactuur
|
||||
LOOP
|
||||
BEGIN
|
||||
v_newline := v_rec.fac_imp_file_line;
|
||||
v_newline := v_rec.fac_imp_file_line;
|
||||
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_bestelnummer);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_regelnummer);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_besteldatum);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_omschrijving);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_nrbesteld);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_stukexcl);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_stukincl);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_eenheid);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_afleverdatum);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_nrgeleverd);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_kostenplaats);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_totaalexcl);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_btwcode);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_totaalbtw);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_totaalincl);
|
||||
fac.imp_getfield (v_newline, v_fielddelimitor, v_factuurnr);
|
||||
fac.imp_getfield (v_newline, c_delim, v_bestelnummer);
|
||||
fac.imp_getfield (v_newline, c_delim, v_regelnummer);
|
||||
fac.imp_getfield (v_newline, c_delim, v_besteldatum);
|
||||
fac.imp_getfield (v_newline, c_delim, v_omschrijving);
|
||||
fac.imp_getfield (v_newline, c_delim, v_nrbesteld);
|
||||
fac.imp_getfield (v_newline, c_delim, v_stukexcl);
|
||||
fac.imp_getfield (v_newline, c_delim, v_stukincl);
|
||||
fac.imp_getfield (v_newline, c_delim, v_eenheid);
|
||||
fac.imp_getfield (v_newline, c_delim, v_afleverdatum);
|
||||
fac.imp_getfield (v_newline, c_delim, v_nrgeleverd);
|
||||
fac.imp_getfield (v_newline, c_delim, v_kostenplaats);
|
||||
fac.imp_getfield (v_newline, c_delim, v_totaalexcl);
|
||||
fac.imp_getfield (v_newline, c_delim, v_btwcode);
|
||||
fac.imp_getfield (v_newline, c_delim, v_totaalbtw);
|
||||
fac.imp_getfield (v_newline, c_delim, v_totaalincl);
|
||||
fac.imp_getfield (v_newline, c_delim, v_factuurnr);
|
||||
|
||||
-- We skippen alles todat we een geldige header tegenkomen
|
||||
-- Zie specs UWVA#16763
|
||||
IF (header_is_valid = 0)
|
||||
-- We skippen alles todat we een geldige header tegenkomen (zie specs
|
||||
-- UWVA#16763).
|
||||
IF (header_is_valid = 0)
|
||||
THEN
|
||||
IF UPPER (v_bestelnummer) = 'BESTELNUMMER'
|
||||
AND UPPER (v_regelnummer) = 'OPDRACHTREGELNUMMER'
|
||||
AND UPPER (v_besteldatum) = 'BESTELDATUM'
|
||||
AND UPPER (v_omschrijving) = 'ARTIKEL OMSCHRIJVING'
|
||||
AND UPPER (v_btwcode) = 'BTW CODE'
|
||||
AND UPPER (v_factuurnr) = 'FACTUURNR'
|
||||
THEN
|
||||
IF UPPER (v_bestelnummer) = 'BESTELNUMMER'
|
||||
AND UPPER (v_regelnummer) = 'OPDRACHTREGELNUMMER'
|
||||
AND UPPER (v_besteldatum) = 'BESTELDATUM'
|
||||
AND UPPER (v_omschrijving) = 'ARTIKEL OMSCHRIJVING'
|
||||
AND UPPER (v_btwcode) = 'BTW CODE'
|
||||
AND UPPER (v_factuurnr) = 'FACTUURNR'
|
||||
THEN
|
||||
header_is_valid := 1;
|
||||
END IF;
|
||||
header_is_valid := 1;
|
||||
END IF;
|
||||
ELSIF (v_rec.regellengte > 1) -- Lege regels overslaan!
|
||||
THEN
|
||||
IF v_check_dec_sign IS NULL
|
||||
THEN
|
||||
v_nrbesteld := REPLACE (SUBSTR (v_nrbesteld, 1, 11), ',', '.');
|
||||
v_stukexcl := REPLACE (SUBSTR (v_stukexcl, 1, 11), ',', '.');
|
||||
v_stukincl := REPLACE (SUBSTR (v_stukincl, 1, 11), ',', '.');
|
||||
v_nrgeleverd := REPLACE (SUBSTR (v_nrgeleverd, 1, 11), ',', '.');
|
||||
v_totaalexcl := REPLACE (SUBSTR (v_totaalexcl, 1, 11), ',', '.');
|
||||
v_totaalbtw := REPLACE (SUBSTR (v_totaalbtw, 1, 11), ',', '.');
|
||||
v_totaalincl := REPLACE (SUBSTR (v_totaalincl, 1, 11), ',', '.');
|
||||
ELSE
|
||||
IF v_check_dec_sign IS NULL
|
||||
THEN
|
||||
v_nrbesteld := REPLACE (SUBSTR (v_nrbesteld, 1, 11), ',', '.');
|
||||
v_stukexcl := REPLACE (SUBSTR (v_stukexcl, 1, 11), ',', '.');
|
||||
v_stukincl := REPLACE (SUBSTR (v_stukincl, 1, 11), ',', '.');
|
||||
v_nrgeleverd := REPLACE (SUBSTR (v_nrgeleverd, 1, 11), ',', '.');
|
||||
v_totaalexcl := REPLACE (SUBSTR (v_totaalexcl, 1, 11), ',', '.');
|
||||
v_totaalbtw := REPLACE (SUBSTR (v_totaalbtw, 1, 11), ',', '.');
|
||||
v_totaalincl := REPLACE (SUBSTR (v_totaalincl, 1, 11), ',', '.');
|
||||
ELSE
|
||||
v_nrbesteld := SUBSTR (v_nrbesteld, 1, 11);
|
||||
v_stukexcl := SUBSTR (v_stukexcl, 1, 11);
|
||||
v_stukincl := SUBSTR (v_stukincl, 1, 11);
|
||||
v_nrgeleverd := SUBSTR (v_nrgeleverd, 1, 11);
|
||||
v_totaalexcl := SUBSTR (v_totaalexcl, 1, 11);
|
||||
v_totaalbtw := SUBSTR (v_totaalbtw, 1, 11);
|
||||
v_totaalincl := SUBSTR (v_totaalincl, 1, 11);
|
||||
END IF;
|
||||
|
||||
INSERT INTO uwva_imp_factuur (
|
||||
bestelnummer,
|
||||
regelnummer,
|
||||
besteldatum,
|
||||
omschrijving,
|
||||
nrbesteld,
|
||||
stukexcl,
|
||||
stukincl,
|
||||
eenheid,
|
||||
afleverdatum,
|
||||
nrgeleverd,
|
||||
kostenplaats,
|
||||
totaalexcl,
|
||||
btwcode,
|
||||
totaalbtw,
|
||||
totaalincl,
|
||||
factuurnr
|
||||
)
|
||||
VALUES (
|
||||
RTRIM (SUBSTR (v_bestelnummer, 1, 15)),
|
||||
RTRIM (SUBSTR (v_regelnummer, 1, 5)),
|
||||
RTRIM (SUBSTR (v_besteldatum, 1, 8)),
|
||||
RTRIM (SUBSTR (v_omschrijving, 1, 60)),
|
||||
RTRIM (SUBSTR (v_nrbesteld, 1, 10)),
|
||||
RTRIM (SUBSTR (v_stukexcl, 1, 10)),
|
||||
RTRIM (SUBSTR (v_stukincl, 1, 10)),
|
||||
RTRIM (SUBSTR (v_eenheid, 1, 30)),
|
||||
RTRIM (SUBSTR (v_afleverdatum, 1, 8)),
|
||||
RTRIM (SUBSTR (v_nrgeleverd, 1, 10)),
|
||||
RTRIM (SUBSTR (v_kostenplaats, 1, 8)),
|
||||
RTRIM (SUBSTR (v_totaalexcl, 1, 10)),
|
||||
RTRIM (SUBSTR (v_btwcode, 1, 1)),
|
||||
RTRIM (SUBSTR (v_totaalbtw, 1, 10)),
|
||||
RTRIM (SUBSTR (v_totaalincl, 1, 10)),
|
||||
RTRIM (SUBSTR (v_factuurnr, 1, 30))
|
||||
);
|
||||
v_nrbesteld := SUBSTR (v_nrbesteld, 1, 11);
|
||||
v_stukexcl := SUBSTR (v_stukexcl, 1, 11);
|
||||
v_stukincl := SUBSTR (v_stukincl, 1, 11);
|
||||
v_nrgeleverd := SUBSTR (v_nrgeleverd, 1, 11);
|
||||
v_totaalexcl := SUBSTR (v_totaalexcl, 1, 11);
|
||||
v_totaalbtw := SUBSTR (v_totaalbtw, 1, 11);
|
||||
v_totaalincl := SUBSTR (v_totaalincl, 1, 11);
|
||||
END IF;
|
||||
|
||||
INSERT INTO uwva_imp_factuur (bestelnummer,
|
||||
regelnummer,
|
||||
besteldatum,
|
||||
omschrijving,
|
||||
nrbesteld,
|
||||
stukexcl,
|
||||
stukincl,
|
||||
eenheid,
|
||||
afleverdatum,
|
||||
nrgeleverd,
|
||||
kostenplaats,
|
||||
totaalexcl,
|
||||
btwcode,
|
||||
totaalbtw,
|
||||
totaalincl,
|
||||
factuurnr)
|
||||
VALUES (RTRIM (SUBSTR (v_bestelnummer, 1, 15)),
|
||||
RTRIM (SUBSTR (v_regelnummer, 1, 5)),
|
||||
RTRIM (SUBSTR (v_besteldatum, 1, 8)),
|
||||
RTRIM (SUBSTR (v_omschrijving, 1, 60)),
|
||||
RTRIM (SUBSTR (v_nrbesteld, 1, 10)),
|
||||
RTRIM (SUBSTR (v_stukexcl, 1, 10)),
|
||||
RTRIM (SUBSTR (v_stukincl, 1, 10)),
|
||||
RTRIM (SUBSTR (v_eenheid, 1, 30)),
|
||||
RTRIM (SUBSTR (v_afleverdatum, 1, 8)),
|
||||
RTRIM (SUBSTR (v_nrgeleverd, 1, 10)),
|
||||
RTRIM (SUBSTR (v_kostenplaats, 1, 8)),
|
||||
RTRIM (SUBSTR (v_totaalexcl, 1, 10)),
|
||||
RTRIM (SUBSTR (v_btwcode, 1, 1)),
|
||||
RTRIM (SUBSTR (v_totaalbtw, 1, 10)),
|
||||
RTRIM (SUBSTR (v_totaalincl, 1, 10)),
|
||||
RTRIM (SUBSTR (v_factuurnr, 1, 30)));
|
||||
|
||||
COMMIT;
|
||||
END;
|
||||
END IF;
|
||||
END LOOP;
|
||||
EXCEPTION
|
||||
WHEN OTHERS
|
||||
THEN
|
||||
oracle_err_num := SQLCODE;
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 100);
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 200);
|
||||
v_errormsg := 'Error: ' || oracle_err_num || '/' || oracle_err_mes;
|
||||
fac.imp_writelog (p_import_key, 'E', v_errormsg, '');
|
||||
fac.imp_writelog (p_import_key,
|
||||
'E',
|
||||
v_errormsg,
|
||||
'Inleesproces facturen afgebroken!');
|
||||
END;
|
||||
/
|
||||
|
||||
/* Formatted on 21-2-2013 13:14:45 (QP5 v5.115.810.9015) */
|
||||
/* Formatted on 10-6-2013 13:34:36 (QP5 v5.115.810.9015) */
|
||||
CREATE OR REPLACE PROCEDURE uwva_update_factuur (p_import_key IN NUMBER)
|
||||
AS
|
||||
-- een factuur(record) wordt aangemaakt voor iedere factuurnr/bestelnummer combinatie
|
||||
-- en dan wordt voor iedere regel een regel aangemaakt (of niet dan?)
|
||||
-- Een factuur(record) wordt aangemaakt voor iedere factuurnr/bestelnummer-
|
||||
-- combinatie en dan wordt voor iedere regel een regel(record) aangemaakt.
|
||||
CURSOR cfactuurregel
|
||||
IS
|
||||
SELECT imp.*, btw.*
|
||||
@@ -5963,7 +5976,9 @@ AS
|
||||
fac.safe_to_date (besteldatum, 'yyyymmdd')
|
||||
besteldatum,
|
||||
fac.safe_to_number (totaalexcl) totaalexcl,
|
||||
fac.safe_to_number (totaalbtw) totaalbtw,
|
||||
--fac.safe_to_number (totaalbtw) totaalbtw,
|
||||
fac.safe_to_number (COALESCE (totaalbtw, '0'))
|
||||
totaalbtw,
|
||||
fac.safe_to_number (nrbesteld) nrbesteld,
|
||||
fac.safe_to_number (nrgeleverd) nrgeleverd,
|
||||
afleverdatum,
|
||||
@@ -5984,6 +5999,8 @@ AS
|
||||
AND btw.fin_btwtabel_key = 1 -- NL standaard
|
||||
ORDER BY imp.factuurnr, imp.bestelnummer, imp.regelnummer;
|
||||
|
||||
v_errormsg VARCHAR2 (1000);
|
||||
oracle_err_mes VARCHAR2 (200);
|
||||
c_i NUMBER;
|
||||
c_teller NUMBER;
|
||||
c_newfactuurkey NUMBER;
|
||||
@@ -5996,22 +6013,18 @@ AS
|
||||
c_bestelnummer_t VARCHAR2 (40);
|
||||
c_old_bestelnummer uwva_imp_factuur.bestelnummer%TYPE;
|
||||
c_old_factuurnr uwva_imp_factuur.factuurnr%TYPE;
|
||||
c_write_bestelnummer VARCHAR2 (20);
|
||||
--c_write_bestelnummer VARCHAR2 (20);
|
||||
c_bestelopdr_id VARCHAR2 (20);
|
||||
c_totaal NUMBER;
|
||||
c_fact_totaal NUMBER;
|
||||
c_factuur_totaal NUMBER;
|
||||
c_factuur_btw NUMBER;
|
||||
c_fact_tot NUMBER;
|
||||
c_fact_totbtw NUMBER;
|
||||
c_find BOOLEAN;
|
||||
c_find_bestelnummer BOOLEAN;
|
||||
--c_find_bestelnummer BOOLEAN;
|
||||
c_mld_opdr_key NUMBER (10);
|
||||
c_cnt_contract_key NUMBER (10);
|
||||
c_bes_bestelopdr_key NUMBER (10);
|
||||
c_prs_bedrijf_naam VARCHAR2 (100);
|
||||
c_opmerking VARCHAR2 (150);
|
||||
v_errormsg VARCHAR (200);
|
||||
oracle_err_mes VARCHAR2 (150);
|
||||
c_factuur_datum DATE;
|
||||
--c_opmerking VARCHAR2 (200);
|
||||
c_fact_datum DATE;
|
||||
|
||||
FUNCTION getfactype (pbestelnr IN VARCHAR2)
|
||||
RETURN VARCHAR2
|
||||
@@ -6036,10 +6049,10 @@ AS
|
||||
THEN
|
||||
lfactype := 'C'; -- Contract
|
||||
ELSE
|
||||
fac.imp_writelog (p_import_key,
|
||||
'I',
|
||||
'Kan besteltype niet bepalen voor ' || pbestelnr,
|
||||
pbestelnr);
|
||||
uwva_imp_writelog (p_import_key,
|
||||
'I',
|
||||
'Kan besteltype niet bepalen voor ' || pbestelnr,
|
||||
pbestelnr);
|
||||
END IF;
|
||||
|
||||
RETURN lfactype;
|
||||
@@ -6048,7 +6061,7 @@ BEGIN
|
||||
c_old_bestelnummer := '';
|
||||
c_old_factuurnr := '';
|
||||
c_teller := 0;
|
||||
c_factuur_datum := SYSDATE;
|
||||
c_fact_datum := SYSDATE;
|
||||
|
||||
-- Facturen
|
||||
FOR rc IN cfactuurregel
|
||||
@@ -6056,8 +6069,7 @@ BEGIN
|
||||
IF rc.bestelnummer = c_old_bestelnummer
|
||||
AND rc.factuurnr = c_old_factuurnr
|
||||
THEN
|
||||
-- voeg nieuwe factuurregel toe
|
||||
-- waarde van c_newfactuurkey is nog steeds actueel
|
||||
-- Toevoegen nieuwe factuurregel; c_newfactuurkey nog steeds actueel!
|
||||
c_factuurregel := c_factuurregel + 1;
|
||||
|
||||
BEGIN
|
||||
@@ -6076,8 +6088,7 @@ BEGIN
|
||||
rc.kostenplaats,
|
||||
rc.fin_btwtabelwaarde_key);
|
||||
|
||||
COMMIT;
|
||||
fac.imp_writelog (
|
||||
uwva_imp_writelog (
|
||||
p_import_key,
|
||||
'I',
|
||||
'Factuurregel '
|
||||
@@ -6089,24 +6100,23 @@ BEGIN
|
||||
EXCEPTION
|
||||
WHEN OTHERS
|
||||
THEN
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 150);
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 200);
|
||||
v_errormsg := 'Error ' || oracle_err_mes;
|
||||
fac.imp_writelog (
|
||||
uwva_imp_writelog (
|
||||
p_import_key,
|
||||
'W',
|
||||
'Factuur(regel) kan niet toegevoegd worden ' || v_errormsg,
|
||||
rc.bestelnummer || '/' || rc.factuurnr
|
||||
'Kan factuur(regel) niet toevoegen! ' || v_errormsg,
|
||||
rc.bestelnummer || ' / ' || rc.factuurnr
|
||||
);
|
||||
END;
|
||||
|
||||
c_teller := c_teller + 1;
|
||||
ELSE
|
||||
-- nieuwe factuur
|
||||
-- Toevoegen nieuwe factuur + factuurregel!
|
||||
c_old_bestelnummer := rc.bestelnummer;
|
||||
c_old_factuurnr := rc.factuurnr;
|
||||
c_factuurregel := 1;
|
||||
c_bestelnummer_index := INSTR (rc.bestelnummer, '/');
|
||||
c_totaal := 0;
|
||||
c_mld_opdr_key := NULL;
|
||||
c_cnt_contract_key := NULL;
|
||||
c_bes_bestelopdr_key := NULL;
|
||||
@@ -6123,20 +6133,20 @@ BEGIN
|
||||
END IF;
|
||||
|
||||
c_find := FALSE;
|
||||
c_find_bestelnummer := FALSE;
|
||||
--c_find_bestelnummer := FALSE;
|
||||
c_fac_type := '';
|
||||
|
||||
c_fac_type := getfactype (rc.bestelnummer);
|
||||
|
||||
IF c_fac_type = 'O'
|
||||
THEN
|
||||
IF (c_bestelnummer_index != 0
|
||||
AND (ASCII (c_prefix1) >= 48 AND ASCII(c_prefix1) <= 57))
|
||||
-- Er is geen prefix maar het is wel een opdracht
|
||||
-- Afgedwongen door /
|
||||
IF c_bestelnummer_index != 0
|
||||
AND ASCII (c_prefix1) >= 48
|
||||
AND ASCII (c_prefix1) <= 57
|
||||
-- Geen prefix maar het is wel een opdracht (afgedwongen door /).
|
||||
THEN
|
||||
-- c_bestelnummer_s2 bevat al het gedeelte na de /
|
||||
-- c_bestelnummer_s1 bevat geen prefix
|
||||
-- c_bestelnummer_s2 bevat het gedeelte na de /
|
||||
c_find := TRUE;
|
||||
ELSE
|
||||
c_i := 1;
|
||||
@@ -6157,31 +6167,33 @@ BEGIN
|
||||
THEN
|
||||
c_bestelnummer_s1 := SUBSTR (c_bestelnummer_s1, c_i);
|
||||
ELSE
|
||||
fac.imp_writelog (p_import_key,
|
||||
'W',
|
||||
'Kan bestelnummer niet bepalen ',
|
||||
rc.bestelnummer || ' / ' || rc.factuurnr);
|
||||
uwva_imp_writelog (
|
||||
p_import_key,
|
||||
'W',
|
||||
'Kan bestelnummer niet bepalen!',
|
||||
rc.bestelnummer || ' / ' || rc.factuurnr
|
||||
);
|
||||
END IF;
|
||||
END IF;
|
||||
ELSIF c_fac_type = 'C'
|
||||
THEN
|
||||
-- haal prefix 'C' of 'c' eraf
|
||||
-- Haal prefix 'C' of 'c' eraf.
|
||||
c_bestelnummer_s1 := SUBSTR (c_bestelnummer_s1, 2);
|
||||
c_find := TRUE;
|
||||
ELSIF c_fac_type = 'B'
|
||||
THEN
|
||||
-- haal prefix O- eraf, c_bestelnummer_s1 is goed
|
||||
-- Haal prefix O- eraf; c_bestelnummer_s2 is goed.
|
||||
c_bestelnummer_s1 := SUBSTR (c_bestelnummer_s1, 3);
|
||||
c_find := TRUE;
|
||||
END IF;
|
||||
|
||||
-- c_bestelnummer_s1 bevat ordernummer
|
||||
-- c_bestelnummer_s2 bevat volgnummer van de opdracht bij meldingen
|
||||
-- Bij bestellingen en contracten is deze waarde leeg
|
||||
-- Vind nu de onderliggende 'O', 'C' of 'B'
|
||||
-- c_bestelnummer_s2 bevat volgnummer van de (bestel)opdracht; bij
|
||||
-- contracten is deze waarde leeg
|
||||
-- Vind nu de onderliggende 'O', 'C' of 'B'.
|
||||
IF c_fac_type = 'O'
|
||||
THEN
|
||||
-- bestaat de opdracht wel <20>n is deze geldig!?
|
||||
-- Bestaat de opdracht wel <20>n is deze geldig!?
|
||||
BEGIN
|
||||
SELECT mld_opdr_key
|
||||
INTO c_mld_opdr_key
|
||||
@@ -6190,18 +6202,18 @@ BEGIN
|
||||
fac.safe_to_number (c_bestelnummer_s1)
|
||||
AND mld_opdr_bedrijfopdr_volgnr =
|
||||
fac.safe_to_number (c_bestelnummer_s2)
|
||||
AND mld_statusopdr_key NOT IN (1, 2, 3); -- dat zijn (nog) ongeldige opdrachten
|
||||
AND mld_statusopdr_key NOT IN (1, 2, 3); -- Ongeldige opdrachten (nog)
|
||||
EXCEPTION
|
||||
WHEN NO_DATA_FOUND
|
||||
THEN
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 150);
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 200);
|
||||
v_errormsg := 'Error ' || oracle_err_mes;
|
||||
fac.imp_writelog (
|
||||
uwva_imp_writelog (
|
||||
p_import_key,
|
||||
'W',
|
||||
'Kan opdrachtreferentie '
|
||||
|| rc.bestelnummer
|
||||
|| ' niet vinden '
|
||||
|| ' niet vinden! '
|
||||
|| v_errormsg,
|
||||
c_bestelnummer_s1 || '/' || c_bestelnummer_s2
|
||||
);
|
||||
@@ -6209,7 +6221,7 @@ BEGIN
|
||||
END;
|
||||
ELSIF c_fac_type = 'C'
|
||||
THEN
|
||||
-- bestaat het contract wel (zie ook UWVA#23124 + UWVA#24359 + UWVA#25579)?
|
||||
-- Bestaat het contract wel (zie ook UWVA#23124 + UWVA#24359 + UWVA#25579)!?
|
||||
BEGIN
|
||||
SELECT cnt_contract_key
|
||||
INTO c_cnt_contract_key
|
||||
@@ -6233,7 +6245,7 @@ BEGIN
|
||||
FROM cnt_v_aanwezigcontract c
|
||||
WHERE c.cnt_contract_nummer_intern =
|
||||
c_bestelnummer_s1
|
||||
AND c.ins_discipline_key = 360 -- Abonnementen
|
||||
AND c.ins_discipline_key = 360 -- Abonnementen
|
||||
AND c.cnt_contract_status = 0 -- NIET Gesloten!
|
||||
AND NOT EXISTS -- Alleen laatste versies van contracten!
|
||||
(SELECT 1
|
||||
@@ -6245,14 +6257,14 @@ BEGIN
|
||||
EXCEPTION
|
||||
WHEN NO_DATA_FOUND
|
||||
THEN
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 150);
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 200);
|
||||
v_errormsg := 'Error ' || oracle_err_mes;
|
||||
fac.imp_writelog (
|
||||
uwva_imp_writelog (
|
||||
p_import_key,
|
||||
'W',
|
||||
'Kan contractreferentie '
|
||||
|| rc.bestelnummer
|
||||
|| ' niet vinden '
|
||||
|| ' niet vinden! '
|
||||
|| v_errormsg,
|
||||
c_bestelnummer_s1
|
||||
);
|
||||
@@ -6260,9 +6272,9 @@ BEGIN
|
||||
END;
|
||||
ELSIF c_fac_type = 'B'
|
||||
THEN
|
||||
-- bestaat de bestelopdracht wel <20>n is deze geldig!?
|
||||
-- Bestaat de bestelopdracht wel <20>n is deze geldig!?
|
||||
BEGIN
|
||||
IF c_bestelnummer_s2 IS NULL
|
||||
IF c_bestelnummer_s2 IS NULL -- Kan dat (nog) wel???
|
||||
THEN
|
||||
c_bestelnummer_t := c_bestelnummer_s1;
|
||||
ELSE
|
||||
@@ -6281,18 +6293,18 @@ BEGIN
|
||||
INTO c_bes_bestelopdr_key
|
||||
FROM bes_bestelopdr
|
||||
WHERE bes_bestelopdr_id = c_bestelnummer_t
|
||||
AND bes_bestelopdr_status IN (4, 6, 7);
|
||||
AND bes_bestelopdr_status IN (4, 6, 7); -- Geldige bestelopdrachten
|
||||
EXCEPTION
|
||||
WHEN OTHERS
|
||||
THEN
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 150);
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 200);
|
||||
v_errormsg := 'Error ' || oracle_err_mes;
|
||||
fac.imp_writelog (
|
||||
uwva_imp_writelog (
|
||||
p_import_key,
|
||||
'W',
|
||||
'Kan bestelopdrachtreferentie '
|
||||
|| rc.bestelnummer
|
||||
|| ' niet vinden '
|
||||
|| ' niet vinden! '
|
||||
|| v_errormsg,
|
||||
c_bestelnummer_s1 || '/' || c_bestelnummer_s2
|
||||
);
|
||||
@@ -6300,7 +6312,7 @@ BEGIN
|
||||
END;
|
||||
END IF;
|
||||
|
||||
c_opmerking := '';
|
||||
--c_opmerking := '';
|
||||
|
||||
BEGIN
|
||||
SELECT fin_s_fin_factuur_key.NEXTVAL
|
||||
@@ -6308,7 +6320,7 @@ BEGIN
|
||||
FROM DUAL;
|
||||
|
||||
SELECT SUM (totaalexcl) totaal, SUM (totaalbtw) totaalbtw
|
||||
INTO c_factuur_totaal, c_factuur_btw
|
||||
INTO c_fact_tot, c_fact_totbtw
|
||||
FROM uwva_imp_factuur
|
||||
WHERE bestelnummer = rc.bestelnummer
|
||||
AND factuurnr = rc.factuurnr;
|
||||
@@ -6326,20 +6338,18 @@ BEGIN
|
||||
fin_factuur_nr,
|
||||
fin_factuur_boekmaand)
|
||||
VALUES (c_newfactuurkey,
|
||||
c_factuur_totaal,
|
||||
c_factuur_btw,
|
||||
c_fact_tot,
|
||||
c_fact_totbtw,
|
||||
c_mld_opdr_key,
|
||||
c_cnt_contract_key,
|
||||
c_bes_bestelopdr_key,
|
||||
NULL,
|
||||
c_factuur_datum,
|
||||
'Ge<EFBFBD>mporteerde factuur ' || c_opmerking,
|
||||
c_fact_datum,
|
||||
'Ge<EFBFBD>mporteerde factuur', -- ' || c_opmerking,
|
||||
2,
|
||||
rc.factuurnr,
|
||||
SUBSTR (rc.afleverdatum, 1, 6));
|
||||
|
||||
COMMIT;
|
||||
|
||||
fac.trackaction ('FINNEW',
|
||||
c_newfactuurkey,
|
||||
NULL,
|
||||
@@ -6361,39 +6371,36 @@ BEGIN
|
||||
rc.kostenplaats,
|
||||
rc.fin_btwtabelwaarde_key);
|
||||
|
||||
COMMIT;
|
||||
--IF c_find_bestelnummer
|
||||
--THEN
|
||||
-- c_write_bestelnummer := c_bestelopdr_id;
|
||||
--ELSE
|
||||
-- c_write_bestelnummer := rc.bestelnummer;
|
||||
--END IF;
|
||||
|
||||
IF c_find_bestelnummer
|
||||
THEN
|
||||
c_write_bestelnummer := c_bestelopdr_id;
|
||||
ELSE
|
||||
c_write_bestelnummer := rc.bestelnummer;
|
||||
END IF;
|
||||
|
||||
fac.imp_writelog (
|
||||
uwva_imp_writelog (
|
||||
p_import_key,
|
||||
'I',
|
||||
'Factuur '
|
||||
|| c_newfactuurkey
|
||||
|| ' toegevoegd met factuurregel '
|
||||
|| c_factuurregel,
|
||||
c_write_bestelnummer || ' / ' || rc.factuurnr
|
||||
--c_write_bestelnummer || ' / ' || rc.factuurnr
|
||||
rc.bestelnummer || ' / ' || rc.factuurnr
|
||||
);
|
||||
EXCEPTION
|
||||
WHEN OTHERS
|
||||
THEN
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 150);
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 200);
|
||||
v_errormsg := 'Error ' || oracle_err_mes;
|
||||
fac.imp_writelog (
|
||||
uwva_imp_writelog (
|
||||
p_import_key,
|
||||
'W',
|
||||
'Factuur(regel) kan niet toegevoegd worden ' || v_errormsg,
|
||||
'Kan factuur(regel) niet toevoegen! ' || v_errormsg,
|
||||
rc.bestelnummer || '/' || rc.factuurnr
|
||||
);
|
||||
END;
|
||||
|
||||
-- END IF;
|
||||
|
||||
c_teller := c_teller + 1;
|
||||
END IF;
|
||||
END LOOP;
|
||||
@@ -6401,17 +6408,44 @@ BEGIN
|
||||
-- Zet facturen automatisch op Akkoord als deze aan match-criteria voldoen.
|
||||
FOR rc IN ( SELECT f.fin_factuur_key factuur_key
|
||||
FROM fin_factuur f
|
||||
WHERE f.fin_factuur_datum = c_factuur_datum
|
||||
WHERE f.fin_factuur_datum = c_fact_datum
|
||||
ORDER BY f.fin_factuur_key)
|
||||
LOOP
|
||||
FIN.matchandsetfactuur (rc.factuur_key, FALSE);
|
||||
COMMIT;
|
||||
--COMMIT;
|
||||
END LOOP;
|
||||
|
||||
-- UWVA#19018: Notificeer niet gefiatteerde facturen naar de budgethouders (1 mail per persoon)
|
||||
-- Maakt hierbij niet veel uit of ze net zijn geimporteerd of vroeger (of handmatig ingevoerd)
|
||||
-- Medium wordt bepaalt door mode bij FININF
|
||||
-- UWVA#19018: Notificeer niet goedgekeurde facturen naar de budgethouders
|
||||
-- (1 mail per persoon). Hierbij maakt het niet veel uit of ze net zijn
|
||||
-- geimporteerd of al eerder (of handmatig ingevoerd). Medium wordt bepaald
|
||||
-- door mode bij FININF.
|
||||
fac.putjobnotifications ('uwva_v_noti_finreminder', NULL, 0);
|
||||
|
||||
SELECT COUNT ( * )
|
||||
INTO c_i
|
||||
FROM imp_log
|
||||
WHERE fac_import_key = p_import_key AND imp_log_status IN ('E', 'W');
|
||||
|
||||
IF c_i > 0
|
||||
THEN
|
||||
uwva_imp_writelog (p_import_key,
|
||||
'E',
|
||||
v_errormsg,
|
||||
'Importproces facturen afgebroken!');
|
||||
ROLLBACK;
|
||||
ELSE
|
||||
COMMIT;
|
||||
END IF;
|
||||
EXCEPTION
|
||||
WHEN OTHERS
|
||||
THEN
|
||||
oracle_err_mes := SUBSTR (SQLERRM, 1, 200);
|
||||
v_errormsg := 'Error ' || oracle_err_mes;
|
||||
uwva_imp_writelog (p_import_key,
|
||||
'E',
|
||||
v_errormsg,
|
||||
'Importproces facturen afgebroken!');
|
||||
ROLLBACK;
|
||||
END;
|
||||
/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user