- my $bank_account_label_sub = sub { $locale->text('Account number #1, bank code #2, #3', $_[0]->{account_number}, $_[0]->{bank_code}, $_[0]->{bank}) };
+ # 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 $translation_list = GenericTranslations->list(translation_type => 'sepa_remittance_info_pfx');
+ my %translations = map { ( ($_->{language_id} || 'default') => $_->{translation} ) } @{ $translation_list };
+
+ foreach my $invoice (@{ $invoices }) {
+ my $prefix = $translations{ $invoice->{language_id} } || $translations{default} || $::locale->text('Invoice');
+ $prefix .= ' ' unless $prefix =~ m/ $/;
+ $invoice->{reference_prefix} = $prefix;
+
+ # add c_vendor_id or v_vendor_id as a prefix if a entry exists
+ next unless $invoice->{vc_vc_id};
+
+ my $prefix_vc_number = $translations{ $invoice->{language_id} } || $translations{default} || $vc_no;
+ $prefix_vc_number .= ' ' unless $prefix_vc_number =~ m/ $/;
+ $invoice->{reference_prefix_vc} = ' ' . $prefix_vc_number unless $prefix_vc_number =~ m/^ /;
+ }