From: Moritz Bunkus Date: Tue, 7 Jan 2014 18:06:35 +0000 (+0100) Subject: SEPA: Feld »Signaturdatum«; Bearbeiten der Felder in Stammdatenmasken; Speichern... X-Git-Tag: release-3.1.0beta1~22^2~22^2~21^2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0e36c22a2610966d3c83957426d0c91b25c65da3;p=kivitendo-erp.git SEPA: Feld »Signaturdatum«; Bearbeiten der Felder in Stammdatenmasken; Speichern in sepa_export_items --- diff --git a/SL/CT.pm b/SL/CT.pm index b7ae9a504..fa1f91477 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -308,7 +308,8 @@ sub get_bank_info { my $table = $params{vc} eq 'customer' ? 'customer' : 'vendor'; my @ids = ref $params{id} eq 'ARRAY' ? @{ $params{id} } : ($params{id}); my $placeholders = join ", ", ('?') x scalar @ids; - my $query = qq|SELECT id, name, account_number, bank, bank_code, iban, bic + my $c_mandate = $params{vc} eq 'customer' ? ', mandator_id, mandate_date_of_signature' : ''; + my $query = qq|SELECT id, name, account_number, bank, bank_code, iban, bic ${c_mandate} FROM ${table} WHERE id IN (${placeholders})|; diff --git a/SL/DB/MetaSetup/Customer.pm b/SL/DB/MetaSetup/Customer.pm index 52414eabd..0f523a466 100644 --- a/SL/DB/MetaSetup/Customer.pm +++ b/SL/DB/MetaSetup/Customer.pm @@ -9,54 +9,55 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->table('customer'); __PACKAGE__->meta->columns( - account_number => { type => 'text' }, - bank => { type => 'text' }, - bank_code => { type => 'text' }, - bcc => { type => 'text' }, - bic => { type => 'varchar', length => 100 }, - business_id => { type => 'integer' }, - c_vendor_id => { type => 'text' }, - cc => { type => 'text' }, - city => { type => 'varchar', length => 75 }, - contact => { type => 'text' }, - country => { type => 'varchar', length => 75 }, - creditlimit => { type => 'numeric', default => '0', precision => 5, scale => 15 }, - currency_id => { type => 'integer', not_null => 1 }, - customernumber => { type => 'text' }, - delivery_term_id => { type => 'integer' }, - department_1 => { type => 'varchar', length => 75 }, - department_2 => { type => 'varchar', length => 75 }, - depositor => { type => 'text' }, - direct_debit => { type => 'boolean', default => 'false' }, - discount => { type => 'float', precision => 4 }, - email => { type => 'text' }, - fax => { type => 'varchar', length => 30 }, - greeting => { type => 'text' }, - homepage => { type => 'text' }, - iban => { type => 'varchar', length => 100 }, - id => { type => 'integer', not_null => 1, sequence => 'id' }, - itime => { type => 'timestamp', default => 'now()' }, - klass => { type => 'integer', default => '0' }, - language => { type => 'varchar', length => 5 }, - language_id => { type => 'integer' }, - mandator_id => { type => 'text' }, - mtime => { type => 'timestamp' }, - name => { type => 'text', not_null => 1 }, - notes => { type => 'text' }, - obsolete => { type => 'boolean', default => 'false' }, - payment_id => { type => 'integer' }, - phone => { type => 'text' }, - salesman_id => { type => 'integer' }, - street => { type => 'varchar', length => 75 }, - taxincluded => { type => 'boolean' }, - taxincluded_checked => { type => 'boolean' }, - taxnumber => { type => 'text' }, - taxzone_id => { type => 'integer', default => '0', not_null => 1 }, - terms => { type => 'integer', default => '0' }, - user_password => { type => 'text' }, - username => { type => 'varchar', length => 50 }, - ustid => { type => 'text' }, - zipcode => { type => 'varchar', length => 10 }, + account_number => { type => 'text' }, + bank => { type => 'text' }, + bank_code => { type => 'text' }, + bcc => { type => 'text' }, + bic => { type => 'varchar', length => 100 }, + business_id => { type => 'integer' }, + c_vendor_id => { type => 'text' }, + cc => { type => 'text' }, + city => { type => 'varchar', length => 75 }, + contact => { type => 'text' }, + country => { type => 'varchar', length => 75 }, + creditlimit => { type => 'numeric', default => '0', precision => 5, scale => 15 }, + currency_id => { type => 'integer', not_null => 1 }, + customernumber => { type => 'text' }, + delivery_term_id => { type => 'integer' }, + department_1 => { type => 'varchar', length => 75 }, + department_2 => { type => 'varchar', length => 75 }, + depositor => { type => 'text' }, + direct_debit => { type => 'boolean', default => 'false' }, + discount => { type => 'float', precision => 4 }, + email => { type => 'text' }, + fax => { type => 'varchar', length => 30 }, + greeting => { type => 'text' }, + homepage => { type => 'text' }, + iban => { type => 'varchar', length => 100 }, + id => { type => 'integer', not_null => 1, sequence => 'id' }, + itime => { type => 'timestamp', default => 'now()' }, + klass => { type => 'integer', default => '0' }, + language => { type => 'varchar', length => 5 }, + language_id => { type => 'integer' }, + mandate_date_of_signature => { type => 'date' }, + mandator_id => { type => 'text' }, + mtime => { type => 'timestamp' }, + name => { type => 'text', not_null => 1 }, + notes => { type => 'text' }, + obsolete => { type => 'boolean', default => 'false' }, + payment_id => { type => 'integer' }, + phone => { type => 'text' }, + salesman_id => { type => 'integer' }, + street => { type => 'varchar', length => 75 }, + taxincluded => { type => 'boolean' }, + taxincluded_checked => { type => 'boolean' }, + taxnumber => { type => 'text' }, + taxzone_id => { type => 'integer', default => '0', not_null => 1 }, + terms => { type => 'integer', default => '0' }, + user_password => { type => 'text' }, + username => { type => 'varchar', length => 50 }, + ustid => { type => 'text' }, + zipcode => { type => 'varchar', length => 10 }, ); __PACKAGE__->meta->primary_key_columns([ 'id' ]); diff --git a/SL/DB/MetaSetup/SepaExportItem.pm b/SL/DB/MetaSetup/SepaExportItem.pm index 4746572dd..f2b325d85 100644 --- a/SL/DB/MetaSetup/SepaExportItem.pm +++ b/SL/DB/MetaSetup/SepaExportItem.pm @@ -9,23 +9,25 @@ use base qw(SL::DB::Object); __PACKAGE__->meta->table('sepa_export_items'); __PACKAGE__->meta->columns( - amount => { type => 'numeric', precision => 5, scale => 25 }, - ap_id => { type => 'integer' }, - ar_id => { type => 'integer' }, - chart_id => { type => 'integer', not_null => 1 }, - end_to_end_id => { type => 'varchar', length => 35 }, - executed => { type => 'boolean', default => 'false' }, - execution_date => { type => 'date' }, - id => { type => 'integer', not_null => 1, sequence => 'id' }, - our_bic => { type => 'varchar', length => 100 }, - our_depositor => { type => 'text' }, - our_iban => { type => 'varchar', length => 100 }, - reference => { type => 'varchar', length => 35 }, - requested_execution_date => { type => 'date' }, - sepa_export_id => { type => 'integer', not_null => 1 }, - vc_bic => { type => 'varchar', length => 100 }, - vc_depositor => { type => 'text' }, - vc_iban => { type => 'varchar', length => 100 }, + amount => { type => 'numeric', precision => 5, scale => 25 }, + ap_id => { type => 'integer' }, + ar_id => { type => 'integer' }, + chart_id => { type => 'integer', not_null => 1 }, + end_to_end_id => { type => 'varchar', length => 35 }, + executed => { type => 'boolean', default => 'false' }, + execution_date => { type => 'date' }, + id => { type => 'integer', not_null => 1, sequence => 'id' }, + our_bic => { type => 'varchar', length => 100 }, + our_depositor => { type => 'text' }, + our_iban => { type => 'varchar', length => 100 }, + reference => { type => 'varchar', length => 35 }, + requested_execution_date => { type => 'date' }, + sepa_export_id => { type => 'integer', not_null => 1 }, + vc_bic => { type => 'varchar', length => 100 }, + vc_depositor => { type => 'text' }, + vc_iban => { type => 'varchar', length => 100 }, + vc_mandate_date_of_signature => { type => 'date' }, + vc_mandator_id => { type => 'text' }, ); __PACKAGE__->meta->primary_key_columns([ 'id' ]); diff --git a/SL/DB/MetaSetup/Vendor.pm b/SL/DB/MetaSetup/Vendor.pm index 8d451ad6b..0493aa374 100644 --- a/SL/DB/MetaSetup/Vendor.pm +++ b/SL/DB/MetaSetup/Vendor.pm @@ -36,7 +36,6 @@ __PACKAGE__->meta->columns( itime => { type => 'timestamp', default => 'now()' }, language => { type => 'varchar', length => 5 }, language_id => { type => 'integer' }, - mandator_id => { type => 'text' }, mtime => { type => 'timestamp' }, name => { type => 'varchar', length => 75, not_null => 1 }, notes => { type => 'text' }, diff --git a/SL/SEPA.pm b/SL/SEPA.pm index 21629ba3d..63efe2c5a 100644 --- a/SL/SEPA.pm +++ b/SL/SEPA.pm @@ -19,12 +19,14 @@ sub retrieve_open_invoices { my $arap = $params{vc} eq 'customer' ? 'ar' : 'ap'; my $vc = $params{vc} eq 'customer' ? 'customer' : 'vendor'; + my $mandate = $params{vc} eq 'customer' ? " AND COALESCE(vc.mandator_id, '') <> '' AND vc.mandate_date_of_signature IS NOT NULL " : ''; + my $query = qq| SELECT ${arap}.id, ${arap}.invnumber, ${arap}.${vc}_id as vc_id, ${arap}.amount AS invoice_amount, ${arap}.invoice, vc.name AS vcname, vc.language_id, ${arap}.duedate as duedate, ${arap}.direct_debit, - COALESCE(vc.iban, '') <> '' AND COALESCE(vc.bic, '') <> '' AS vc_bank_info_ok, + COALESCE(vc.iban, '') <> '' AND COALESCE(vc.bic, '') <> '' ${mandate} AS vc_bank_info_ok, ${arap}.amount - ${arap}.paid - COALESCE(open_transfers.amount, 0) AS open_amount @@ -76,14 +78,16 @@ sub create_export { my $q_item_id = qq|SELECT nextval('id')|; my $h_item_id = prepare_query($form, $dbh, $q_item_id); + my $c_mandate = $params{vc} eq 'customer' ? ', vc_mandator_id, vc_mandate_date_of_signature' : ''; + my $p_mandate = $params{vc} eq 'customer' ? ', ?, ?' : ''; my $q_insert = qq|INSERT INTO sepa_export_items (id, sepa_export_id, ${arap}_id, chart_id, amount, requested_execution_date, reference, end_to_end_id, - our_iban, our_bic, vc_iban, vc_bic) + our_iban, our_bic, vc_iban, vc_bic ${c_mandate}) VALUES (?, ?, ?, ?, ?, ?, ?, ?, - ?, ?, ?, ?)|; + ?, ?, ?, ? ${p_mandate})|; my $h_insert = prepare_query($form, $dbh, $q_insert); my $q_reference = @@ -130,6 +134,8 @@ sub create_export { $transfer->{reference}, $end_to_end_id, map { my $pfx = $_; map { $transfer->{"${pfx}_${_}"} } qw(iban bic) } qw(our vc)); + push @values, $transfer->{vc_mandator_id}, conv_date($transfer->{vc_mandate_date_of_signature}) if $params{vc} eq 'customer'; + do_statement($form, $h_insert, $q_insert, @values); } @@ -177,10 +183,10 @@ sub retrieve_export { if ($export->{id}) { my ($columns, $joins); - my $mandator_id = $params{vc} eq 'customer' ? ', mandator_id' : ''; + my $mandator_id = $params{vc} eq 'customer' ? ', mandator_id, mandate_date_of_signature' : ''; if ($params{details}) { - $columns = qq|, arap.invnumber, arap.invoice, arap.transdate AS reference_date, vc.name AS vc_name, vc.${vc}number AS vc_number, c.accno AS chart_accno, c.description AS chart_description, ${mandator_id}|; + $columns = qq|, arap.invnumber, arap.invoice, arap.transdate AS reference_date, vc.name AS vc_name, vc.${vc}number AS vc_number, c.accno AS chart_accno, c.description AS chart_description ${mandator_id}|; $joins = qq|LEFT JOIN ${arap} arap ON (sei.${arap}_id = arap.id) LEFT JOIN ${vc} vc ON (arap.${vc}_id = vc.id) LEFT JOIN chart c ON (sei.chart_id = c.id)|; diff --git a/SL/SEPA/XML.pm b/SL/SEPA/XML.pm index f939453fe..8ccfa8374 100644 --- a/SL/SEPA/XML.pm +++ b/SL/SEPA/XML.pm @@ -224,7 +224,7 @@ sub to_xml { $xml->startTag('MndtRltdInf'); $xml->dataElement('MndtId', $self->_restricted_identification_sepa2($transaction->get('mandator_id'))); - $xml->dataElement('DtOfSgntr', $transaction->get('reference_date', 2010-12-02)); + $xml->dataElement('DtOfSgntr', $self->_restricted_identification_sepa2($transaction->get('date_of_signature'))); $xml->endTag('MndtRltdInf'); $xml->startTag('CdtrSchmeId'); diff --git a/bin/mozilla/sepa.pl b/bin/mozilla/sepa.pl index e7ca5ecd4..6fb9907d2 100755 --- a/bin/mozilla/sepa.pl +++ b/bin/mozilla/sepa.pl @@ -110,11 +110,14 @@ sub bank_transfer_create { my ($vc_bank_info); my $error_message; + my @bank_columns = qw(iban bic); + push @bank_columns, qw(mandator_id mandate_date_of_signature) if $vc eq 'customer'; + if ($form->{confirmation}) { $vc_bank_info = { map { $_->{id} => $_ } @{ $form->{vc_bank_info} || [] } }; foreach my $info (values %{ $vc_bank_info }) { - if (any { !$info->{$_} } qw(iban bic)) { + if (any { !$info->{$_} } @bank_columns) { $error_message = $locale->text('The bank information must not be empty.'); last; } @@ -143,7 +146,7 @@ sub bank_transfer_create { } else { foreach my $bank_transfer (@bank_transfers) { - foreach (qw(iban bic)) { + foreach (@bank_columns) { $bank_transfer->{"vc_${_}"} = $vc_bank_info->{ $bank_transfer->{vc_id} }->{$_}; $bank_transfer->{"our_${_}"} = $bank_account->{$_}; } @@ -506,6 +509,10 @@ sub bank_transfer_download_sepa_xml { my ($yy, $mm, $dd) = $locale->parse_date($myconfig, $item->{reference_date}); $item->{reference_date} = sprintf '%04d-%02d-%02d', $yy, $mm, $dd; $mandator_id = $item->{mandator_id}; + if ($item->{mandate_date_of_signature}) { + ($yy, $mm, $dd) = $locale->parse_date($myconfig, $item->{mandate_date_of_signature}); + $item->{mandate_date_of_signature} = sprintf '%04d-%02d-%02d', $yy, $mm, $dd; + } } $sepa_xml->add_transaction({ 'src_iban' => $item->{our_iban}, @@ -519,7 +526,8 @@ sub bank_transfer_download_sepa_xml { 'mandator_id' => $mandator_id, 'reference_date' => $item->{reference_date}, 'execution_date' => $requested_execution_date, - 'end_to_end_id' => $item->{end_to_end_id} }); + 'end_to_end_id' => $item->{end_to_end_id}, + 'date_of_signature' => $item->{mandate_date_of_signature}, }); } my $xml = $sepa_xml->to_xml(); diff --git a/locale/de/all b/locale/de/all index 93453293e..7c529a31f 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1287,6 +1287,7 @@ $self->{texts} = { 'Make default profile' => 'Zu Standardprofil machen', 'Manage Custom Variables' => 'Benutzerdefinierte Variablen', 'Mandantennummer' => 'Mandantennummer', + 'Mandate Date of Signature' => 'Mandat-Unterschriftsdatum', 'Mandator ID' => 'Mandanten-ID', 'Mandatory Departments' => 'Benutzer muss Abteilungen vergeben', 'Map' => 'Karte', @@ -2227,6 +2228,8 @@ $self->{texts} = { 'The project type has been deleted.' => 'Der Projekttyp wurde gelöscht.', 'The project type has been saved.' => 'Der Projekttyp wurde gespeichert.', 'The project type is in use and cannot be deleted.' => 'Der Projekttyp wird verwendet und kann nicht gelöscht werden.', + 'The required information consists of the IBAN and the BIC.' => 'Die benötigten Informationen bestehen aus der IBAN und der BIC.', + 'The required information consists of the IBAN, the BIC, the mandator ID and the mandate\'s date of signature.' => 'Die benötigten Informationen bestehen aus IBAN, BIC, Mandanten-ID und dem Unterschriftsdatum des Mandates.', 'The second reason is that kivitendo allowed the user to enter the tax amount manually regardless of the taxkey used.' => 'Der zweite Grund war, dass kivitendo zuließ, dass die Benutzer beliebige, von den tatsächlichen Steuerschlüsseln unabhängige Steuerbeträge eintrugen.', 'The second way is to use Perl\'s CPAN module and let it download and install the module for you.' => 'Die zweite Variante besteht darin, Perls CPAN-Modul zu benutzen und es das Modul für Sie installieren zu lassen.', 'The selected bank account does not exist anymore.' => 'Das ausgewählte Bankkonto existiert nicht mehr.', diff --git a/sql/Pg-upgrade2/add_customer_mandator_id.sql b/sql/Pg-upgrade2/add_customer_mandator_id.sql index e27eba5c3..99a788e92 100644 --- a/sql/Pg-upgrade2/add_customer_mandator_id.sql +++ b/sql/Pg-upgrade2/add_customer_mandator_id.sql @@ -1,6 +1,18 @@ -- @tag: add_customer_mandator_id --- @description: Einführen einer Mandanten ID Spalte bei Kunden und Lieferanten. +-- @description: Einführen einer Mandanten-ID- und Signatur-Datums-Spalte bei Kunden. -- @depends: release_3_0_0 -ALTER TABLE customer ADD mandator_id text; -ALTER TABLE vendor ADD mandator_id text; +ALTER TABLE customer ADD COLUMN mandator_id text; +ALTER TABLE customer ADD COLUMN mandate_date_of_signature date; +ALTER TABLE sepa_export_items ADD COLUMN vc_mandator_id text; +ALTER TABLE sepa_export_items ADD COLUMN vc_mandate_date_of_signature date; + +UPDATE sepa_export_items +SET vc_mandator_id = ( + SELECT c.customernumber + FROM ar + LEFT JOIN customer c ON (ar.customer_id = c.id) + WHERE ar.id = sepa_export_items.ar_id +), +vc_mandate_date_of_signature = '2010-01-01'::date +WHERE ar_id IS NOT NULL; diff --git a/templates/webpages/customer_vendor/tabs/bank.html b/templates/webpages/customer_vendor/tabs/bank.html index 878a928b3..1f08af4b5 100644 --- a/templates/webpages/customer_vendor/tabs/bank.html +++ b/templates/webpages/customer_vendor/tabs/bank.html @@ -12,10 +12,17 @@ [% L.input_tag('cv.depositor', SELF.cv.depositor, size = 20) %] + [%- IF ( SELF.is_customer ) %] [% 'Mandator ID' | $T8 %] [% L.input_tag('cv.mandator_id', SELF.cv.mandator_id, size = 20) %] + + [% 'Mandate Date of Signature' | $T8 %] + + [% L.date_tag('cv.mandate_date_of_signature', SELF.cv.mandate_date_of_signature) %] + + [%- END %] diff --git a/templates/webpages/sepa/bank_transfer_add.html b/templates/webpages/sepa/bank_transfer_add.html index 279326368..4ae82d12d 100644 --- a/templates/webpages/sepa/bank_transfer_add.html +++ b/templates/webpages/sepa/bank_transfer_add.html @@ -89,8 +89,10 @@ (1) [%- IF is_vendor %] [%- 'No bank information has been entered in this vendor\'s master data entry. You cannot create bank transfers unless you enter bank information.' | $T8 %] + [% "The required information consists of the IBAN and the BIC." | $T8 %] [%- ELSE %] [%- 'No bank information has been entered in this customer\'s master data entry. You cannot create bank collections unless you enter bank information.' | $T8 %] + [% "The required information consists of the IBAN, the BIC, the mandator ID and the mandate's date of signature." | $T8 %] [%- END %]

[%- END %] diff --git a/templates/webpages/sepa/bank_transfer_create.html b/templates/webpages/sepa/bank_transfer_create.html index e5ef6568f..80af4c49d 100644 --- a/templates/webpages/sepa/bank_transfer_create.html +++ b/templates/webpages/sepa/bank_transfer_create.html @@ -49,6 +49,7 @@ [% 'Bank' | $T8 %] [% IF vc == 'customer' %] [% 'Mandator ID' | $T8 %] + [% 'Mandate Date of Signature' | $T8 %] [%- END %] @@ -64,6 +65,7 @@ [% IF vc == 'customer' %] + [% L.date_tag("vc_bank_info[].mandate_date_of_signature", vbi.mandate_date_of_signature) %] [%- END %] [%- END %]