Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 8bb3b201

Von Moritz Bunkus vor fast 2 Jahren hinzugefügt

  • ID 8bb3b201b2a80784f0a503ab9f4af7d91aafcc5b
  • Vorgänger b6fada0c

MT940: konfigurierbare Leerzeichen in Unterfeldern des Verwendunszwecks

Unterschiede anzeigen:

SL/Controller/BankImport.pm
16 16

  
17 17
use Rose::Object::MakeMethods::Generic
18 18
(
19
  scalar                  => [ qw(file_name transactions statistics charset) ],
19
  scalar                  => [ qw(file_name transactions statistics charset space_in_reference) ],
20 20
  'scalar --get_set_init' => [ qw(bank_accounts) ],
21 21
);
22 22

  
......
44 44
  $file->fh->close;
45 45

  
46 46
  $self->charset($::form->{charset});
47
  $self->space_in_reference($::form->{space_in_reference} // 1);
47 48
  $self->file_name($file->file_name);
48 49
  $self->parse_and_analyze_transactions;
49 50

  
......
58 59

  
59 60
  $self->file_name($::form->{file_name});
60 61
  $self->charset($::form->{charset});
62
  $self->space_in_reference($::form->{space_in_reference});
61 63
  $self->parse_and_analyze_transactions;
62 64
  $self->import_transactions;
63 65

  
......
73 75

  
74 76
  my $currency_id = SL::DB::Default->get->currency_id;
75 77

  
76
  $self->transactions([ sort { $a->{transdate} cmp $b->{transdate} } SL::MT940->parse($self->file_name, charset => $self->charset) ]);
78
  my @transactions = SL::MT940->parse(
79
    $self->file_name,
80
    charset            => $self->charset,
81
    space_in_reference => $self->space_in_reference,
82
  );
83
  $self->transactions([ sort { $a->{transdate} cmp $b->{transdate} } @transactions ]);
77 84

  
78 85
  foreach my $transaction (@{ $self->transactions }) {
79 86
    $transaction->{bank_account}   = $self->bank_accounts->{ make_bank_account_idx($transaction->{local_bank_code}, $transaction->{local_account_number}) };
SL/MT940.pm
22 22
}
23 23

  
24 24
sub _join_entries_sepa {
25
  my ($parts) = @_;
25
  my ($parts, $separator) = @_;
26 26

  
27 27
  my $line = '';
28 28

  
29 29
  foreach my $field (grep { $_ } map  { $parts->{$_} } (20..29)) {
30 30
    if (($line ne '') && ($field =~ m{^[A-Z]+\+})) {
31 31
      $line .= ' ';
32

  
33
    } elsif ($line ne '') {
34
      $line .= $separator;
32 35
    }
36

  
33 37
    $line .= $field;
34 38
  }
35 39

  
......
37 41
}
38 42

  
39 43
sub _join_entries_austria {
40
  my ($parts) = @_;
44
  my ($parts, $separator) = @_;
41 45

  
42
  return _join_entries($parts, 20, 23, ' ');
46
  return join ' ',
47
    grep { $_ }
48
    (_join_entries($parts, 20, 21, $separator),
49
     _join_entries($parts, 22, 23, $separator));
43 50
}
44 51

  
45 52
sub parse {
......
80 87
    }
81 88
  }
82 89

  
90
  my $sub_field_separator = $params{space_in_reference} ? ' ' : '';
