Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b49dd24d

Von Jan Büren vor mehr als 2 Jahren hinzugefügt

  • ID b49dd24d85c5a2e1683e32da92ea2160367c4cf3
  • Vorgänger e04af795
  • Nachfolger 72e90469

Testfälle für Payment umgestellt difference_as_skonto => free_skonto

Anwendungsfall difference_as_skonto ist nichts anderes als
free_skonto mit dem Skonto-Betrag entsprechend dem vollen
Rechnungsbetrag. Der Fall difference_as_skonto ist ansonsten toter Code
in der kivi und wurde nur von diesem Testfall noch am Leben erhalten

Unterschiede anzeigen:

t/db_helper/payment.t
53 53
test_default_invoice_one_item_19_without_skonto_overpaid();
54 54
test_credit_note_two_items_19_7_tax_tax_not_included();
55 55

  
56
# test cases: difference_as_skonto
57
test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto();
58
test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto_1cent();
59
test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto_2cent();
60
test_default_invoice_one_item_19_multiple_payment_final_difference_as_skonto();
61
test_default_invoice_one_item_19_multiple_payment_final_difference_as_skonto_1cent();
62
test_default_ap_transaction_two_charts_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto();
56
# test cases: free_skonto
57
test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_free_skonto();
58
test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_free_skonto_1cent();
59
test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_free_skonto_2cent();
60
test_default_invoice_one_item_19_multiple_payment_final_free_skonto();
61
test_default_invoice_one_item_19_multiple_payment_final_free_skonto_1cent();
62
test_default_ap_transaction_two_charts_19_7_tax_without_skonto_multiple_payments_final_free_skonto();
63 63

  
64 64
# test cases: with_skonto_pt
65 65
test_default_invoice_two_items_19_7_tax_with_skonto_50_50();
......
289 289
  my $paid_amount;
290 290
  foreach my $transaction ( @{ $invoice->transactions } ) {
291 291
    if ( $transaction->chart_link =~ /(AR_paid|AP_paid)/ ) {
292
      $paid_amount += $transaction->amount ;
292
      $paid_amount += $transaction->amount;
293 293
      $number_of_payments++;
294 294
    }
295 295
  };
