Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 38b14007

Von Jan Büren vor etwa 2 Jahren hinzugefügt

  • ID 38b1400715c292bd12327e7a7080d7ddea2fe595
  • Vorgänger bbb2befc
  • Nachfolger 21be019f

SEPA: within_skonto_period direkt aus SQL Abfrage und keine Helper-Funktionen

- transfer_amount aus sql ist identisch mit open_sepa_transfer_amount
- SEPA Transfer Amount in Template auch als Wert angeben

Unterschiede anzeigen:

SL/SEPA.pm
47 47

  
48 48
         ${arap}.amount - ${arap}.paid - COALESCE(open_transfers.amount, 0) AS open_amount,
49 49
         COALESCE(open_transfers.amount, 0) AS transfer_amount,
50
         pt.description as pt_description
51

  
50
         pt.description as pt_description,
51
         (current_date < (${arap}.transdate + pt.terms_skonto)) as within_skonto_period
52 52
       FROM ${arap}
53 53
       LEFT JOIN ${vc} vc ON (${arap}.${vc}_id = vc.id)
54 54
       LEFT JOIN (SELECT sei.${arap}_id, SUM(sei.amount) + SUM(COALESCE(sei.skonto_amount,0)) AS amount
......
72 72
  # add some more data to $results:
73 73
  # create drop-down data for payment types and suggest amount to be paid according
74 74
  # to open amount or skonto
75
  # One minor fault: amount_less_skonto does not subtract the not yet booked sepa transfer amounts
75 76

  
76 77
  foreach my $result ( @$results ) {
77
    my $invoice = $vc eq 'customer' ? SL::DB::Manager::Invoice->find_by(         id => $result->{id} )
78
                                    : SL::DB::Manager::PurchaseInvoice->find_by( id => $result->{id} );
79

  
80
    $invoice->get_payment_suggestions(sepa => 1); # consider amounts of open entries in sepa_export_items
81
    $result->{skonto_amount}             = $invoice->skonto_amount;
82
    $result->{within_skonto_period}      = $invoice->within_skonto_period;
83
    $result->{invoice_amount_suggestion} = $invoice->{invoice_amount_suggestion};
84
    $result->{payment_select_options}    = $invoice->{payment_select_options};
85
  };
78
    my   @options;
79
    push @options, { payment_type => 'without_skonto',  display => t8('without skonto') };
80
    push @options, { payment_type => 'with_skonto_pt',  display => t8('with skonto acc. to pt'), selected => 1 } if $result->{within_skonto_period};
81
    $result->{payment_select_options}  = \@options;
82
  }
86 83

  
87 84
  $main::lxdebug->leave_sub();
88 85

  
locale/de/all
3095 3095
  'SAVED FOR DUNNING'           => 'Gespeichert zum Mahnen',
3096 3096
  'SCREENED'                    => 'Angezeigt',
3097 3097
  'SEPA'                        => 'SEPA',
3098
  'SEPA Transfer Amount'        => 'Betrag in offenen SEPA Exporten',
3098 3099
  'SEPA XML download'           => 'SEPA-XML-Download',
3099 3100
  'SEPA creditor ID'            => 'SEPA-Kreditoren-Identifikation',
3100 3101
  'SEPA exports'                => 'SEPA-Exporte',
templates/webpages/sepa/bank_transfer_add.html
36 36
     <th class="listheading">[% IF is_vendor %][% 'Vendor' | $T8 %][%- ELSE %][%- LxERP.t8('Customer') %][%- END %]</th>
37 37
     <th class="listheading">[% 'Invoice' | $T8 %]</th>
38 38
     <th class="listheading" align="right">[% 'Amount' | $T8 %]</th>
39
     <th class="listheading" align="right">[% 'SEPA Transfer Amount' | $T8 %]</th>
39 40
     <th class="listheading" align="right">[% 'Open amount' | $T8 %]</th>
40 41
     <th class="listheading" align="right">[% 'Invoice Date' | $T8 %]</th>
