taxincluded von Rose laden lassen
[kivitendo-erp.git] / bin / mozilla / sepa.pl
index f559c60..518b9a8 100755 (executable)
@@ -40,6 +40,13 @@ sub bank_transfer_add {
     return;
   }
 
+  # Only include those per default that require manual action from our
+  # side. For sales invoices these are the ones for which direct debit
+  # has been selected. For purchase invoices it's the other way
+  # around: if direct debit is active then the vendor will collect
+  # from us automatically and we don't have to send money manually.
+  $_->{checked} = ($vc eq 'customer' ? $_->{direct_debit} : !$_->{direct_debit}) for @{ $invoices };
+
   my $bank_account_label_sub = sub { $locale->text('Account number #1, bank code #2, #3', $_[0]->{account_number}, $_[0]->{bank_code}, $_[0]->{bank}) };
 
   my $translation_list = GenericTranslations->list(translation_type => 'sepa_remittance_info_pfx');
@@ -176,7 +183,7 @@ sub bank_transfer_list {
 
   my $form   = $main::form;
   my $locale = $main::locale;
-  my $cgi    = $main::cgi;
+  my $cgi    = $::request->{cgi};
   my $vc     = $form->{vc} eq 'customer' ? 'customer' : 'vendor';
 
   $form->{title}     = $vc eq 'customer' ? $::locale->text('List of bank collections') : $locale->text('List of bank transfers');
@@ -443,7 +450,7 @@ sub bank_transfer_download_sepa_xml {
   my $form     =  $main::form;
   my $myconfig = \%main::myconfig;
   my $locale   =  $main::locale;
-  my $cgi      =  $main::cgi;
+  my $cgi      =  $::request->{cgi};
   my $vc       = $form->{vc} eq 'customer' ? 'customer' : 'vendor';
 
   if (!$myconfig->{company}) {