Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0d34b381

Von Kivitendo Admin vor etwa 8 Jahren hinzugefügt

  • ID 0d34b38184fdd6a6f1dd1bc7ce509c560e326b4e
  • Vorgänger 44703001
  • Nachfolger c4e13bb2

Payment Helper setzt $self->transactions zurück

Als es noch eine Methode transactions in SL::DB::Helper::Payment gab
wurden die acc_trans-Einträge bei Zugriff per $self->transactions jedes
Mal aus der Datenbank ausgelesen:
(SL::DB::Manager::AccTransaction->get_all(query => [ trans_id => $self->id ]);

Seit Commit 01b298ec3 wird stattdessen der aktuelle relationship Array
verwendet, wenn die transactions noch nicht ausgelesen wurden werden sie
wie oben geladen, wenn sie aber schon existieren dann werden die
Transaktionen im Speicher benutzt.

Bei den Tests gab es aber das Problem, daß in pay_invoice die
acc_trans-Einträge der Zahlungen als AccTrans-Objekte unabhängig vom
Rechnungsobjekt gespeichert wurden, und der transaction Array daher
nicht aktualisiert wurde. Am Ende von pay_invoice wird nun per
forget_related der transaction-Array zurückgesetzt, damit bei der
nächsten Verwendung die aktuell gespeicherten Transaktionen nachgeladen
werden.

Unterschiede anzeigen:

t/db_helper/payment.t
257 257
}
258 258

  
259 259
sub number_of_payments {
260
  my $transactions = shift;
260
  my $invoice = shift;
261 261

  
262 262
  my $number_of_payments;
263 263
  my $paid_amount;
264
  foreach my $transaction ( @$transactions ) {
264
  foreach my $transaction ( @{ $invoice->transactions } ) {
265 265
    if ( $transaction->chart_link =~ /(AR_paid|AP_paid)/ ) {
266 266
      $paid_amount += $transaction->amount ;
267 267
      $number_of_payments++;
......
271 271
};
272 272

  
273 273
sub total_amount {
274
  my $transactions = shift;
274
  my $invoice = shift;
275 275

  
276
  my $total = sum map { $_->amount } @$transactions;
276
  my $total = sum map { $_->amount } @{ $invoice->transactions };
277 277

  
278 278
  return $::form->round_amount($total, 5);
279 279

  
......
305 305

  
306 306
  $invoice->pay_invoice( %params );
307 307

  
308
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
309
  my $total = total_amount($invoice->transactions);
308
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
309
  my $total = total_amount($invoice);
310 310

  
311 311
  my $title = 'default invoice, one item, 19% tax, without_skonto';
312 312

  
......
345 345
  $params{amount} = '-10.00';
346 346
  $invoice->pay_invoice( %params );
347 347

  
348
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
349
  my $total = total_amount($invoice->transactions);
348
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
349
  my $total = total_amount($invoice);
350 350

  
351 351
  my $title = 'default invoice, one item, 19% tax, without_skonto';
352 352

  
......
383 383

  
384 384
  $invoice->pay_invoice( %params );
385 385

  
386
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
387
  my $total = total_amount($invoice->transactions);
386
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
387
  my $total = total_amount($invoice);
388 388

  
389 389
  my $title = 'default invoice, two items, 19/7% tax with_skonto_pt';
390 390

  
......
418 418

  
419 419
  $invoice->pay_invoice( %params );
420 420

  
421
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
422
  my $total = total_amount($invoice->transactions);
421
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
422
  my $total = total_amount($invoice);
423 423

  
424 424
  my $title = 'default invoice, two items, 19/7% tax with_skonto_pt';
425 425

  
......
456 456

  
457 457
  $invoice->pay_invoice( %params );
458 458

  
459
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
460
  my $total = total_amount($invoice->transactions);
459
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
460
  my $total = total_amount($invoice);
461 461

  
462 462
  my $title = 'default invoice, two items, 19/7% tax without skonto';
463 463

  
......
488 488
                         transdate    => DateTime->today_local->to_kivitendo,
489 489
                       );
490 490

  
491
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
492
  my $total = total_amount($invoice->transactions);
491
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
492
  my $total = total_amount($invoice);
493 493

  
494 494
  my $title = 'default invoice, two items, 19/7% tax without skonto incomplete payment';
495 495

  
......
524 524
                         transdate    => DateTime->today_local->to_kivitendo
525 525
                       );
526 526

  
527
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
528
  my $total = total_amount($invoice->transactions);
527
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
528
  my $total = total_amount($invoice);
529 529

  
530 530
  my $title = 'default invoice, two items, 19/7% tax not included';
531 531

  
......
567 567
                         transdate    => DateTime->today_local->to_kivitendo
568 568
                       );
569 569

  
570
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
571
  my $total = total_amount($invoice->transactions);
570
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
571
  my $total = total_amount($invoice);
572 572

  
573 573
  my $title = 'default invoice, two items, 19/7% tax not included';
574 574

  
......
609 609
                         transdate    => DateTime->today_local->to_kivitendo
610 610
                       );
