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})|;
__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' ]);
__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' ]);
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' },
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
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 =
$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);
}
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)|;
$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');
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;
}
} 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->{$_};
}
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},
'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();
'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',
'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.',
-- @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;
[% L.input_tag('cv.depositor', SELF.cv.depositor, size = 20) %]
</td>
+ [%- IF ( SELF.is_customer ) %]
<th align="right">[% 'Mandator ID' | $T8 %]</th>
<td>
[% L.input_tag('cv.mandator_id', SELF.cv.mandator_id, size = 20) %]
</td>
+
+ <th align="right">[% 'Mandate Date of Signature' | $T8 %]</th>
+ <td>
+ [% L.date_tag('cv.mandate_date_of_signature', SELF.cv.mandate_date_of_signature) %]
+ </td>
+ [%- END %]
</tr>
<tr>
<sup>(1)</sup>
[%- 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 %]
</p>
[%- END %]
<th class="listheading">[% 'Bank' | $T8 %]</th>
[% IF vc == 'customer' %]
<th class="listheading">[% 'Mandator ID' | $T8 %]</th>
+ <th class="listheading">[% 'Mandate Date of Signature' | $T8 %]</th>
[%- END %]
</tr>
<td><input name="vc_bank_info[].bank" size="30" value="[% HTML.escape(vbi.bank) %]"></td>
[% IF vc == 'customer' %]
<td><input name="vc_bank_info[].mandator_id" size="30" value="[% HTML.escape(vbi.mandator_id) %]"></td>
+ <td>[% L.date_tag("vc_bank_info[].mandate_date_of_signature", vbi.mandate_date_of_signature) %]</td>
[%- END %]
</tr>
[%- END %]