Revision e5f53eb5
Von Moritz Bunkus vor etwa 4 Jahren hinzugefügt
SL/DB/Helper/ZUGFeRD.pm | ||
---|---|---|
6 | 6 |
use parent qw(Exporter); |
7 | 7 |
our @EXPORT = qw(create_zugferd_data create_zugferd_xmp_data); |
8 | 8 |
|
9 |
use SL::DB::GenericTranslation; |
|
9 | 10 |
use SL::DB::Tax; |
10 | 11 |
use SL::DB::TaxKey; |
11 | 12 |
use SL::Helper::ISO3166; |
... | ... | |
15 | 16 |
use Carp; |
16 | 17 |
use Encode qw(encode); |
17 | 18 |
use List::MoreUtils qw(pairwise); |
18 |
use List::Util qw(sum); |
|
19 |
use List::Util qw(first sum);
|
|
19 | 20 |
use Template; |
20 | 21 |
use XML::Writer; |
21 | 22 |
|
... | ... | |
308 | 309 |
# </rsm:ExchangedDocumentContext> |
309 | 310 |
} |
310 | 311 |
|
312 |
sub _included_note { |
|
313 |
my ($self, %params) = @_; |
|
314 |
|
|
315 |
$params{xml}->startTag("ram:IncludedNote"); |
|
316 |
$params{xml}->dataElement("ram:Content", _u8($params{note})); |
|
317 |
$params{xml}->endTag; |
|
318 |
} |
|
319 |
|
|
311 | 320 |
sub _exchanged_document { |
312 | 321 |
my ($self, %params) = @_; |
313 | 322 |
|
... | ... | |
328 | 337 |
$params{xml}->dataElement("ram:LanguageID", uc($1)); |
329 | 338 |
} |
330 | 339 |
|
331 |
if ($self->transaction_description) { |
|
332 |
$params{xml}->startTag("ram:IncludedNote"); |
|
333 |
$params{xml}->dataElement("ram:Content", _u8($self->transaction_description)); |
|
334 |
$params{xml}->endTag; |
|
335 |
} |
|
340 |
my $std_notes = SL::DB::Manager::GenericTranslation->get_all( |
|
341 |
where => [ |
|
342 |
translation_type => 'ZUGFeRD/notes', |
|
343 |
or => [ |
|
344 |
language_id => undef, |
|
345 |
language_id => $self->language_id, |
|
346 |
], |
|
347 |
'!translation' => undef, |
|
348 |
'!translation' => '', |
|
349 |
], |
|
350 |
); |
|
351 |
|
|
352 |
my $std_note = first { $_->language_id == $self->language_id } @{ $std_notes }; |
|
353 |
$std_note //= first { !defined $_->language_id } @{ $std_notes }; |
|
336 | 354 |
|
337 | 355 |
my $notes = $self->notes_as_stripped_html; |
338 |
if ($notes) { |
|
339 |
$params{xml}->startTag("ram:IncludedNote"); |
|
340 |
$params{xml}->dataElement("ram:Content", _u8($notes)); |
|
341 |
$params{xml}->endTag; |
|
342 |
} |
|
356 |
|
|
357 |
_included_note($self, %params, note => $self->transaction_description) if $self->transaction_description; |
|
358 |
_included_note($self, %params, note => $notes) if $notes; |
|
359 |
_included_note($self, %params, note => $std_note->translation) if $std_note; |
|
343 | 360 |
|
344 | 361 |
$params{xml}->endTag; |
345 | 362 |
# </rsm:ExchangedDocument> |
Auch abrufbar als: Unified diff
ZUGFeRD: allgemeine Notizen für alle Rechnungen in Übersetzungen anlegen können