Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 07181f33

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

  • ID 07181f33712819fddc1dbb460f2fd4b86f441d56
  • Vorgänger c5dccb51
  • Nachfolger 665741c4

save_single_bank_transaction: acc_trans_ids von pay_invoice speichern

Unterschiede anzeigen:

SL/Controller/BankTransaction.pm
20 20
use SL::JSON;
21 21
use SL::DB::Chart;
22 22
use SL::DB::AccTransaction;
23
use SL::DB::BankTransactionAccTrans;
23 24
use SL::DB::Tax;
24 25
use SL::DB::BankAccount;
25 26
use SL::DB::RecordTemplate;
......
647 648
          $bank_transaction->invoice_amount($bank_transaction->invoice_amount - $open_amount);
648 649
        }
649 650
        # ... and then pay the invoice
650
        $invoice->pay_invoice(chart_id     => $bank_transaction->local_bank_account->chart_id,
651
        my @acc_ids = $invoice->pay_invoice(chart_id => $bank_transaction->local_bank_account->chart_id,
651 652
                              trans_id     => $invoice->id,
652 653
                              amount       => $open_amount,
653 654
                              payment_type => $payment_type,
654 655
                              source       => $source,
655 656
                              memo         => $memo,
656 657
                              transdate    => $bank_transaction->transdate->to_kivitendo);
658
        # ... and record the origin via BankTransactionAccTrans
659
        if (scalar(@acc_ids) != 2) {
660
          return {
661
            %data,
662
            result  => 'error',
663
            message => $::locale->text("Unable to book transactions for bank purpose #1", $bank_transaction->purpose),
664
          };
665
        }
666
        foreach my $acc_trans_id (@acc_ids) {
667
            my $id_type = $invoice->is_sales ? 'ar' : 'ap';
668
            my  %props_acc = (
669
              acc_trans_id        => $acc_trans_id,
670
              bank_transaction_id => $bank_transaction->id,
671
              $id_type            => $invoice->id,
672
            );
673
            SL::DB::BankTransactionAccTrans->new(%props_acc)->save;
674
        }
675

  
676

  
657 677
      } else {
658 678
      # use the whole amount of the bank transaction for the invoice, overpay the invoice if necessary
659 679

  

Auch abrufbar als: Unified diff