91

  
83 92
  foreach my $line (@lines) {
84 93
    # AT MT940 has the format  :25://AT20151/00797453990/EUR
85 94
    # DE MT940 has the format  :25:BLZ/Konto
......
140 149
        my $is_sepa    = !$is_austria && ($code =~ m{^1});
141 150
        my %parts      = map { ((substr($_, 0, 2) // '0') * 1 => substr($_, 2)) } split quotemeta($separator), $rest;
142 151

  
143
        $transaction{purpose}               = $is_sepa    ? _join_entries_sepa(\%parts)
144
                                            : $is_austria ? _join_entries(\%parts, 20, 23, ' ')
145
                                            :               _join_entries(\%parts, 20, 29);
152
        $transaction{purpose}               = $is_sepa    ? _join_entries_sepa(\%parts, $sub_field_separator)
153
                                            : $is_austria ? _join_entries_austria(\%parts, $sub_field_separator)
154
                                            :               _join_entries(\%parts, 20, 29, $sub_field_separator);
146 155
        $transaction{remote_name}           = _join_entries(\%parts, 32, 33);
147 156
        $transaction{remote_bank_code}      = $parts{30};
148 157
        $transaction{remote_account_number} = $parts{31};
locale/de/all
1212 1212
  'Do not check for duplicates' => 'Nicht nach Dubletten suchen',
1213 1213
  'Do not create Factur-X/ZUGFeRD invoices' => 'Keine Factur-X-/ZUGFeRD-Rechnungen erzeugen',
1214 1214
  'Do not create QR-bill invoices' => 'Keine QR-Rechnungen erzeugen',
1215
  'Do not insert an extra space between sub-fields of the reference field' => 'Keine Leerzeichen zwischen Unterfeldern des Verwendungszwecks einfügen',
1215 1216
  'Do not leave booking form?'  => 'Buchungsmaske nicht verlassen?',
1216 1217
  'Do not link to a project.'   => 'Nicht mit einem Projekt verknüpfen.',
1217 1218
  'Do not modify this position' => 'Diese Position nicht verändern',
......
1980 1981
  'Input to string: #1'         => 'Eingabe Bis-Zeichenkete: #1',
1981 1982
  'Insert'                      => 'Einfügen',
1982 1983
  'Insert Date'                 => 'Erfassungsdatum',
1984
  'Insert an extra space between sub-fields of the reference field' => 'Leerzeichen zwischen Unterfeldern des Verwendungszwecks einfügen',
1983 1985
  'Insert new'                  => 'Hinzufügen',
1984 1986
  'Insert with new customer/vendor number' => 'Mit neuer Kunden-/Lieferantennummer anlegen',
1985 1987
  'Insert with new database ID' => 'Neu anlegen mit neuer Datenbank-ID',
......
3536 3538
  'Source bank account'         => 'Quellkonto',
3537 3539
  'Source bin'                  => 'Quelllagerplatz',
3538 3540
  'Space'                       => 'Leerzeichen',
3541
  'Spaces in reference field'   => 'Leerzeichen im Verwendungszweck',
3539 3542
  'Split entry detected. The values you have entered will result in an entry with more than one position on both debit and credit. Due to known problems involving accounting software kivitendo does not allow these.' => 'Splitbuchung! Die eingebenen Werte würden eine Buchung auslösen, die jeweils mehr als eine Position auf Soll und Haben hätte. Um Kompatibilität mit DATEV zu gewährleisten erlaubt kivitendo keine Splitbuchungen.',
3540 3543
  'Spoolfile'                   => 'Druckdatei',
3541 3544
  'Staff member must not be empty.' => 'Mitarbeiter darf nicht leer sein.',
templates/design40_webpages/bank_import/import_mt940.html
9 9
  <form method="post" action="controller.pl" enctype="multipart/form-data" id="form">
10 10
    [% L.hidden_tag('file_name', SELF.file_name) %]
11 11
    [% L.hidden_tag('charset', SELF.charset) %]
12
    [% L.hidden_tag('space_in_reference', SELF.space_in_reference) %]
12 13
  </form>
13 14
[% END %]
14 15

  
templates/design40_webpages/bank_import/upload_mt940.html
10 10
<div class="wrapper">
11 11
  <form method="post" action="controller.pl" enctype="multipart/form-data" id="form">
12 12
    <table class="tbl-horizontal">
13
    <caption>[% "Import a MT940 file:" | $T8 %]</caption>
13
      <caption>[% "Import a MT940 file:" | $T8 %]</caption>
14 14
      <tbody>
15 15
        <tr>
16 16
          <th>[% LxERP.t8("Charset") %]:</th>
......
20 20
          <th>[% LxERP.t8("MT940 file") %]:</th>
21 21
          <td>[% L.input_tag('file', '', type => 'file', accept => '*') %]</td>
22 22
        </tr>
23
    <tbody>
23
        <tr>
24
          <td>[% LxERP.t8("Spaces in reference field") %]:</td>
25
          <td>[% L.select_tag('space_in_reference', [ [ 0, LxERP.t8('Do not insert an extra space between sub-fields of the reference field') ],
26
                                                      [ 1, LxERP.t8('Insert an extra space between sub-fields of the reference field') ] ], default=1) %]</td>
27
        </tr>
28
      <tbody>
24 29
    </table>
25 30
  </form>
26 31
</div>
templates/webpages/bank_import/import_mt940.html
9 9
  <form method="post" action="controller.pl" enctype="multipart/form-data" id="form">
10 10
    [% L.hidden_tag('file_name', SELF.file_name) %]
11 11
    [% L.hidden_tag('charset', SELF.charset) %]
12
    [% L.hidden_tag('space_in_reference', SELF.space_in_reference) %]
12 13
  </form>
13 14
[% END %]
14 15

  
templates/webpages/bank_import/upload_mt940.html
14 14
      <td>[% L.select_tag('charset', [ [ 'ISO-8859-15', 'ISO-8859-15 (Latin 1)' ], [ 'UTF-8', 'UTF-8' ], [ 'Windows-1252', 'Windows-1252' ] ], default='UTF-8') %]</td>
15 15
    </tr>
16 16

  
17
    <tr>
18
      <td>[% LxERP.t8("Spaces in reference field") %]:</td>
19
      <td>[% L.select_tag('space_in_reference', [ [ 0, LxERP.t8('Do not insert an extra space between sub-fields of the reference field') ],
20
                                                  [ 1, LxERP.t8('Insert an extra space between sub-fields of the reference field') ] ], default=1) %]</td>
21
    </tr>
22

  
17 23
    <tr>
18 24
      <td>[% LxERP.t8("MT940 file") %]:</td>
19 25
      <td>[% L.input_tag('file', '', type => 'file', accept => '*') %]</td>

Auch abrufbar als: Unified diff