my $form = $main::form;
my $locale = $main::locale;
my $myconfig = \%main::myconfig;
+ my $vc = $form->{vc} eq 'customer' ? 'customer' : 'vendor';
- $form->{title} = $locale->text('Create bank transfer via SEPA XML');
+ $form->{title} = $vc eq 'customer' ? $::locale->text('Create bank collection via SEPA XML') : $locale->text('Create bank transfer via SEPA XML');
my $bank_accounts = SL::BankAccount->list();
$form->error($locale->text('The selected bank account does not exist anymore.'));
}
- my $invoices = SL::SEPA->retrieve_open_invoices();
+ my $arap_id = $vc eq 'customer' ? 'ar_id' : 'ap_id';
+ my $invoices = SL::SEPA->retrieve_open_invoices(vc => $vc);
+
my %invoices_map = map { $_->{id} => $_ } @{ $invoices };
my @bank_transfers =
- map +{ %{ $invoices_map{ $_->{ap_id} } }, %{ $_ } },
- grep { $_->{selected} && (0 < $_->{amount}) && $invoices_map{ $_->{ap_id} } }
+ map +{ %{ $invoices_map{ $_->{$arap_id} } }, %{ $_ } },
+ grep { $_->{selected} && (0 < $_->{amount}) && $invoices_map{ $_->{$arap_id} } }
map { $_->{amount} = $form->parse_amount($myconfig, $_->{amount}); $_ }
@{ $form->{bank_transfers} || [] };
$form->error($locale->text('You have selected none of the invoices.'));
}
- my ($vendor_bank_info);
+ my ($vc_bank_info);
my $error_message;
if ($form->{confirmation}) {
- $vendor_bank_info = { map { $_->{id} => $_ } @{ $form->{vendor_bank_info} || [] } };
+ $vc_bank_info = { map { $_->{id} => $_ } @{ $form->{vc_bank_info} || [] } };
- foreach my $info (values %{ $vendor_bank_info }) {
+ foreach my $info (values %{ $vc_bank_info }) {
if (any { !$info->{$_} } qw(iban bic)) {
$error_message = $locale->text('The bank information must not be empty.');
last;
}
if ($error_message || !$form->{confirmation}) {
- my @vendor_ids = uniq map { $_->{vendor_id} } @bank_transfers;
- $vendor_bank_info ||= CT->get_bank_info('vc' => 'vendor',
- 'id' => \@vendor_ids);
- my @vendor_bank_info = sort { lc $a->{name} cmp lc $b->{name} } values %{ $vendor_bank_info };
+ my @vc_ids = uniq map { $_->{"${vc}_id"} } @bank_transfers;
+ $vc_bank_info ||= CT->get_bank_info('vc' => $vc,
+ 'id' => \@vc_ids);
+ my @vc_bank_info = sort { lc $a->{name} cmp lc $b->{name} } values %{ $vc_bank_info };
my $bank_account_label_sub = sub { $locale->text('Account number #1, bank code #2, #3', $_[0]->{account_number}, $_[0]->{bank_code}, $_[0]->{bank}) };
print $form->parse_html_template('sepa/bank_transfer_create',
{ 'BANK_TRANSFERS' => \@bank_transfers,
'BANK_ACCOUNTS' => $bank_accounts,
- 'VENDOR_BANK_INFO' => \@vendor_bank_info,
+ 'VC_BANK_INFO' => \@vc_bank_info,
'bank_account' => $bank_account,
'bank_account_label' => $bank_account_label_sub,
'error_message' => $error_message,
+ 'vc' => $vc,
});
} else {
foreach my $bank_transfer (@bank_transfers) {
foreach (qw(iban bic)) {
- $bank_transfer->{"vendor_${_}"} = $vendor_bank_info->{ $bank_transfer->{vendor_id} }->{$_};
- $bank_transfer->{"our_${_}"} = $bank_account->{$_};
+ $bank_transfer->{"vc_${_}"} = $vc_bank_info->{ $bank_transfer->{vc_id} }->{$_};
+ $bank_transfer->{"our_${_}"} = $bank_account->{$_};
}
$bank_transfer->{chart_id} = $bank_account->{chart_id};
}
my $id = SL::SEPA->create_export('employee' => $form->{login},
- 'bank_transfers' => \@bank_transfers);
+ 'bank_transfers' => \@bank_transfers,
+ 'vc' => $vc);
$form->header();
- print $form->parse_html_template('sepa/bank_transfer_created', { 'id' => $id });
+ print $form->parse_html_template('sepa/bank_transfer_created', { 'id' => $id, 'vc' => $vc });
}
$main::lxdebug->leave_sub();
'Bank Connections' => 'Bankverbindungen',
'Bank accounts' => 'Bankkonten',
'Bank code' => 'Bankleitzahl',
+ 'Bank collection amount' => 'Einzugsbetrag',
'Bank collection via SEPA' => 'Bankeinzug via SEPA',
'Bank collections via SEPA' => 'Bankeinzüge via SEPA',
'Bank transfer amount' => 'Überweisungssumme',
'Create and edit sales orders' => 'Auftragsbestätigungen erfassen und bearbeiten',
'Create and edit sales quotations' => 'Angebote erfassen und bearbeiten',
'Create and edit vendor invoices' => 'Eingangsrechnungen erfassen und bearbeiten',
+ 'Create bank collection' => 'Bankeinzug erstellen',
+ 'Create bank collection via SEPA XML' => 'Banküberweisung via SEPA XML erstellen',
'Create bank transfer' => 'Überweisung erstellen',
'Create bank transfer via SEPA XML' => 'Überweisung via SEPA XML erzeugen',
'Create invoice?' => 'Rechnung erstellen?',
'Phone1' => 'Telefon 1 ',
'Phone2' => 'Telefon 2',
'Pick List' => 'Sammelliste',
+ 'Please Check the bank information for each customer:' => 'Bitte überprüfen Sie die Bankinformationen der Kunden:',
'Please Check the bank information for each vendor:' => 'Bitte überprüfen Sie die Kontoinformationen der Lieferanten:',
'Please ask your administrator to create warehouses and bins.' => 'Bitten Sie Ihren Administrator, dass er Lager und Lagerplätze anlegt.',
'Please enter a license key.' => 'Bitte geben Sie einen Lizenzschlüssel an.',
[%- USE T8 %]
[% USE HTML %][% USE LxERP %]
+[% IF vc == 'vendor' %]
+ [% SET is_vendor = 1 %]
+ [% SET arap = 'ap' %]
+ [% SET iris = 'ir' %]
+[% ELSE %]
+ [% SET is_vendor = 0 %]
+ [% SET arap = 'ar' %]
+ [% SET iris = 'is' %]
+[%- END %]
<body>
[%- IF error_message %]
<p><div class="listtop">[% title %]</div></p>
<form action="sepa.pl" method="post">
- <p>1. [% 'Please select the source bank account for the transfers:' | $T8 %]
+ <p>1.
+ [%- IF is_vendor %]
+ [% 'Please select the source bank account for the transfers:' | $T8 %]
+ [%- ELSE %]
+ [% 'Please select the destination bank account for the collections:' | $T8 %]
+ [%- END %]
<br>
[%- INCLUDE generic/multibox.html
name = 'bank_account.id',
</p>
<p>
- 2. [% 'Please Check the bank information for each vendor:' | $T8 %]
+ 2.
+ [%- IF is_vendor %]
+ [% 'Please Check the bank information for each vendor:' | $T8 %]
+ [%- ELSE %]
+ [% 'Please Check the bank information for each customer:' | $T8 %]
+ [%- END %]
<br>
<table>
<tr>
- <th class="listheading">[% 'Vendor' | $T8 %]</th>
+ <th class="listheading">[%- IF is_vendor %][% 'Vendor' | $T8 %][%- ELSE %][%- LxERP.t8('Customer') %][%- END %]</th>
<th class="listheading">[% 'IBAN' | $T8 %]</th>
<th class="listheading">[% 'BIC' | $T8 %]</th>
<th class="listheading">[% 'Bank' | $T8 %]</th>
</tr>
- [%- FOREACH vbi = VENDOR_BANK_INFO %]
+ [%- FOREACH vbi = VC_BANK_INFO %]
<tr class="listrow[% loop.count % 1 %]">
<td>
- <input type="hidden" name="vendor_bank_info[+].id" value="[% HTML.escape(vbi.id) %]">
- <input type="hidden" name="vendor_bank_info[].name" value="[% HTML.escape(vbi.name) %]">
+ <input type="hidden" name="vc_bank_info[+].id" value="[% HTML.escape(vbi.id) %]">
+ <input type="hidden" name="vc_bank_info[].name" value="[% HTML.escape(vbi.name) %]">
[% HTML.escape(vbi.name) %]
</td>
- <td><input name="vendor_bank_info[].iban" size="20" value="[% HTML.escape(vbi.iban) %]"></td>
- <td><input name="vendor_bank_info[].bic" size="20" value="[% HTML.escape(vbi.bic) %]"></td>
- <td><input name="vendor_bank_info[].bank" size="30" value="[% HTML.escape(vbi.bank) %]"></td>
+ <td><input name="vc_bank_info[].iban" size="20" value="[% HTML.escape(vbi.iban) %]"></td>
+ <td><input name="vc_bank_info[].bic" size="20" value="[% HTML.escape(vbi.bic) %]"></td>
+ <td><input name="vc_bank_info[].bank" size="30" value="[% HTML.escape(vbi.bank) %]"></td>
</tr>
[%- END %]
</table>
<br>
<table>
<tr>
- <th class="listheading">[% 'Vendor' | $T8 %]</th>
+ <th class="listheading">[%- IF is_vendor %][% 'Vendor' | $T8 %][%- ELSE %][%- LxERP.t8('Customer') %][%- END %]</th>
<th class="listheading">[% 'Invoice' | $T8 %]</th>
<th class="listheading" align="right">[% 'Amount' | $T8 %]</th>
<th class="listheading" align="right">[% 'Open amount' | $T8 %]</th>
<th class="listheading">[% 'Purpose' | $T8 %]</th>
- <th class="listheading" align="right">[% 'Bank transfer amount' | $T8 %]</th>
+ <th class="listheading" align="right">[%- IF is_vendor %][% 'Bank transfer amount' | $T8 %][%- ELSE %][%- LxERP.t8('Bank collection amount') %][%- END %]</th>
<th class="listheading">[% 'Execution date' | $T8 %]</th>
</tr>
[%- FOREACH bank_transfer = BANK_TRANSFERS %]
- <input type="hidden" name="bank_transfers[+].ap_id" value="[% HTML.escape(bank_transfer.id) %]">
- <input type="hidden" name="bank_transfers[].vendor_id" value="[% HTML.escape(bank_transfer.vendor_id) %]">
+ <input type="hidden" name="bank_transfers[+].[% arap %]_id" value="[% HTML.escape(bank_transfer.id) %]">
+ <input type="hidden" name="bank_transfers[].vc_id" value="[% HTML.escape(bank_transfer.vc_id) %]">
<input type="hidden" name="bank_transfers[].selected" value="1">
<tr class="listrow[% loop.count % 2 %]">
<td>
- [%- IF loop.first || (previous_vendorname != bank_transfer.vendorname) %]
- <a href="ct.pl?action=edit&db=vendor&id=[% HTML.url(bank_transfer.vendor_id) %]&callback=[% HTML.url('sepa.pl?action=bank_transfer_add') %]">
- [%- GET HTML.escape(bank_transfer.vendorname);
- SET previous_vendorname = bank_transfer.vendorname; -%]
+ [%- IF loop.first || (previous_vcname != bank_transfer.vcname) %]
+ <a href="ct.pl?action=edit&db=[% vc %]&id=[% HTML.url(bank_transfer.vc_id) %]&callback=[% HTML.url('sepa.pl?action=bank_transfer_add&vc=' _ vc) %]">
+ [%- GET HTML.escape(bank_transfer.vcname);
+ SET previous_vcname = bank_transfer.vcname; -%]
</a>
[%- END -%]
</td>
<td>
- <a href="[% IF bank_transfer.invoice %]ir[% ELSE %]ap[% END %].pl?action=edit&id=[% HTML.escape(bank_transfer.id) %]">
+ <a href="[% IF bank_transfer.invoice %][% iris %][% ELSE %][% arap %][% END %].pl?action=edit&id=[% HTML.escape(bank_transfer.id) %]">
[% HTML.escape(bank_transfer.invnumber) %]
</a>
</td>
</p>
<p>
- <input type="submit" class="submit" name="action_bank_transfer_create" value="[% 'Create bank transfer' | $T8 %]">
+ [%- IF is_vendor %]
+ <input type="submit" class="submit" name="action_bank_transfer_create" value="[% 'Create bank transfer' | $T8 %]">
+ [%- ELSE %]
+ <input type="submit" class="submit" name="action_bank_transfer_create" value="[% 'Create bank collection' | $T8 %]">
+ [%- END %]
</p>
<input type="hidden" name="action" value="dispatcher">
+ <input type="hidden" name="vc" value="[%- HTML.escape(vc) %]">
<input type="hidden" name="confirmation" value="1">
</form>