......
553 553
}
554 554

  
555 555
# test 6
556
sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto {
556
sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_free_skonto {
557 557
  my $title = 'default invoice, two items, 19/7% tax not included';
558 558

  
559 559
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
......
575 575
                         chart_id     => $bank_account->chart_id,
576 576
                         transdate    => $transdate1,
577 577
                       );
578
  $invoice->pay_invoice( amount       => $invoice->open_amount,
579
                         payment_type => 'difference_as_skonto',
580
                         chart_id     => $bank_account->chart_id,
581
                         transdate    => $transdate1,
582
                         bt_id        => $bt->id,
578
  # free_skonto does:
579
  #  my $open_amount = $payment_type eq 'with_skonto_pt' ? $invoice->amount_less_skonto : $invoice->open_amount;
580
  #  $open_amount    = abs($open_amount);
581
  #  $open_amount   -= $free_skonto_amount if ($payment_type eq 'free_skonto');
582

  
583
  $invoice->pay_invoice( skonto_amount => $invoice->open_amount,
584
                         amount        => 0,
585
                         payment_type  => 'free_skonto',
586
                         chart_id      => $bank_account->chart_id,
587
                         transdate     => $transdate1,
588
                         bt_id         => $bt->id,
583 589
                       );
584 590

  
585 591
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
586 592
  my $total = total_amount($invoice);
587

  
588 593
  is($invoice->netamount,        5.85 + 11.66,     "${title}: netamount");
589 594
  is($invoice->amount,           6.96 + 12.48,     "${title}: amount");
590 595
  is($paid_amount,                     -19.44,     "${title}: paid amount");
......
594 599

  
595 600
}
596 601

  
597
sub  test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto_1cent {
602
sub  test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_free_skonto_1cent {
598 603
  my $title = 'default invoice, two items, 19/7% tax not included';
599 604

  
600 605
  # if there is only one cent left there can only be one skonto booking, the
601 606
  # error handling should choose the highest amount, which is the 7% account
602 607
  # (11.66) rather than the 19% account (5.85).  The actual tax amount is
603 608
  # higher for the 19% case, though (1.11 compared to 0.82)
609
  #
610
  # -> wrong: sub name. two cents are still left. one cent for each tax case. no tax correction
604 611

  
605 612
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
606 613
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
......
616 623
                         chart_id     => $bank_account->chart_id,
617 624
                         transdate    => $transdate1,
618 625
                       );
619
  $invoice->pay_invoice( amount       => $invoice->open_amount,
620
                         payment_type => 'difference_as_skonto',
626
  $invoice->pay_invoice( skonto_amount => $invoice->open_amount,
627
                         amount       => 0,
628
                         payment_type => 'free_skonto',
621 629
                         chart_id     => $bank_account->chart_id,
622 630
                         transdate    => $transdate1,
623 631
                         bt_id        => $bt->id,
624 632
                       );
625

  
626 633
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
627 634
  my $total = total_amount($invoice);
628 635

  
......
630 637
  is($invoice->amount,           6.96 + 12.48,     "${title}: amount");
631 638
  is($paid_amount,                     -19.44,     "${title}: paid amount");
632 639
  is($invoice->paid,                    19.44,     "${title}: paid");
633
  is($number_of_payments,                   3,     "${title}: 2 AR_paid bookings");
640
  is($number_of_payments,                   3,     "${title}: 3 AR_paid bookings");
634 641
  is($total,                                0,     "${title}: even balance");
635

  
636 642
}
637 643

  
638
sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto_2cent {
644
sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_free_skonto_2cent {
639 645
  my $title = 'default invoice, two items, 19/7% tax not included';
640 646

  
641 647
  # if there are two cents left there will be two skonto bookings, 1 cent each
......
653 659
                         chart_id     => $bank_account->chart_id,
654 660
                         transdate    => $transdate1,
655 661
                       );
656
  $invoice->pay_invoice( amount       => $invoice->open_amount,
657
                         payment_type => 'difference_as_skonto',
662
  $invoice->pay_invoice( skonto_amount => $invoice->open_amount,
663
                         amount       => 0,
664
                         payment_type => 'free_skonto',
658 665
                         chart_id     => $bank_account->chart_id,
659 666
                         transdate    => $transdate1,
660 667
                         bt_id        => $bt->id,
......
672 679

  
673 680
}
674 681

  
675
sub test_default_invoice_one_item_19_multiple_payment_final_difference_as_skonto {
682
sub test_default_invoice_one_item_19_multiple_payment_final_free_skonto {
676 683
  my $title = 'default invoice, one item, 19% tax, without_skonto';
677 684

  
678 685
  my $item    = create_invoice_item(part => $parts[0], qty => 2.5);
......
697 704
  $params{payment_type} = 'without_skonto';
698 705
  $invoice->pay_invoice( %params );
699 706

  
700
  $params{amount}       = $invoice->open_amount; # set amount, otherwise previous 3.81 is used
701
  $params{payment_type} = 'difference_as_skonto';
707
  $params{skonto_amount} = $invoice->open_amount; # set amount, otherwise previous 3.81 is used
708
  $params{amount}        = 0,
709
  $params{payment_type}  = 'free_skonto';
702 710
  $invoice->pay_invoice( %params );
703 711

  
704 712
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
......
713 721

  
714 722
}
715 723

  
716
sub test_default_invoice_one_item_19_multiple_payment_final_difference_as_skonto_1cent {
724
sub test_default_invoice_one_item_19_multiple_payment_final_free_skonto_1cent {
717 725
  my $title = 'default invoice, one item, 19% tax, without_skonto';
718 726

  
719 727
  my $item    = create_invoice_item(part => $parts[0], qty => 2.5);
......
734 742
  $params{payment_type} = 'without_skonto';
735 743
  $invoice->pay_invoice( %params );
736 744

  
737
  $params{amount}       = $invoice->open_amount; # set amount, otherwise previous value 6.95 is used
738
  $params{payment_type} = 'difference_as_skonto';
745
  $params{skonto_amount} = $invoice->open_amount;
746
  $params{amount}        = 0,
747
  $params{payment_type} = 'free_skonto';
739 748
  $invoice->pay_invoice( %params );
740 749

  
741 750
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
......
783 792
                 transdate => $transdate1,
784 793
                 bt_id     => $bt->id,
785 794
               );
786

  
787
  # $params{amount} = '226'; # pass full amount
795
  # BankTransaction-Controller __always__ calcs amount:
796
  # my $open_amount = $payment_type eq 'with_skonto_pt' ? $invoice->amount_less_skonto : $invoice->open_amount;
797
  $ap_transaction->payment_terms($ap_transaction->vendor->payment);
798
  $params{amount}       = $ap_transaction->amount_less_skonto; # pass calculated skonto amount
788 799
  $params{payment_type} = 'with_skonto_pt';
789 800

  
790
  $ap_transaction->payment_terms($ap_transaction->vendor->payment);
791 801
  $ap_transaction->pay_invoice( %params );
792 802

  
793 803
  my ($number_of_payments, $paid_amount) = number_of_payments($ap_transaction);
......
819 829
};
820 830

  
821 831

  
822
sub test_default_ap_transaction_two_charts_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto {
823
  my $title = 'default ap_transaction, two charts, 19/7% tax multiple payments with final difference as skonto';
832
sub test_default_ap_transaction_two_charts_19_7_tax_without_skonto_multiple_payments_final_free_skonto {
833
  my $title = 'default ap_transaction, two charts, 19/7% tax multiple payments with final free skonto';
824 834

  
825 835
  my $ap_transaction = new_ap_transaction();
826 836

  
......
838 848
                          transdate    => $transdate1,
839 849
                         );
840 850
  $ap_transaction->pay_invoice(
841
                          payment_type => 'difference_as_skonto',
851
                          payment_type => 'free_skonto',
852
                          skonto_amount => $ap_transaction->open_amount,
853
                          amount       => 0,
842 854
                          chart_id     => $bank_account->chart_id,
843 855
                          transdate    => $transdate1,
844 856
                          bt_id        => $bt->id,
......
848 860
  my $total = total_amount($ap_transaction);
849 861

  
850 862
  is($paid_amount,         226, "${title}: paid amount");
851
  is($number_of_payments,    4, "${title}: 1 AP_paid bookings");
863
  is($number_of_payments,    4, "${title}: 4 AP_paid bookings");
852 864
  is($total,                 0, "${title}: even balance");
853 865

  
854 866
}

Auch abrufbar als: Unified diff