Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 994826a2

Von Moritz Bunkus vor etwa 1 Monat hinzugefügt

  • ID 994826a27d0d05f995c5b9a1617e1e64c3a3906e
  • Vorgänger 5102c470

Banktransaktionen CSV-Import: Ende-zu-Ende-ID extrahieren, speichern, bei Duplikatscheck

Unterschiede anzeigen:

SL/Controller/CsvImport/BankTransaction.pm
50 50
    $self->check_currency($entry, take_default => 1);
51 51
    $self->join_purposes($entry);
52 52
    $self->join_remote_names($entry);
53
    $self->extract_end_to_end_id($entry);
53 54
    $self->check_existing($entry) unless @{ $entry->{errors} };
54 55
  } continue {
55 56
    $i++;
......
57 58

  
58 59
  $self->add_info_columns({ header => $::locale->text('Bank account'), method => 'local_bank_name' });
59 60
  $self->add_raw_data_columns("currency", "currency_id") if grep { /^currency(?:_id)?$/ } @{ $self->csv->header };
61
  $self->add_info_columns({ header => $::locale->text('End to end ID'), method => 'end_to_end_id' });
60 62
}
61 63

  
62 64
sub check_existing {
......
76 78
    # * amount
77 79
    # * local_bank_account_id (case flatrate bank charges for two accounts in one bank: same purpose, transdate, remote_account_number(empty), amount. Just different local_bank_account_id)
78 80
    my $num;
79
    if ( $num = SL::DB::Manager::BankTransaction->get_all_count(query =>[ remote_account_number => $object->remote_account_number, transdate => $object->transdate, purpose => $object->purpose, amount => $object->amount, local_bank_account_id => $object->local_bank_account_id] ) ) {
81

  
82
    my @conditions;
83

  
84
    if ($object->end_to_end_id) {
85
      push @conditions, ( end_to_end_id => $object->end_to_end_id );
86
    } else {
87
      push @conditions, ( purpose => $object->purpose );
88
    }
89

  
90
    if ( $num = SL::DB::Manager::BankTransaction->get_all_count(query =>[ remote_account_number => $object->remote_account_number, transdate => $object->transdate, amount => $object->amount, local_bank_account_id => $object->local_bank_account_id, @conditions] ) ) {
80 91
      push(@{$entry->{errors}}, $::locale->text('Skipping due to existing bank transaction in database'));
81 92
    };
82 93
  } else {
......
203 214
  $object->remote_name($remote_name);
204 215
}
205 216

  
217
sub extract_end_to_end_id {
218
  my ($self, $entry) = @_;
219

  
220
  my $object = $entry->{object};
221

  
222
  return if $object->purpose !~ m{\b(?:end\W?to\W?end:|eref\+) *([^ ]+)}i;
223

  
224
  my $id = $1;
225

  
226
  $object->end_to_end_id($id) if $id !~ m{notprovided}i;
227
  $entry->{info_data}->{end_to_end_id} = $object->end_to_end_id;
228
}
229

  
206 230
sub check_auth {
207 231
  $::auth->assert('config') if ! $::auth->assert('bank_transaction',1);
208 232
}

Auch abrufbar als: Unified diff