-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxr-validate
executable file
·83 lines (67 loc) · 2.7 KB
/
xr-validate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
# Copyright 2024 - present Dr Tim Brunne (Munich)
#
# This file is part of XFakturist, <https://github.com/drbrnn/XFakturist>.
#
# XFakturist is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# XFakturist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with XFakturist. If not, see <http://www.gnu.org/licenses/>.
# purpose: Validate electronic invoices in XML format that are intended
# to be compliant with European norm EN 16931 and, potentially,
# also with a specific Core Invoice Usage Specification (CIUS),
# which is German XRechnung standard in the context of this
# software. For the validation and validation configuration, this
# script employs the reference implementation of German government
# body KoSIT, which is also responsible for the specification of
# the standard XRechnung.
# see: https://ec.europa.eu/digital-building-blocks/sites/display/DIGITAL/EN+16931+compliance
# https://ec.europa.eu/digital-building-blocks/sites/display/DIGITAL/eInvoicing+in+Germany
# https://xeinkauf.de/xrechnung/
# (-1-) determine real path to the script: resolve (multiple) soft link(s)
SCRIPT="$0"
while [ -h "$SCRIPT" ]
do
LS_SCRIPT=`ls -ld "$SCRIPT"`
LINK=`expr "$LS_SCRIPT" : '.*-> \(.*\)$'`
if expr "$LINK" : '/.*' > /dev/null
then
SCRIPT="$LINK"
else
SCRIPT=`dirname "$SCRIPT"`/"$LINK"
fi
done
# (-2-) get invoice file name (1st script parameter)
INVOICE=$1
ERROR=""
if [ -z "${INVOICE}" ]; then
ERROR="usage: $(basename $0) <XML electronic invoice>"
elif [ ! -f "${INVOICE}" ] ; then
ERROR="${INVOICE} - invoice file does not exist"
fi
if [ -n "${ERROR}" ] ; then
echo ${ERROR}
echo "an error occurred, execution halted"
exit 1
else
INVOICE_BASENAME=$(basename ${INVOICE})
INVOICE_BASENAME=${INVOICE_BASENAME%.*}
fi
# (-3-) run the KoSIT validator
KOSIT_DIR="$(dirname ${SCRIPT})/kosit-xr"
java -jar ${KOSIT_DIR}/validationtool.jar \
-s ${KOSIT_DIR}/validator-configuration/scenarios.xml \
-r ${KOSIT_DIR}/validator-configuration \
-h ${INVOICE}
for REPORT in ${INVOICE_BASENAME}-report.*ml
do
mv ${REPORT} $(echo ${REPORT} | sed "s/-report\./_validation_report./")
done