Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b93886a3

Von Jan Büren vor mehr als 2 Jahren hinzugefügt

  • ID b93886a387e00d690e5a520b7bb84e52ace563f1
  • Vorgänger 5104f579
  • Nachfolger 07cd18f5

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
44 44

  
45 45
         ${arap}.amount - ${arap}.paid - COALESCE(open_transfers.amount, 0) AS open_amount,
46 46
         COALESCE(open_transfers.amount, 0) AS transfer_amount,
47
         pt.description as pt_description
48

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

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

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

  
84 81
  $main::lxdebug->leave_sub();
85 82

  
locale/de/all
2978 2978
  'SAVED FOR DUNNING'           => 'Gespeichert zum Mahnen',
2979 2979
  'SCREENED'                    => 'Angezeigt',
2980 2980
  'SEPA'                        => 'SEPA',
2981
  'SEPA Transfer Amount'        => 'Betrag in offenen SEPA Exporten',
2981 2982
  'SEPA XML download'           => 'SEPA-XML-Download',
2982 2983
  'SEPA creditor ID'            => 'SEPA-Kreditoren-Identifikation',
2983 2984
  '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

  
......
81 82
       </a>
82 83
      </td>
83 84

  
84
      <td align="right">[% LxERP.format_amount(invoice.invoice_amount-invoice.open_sepa_transfer_amount, 2) %]</td>
85
      <td align="right">[% LxERP.format_amount(invoice.open_amount-invoice.open_sepa_transfer_amount, 2) %]</td>
85
      <td align="right">[% LxERP.format_amount(invoice.invoice_amount, 2) %]</td>
86
      <td align="right">[% LxERP.format_amount(invoice.transfer_amount * -1, 2) %]</td>
87
      <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>
86 88
      <td align="right">[% invoice.transdate %]</td>
87 89
      <td align="right">[% invoice.duedate %]</td>
88 90
      <td>
......
94 96
       <input name="bank_transfers[].reference" value="[% HTML.escape(reference.substr(0, 140)) %]" maxlength="140" size="30">
95 97
      </td>
96 98
      <td align="right">
97
       <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">
99
       <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">
98 100
      </td>
99 101
      <td>
100 102
      [% 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' ) %]
......
147 149
  // alert("found id " + id);
148 150
  if ( $(this).val() == "without_skonto" ) {
149 151
      $('#' + id).val( $('#invoice_open_amount_' + id).val() );
150
  } else if ( $(this).val() == "difference_as_skonto" ) {
151
      $('#' + id).val( $('#invoice_open_amount_' + id).val() );
152 152
  } else if ( $(this).val() == "with_skonto_pt" ) {
153 153
            $('#' + id).val( $('#amount_less_skonto_' + id).val() );
154 154
  }

Auch abrufbar als: Unified diff