From 67ae175a8aef3e189d6b44c2e0261a8e0448e5b1 Mon Sep 17 00:00:00 2001
From: Moritz Bunkus
Date: Thu, 2 Dec 2010 09:38:08 +0100
Subject: [PATCH] =?utf8?q?Unterscheidung=20Bankeinzug/=C3=9Cberweisung=20i?=
=?utf8?q?n=20zweiter=20Maske=20(Best=C3=A4tigung=20der=20Informationen)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
---
bin/mozilla/sepa.pl | 37 ++++++-----
locale/de/all | 4 ++
.../webpages/sepa/bank_transfer_create.html | 62 +++++++++++++------
3 files changed, 68 insertions(+), 35 deletions(-)
diff --git a/bin/mozilla/sepa.pl b/bin/mozilla/sepa.pl
index 81e63e928..058208b22 100755
--- a/bin/mozilla/sepa.pl
+++ b/bin/mozilla/sepa.pl
@@ -58,8 +58,9 @@ sub bank_transfer_create {
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();
@@ -73,11 +74,13 @@ sub bank_transfer_create {
$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} || [] };
@@ -85,13 +88,13 @@ sub bank_transfer_create {
$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;
@@ -100,10 +103,10 @@ sub bank_transfer_create {
}
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}) };
@@ -113,27 +116,29 @@ sub bank_transfer_create {
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();
diff --git a/locale/de/all b/locale/de/all
index 1fc92b19b..3a1d31413 100644
--- a/locale/de/all
+++ b/locale/de/all
@@ -243,6 +243,7 @@ $self->{texts} = {
'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',
@@ -419,6 +420,8 @@ $self->{texts} = {
'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?',
@@ -1201,6 +1204,7 @@ $self->{texts} = {
'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.',
diff --git a/templates/webpages/sepa/bank_transfer_create.html b/templates/webpages/sepa/bank_transfer_create.html
index 06bbea880..0a5059a20 100644
--- a/templates/webpages/sepa/bank_transfer_create.html
+++ b/templates/webpages/sepa/bank_transfer_create.html
@@ -1,5 +1,14 @@
[%- 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 %]
[%- IF error_message %]
@@ -9,7 +18,12 @@
[% title %]