Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7e31f203

Von Jan Büren vor fast 5 Jahren hinzugefügt

  • ID 7e31f203df4cabbd9fa2c65a93be2e0abafc25b5
  • Vorgänger 6caf1000
  • Nachfolger 1acc9e56

Fixt #266 Kontenabgleich mit Bank transaktionssicher

Unterschiede anzeigen:

SL/Controller/Reconciliation.pm
179 179

  
180 180
  my $counter = 0;
181 181

  
182
  foreach my $bt_id ( @{ $::form->{bt_ids} }) {
183
    my $rec_group = SL::DB::Manager::ReconciliationLink->get_new_rec_group();
184
    my $bank_transaction = SL::DB::Manager::BankTransaction->find_by(id => $bt_id);
185
    $bank_transaction->cleared('1');
186
    $bank_transaction->save;
187
    foreach my $acc_trans_id (@{ $::form->{proposal_list}->{$bt_id}->{BB} }) {
188
      SL::DB::ReconciliationLink->new(
189
        rec_group => $rec_group,
190
        bank_transaction_id => $bt_id,
191
        acc_trans_id => $acc_trans_id
192
      )->save;
193
      my $acc_trans = SL::DB::Manager::AccTransaction->find_by(acc_trans_id => $acc_trans_id);
194
      $acc_trans->cleared('1');
195
      $acc_trans->save;
182
  # reconcile transaction safe
183
  SL::DB->client->with_transaction(sub {
184
    foreach my $bt_id ( @{ $::form->{bt_ids} }) {
185
      my $rec_group = SL::DB::Manager::ReconciliationLink->get_new_rec_group();
186
      my $bank_transaction = SL::DB::Manager::BankTransaction->find_by(id => $bt_id);
187
      $bank_transaction->cleared('1');
188
      $bank_transaction->save;
189
      foreach my $acc_trans_id (@{ $::form->{proposal_list}->{$bt_id}->{BB} }) {
190
        SL::DB::ReconciliationLink->new(
191
          rec_group => $rec_group,
192
          bank_transaction_id => $bt_id,
193
          acc_trans_id => $acc_trans_id
194
        )->save;
195
        my $acc_trans = SL::DB::Manager::AccTransaction->find_by(acc_trans_id => $acc_trans_id);
196
        $acc_trans->cleared('1');
197
        $acc_trans->save;
198
      }
199
      $counter++;
196 200
    }
197
    $counter++;
198
  }
201
  }) or die t8('Unable to reconcile, database transaction failure');
199 202

  
200 203
  flash('ok', t8('#1 proposal(s) saved.', $counter));
201 204

  
......
354 357
sub _reconcile {
355 358
  my ($self) = @_;
356 359

  
357
  # 1. step: set AccTrans and BankTransactions to 'cleared'
358
  foreach my $element (@{ $self->{ELEMENTS} }) {
359
    $element->cleared('1');
360
    # veto either invoice_amount is fully assigned or not! No state tricks in later workflow!
361
    # invoice_amount should be a distinct sign, that some bookings were really made from a bank transaction
362
    # $element->invoice_amount($element->amount) if $element->isa('SL::DB::BankTransaction');
363
    $element->save;
364
  }
360
  # reconcile transaction safe
361
  SL::DB->client->with_transaction(sub {
365 362

  
366
  # 2. step: insert entry in reconciliation_links
367
  my $rec_group = SL::DB::Manager::ReconciliationLink->get_new_rec_group();
368
  #There is either a 1:n relation or a n:1 relation
369
  if (scalar @{ $::form->{bt_ids} } == 1) {
370
    my $bt_id = @{ $::form->{bt_ids} }[0];
371
    foreach my $bb_id (@{ $::form->{bb_ids} }) {
372
      my $rec_link = SL::DB::ReconciliationLink->new(bank_transaction_id => $bt_id,
373
                                                     acc_trans_id        => $bb_id,
374
                                                     rec_group           => $rec_group);
375
      $rec_link->save;
363
    # 1. step: set AccTrans and BankTransactions to 'cleared'
364
    foreach my $element (@{ $self->{ELEMENTS} }) {
365
      $element->cleared('1');
366
      # veto either invoice_amount is fully assigned or not! No state tricks in later workflow!
367
      $element->save;
376 368
    }
377
  } else {
378
    my $bb_id = @{ $::form->{bb_ids} }[0];
379
    foreach my $bt_id (@{ $::form->{bt_ids} }) {
380
      my $rec_link = SL::DB::ReconciliationLink->new(bank_transaction_id => $bt_id,
381
                                                     acc_trans_id        => $bb_id,
382
                                                     rec_group           => $rec_group);
383
      $rec_link->save;
369
    # 2. step: insert entry in reconciliation_links
370
    my $rec_group = SL::DB::Manager::ReconciliationLink->get_new_rec_group();
371
    #There is either a 1:n relation or a n:1 relation
372
    if (scalar @{ $::form->{bt_ids} } == 1) {
373
      my $bt_id = @{ $::form->{bt_ids} }[0];
374
      foreach my $bb_id (@{ $::form->{bb_ids} }) {
375
        my $rec_link = SL::DB::ReconciliationLink->new(bank_transaction_id => $bt_id,
376
                                                       acc_trans_id        => $bb_id,
377
                                                       rec_group           => $rec_group);
378
        $rec_link->save;
379
      }
380
    } else {
381
      my $bb_id = @{ $::form->{bb_ids} }[0];
382
      foreach my $bt_id (@{ $::form->{bt_ids} }) {
383
        my $rec_link = SL::DB::ReconciliationLink->new(bank_transaction_id => $bt_id,
384
                                                       acc_trans_id        => $bb_id,
385
                                                       rec_group           => $rec_group);
386
        $rec_link->save;
387
      }
384 388
    }
385
  }
389
  }) or die t8('Unable to reconcile, database transaction failure');
386 390
}
387 391

  
388 392
sub _filter_to_where {

Auch abrufbar als: Unified diff