Revision 34d54675
Von Moritz Bunkus vor fast 5 Jahren hinzugefügt
SL/DB/Helper/ZUGFeRD.pm | ||
---|---|---|
209 | 209 |
} |
210 | 210 |
} |
211 | 211 |
|
212 |
sub _format_payment_terms_description {
|
|
212 |
sub _calculate_payment_terms_values {
|
|
213 | 213 |
my ($self) = @_; |
214 | 214 |
|
215 | 215 |
my (%vars, %amounts, %formatted_amounts); |
... | ... | |
243 | 243 |
$formatted_amounts{$_} = $::form->format_amount(\%::myconfig, $amounts{$_}, 2); |
244 | 244 |
} |
245 | 245 |
|
246 |
return ( |
|
247 |
vars => \%vars, |
|
248 |
amounts => \%amounts, |
|
249 |
formatted_amounts => \%formatted_amounts, |
|
250 |
); |
|
251 |
} |
|
252 |
|
|
253 |
sub _format_payment_terms_description { |
|
254 |
my ($self, %params) = @_; |
|
255 |
|
|
246 | 256 |
my $description = ($self->payment_terms->translated_attribute('description_long_invoice', $self->language_id) // '') || $self->payment_terms->description_long_invoice; |
247 |
$description =~ s{<\%$_\%>}{ $vars{$_} }ge for keys %vars;
|
|
248 |
$description =~ s{<\%$_\%>}{ $formatted_amounts{$_} }ge for keys %formatted_amounts;
|
|
257 |
$description =~ s{<\%$_\%>}{ $params{vars}->{$_} }ge for keys %{ $params{vars} };
|
|
258 |
$description =~ s{<\%$_\%>}{ $params{formatted_amounts}->{$_} }ge for keys %{ $params{formatted_amounts} };
|
|
249 | 259 |
|
250 | 260 |
return $description; |
251 | 261 |
} |
... | ... | |
255 | 265 |
|
256 | 266 |
return unless $self->payment_terms; |
257 | 267 |
|
268 |
my %payment_terms_vars = _calculate_payment_terms_values($self); |
|
269 |
|
|
258 | 270 |
# <ram:SpecifiedTradePaymentTerms> |
259 | 271 |
$params{xml}->startTag("ram:SpecifiedTradePaymentTerms"); |
260 | 272 |
|
261 |
$params{xml}->dataElement("ram:Description", _u8(_format_payment_terms_description($self))); |
|
273 |
$params{xml}->dataElement("ram:Description", _u8(_format_payment_terms_description($self, %payment_terms_vars)));
|
|
262 | 274 |
|
263 | 275 |
# <ram:DueDateDateTime> |
264 | 276 |
$params{xml}->startTag("ram:DueDateDateTime"); |
... | ... | |
267 | 279 |
# </ram:DueDateDateTime> |
268 | 280 |
|
269 | 281 |
if ($self->payment_terms->percent_skonto && $self->payment_terms->terms_skonto) { |
282 |
my $currency_id = _u8(SL::Helper::ISO4217::map_currency_name_to_code($self->currency->name) // 'EUR'); |
|
283 |
|
|
270 | 284 |
# <ram:ApplicableTradePaymentDiscountTerms> |
271 | 285 |
$params{xml}->startTag("ram:ApplicableTradePaymentDiscountTerms"); |
272 | 286 |
$params{xml}->dataElement("ram:BasisPeriodMeasure", $self->payment_terms->terms_skonto, "unitCode" => "DAY"); |
287 |
$params{xml}->dataElement("ram:BasisAmount", _r2($payment_terms_vars{amounts}->{invtotal}), currencyID => $currency_id); |
|
273 | 288 |
$params{xml}->dataElement("ram:CalculationPercent", _r2($self->payment_terms->percent_skonto * 100)); |
274 | 289 |
$params{xml}->endTag; |
275 | 290 |
# </ram:ApplicableTradePaymentDiscountTerms> |
Auch abrufbar als: Unified diff
ZUGFeRD: Zahlungsbedingungen: Skonto-Basis-Betrag mit ausgeben