Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6a61183c

Von Moritz Bunkus vor etwa 13 Jahren hinzugefügt

  • ID 6a61183cc307da9aaf159849315301706a7f1962
  • Vorgänger cb9719b1
  • Nachfolger 2dd5cce2

Update SEPA-XML-Dateien-Erzeugung auf Spezifikation v2.5

Fix für Bug 1699.

Unterschiede anzeigen:

SL/SEPA/XML.pm
105 105
  return $grouped;
106 106
}
107 107

  
108
sub _restricted_identification_sepa1 {
109
  my ($self, $string) = @_;
110

  
111
  $string =~ s/[^A-Za-z0-9\+\?\/\-:\(\)\.,' ]//g;
112
  return substr $string, 0, 35;
113
}
114

  
115
sub _restricted_identification_sepa2 {
116
  my ($self, $string) = @_;
117

  
118
  $string =~ s/[^A-Za-z0-9\+\?\/\-:\(\)\.,']//g;
119
  return substr $string, 0, 35;
120
}
121

  
108 122
sub to_xml {
109 123
  my $self = shift;
110 124

  
......
122 136
  my $now_str   = strftime('%Y-%m-%dT%H:%M:%S', @now) . substr($time_zone, 0, 3) . ':' . substr($time_zone, 3, 2);
123 137

  
124 138
  my $is_coll   = $self->{collection};
125
  my $cd_src    = $is_coll ? 'Cdtr' : 'Dbtr';
126
  my $cd_dst    = $is_coll ? 'Dbtr' : 'Cdtr';
127
  my $pain_id   = $is_coll ? 'pain.008.002.01' : 'pain.001.001.02';
128
  my $pain_elmt = $is_coll ? 'pain.008.001.01' : 'pain.001.001.02';
139
  my $cd_src    = $is_coll ? 'Cdtr'              : 'Dbtr';
140
  my $cd_dst    = $is_coll ? 'Dbtr'              : 'Cdtr';
141
  my $pain_id   = $is_coll ? 'pain.008.002.02'   : 'pain.001.002.03';
142
  my $pain_elmt = $is_coll ? 'CstmrDrctDbtInitn' : 'CstmrCdtTrfInitn';
129 143
  my @pii_base  = (strftime('PII%Y%m%d%H%M%S', @now), rand(1000000000));
130 144

  
131 145
  my $grouped_transactions = $self->_group_transactions();
......
133 147
  $xml->xmlDecl();
134 148

  
135 149
  $xml->startTag('Document',
136
                 'xmlns'              => "urn:swift:xsd:\$${pain_id}",
150
                 'xmlns'              => "urn:iso:std:iso:20022:tech:xsd:${pain_id}",
137 151
                 'xmlns:xsi'          => 'http://www.w3.org/2001/XMLSchema-instance',
138
                 'xsi:schemaLocation' => "urn:swift:xsd:\$${pain_id} ${pain_id}.xsd");
152
                 'xsi:schemaLocation' => "urn:iso:std:iso:20022:tech:xsd:${pain_id} ${pain_id}.xsd");
139 153

  
140 154
  $xml->startTag($pain_elmt);
141 155

  
142 156
  $xml->startTag('GrpHdr');
143
  $xml->dataElement('MsgId', encode('UTF-8', substr($self->{message_id}, 0, 35)));
157
  $xml->dataElement('MsgId', encode('UTF-8', $self->_restricted_identification_sepa1($self->{message_id})));
144 158
  $xml->dataElement('CreDtTm', $now_str);
145 159
  $xml->dataElement('NbOfTxs', scalar @{ $self->{transactions} });
146 160
  $xml->dataElement('CtrlSum', $self->_format_amount($grouped_transactions->{sum_amount}));
147
  $xml->dataElement('Grpg', 'MIXD');
148 161

  
149 162
  $xml->startTag('InitgPty');
150 163
  $xml->dataElement('Nm', encode('UTF-8', substr($self->{company}, 0, 70)));
......
157 170
    my $master_transaction = $transaction_group->{transactions}->[0];
158 171

  
159 172
    $xml->startTag('PmtInf');
160
    if ($is_coll) {
161
      $xml->dataElement('PmtInfId', sprintf('%s%010d', @pii_base));
162
      $pii_base[1]++;
163
    }
173
    $xml->dataElement('PmtInfId', sprintf('%s%010d', @pii_base));
174
    $pii_base[1]++;
164 175
    $xml->dataElement('PmtMtd', $is_coll ? 'DD' : 'TRF');
176
    $xml->dataElement('NbOfTxs', scalar @{ $transaction_group->{transactions} });
177
    $xml->dataElement('CtrlSum', $self->_format_amount($transaction_group->{sum_amount}));
165 178

  
166 179
    $xml->startTag('PmtTpInf');
167 180
    $xml->startTag('SvcLvl');
......
199 212
      $xml->startTag($is_coll ? 'DrctDbtTxInf' : 'CdtTrfTxInf');
200 213

  
201 214
      $xml->startTag('PmtId');
202
      $xml->dataElement('EndToEndId', $transaction->get('end_to_end_id', 35));
215
      $xml->dataElement('EndToEndId', $self->_restricted_identification_sepa1($transaction->get('end_to_end_id')));
203 216
      $xml->endTag('PmtId');
204 217

  
205 218
      if ($is_coll) {
......
210 223
        $xml->startTag('DrctDbtTx');
211 224

  
212 225
        $xml->startTag('MndtRltdInf');
213
        $xml->dataElement('MndtId', $transaction->get('reference', 35));
226
        $xml->dataElement('MndtId', $self->_restricted_identification_sepa2($transaction->get('reference')));
214 227
        $xml->dataElement('DtOfSgntr', $transaction->get('reference_date', 2010-12-02));
215 228
        $xml->endTag('MndtRltdInf');
216 229

  
217 230
        $xml->startTag('CdtrSchmeId');
218 231
        $xml->startTag('Id');
219 232
        $xml->startTag('PrvtId');
220
        $xml->startTag('OthrId');
233
        $xml->startTag('Othr');
221 234
        $xml->dataElement('Id', encode('UTF-8', substr($self->{creditor_id}, 0, 35)));
222
        $xml->dataElement('IdTp', 'SEPA');
223
        $xml->endTag('OthrId');
235
        $xml->startTag('SchmeNm');
236
        $xml->dataElement('Prtry', 'SEPA');
237
        $xml->endTag('SchmeNm');
238
        $xml->endTag('Othr');
224 239
        $xml->endTag('PrvtId');
225 240
        $xml->endTag('Id');
226 241
        $xml->endTag('CdtrSchmeId');

Auch abrufbar als: Unified diff