Revision 38b14007
Von Jan Büren vor fast 2 Jahren hinzugefügt
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 |
|
Auch abrufbar als: Unified diff
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