Merge branch 'master' of github.com:kivitendo/kivitendo-erp
[kivitendo-erp.git] / bin / mozilla / sepa.pl
index 40d2dff..18f48b2 100755 (executable)
@@ -40,7 +40,12 @@ sub bank_transfer_add {
     return;
   }
 
-  $_->{checked} = $_->{direct_debit} for @{ $invoices };
+  # 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}) };
 
@@ -506,6 +511,7 @@ sub bank_transfer_download_sepa_xml {
                                  'dst_iban'       => $item->{vc_iban},
                                  'dst_bic'        => $item->{vc_bic},
                                  'company'        => $item->{vc_name},
+                                 'company_number' => $item->{vc_number},
                                  'amount'         => $item->{amount},
                                  'reference'      => $item->{reference},
                                  'reference_date' => $item->{reference_date},