Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision de009a3f

Von Moritz Bunkus vor mehr als 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/Controller/PaymentTerm.pm
110 110
  $self->{payment_term}->save;
111 111
  foreach my $language (@{ $self->{languages} }) {
112 112
    $self->{payment_term}->save_attribute_translation('description_long', $language, $::form->{"translation_" . $language->id});
113
    $self->{payment_term}->save_attribute_translation('description_long_invoice', $language, $::form->{"translation_invoice_" . $language->id});
113 114
  }
114 115

  
115 116
  flash_later('info', $is_new ? $::locale->text('The payment term has been created.') : $::locale->text('The payment term has been saved.'));
SL/DB/Manager/PaymentTerm.pm
14 14
sub _sort_spec {
15 15
  return ( default => [ 'sortkey', 1 ],
16 16
           columns => { SIMPLE => 'ALL',
17
                        map { ( $_ => "lower(payment_terms.${_})" ) } qw(description description_long),
17
                        map { ( $_ => "lower(payment_terms.${_})" ) } qw(description description_long description_long_invoice),
18 18
                      });
19 19
}
20 20

  
SL/DB/MetaSetup/PaymentTerm.pm
9 9
__PACKAGE__->meta->table('payment_terms');
10 10

  
11 11
__PACKAGE__->meta->columns(
12
  auto_calculation => { type => 'boolean', not_null => 1 },
13
  description      => { type => 'text' },
14
  description_long => { type => 'text' },
15
  id               => { type => 'integer', not_null => 1, sequence => 'id' },
16
  itime            => { type => 'timestamp', default => 'now()' },
17
  mtime            => { type => 'timestamp' },
18
  percent_skonto   => { type => 'float', scale => 4 },
19
  ranking          => { type => 'integer' },
20
  sortkey          => { type => 'integer', not_null => 1 },
21
  terms_netto      => { type => 'integer' },
22
  terms_skonto     => { type => 'integer' },
12
  auto_calculation         => { type => 'boolean', not_null => 1 },
13
  description              => { type => 'text' },
14
  description_long         => { type => 'text' },
15
  description_long_invoice => { type => 'text' },
16
  id                       => { type => 'integer', not_null => 1, sequence => 'id' },
17
  itime                    => { type => 'timestamp', default => 'now()' },
18
  mtime                    => { type => 'timestamp' },
19
  percent_skonto           => { type => 'float', precision => 4, scale => 4 },
20
  ranking                  => { type => 'integer' },
21
  sortkey                  => { type => 'integer', not_null => 1 },
22
  terms_netto              => { type => 'integer' },
23
  terms_skonto             => { type => 'integer' },
23 24
);
24 25

  
25 26
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
SL/DO.pm
1055 1055
  $h_bin_wh->finish();
1056 1056

  
1057 1057
  $form->{delivery_term} = SL::DB::Manager::DeliveryTerm->find_by(id => $form->{delivery_term_id} || undef);
1058
  $form->{delivery_term}->description_long($form->{delivery_term}->translated_attribute('description_long', $form->{language_id})) if $form->{delivery_term} && $form->{language_id};
1058
  if ($form->{delivery_term} && $form->{language_id}) {
1059
    $form->{delivery_term}->description_long(        $form->{delivery_term}->translated_attribute('description_long',         $form->{language_id}));
1060
    $form->{delivery_term}->description_long_invoice($form->{delivery_term}->translated_attribute('description_long_invoice', $form->{language_id}));
1061
  }
1062

  
1059 1063
  $form->{department}    = SL::DB::Manager::Department->find_by(id => $form->{department_id})->description if $form->{department_id};
1060 1064

  
1061 1065
  $form->{username} = $myconfig->{name};
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;
SL/IS.pm
525 525
  $form->{invtotal} = $form->format_amount($myconfig, $form->{invtotal}, 2);
526 526
  $form->{paid}     = $form->format_amount($myconfig, $form->{paid}, 2);
527 527

  
528
  $form->set_payment_options($myconfig, $form->{invdate});
528
  $form->set_payment_options($myconfig, $form->{invdate}, 'sales_invoice');
529 529

  
530 530
  $form->{delivery_term} = SL::DB::Manager::DeliveryTerm->find_by(id => $form->{delivery_term_id} || undef);
531
  $form->{delivery_term}->description_long($form->{delivery_term}->translated_attribute('description_long', $form->{language_id})) if $form->{delivery_term} && $form->{language_id};
531
  if ($form->{delivery_term} && $form->{language_id}) {
532
    $form->{delivery_term}->description_long(        $form->{delivery_term}->translated_attribute('description_long',         $form->{language_id}));
533
    $form->{delivery_term}->description_long_invoice($form->{delivery_term}->translated_attribute('description_long_invoice', $form->{language_id}));
534
  }
