Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision de009a3f

Von Moritz Bunkus vor fast 8 Jahren hinzugefügt

  • ID de009a3fee7e0471c3e095ce92d8708ff2b42597
  • Vorgänger 18a9328c
  • Nachfolger c9a40818

Zahlungsbedingungen: Unterscheidung zwischen Angeboten/Aufträgen und Rechnungen

Dies führt ein neues Attribut »payment_terms.description_long_invoice«
und dazugehörige Übersetzungen in »generic_translation« ein.

Die Druckvariable »payment_terms« wird nun in Abhängigkeit vom
auszudruckenden Beleg gesetzt:

1. Für Verkaufsrechnungen wird zuerst eine Übersetzung von
»description_long_invoice« für die ausgewählte Sprache gesucht. Falls
die leer ist oder keine Sprache ausgewählt, so wird die nicht
übersetzte »description_long_invoice« genommen. Ist auch die leer, so
erfolgt ein Fallback auf 2.

2. Für alle anderen Belege oder falls bei 1. nichts heraus gekommen ist,
wird wie vor dieser Änderung eine Übersetzung von »description_long«
für die ausgewählte Sprache gesucht. Falls die leer ist oder keine
Sprache ausgewählt, so wird die nicht übersetzte »description_long«
genommen.

Unterschiede anzeigen:

SL/Form.pm
1697 1697
}
1698 1698

  
1699 1699
sub set_payment_options {
1700
  my ($self, $myconfig, $transdate) = @_;
1700
  my ($self, $myconfig, $transdate, $type) = @_;
1701 1701

  
1702 1702
  my $terms = $self->{payment_id} ? SL::DB::PaymentTerm->new(id => $self->{payment_id})->load : undef;
1703 1703
  return if !$terms;
1704 1704

  
1705
  my $is_invoice                = $type =~ m{invoice}i;
1706

  
1705 1707
  $transdate                  ||= $self->{invdate} || $self->{transdate};
1706 1708
  my $due_date                  = $self->{duedate} || $self->{reqdate};
1707 1709

  
1708 1710
  $self->{$_}                   = $terms->$_ for qw(terms_netto terms_skonto percent_skonto);
1709
  $self->{payment_terms}        = $terms->description_long;
1710 1711
  $self->{payment_description}  = $terms->description;
1711 1712
  $self->{netto_date}           = $terms->calc_date(reference_date => $transdate, due_date => $due_date, terms => 'net')->to_kivitendo;
1712 1713
  $self->{skonto_date}          = $terms->calc_date(reference_date => $transdate, due_date => $due_date, terms => 'discount')->to_kivitendo;
......
1739 1740
  }
1740 1741

  
1741 1742
  if ($self->{"language_id"}) {
1742
    my $dbh   = $self->get_standard_dbh($myconfig);
1743
    my $query =
1744
      qq|SELECT t.translation, l.output_numberformat, l.output_dateformat, l.output_longdates | .
1745
      qq|FROM generic_translations t | .
1746
      qq|LEFT JOIN language l ON t.language_id = l.id | .
1747
      qq|WHERE (t.language_id = ?)
1748
           AND (t.translation_id = ?)
1749
           AND (t.translation_type = 'SL::DB::PaymentTerm/description_long')|;
1750
    my ($description_long, $output_numberformat, $output_dateformat,
1751
      $output_longdates) =
1752
      selectrow_query($self, $dbh, $query,
1753
                      $self->{"language_id"}, $self->{"payment_id"});
1754

  
1755
    $self->{payment_terms} = $description_long if ($description_long);
1756

  
1757
    if ($output_dateformat) {
1743
    my $language             = SL::DB::Language->new(id => $self->{language_id})->load;
1744

  
1745
    $self->{payment_terms}   = $type =~ m{invoice}i ? $terms->translated_attribute('description_long_invoice', $language->id) : undef;
1746
    $self->{payment_terms} ||= $terms->translated_attribute('description_long', $language->id);
1747

  
1748
    if ($language->output_dateformat) {
1758 1749
      foreach my $key (qw(netto_date skonto_date)) {
1759
        $self->{$key} =
1760
          $main::locale->reformat_date($myconfig, $self->{$key},
1761
                                       $output_dateformat,
1762
                                       $output_longdates);
1750
        $self->{$key} = $::locale->reformat_date($myconfig, $self->{$key}, $language->output_dateformat, $language->output_longdates);
1763 1751
      }
1764 1752
    }
1765 1753

  
1766
    if ($output_numberformat &&
1767
        ($output_numberformat ne $myconfig->{"numberformat"})) {
1768
      my $saved_numberformat = $myconfig->{"numberformat"};
1769
      $myconfig->{"numberformat"} = $output_numberformat;
1770
      map { $formatted_amounts{$_} = $self->format_amount($myconfig, $amounts{$_}) } keys %amounts;
1771
      $myconfig->{"numberformat"} = $saved_numberformat;
1754
    if ($language->output_numberformat && ($language->output_numberformat ne $myconfig->{numberformat})) {
1755
      local $myconfig->{numberformat};
1756
      $myconfig->{"numberformat"} = $language->output_numberformat;
1757
      $formatted_amounts{$_} = $self->format_amount($myconfig, $amounts{$_}) for keys %amounts;
1772 1758
    }
1773 1759
  }
1774 1760

  
1761
  $self->{payment_terms} =  $self->{payment_terms} || ($is_invoice ? $terms->description_long_invoice : undef) || $terms->description_long;
1762

  
1775 1763
  $self->{payment_terms} =~ s/<%netto_date%>/$self->{netto_date}/g;
1776 1764
  $self->{payment_terms} =~ s/<%skonto_date%>/$self->{skonto_date}/g;
1777 1765
  $self->{payment_terms} =~ s/<%currency%>/$self->{currency}/g;

Auch abrufbar als: Unified diff