41 42
     <th class="listheading" align="right">[% 'Due Date' | $T8 %]</th>
......
48 49
    [%- FOREACH invoice = INVOICES %]
49 50
     <input type="hidden" name="bank_transfers[+].[% arap %]_id" value="[% HTML.escape(invoice.id) %]">
50 51
     <input type="hidden" id="amount_less_skonto_[% loop.count %]" name="amount_less_skonto_[% loop.count %]" value="[% LxERP.format_amount(invoice.amount_less_skonto, 2) %]">
51
     <input type="hidden" id="invoice_open_amount_[% loop.count %]" name="invoice_open_amount_[% loop.count %]" value="[% LxERP.format_amount(invoice.open_amount - invoice.open_sepa_transfer_amount, 2) %]">
52
     <input type="hidden" id="invoice_open_amount_[% loop.count %]" name="invoice_open_amount_[% loop.count %]" value="[% LxERP.format_amount(invoice.open_amount - invoice.transfer_amount, 2) %]">
52 53
     <input type="hidden" id="skonto_amount_[% loop.count %]" name="skonto_amount_[% loop.count %]" value="[% LxERP.format_amount(invoice.skonto_amount, 2) %]">
53 54

  
54 55

  
......
86 87
       </a>
87 88
      </td>
88 89

  
89
      <td align="right">[% LxERP.format_amount(invoice.invoice_amount-invoice.open_sepa_transfer_amount, 2) %]</td>
90
      <td align="right">[% LxERP.format_amount(invoice.open_amount-invoice.open_sepa_transfer_amount, 2) %]</td>
90
      <td align="right">[% LxERP.format_amount(invoice.invoice_amount, 2) %]</td>
91
      <td align="right">[% LxERP.format_amount(invoice.transfer_amount * -1, 2) %]</td>
92
      <td align="right">[% IF invoice.within_skonto_period %] [% LxERP.format_amount(invoice.amount_less_skonto, 2) %] [% ELSE %] [% LxERP.format_amount(invoice.open_amount - invoice.transfer_amount, 2) %][% END %] </td>
91 93
      <td align="right">[% invoice.transdate %]</td>
92 94
      <td align="right">[% invoice.duedate %]</td>
93 95
      <td>
......
99 101
       <input name="bank_transfers[].reference" value="[% HTML.escape(reference.substr(0, 140)) %]" maxlength="140" size="30">
100 102
      </td>
101 103
      <td align="right">
102
       <input id=[% loop.count %] name="bank_transfers[].amount" id="amount_[% loop.count %]" value="[% LxERP.format_amount(invoice.invoice_amount_suggestion, 2) %]" style="text-align: right" size="12">
104
       <input id=[% loop.count %] name="bank_transfers[].amount" id="amount_[% loop.count %]" value="[% IF invoice.within_skonto_period %] [% LxERP.format_amount(invoice.amount_less_skonto, 2) %] [% ELSE %] [% LxERP.format_amount(invoice.open_amount - invoice.transfer_amount, 2) %][% END %]" style="text-align: right" size="12">
103 105
      </td>
104 106
      <td>
105 107
      [% L.select_tag('bank_transfers[].payment_type', invoice.payment_select_options, value_key => 'payment_type', title_key => 'display', id => 'payment_type_' _ loop.count, class => 'type_target' ) %]
......
159 161
  // alert("found id " + id);
160 162
  if ( $(this).val() == "without_skonto" ) {
161 163
      $('#' + id).val( $('#invoice_open_amount_' + id).val() );
162
  } else if ( $(this).val() == "difference_as_skonto" ) {
163
      $('#' + id).val( $('#invoice_open_amount_' + id).val() );
164 164
  } else if ( $(this).val() == "with_skonto_pt" ) {
165 165
            $('#' + id).val( $('#amount_less_skonto_' + id).val() );
166 166
  }

Auch abrufbar als: Unified diff