Revision e2f0105f
Von Moritz Bunkus vor mehr als 3 Jahren hinzugefügt
SL/DB/Helper/ZUGFeRD.pm | ||
---|---|---|
27 | 27 |
|
28 | 28 |
my %standards_ids = ( |
29 | 29 |
PROFILE_FACTURX_EXTENDED() => 'urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended', |
30 |
PROFILE_XRECHNUNG() => 'urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_2.0', |
|
31 |
); |
|
32 |
|
|
30 | 33 |
sub _is_profile { |
31 | 34 |
my ($self, @profiles) = @_; |
32 | 35 |
return any { $self->{_zugferd}->{profile} == $_ } @profiles; |
... | ... | |
288 | 291 |
$description =~ s{<\%$_\%>}{ $params{vars}->{$_} }ge for keys %{ $params{vars} }; |
289 | 292 |
$description =~ s{<\%$_\%>}{ $params{formatted_amounts}->{$_} }ge for keys %{ $params{formatted_amounts} }; |
290 | 293 |
|
294 |
if (_is_profile($self, PROFILE_XRECHNUNG())) { |
|
295 |
my @terms; |
|
296 |
|
|
297 |
if ($self->payment_terms->terms_skonto && ($self->payment_terms->percent_skonto * 1)) { |
|
298 |
push @terms, sprintf("#SKONTO#TAGE=\%d#PROZENT=\%.2f#\n", $self->payment_terms->terms_skonto, $self->payment_terms->percent_skonto * 100); |
|
299 |
} |
|
300 |
|
|
301 |
$description =~ s{#}{_}g; |
|
302 |
$description = join('', @terms) . $description; |
|
303 |
} |
|
304 |
|
|
291 | 305 |
return $description; |
292 | 306 |
} |
293 | 307 |
|
... | ... | |
309 | 323 |
$params{xml}->endTag; |
310 | 324 |
# </ram:DueDateDateTime> |
311 | 325 |
|
312 |
if ($self->payment_terms->percent_skonto && $self->payment_terms->terms_skonto) { |
|
326 |
if ( _is_profile($self, PROFILE_FACTURX_EXTENDED()) |
|
327 |
&& $self->payment_terms->percent_skonto |
|
328 |
&& $self->payment_terms->terms_skonto) { |
|
313 | 329 |
my $currency_id = _u8(SL::Helper::ISO4217::map_currency_name_to_code($self->currency->name) // 'EUR'); |
314 | 330 |
|
315 | 331 |
# <ram:ApplicableTradePaymentDiscountTerms> |
... | ... | |
376 | 392 |
$params{xml}->startTag("rsm:ExchangedDocument"); |
377 | 393 |
|
378 | 394 |
$params{xml}->dataElement("ram:ID", _u8($self->invnumber)); |
379 |
$params{xml}->dataElement("ram:Name", _u8(_type_name($self))); |
|
395 |
$params{xml}->dataElement("ram:Name", _u8(_type_name($self))) if _is_profile($self, PROFILE_FACTURX_EXTENDED());
|
|
380 | 396 |
$params{xml}->dataElement("ram:TypeCode", _u8(_type_code($self))); |
381 | 397 |
|
382 | 398 |
# <ram:IssueDateTime> |
... | ... | |
385 | 401 |
$params{xml}->endTag; |
386 | 402 |
# </ram:IssueDateTime> |
387 | 403 |
|
388 |
if ($self->language && (($self->language->template_code // '') =~ m{^(de|en)}i)) { |
|
404 |
if ( _is_profile($self, PROFILE_FACTURX_EXTENDED()) |
|
405 |
&& $self->language |
|
406 |
&& (($self->language->template_code // '') =~ m{^(de|en)}i)) { |
|
389 | 407 |
$params{xml}->dataElement("ram:LanguageID", uc($1)); |
390 | 408 |
} |
391 | 409 |
|
... | ... | |
507 | 525 |
# <ram:ApplicableHeaderTradeAgreement> |
508 | 526 |
$params{xml}->startTag("ram:ApplicableHeaderTradeAgreement"); |
509 | 527 |
|
528 |
$params{xml}->dataElement("ram:BuyerReference", _u8($self->customer->c_vendor_routing_id)) if $self->customer->c_vendor_routing_id; |
|
529 |
|
|
510 | 530 |
_seller_trade_party($self, %params); |
511 | 531 |
_buyer_trade_party($self, %params); |
512 | 532 |
|
... | ... | |
620 | 640 |
} |
621 | 641 |
} |
622 | 642 |
|
643 |
if (_is_profile($self, PROFILE_XRECHNUNG())) { |
|
644 |
if (!$self->customer->c_vendor_routing_id) { |
|
645 |
SL::X::ZUGFeRDValidation->throw(message => $prefix . $::locale->text('The value \'our routing id at customer\' must be set in the customer\'s master data for profile #1.', 'XRechnung 2.0')); |
|
646 |
} |
|
647 |
} |
|
648 |
|
|
623 | 649 |
return %result; |
624 | 650 |
} |
625 | 651 |
|
Auch abrufbar als: Unified diff
Factur-X/ZUGFeRD: Unterstütztung für Profil »XRechnung 2.0.0«