Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b93886a3

Von Jan Büren vor etwa 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

  

Auch abrufbar als: Unified diff