X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fsepa.pl;h=7218846a97fbadc47d671a3bbb430bebb45fba2b;hb=48c71a4b51f5359a7ab7e9bc51280baf9bc9b9b2;hp=36f2ff4c604a6c404d55354e082ec62c92b2b2b9;hpb=60b170eb823d19d211db6412d2137129113e5c84;p=kivitendo-erp.git 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;