611 611

  
612
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
613
  my $total = total_amount($invoice->transactions);
612
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
613
  my $total = total_amount($invoice);
614 614

  
615 615
  my $title = 'default invoice, two items, 19/7% tax not included';
616 616

  
......
647 647
                         transdate    => DateTime->today_local->to_kivitendo
648 648
                       );
649 649

  
650
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
651
  my $total = total_amount($invoice->transactions);
650
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
651
  my $total = total_amount($invoice);
652 652

  
653 653
  my $title = 'default invoice, two items, 19/7% tax not included';
654 654

  
......
689 689
  $params{payment_type} = 'difference_as_skonto';
690 690
  $invoice->pay_invoice( %params );
691 691

  
692
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
693
  my $total = total_amount($invoice->transactions);
692
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
693
  my $total = total_amount($invoice);
694 694

  
695 695
  my $title = 'default invoice, one item, 19% tax, without_skonto';
696 696

  
......
727 727
  $params{payment_type} = 'difference_as_skonto';
728 728
  $invoice->pay_invoice( %params );
729 729

  
730
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
731
  my $total = total_amount($invoice->transactions);
730
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
731
  my $total = total_amount($invoice);
732 732

  
733 733
  my $title = 'default invoice, one item, 19% tax, without_skonto';
734 734

  
......
756 756

  
757 757
  $purchase_invoice->pay_invoice( %params );
758 758

  
759
  my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice->transactions);
760
  my $total = total_amount($purchase_invoice->transactions);
759
  my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice);
760
  my $total = total_amount($purchase_invoice);
761 761

  
762 762
  my $title = 'default invoice, two items, 19/7% tax without skonto';
763 763

  
......
781 781

  
782 782
  $purchase_invoice->pay_invoice( %params );
783 783

  
784
  my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice->transactions);
785
  my $total = total_amount($purchase_invoice->transactions);
784
  my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice);
785
  my $total = total_amount($purchase_invoice);
786 786

  
787 787
  my $title = 'default invoice, two items, 19/7% tax without skonto';
788 788

  
......
802 802
                          chart_id     => $bank_account->chart_id,
803 803
                          transdate    => DateTime->today_local->to_kivitendo
804 804
                         );
805
  my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice->transactions);
806
  my $total = total_amount($purchase_invoice->transactions);
805
  my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice);
806
  my $total = total_amount($purchase_invoice);
807 807

  
808 808
  my $title = 'default purchase_invoice, two charts, 19/7% tax multiple payments with final difference as skonto';
809 809

  
......
837 837
                          transdate    => DateTime->today_local->to_kivitendo
838 838
                         );
839 839

  
840
  my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice->transactions);
841
  my $total = total_amount($purchase_invoice->transactions);
840
  my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice);
841
  my $total = total_amount($purchase_invoice);
842 842

  
843 843
  my $title = 'default purchase_invoice, two charts, 19/7% tax multiple payments with final difference as skonto';
844 844

  
......
871 871

  
872 872
  $invoice->pay_invoice( %params );
873 873

  
874
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
875
  my $total = total_amount($invoice->transactions);
874
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
875
  my $total = total_amount($invoice);
876 876

  
877 877
  my $title = 'default invoice, two items, 19/7% tax with_skonto_pt 50/50';
878 878

  
......
909 909

  
910 910
  $invoice->pay_invoice( %params );
911 911

  
912
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
913
  my $total = total_amount($invoice->transactions);
912
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
913
  my $total = total_amount($invoice);
914 914

  
915 915
  my $title = 'default invoice, four items, 19/7% tax with_skonto_pt 4x25';
916 916

  
......
946 946

  
947 947
  $invoice->pay_invoice( %params );
948 948

  
949
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
950
  my $total = total_amount($invoice->transactions);
949
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
950
  my $total = total_amount($invoice);
951 951

  
952 952
  my $title = 'default invoice, four items, 19/7% tax with_skonto_pt 4x25';
953 953

  
......
985 985
                         transdate    => DateTime->today_local->to_kivitendo
986 986
                       );
987 987

  
988
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice->transactions);
989
  my $total = total_amount($invoice->transactions);
988
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
989
  my $total = total_amount($invoice);
990 990

  
991 991
  my $title = 'default invoice, four items, 19/7% tax with_skonto_pt 4x25';
992 992

  

Auch abrufbar als: Unified diff