535

  
532 536
  $form->{department}    = SL::DB::Manager::Department->find_by(id => $form->{department_id})->description if $form->{department_id};
533 537

  
534 538
  $form->{username} = $myconfig->{name};
SL/OE.pm
1584 1584
  # format amounts
1585 1585
  $form->{quototal} = $form->{ordtotal} = $form->format_amount($myconfig, $form->{ordtotal}, 2);
1586 1586

  
1587
  if ($form->{type} =~ /_quotation/) {
1588
    $form->set_payment_options($myconfig, $form->{quodate});
1589
  } else {
1590
    $form->set_payment_options($myconfig, $form->{orddate});
1591
  }
1587
  $form->set_payment_options($myconfig, $form->{$form->{type} =~ /_quotation/ ? 'quodate' : 'orddate'}, $form->{type});
1592 1588

  
1593 1589
  $form->{username} = $myconfig->{name};
1594 1590

  
1595 1591
  $dbh->disconnect;
1596 1592

  
1597 1593
  $form->{delivery_term} = SL::DB::Manager::DeliveryTerm->find_by(id => $form->{delivery_term_id} || undef);
1598
  $form->{delivery_term}->description_long($form->{delivery_term}->translated_attribute('description_long', $form->{language_id})) if $form->{delivery_term} && $form->{language_id};
1594
  if ($form->{delivery_term} && $form->{language_id}) {
1595
    $form->{delivery_term}->description_long(        $form->{delivery_term}->translated_attribute('description_long',         $form->{language_id}));
1596
    $form->{delivery_term}->description_long_invoice($form->{delivery_term}->translated_attribute('description_long_invoice', $form->{language_id}));
1597
  }
1599 1598

  
1600 1599
  $form->{order} = SL::DB::Manager::Order->find_by(id => $form->{id}) if $form->{id};
1601 1600

  
locale/de/all
1633 1633
  'Logout now'                  => 'kivitendo jetzt verlassen',
1634 1634
  'Long Dates'                  => 'Lange Monatsnamen',
1635 1635
  'Long Description'            => 'Langtext',
1636
  'Long Description (invoices)' => 'Langtext (Rechnungen)',
1637
  'Long Description (quotations & orders)' => 'Langtext (Angebote & Aufträge)',
1636 1638
  'Luxembourg'                  => 'Luxemburg',
1637 1639
  'MAILED'                      => 'Gesendet',
1638 1640
  'MD'                          => 'PT',
......
2704 2706
  'Text field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the text field. They default to 30 and 5 respectively.' => 'Textfelder: \'WIDTH=w HEIGHT=h\' setzen die Breite und die H&ouml;he des Textfeldes. Wenn nicht anders angegeben, so werden sie 30 Zeichen breit und f&uuml;nf Zeichen hoch dargestellt.',
2705 2707
  'Text variables: \'MAXLENGTH=n\' sets the maximum entry length to \'n\'.' => 'Textzeilen: \'MAXLENGTH=n\' setzt eine Maximall&auml;nge von n Zeichen.',
2706 2708
  'Text, text field and number variables: The default value will be used as-is.' => 'Textzeilen, Textfelder und Zahlenvariablen: Der Standardwert wird so wie er ist &uuml;bernommen.',
2709
  'Texts for invoices'          => 'Texte für Rechnungen',
2710
  'Texts for quotations & orders' => 'Texte für Angebote & Aufträge',
2707 2711
  'That export does not exist.' => 'Dieser Export existiert nicht.',
2708 2712
  'That is why kivitendo could not find a default currency.' => 'Daher konnte kivitendo keine Standardwährung finden.',
2709 2713
  'The \'name\' is the field shown to the user during login.' => 'Der \'Name\' ist derjenige, der dem Benutzer beim Login angezeigt wird.',
sql/Pg-upgrade2/payment_terms_for_invoices.sql
1
-- @tag: payment_terms_for_invoices
2
-- @description: Unterscheidung in Zahlungsbedingungen für Angebote/Aufträge und Rechnungen
3
-- @depends: release_3_4_0
4
ALTER TABLE payment_terms ADD COLUMN description_long_invoice TEXT;
5
UPDATE payment_terms SET description_long_invoice = description_long;
6

  
7
INSERT INTO generic_translations (translation_type, language_id, translation_id, translation)
8
SELECT translation_type || '_invoice', language_id, translation_id, translation
9
FROM generic_translations
10
WHERE translation_type = 'SL::DB::PaymentTerm/description_long';
11

  
12
CREATE OR REPLACE FUNCTION generic_translations_delete_on_payment_terms_delete_trigger()
13
RETURNS TRIGGER AS $$
14
  BEGIN
15
    DELETE FROM generic_translations
16
    WHERE (translation_id = OLD.id)
