| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | Quiq::Mustang - Frontend für Mustang Kommendozeilen-Werkzeug | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | L<Quiq::Hash> | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | B<Mustang> ist eine Java-Biblithek sowie ein Kommandzeilen-Werkzeug für den | ||||||||||||||||||||||||||||
| 16 | Umgang mit ZUGFeRD-Rechnungen. Die Klasse Quiq::Mustang stellt ein | ||||||||||||||||||||||||||||
| 17 | Perl-Frontend für die Nutzung des Kommandozeilen-Werkzeugs bereit. | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head2 Links | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =over 2 | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =item * | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | L<Homepage Mustang-Projekt|https://www.mustangproject.org/> | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =item * | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | L<Kommandozeilen-Werkzeug|https://www.mustangproject.org/commandline/> | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =item * | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | L<Mustang-Projekt auf GitHub|https://github.com/ZUGFeRD/mustangproject> | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =back | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =cut | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | package Quiq::Mustang; | ||||||||||||||||||||||||||||
| 42 | 1 | ▶ | use base qw/Quiq::Hash/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 46 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | our $VERSION = '1.240'; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 1 | ▶ | use Quiq::Path; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 51 | 1 | ▶ | use Quiq::PerlModule; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 52 | 1 | ▶ | use Quiq::Shell; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 1 | ▶ | use Quiq::Html::Producer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 54 | 1 | ▶ | use Quiq::Html::List; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 55 | 1 | ▶ | use Quiq::Html::Page; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head1 METHODS | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head2 Klassenmethoden | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head3 new() - Konstruktor | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | $mus = $class->new($jarFile,%options); | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =head4 Arguments | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =over 4 | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =item $jarFile | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | Pfad zur JAR-Datei C<Mustang-CLI-X.Y.Z.jar>, z.B. | ||||||||||||||||||||||||||||
| 76 | C<~/Mustang-CLI-2.16.2.jar> | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =back | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =head4 Options | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =over 4 | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =item -javaDir => $javaDir (Default: undef) | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | Verzeichns mit dem Programm C<java>. Beispiel: C</opt/jdk/bin> | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =back | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =head4 Returns | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | Mustang-Objekt | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head4 Description | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Instantiiere ein Objekt der Klasse und liefere eine Referenz auf | ||||||||||||||||||||||||||||
| 97 | dieses Objekt zurück. | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =cut | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 104 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | # Optionen und Argumente | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | my $javaDir = undef; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | my $argA = $class->parameters(1,1,\@_, | |||||||||||||||||||||||||||
| 111 | -javaDir => \$javaDir, | ||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||
| 113 | 0 | my $jarFile = shift @$argA; | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if (!Quiq::Path->exists($jarFile)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | 0 | $class->throw( | |||||||||||||||||||||||||||
| 117 | 'MUSTANG-00099: Jarfile does not exists', | ||||||||||||||||||||||||||||
| 118 | JarFile => $jarFile, | ||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | my $mustangDir; | |||||||||||||||||||||||||||
| 123 | 0 | ▶ | if ($0 =~ /\.cotedo/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 0 | $mustangDir = $ENV{'HOME'}.'/dvl/jaz/Blob/mustang'; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | else { | ||||||||||||||||||||||||||||
| 127 | 0 | my $mod = Quiq::PerlModule->new('Quiq::Mustang'); | |||||||||||||||||||||||||||
| 128 | 0 | $mustangDir = $mod->moduleDir; | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | my $javaExe = 'java'; | |||||||||||||||||||||||||||
| 132 | 0 | ▶ | if ($javaDir) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 0 | $javaExe = "$javaDir/$javaExe"; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 0 | return $class->SUPER::new( | |||||||||||||||||||||||||||
| 137 | mustangDir => $mustangDir, | ||||||||||||||||||||||||||||
| 138 | javaExe => $javaExe, | ||||||||||||||||||||||||||||
| 139 | jarFile => $jarFile, | ||||||||||||||||||||||||||||
| 140 | brH => undef, # wird bei Bedarf geladen | ||||||||||||||||||||||||||||
| 141 | ); | ||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | =head2 Objektmethoden | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | =head3 validate() - Validiere ZUGFeRD-Datei | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | $status = $mus->validate($file,%options); | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =head4 Arguments | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | =over 4 | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | =item $file | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | ZUGFeRD-Datei, wie B<Mustang> sie erwartet (als XML oder PDF). | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =back | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | =head4 Options | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | =over 4 | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | =item -logger => $log (Default: undef) | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | Gib Laufzeitinformation über die Verarbeitung via $log aus. | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | =item -notice => $bool (Default: 0) | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | Protokolliere nicht nur Validierungsfehler, sondern gib darüber | ||||||||||||||||||||||||||||
| 175 | hinaus Empfehlungen zu Verbesserungen am ZUGFeRD XML aus. | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | =item -verbose => $bool (Default: 0) | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | Gib Laufzeitinformation über die Verarbeitung auf STDOUT aus. | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | =back | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | =head4 Returns | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | (Integer) Status der Validierung: 0 = ok, 1 = fehlgeschlagen. | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | =head4 Description | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | Validiere die ZUGFeRD-Datei $file und liefere den Status der | ||||||||||||||||||||||||||||
| 190 | Validierung zurück. Ferner wird eine XML-Datei geschrieben(_result.xml), | ||||||||||||||||||||||||||||
| 191 | die das Validierungsergebnis enhält. | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | =cut | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub validate { | ||||||||||||||||||||||||||
|
Subroutine
validate: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 198 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | # Optionen und Argumente | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | my $force = 0; | |||||||||||||||||||||||||||
| 203 | 0 | my $log = undef, | |||||||||||||||||||||||||||
| 204 | my $notice = 0; | ||||||||||||||||||||||||||||
| 205 | 0 | my $verbose = 0; | |||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 0 | my $argA = $self->parameters(1,1,\@_, | |||||||||||||||||||||||||||
| 208 | -logger => \$log, | ||||||||||||||||||||||||||||
| 209 | -notice => \$notice, | ||||||||||||||||||||||||||||
| 210 | -verbose => \$verbose, | ||||||||||||||||||||||||||||
| 211 | ); | ||||||||||||||||||||||||||||
| 212 | 0 | my $file = shift @$argA; | |||||||||||||||||||||||||||
| 213 | 0 | ▶ | my $noticeOpt = $notice? '': ' --no-notice'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | my $p = Quiq::Path->new; | |||||||||||||||||||||||||||
| 216 | 0 | my $sh = Quiq::Shell->new(sloppy=>1); | |||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 0 | (my $dir,$file,my $basename) = $p->split($file); | |||||||||||||||||||||||||||
| 219 | # $dir ||= '.'; | ||||||||||||||||||||||||||||
| 220 | 0 | $sh->cd($dir); | |||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | my $resultFile = sprintf '%s_result.xml',$basename; | |||||||||||||||||||||||||||
| 223 | 0 | my $logFile = sprintf '%s_result.log',$basename; | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 0 | my $status; | |||||||||||||||||||||||||||
| 226 | 0 | my $javaExe = $self->javaExe; | |||||||||||||||||||||||||||
| 227 | 0 | my $cmd = "$javaExe -Xmx1G -Dfile.encoding=UTF-8". | |||||||||||||||||||||||||||
| 228 | " -jar $self->{'jarFile'} --action validate". | ||||||||||||||||||||||||||||
| 229 | " --source $file --log-as-pdf$noticeOpt >$resultFile 2>$logFile"; | ||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if ($log) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 0 | $log->info("Validiere ZUGFeRD-XML: $cmd"); | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | 0 | my $exitCode = $sh->exec($cmd,-log=>$verbose); | |||||||||||||||||||||||||||
| 234 | 0 | ▶ | if ($exitCode == 130) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | # Ausführung wurde mit ^C abgebrochen. Wir entfernen die | ||||||||||||||||||||||||||||
| 236 | # durch die Ausgabeumlenkung angelegten Resultat-Dateien | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 0 | for my $file ($p->glob("*_result.*")) { | |||||||||||||||||||||||||||
| 239 | 0 | say "DELETING $file"; | |||||||||||||||||||||||||||
| 240 | 0 | $p->delete($file); | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | 0 | exit 130; | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $status = $exitCode? 1: 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | $sh->back; | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | return $status; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | =head3 getResult() - Liefere Validierungsresultat | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | ($status,$text,$html,$ruleH) = $mus->getResult($pattern); | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | =head4 Arguments | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | =over 4 | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | =item $pattern | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | Glob()-Pattern der Resultat-Datei des Mustang Validators. | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | =back | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | =head4 Returns | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | =over 4 | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | =item $status | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | Status der Validierung. Mögliche Werte: | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | =over 4 | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | =item Z<>0 | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | Validierung war erfolgreich. | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | =item Z<>1 | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | Es sind bei der Validierung Fehler aufgetreten. | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | =item Z<>2 | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | Es liegt kein Validierungsergebis vor. | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | =back | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | =item $text | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | Textuelle Beschreibung | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | =item $html | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | Beschreibung in HTML | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =item $ruleH | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | Hash der verletzten Regeln | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | =back | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | =head4 Description | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | Liefere das Ergebnis der ZUGFeRD-Validierung. | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | =cut | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub getResult { | ||||||||||||||||||||||||||
|
Subroutine
getResult: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||
| 316 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 317 | # @_: $pattern | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | # Optionen und Argumente | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 0 | my $language = 'de'; | |||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 0 | my $argA = $self->parameters(1,1,\@_, | |||||||||||||||||||||||||||
| 324 | -language => \$language, | ||||||||||||||||||||||||||||
| 325 | ); | ||||||||||||||||||||||||||||
| 326 | 0 | my $pattern = shift @$argA; | |||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | # Operation ausführen | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 0 | my $p = Quiq::Path->new; | |||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 0 | my $status = 0; | |||||||||||||||||||||||||||
| 333 | 0 | my $text = ''; | |||||||||||||||||||||||||||
| 334 | 0 | my %rule; | |||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 0 | my ($resultFile) = $p->glob($pattern); | |||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 0 | my $xml = Quiq::Path->read($resultFile,-decode=>'UTF-8'); | |||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 0 | my ($failed) = $xml =~ m|<failed>(.+?)</failed>|; | |||||||||||||||||||||||||||
| 341 | # Wenn <failed> auf 0 gefaked ist | ||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if (!$failed && $xml =~ m|<summary status="invalid"/>|) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $failed and $xml =~ m[<summary status="invalid"/>]
MC/DC0%0/2
not $failed and $xml =~ m[<summary status="invalid"/>]
not $failed
$xml =~ m[<summary status="invalid"/>]
Truth table0%0/3
not(A) and B
A= not $failedB= $xml =~ m[<summary status="invalid"/>]
| |||||||||||||||||||||||||||||
| 343 | 0 | $failed = 1; | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 0 | ▶ | $status = $failed? 1: 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | # Text und Hash | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | 0 | ▶ | while ($xml =~ m|(<error.*?</error>)|g) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 351 | 0 | my $error = $1; | |||||||||||||||||||||||||||
| 352 | 0 | my $path = ''; | |||||||||||||||||||||||||||
| 353 | 0 | ▶ | while ($error =~ m|/\*:(.*?)\[|g) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 354 | 0 | ▶ | if ($path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 355 | 0 | $path .= '/'; | |||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | 0 | $path .= $1; | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | 0 | my $br = 'NOT_FOUND'; | |||||||||||||||||||||||||||
| 360 | 0 | my ($msg) = $error =~ m|>(.*)</|; | |||||||||||||||||||||||||||
| 361 | 0 | ▶ | if ($msg =~ /^\[(.*?)\]/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 362 | 0 | $br = $1; | |||||||||||||||||||||||||||
| 363 | 0 | ▶ | if ($rule{$br}++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 364 | # Wir melden jede BR-Verletzung nur ein Mal | ||||||||||||||||||||||||||||
| 365 | 0 | next; | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | 0 | ▶ | if ($language eq 'de') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | 0 | my $text = $self->br($br); | |||||||||||||||||||||||||||
| 370 | 0 | ▶ | if ($text) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 371 | 0 | $msg = "[$br] $text"; | |||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | 0 | $text .= "ERROR: $path\n$msg\n-----\n"; | |||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | # HTML | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 0 | my @arr = split /^-+\n/m,$text; | |||||||||||||||||||||||||||
| 380 | 0 | for (@arr) { | |||||||||||||||||||||||||||
| 381 | 0 | s|(ERROR:)|<span class="red">$1</span>|g; | |||||||||||||||||||||||||||
| 382 | 0 | s|(.*)\[|<span class="bold">$1</span>[|s; | |||||||||||||||||||||||||||
| 383 | 0 | s|(B[TGR]-[-\w]+)|<span class="red">$1</span>|g; | |||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||
| 385 | 0 | my $h = Quiq::Html::Producer->new; | |||||||||||||||||||||||||||
| 386 | 0 | my $body; | |||||||||||||||||||||||||||
| 387 | 0 | ▶ | if ($status) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 388 | 0 | $body = Quiq::Html::List->html($h, | |||||||||||||||||||||||||||
| 389 | items => \@arr, | ||||||||||||||||||||||||||||
| 390 | ); | ||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||
| 392 | else { | ||||||||||||||||||||||||||||
| 393 | 0 | $body = $h->tag('span', | |||||||||||||||||||||||||||
| 394 | class => 'bold green', | ||||||||||||||||||||||||||||
| 395 | 'E-Rechnung: Das XML ist valide' | ||||||||||||||||||||||||||||
| 396 | ); | ||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | 0 | my $html = Quiq::Html::Page->html($h, | |||||||||||||||||||||||||||
| 399 | styleSheet => q~ | ||||||||||||||||||||||||||||
| 400 | body { | ||||||||||||||||||||||||||||
| 401 | font-family: sans-serif; | ||||||||||||||||||||||||||||
| 402 | font-size: 10pt; | ||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | li { | ||||||||||||||||||||||||||||
| 405 | padding-bottom: 0.5em; | ||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||
| 407 | .bold { | ||||||||||||||||||||||||||||
| 408 | font-weight: bold; | ||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||
| 410 | .red { | ||||||||||||||||||||||||||||
| 411 | color: red; | ||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||
| 413 | .green { | ||||||||||||||||||||||||||||
| 414 | color: green; | ||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||
| 416 | ~, | ||||||||||||||||||||||||||||
| 417 | body => $body, | ||||||||||||||||||||||||||||
| 418 | ); | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 0 | return ($status,$text,$html,\%rule); | |||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | =head3 visualize() - Visualisiere ZUGFeRD-Datei | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | $mus->visualize($xmlFile,$outFile,%options); | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | =head4 Arguments | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | =over 4 | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | =item $xmlFile | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | ZUGFeRD XML-Datei | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | =item $outFile | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | Erzeugte Visualisierungsdatei. Hat der Dateiname die Endung .pdf, | ||||||||||||||||||||||||||||
| 442 | wird eine PDF-Datei erzeugt, sonst eine HTML-Datei. | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | =back | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | =head4 Options | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | =over 4 | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | =item -addBusinessTerms => $bool (Default: 0) | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | Füge im Falle von HTML als Zielformat die Kürzel der Business-Terms | ||||||||||||||||||||||||||||
| 453 | ("BT-NNN") zu den Feldinhelten hinzu. | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | =back | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | =head4 Description | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | Visualisiere die ZUGFeRD-Datei $xmlFile als PDF- oder HTML-Datei $pdfFile. | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | =head4 Example | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | Erzeuge PDF-Visualisierung: | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | perl -MQuiq::Mustang -E '$mus = Quiq::Mustang->new("~/sys/opt/mustang/Mustang-CLI-2.17.0.jar"); $mus->visualize("174284711604.xml","174284711604.pdf")' | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | Erzeuge HTML-Visualisierung: | ||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | perl -MQuiq::Mustang -E '$mus = Quiq::Mustang->new("~/sys/opt/mustang/Mustang-CLI-2.17.0.jar"); $mus->visualize("174284711604.xml","174284711604.html")' | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | =cut | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 0 | ▶ | sub visualize { | ||||||||||||||||||||||||||
|
Subroutine
visualize: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 476 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | # Optionen und Argumente | ||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 0 | my $addBusinessTerms = 0; | |||||||||||||||||||||||||||
| 481 | 0 | my $verbose = 0; | |||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | 0 | my $argA = $self->parameters(2,2,\@_, | |||||||||||||||||||||||||||
| 484 | -addBusinessTerms => \$addBusinessTerms, | ||||||||||||||||||||||||||||
| 485 | -verbose => \$verbose, | ||||||||||||||||||||||||||||
| 486 | ); | ||||||||||||||||||||||||||||
| 487 | 0 | my ($xmlFile,$outFile) = @$argA; | |||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | # Operation ausführen | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | 0 | (my $logFile = $outFile) =~ s/\..*/.log/; | |||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | 0 | my $p = Quiq::Path->new; | |||||||||||||||||||||||||||
| 494 | 0 | my $sh = Quiq::Shell->new(log=>$verbose); | |||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | # Wir erzeugen die Ausgabedatei auf jeden Fall neu | ||||||||||||||||||||||||||||
| 497 | 0 | $p->delete($outFile); | |||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | 0 | my $cmd; | |||||||||||||||||||||||||||
| 500 | 0 | my $javaExe = $self->javaExe; | |||||||||||||||||||||||||||
| 501 | 0 | ▶ | if ($outFile =~ /\.pdf$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 502 | 0 | $cmd = "$javaExe -Xmx1G -Dfile.encoding=UTF-8 -jar $self->{'jarFile'}". | |||||||||||||||||||||||||||
| 503 | " --action pdf --source $xmlFile --out $outFile". | ||||||||||||||||||||||||||||
| 504 | " >$logFile 2>&1"; | ||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | else { | ||||||||||||||||||||||||||||
| 507 | 0 | $cmd = "$javaExe -Xmx1G -Dfile.encoding=UTF-8 -jar $self->{'jarFile'}". | |||||||||||||||||||||||||||
| 508 | " --action visualize --language de --source $xmlFile". | ||||||||||||||||||||||||||||
| 509 | " --out $outFile >$logFile 2>&1"; | ||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||
| 511 | 0 | $sh->exec($cmd); | |||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | # Wenn in der Logdatei eine Exception gemeldet wird, löschen | ||||||||||||||||||||||||||||
| 514 | # wir die Outdatei, da diese dann ggf. fehlerhaft ist (die PDF-Datei | ||||||||||||||||||||||||||||
| 515 | # is dann korrupt) und kehren zurück. | ||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 0 | my $logData = $p->read($logFile); | |||||||||||||||||||||||||||
| 518 | 0 | ▶ | if ($logData =~ /Exception/i) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 519 | 0 | $p->delete($outFile); | |||||||||||||||||||||||||||
| 520 | 0 | return; | |||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | 0 | ▶ | if ($outFile =~ /\.html$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 524 | 0 | my $p = Quiq::Path->new; | |||||||||||||||||||||||||||
| 525 | 0 | my $h = Quiq::Html::Producer->new; | |||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | 0 | (my $resultFile = $outFile) =~ s/muster\.html/result.txt/; | |||||||||||||||||||||||||||
| 528 | 0 | my $text = $p->read($resultFile,-decode=>'UTF-8'); | |||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | 0 | my %key; | |||||||||||||||||||||||||||
| 531 | 0 | ▶ | while ($text =~ /(B[GT]-[-\w]+)/g) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 532 | 0 | $key{$1} = 1; | |||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | 0 | ▶ | if ($addBusinessTerms) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 536 | 0 | ▶ | my $sub = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 537 | 0 | my ($keyH,$key) = @_; | |||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | 0 | ▶ | my $color = $keyH->{$key}? 'red': | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 540 | substr($key,0,2) eq 'BT'? 'green': '#bbbbbb'; | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | # <span style="color: $color">$key</span>)</div>|; | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | 0 | return $h->tag('span', | |||||||||||||||||||||||||||
| 545 | style => "color: $color", | ||||||||||||||||||||||||||||
| 546 | $key | ||||||||||||||||||||||||||||
| 547 | ); | ||||||||||||||||||||||||||||
| 548 | 0 | }; | |||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | 0 | my $html = $p->read($outFile,-decode=>'UTF-8'); | |||||||||||||||||||||||||||
| 551 | 0 | $html =~ s{<div class="haftungausschluss">.*?</div>\n}{}g; | |||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | 0 | $html =~ s{(title="(B[GT]-.*?)".*?)</div>} | |||||||||||||||||||||||||||
| 554 | 0 | {"$1 (".$sub->(\%key,$2).')</div>'}sge; | |||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | 0 | $p->write($outFile,$html,-encode=>'UTF-8'); | |||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | # Eine CSS- und JS-Datei werden erzeugt, die wir jedoch nicht | ||||||||||||||||||||||||||||
| 560 | # brauchen, da der Code in der erzeugten HTML-Datei enthalten ist | ||||||||||||||||||||||||||||
| 561 | 0 | $sh->exec('rm -f xrechnung-viewer.*'); | |||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | 0 | return; | |||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||
| 567 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||
| 569 | =head2 Information | ||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | =head3 br() - Text Geschäftsregel (Business Rule) | ||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | $text = $zug->br($br); | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | =head4 Arguments | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | =over 4 | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | =item $br | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | Bezeichner der Geschäftsregel. Beispiel: C<BR-CO-17> | ||||||||||||||||||||||||||||
| 584 | (Umsatzsteueraufschlüsselung) | ||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | =back | ||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | =head4 Returns | ||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | (String) Text der Geschäftsregel | ||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||
| 592 | =head4 Description | ||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||
| 594 | Liefere den Text der Geschäftsregel $br. Ist die Geschäftsregel nicht | ||||||||||||||||||||||||||||
| 595 | definiert, wird ein Leerstring ('') geliefert. | ||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||
| 597 | =head4 Example | ||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||
| 599 | $ perl -MQuiq::Mustang -E 'say Quiq::Mustang->new($jarFile)->br("BR-CO-17")' | ||||||||||||||||||||||||||||
| 600 | (Umsatzsteueraufschlüsselung) Der Inhalt des Elementes „VAT category tax | ||||||||||||||||||||||||||||
| 601 | amount“ (BT-117) entspricht dem Inhalt des Elementes „VAT category taxable | ||||||||||||||||||||||||||||
| 602 | amount“ (BT-116), multipliziert mit dem Inhalt des Elementes „VAT category | ||||||||||||||||||||||||||||
| 603 | rate“ (BT-119) geteilt durch 100, gerundet auf zwei Dezimalstellen. | ||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||
| 605 | =cut | ||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||
| 607 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | 0 | ▶ | sub br { | ||||||||||||||||||||||||||
|
Subroutine
br: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 610 | 0 | my ($self,$name) = @_; | |||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||
| 612 | 0 | ▶ | my $brH = $self->memoize('brH',sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 613 | 0 | my ($self,$key) = @_; | |||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||
| 615 | 0 | my %h; | |||||||||||||||||||||||||||
| 616 | 0 | my $text = Quiq::Path->read($self->mustangDir('business-rule.txt'), | |||||||||||||||||||||||||||
| 617 | -decode => 'UTF-8', | ||||||||||||||||||||||||||||
| 618 | ); | ||||||||||||||||||||||||||||
| 619 | 0 | my @rules = split /^\n^/m,$text; | |||||||||||||||||||||||||||
| 620 | 0 | for (@rules) { | |||||||||||||||||||||||||||
| 621 | 0 | s/\s+/ /g; | |||||||||||||||||||||||||||
| 622 | 0 | my ($br,$text) = $_ =~ /^(\S+)\s+(.*)/; | |||||||||||||||||||||||||||
| 623 | 0 | $h{$br} = $text; | |||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||
| 626 | 0 | return \%h; | |||||||||||||||||||||||||||
| 627 | 0 | }); | |||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||
| 629 | 0 | ▶ | return $brH->{$name} // ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$brH->{$name} // ""
MC/DC0%0/1
$brH->{$name} // ""
$brH->{$name}
Truth table0%0/2
A
A= $brH->{$name}
| |||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | =head3 mustangDir() - Pfad des Mustang-Verzeichnisses | ||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||
| 638 | $path = $zug->mustangDir; | ||||||||||||||||||||||||||||
| 639 | $path = $zug->mustangDir($subPath); | ||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||
| 641 | =head4 Arguments | ||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||
| 643 | =over 4 | ||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||
| 645 | =item $subPath | ||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | Subpfad ins Verzeichnis | ||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||
| 649 | =back | ||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | =head4 Returns | ||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||
| 653 | (String) Dateipfad | ||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||
| 655 | =head4 Description | ||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||
| 657 | Liefere den Dateipfad des Mustang-Verzeichnisses, optional ergänzt um | ||||||||||||||||||||||||||||
| 658 | Subpfad $subPath. | ||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | =cut | ||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||
| 662 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||
| 664 | 0 | ▶ | sub mustangDir { | ||||||||||||||||||||||||||
|
Subroutine
mustangDir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 665 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | 0 | my $path = $self->{'mustangDir'}; | |||||||||||||||||||||||||||
| 668 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 669 | 0 | $path .= "/$_[0]"; | |||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||
| 672 | 0 | return $path; | |||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||
| 675 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||
| 677 | =head1 VERSION | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | 1.240 | ||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||
| 681 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||
| 685 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||
| 687 | Copyright (C) 2026 Frank Seitz | ||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||
| 689 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||
| 691 | This code is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 692 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||
| 694 | =cut | ||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||
| 696 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||
| 698 | 1 | 1; | |||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | # eof | ||||||||||||||||||||||||||||