X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/60b170eb823d19d211db6412d2137129113e5c84..cea7e7c53f1005f6143edbddb5832b6c48b5dc8e:/bin/mozilla/sepa.pl diff --git a/bin/mozilla/sepa.pl b/bin/mozilla/sepa.pl index 36f2ff4c6..7218846a9 100755 --- a/bin/mozilla/sepa.pl +++ b/bin/mozilla/sepa.pl @@ -116,7 +116,21 @@ sub bank_transfer_create { # override default payment_type selection and set it to the one chosen by the user # in the previous step, so that we don't need the logic in the template + my $subtract_days = $::instance_conf->get_sepa_set_skonto_date_buffer_in_days; + my $set_skonto_date = $::instance_conf->get_sepa_set_skonto_date_as_default_exec_date; + my $set_duedate = $::instance_conf->get_sepa_set_duedate_as_default_exec_date; foreach my $bt (@bank_transfers) { + # add a good recommended exec date + # set to skonto date if exists or to duedate + # in both cases subtract the same buffer (if configured, default 0) + $bt->{recommended_execution_date} = + $set_skonto_date && $bt->{payment_type} eq 'with_skonto_pt' ? + DateTime->from_kivitendo($bt->{skonto_date})->subtract(days => $subtract_days)->to_kivitendo + : $set_duedate && $bt->{duedate} ? + DateTime->from_kivitendo($bt->{duedate} )->subtract(days => $subtract_days)->to_kivitendo + : undef; + + foreach my $type ( @{$bt->{payment_select_options}} ) { if ( $type->{payment_type} eq $bt->{payment_type} ) { $type->{selected} = 1;