17
      AND (translation_type IN ('SL::DB::PaymentTerm/description_long', 'SL::DB::PaymentTerm/description_long_invoice'));
18
    RETURN OLD;
19
  END;
20
$$ LANGUAGE plpgsql;
templates/webpages/payment_term/form.html
6 6
[%- INCLUDE 'common/flash.html' %]
7 7

  
8 8
  <table>
9
   <tr class="listheading">
10
    <th></th>
11
    <th>[% LxERP.t8("General settings") %]</th>
12
   </tr>
13

  
9 14
   <tr>
10 15
    <td>[%- 'Description' | $T8 %]</td>
11 16
    <td>
......
13 18
    </td>
14 19
   </tr>
15 20

  
16
   <tr>
17
    <td>[%- 'Long Description' | $T8 %]</td>
18
    <td>
19
     <input name="payment_term.description_long" value="[%- HTML.escape(SELF.payment_term.description_long) %]" size="60">
20
    </td>
21
   </tr>
22

  
23
   [%- FOREACH language = SELF.languages %]
24
    <tr>
25
     <td>[%- HTML.escape(language.description) %] ([%- LxERP.t8('Translation') %])</td>
26
     <td>
27
      <input name="translation_[% language.id %]" value="[%- HTML.escape(SELF.payment_term.translated_attribute('description_long', language, 1)) %]" size="60">
28
     </td>
29
    </tr>
30
   [%- END %]
31

  
32 21
   <tr>
33 22
    <td>[% LxERP.t8("Calculate due date automatically") %]</td>
34 23
    <td>[% L.yes_no_tag("payment_term.auto_calculation", SELF.payment_term.auto_calculation, "data-auto-calculation-toggle"="1") %]</td>
......
54 43
     <input name="payment_term.percent_skonto_as_percent" value="[%- HTML.escape(SELF.payment_term.percent_skonto_as_percent) %]" size="6">%
55 44
    </td>
56 45
   </tr>
46

  
47
   <tr class="listheading">
48
    <th></th>
49
    <th>[% LxERP.t8("Texts for quotations & orders") %]</th>
50
    <th>[% LxERP.t8("Texts for invoices") %]</th>
51
   </tr>
52

  
53
   <tr>
54
    <td>[%- 'Long Description' | $T8 %]</td>
55
    <td>
56
     <input name="payment_term.description_long" value="[%- HTML.escape(SELF.payment_term.description_long) %]" size="60">
57
    </td>
58

  
59
    <td>
60
     <input name="payment_term.description_long_invoice" value="[%- HTML.escape(SELF.payment_term.description_long_invoice) %]" size="60">
61
    </td>
62
   </tr>
63

  
64
   [%- FOREACH language = SELF.languages %]
65
    <tr>
66
     <td>[%- HTML.escape(language.description) %] ([%- LxERP.t8('Translation') %])</td>
67
     <td>
68
      <input name="translation_[% language.id %]" value="[%- HTML.escape(SELF.payment_term.translated_attribute('description_long', language, 1)) %]" size="60">
69
     </td>
70

  
71
     <td>
72
      <input name="translation_invoice_[% language.id %]" value="[%- HTML.escape(SELF.payment_term.translated_attribute('description_long_invoice', language, 1)) %]" size="60">
73
     </td>
74
    </tr>
75
   [%- END %]
57 76
  </table>
58 77

  
59 78
  <p>
templates/webpages/payment_term/list.html
15 15
    <tr class="listheading">
16 16
     <th align="center"><img src="image/updown.png" alt="[%- LxERP.t8('reorder item') %]"></th>
17 17
     <th>[%- 'Description' | $T8 %]</th>
18
     <th>[%- 'Long Description' | $T8 %]</th>
18
     <th>[%- 'Long Description (quotations & orders)' | $T8 %]</th>
19
     <th>[%- 'Long Description (invoices)' | $T8 %]</th>
19 20
     <th>[% 'Automatic date calculation' | $T8 %]</th>
20 21
     <th align="right">[%- 'Netto Terms' | $T8 %]</th>
21 22
     <th align="right">[%- 'Skonto Terms' | $T8 %]</th>
......
33 34
      </a>
34 35
     </td>
35 36
     <td>[%- HTML.escape(payment_term.description_long) %]</td>
37
     <td>[%- HTML.escape(payment_term.description_long_invoice) %]</td>
36 38
     <td>[% IF payment_term.auto_calculation %][% LxERP.t8("yes") %][% ELSE %][% LxERP.t8("no") %][% END %]</td>
37 39
     <td align="right">[%- HTML.escape(payment_term.terms_netto_as_number) %]</td>
38 40
     <td align="right">[%- HTML.escape(payment_term.terms_skonto_as_number) %]</td>

Auch abrufbar als: Unified diff