Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2c2447e3

Von G. Richardson vor mehr als 6 Jahren hinzugefügt

  • ID 2c2447e3b398aa0a9888f9f8312960f1a001ec9b
  • Vorgänger 4b69fb00
  • Nachfolger 3b4876c5

Refactoring payment.t

reset_state in init_state umbenannt und params entfernt. Die Daten werden nur
einmal aufbereitet.

Überall title an Anfang der Funktion verschoben, bzw. neu angelegt.

ALWAYS_RESET entfernt. Es werden nun während des Tests nie Rechnungen gelöscht.
Immer alle Daten der Einzeltests zu löschen und alles neu zu initialisieren
würde den Test auch recht langsam, und war eh nicht sauber implementiert.

Unterschiede anzeigen:

t/db_helper/payment.t
1
use Test::More;
1
use strict;
2
use Test::More tests => 197;
2 3

  
3 4
use strict;
4 5

  
......
32 33
my ($transdate1, $transdate2, $transdate3, $transdate4, $currency, $exchangerate, $exchangerate2, $exchangerate3, $exchangerate4);
33 34
my ($ar_chart,$bank,$ar_amount_chart, $ap_chart, $ap_amount_chart, $fxloss_chart, $fxgain_chart);
34 35

  
35
my $ALWAYS_RESET = 1;
36

  
37
my $reset_state_counter = 0;
38

  
39 36
my $purchase_invoice_counter = 0; # used for generating purchase invnumber
40 37

  
41 38
Support::TestSetup::login();
42 39

  
40
init_state();
41

  
43 42
# test cases: without_skonto
44 43
test_default_invoice_one_item_19_without_skonto();
45 44
test_default_invoice_two_items_19_7_tax_with_skonto();
......
80 79
test_ap_currency_tax_not_included_and_payment_2();             # two exchangerates, with fx_gain_loss
81 80
test_ap_currency_tax_not_included_and_payment_2_credit_note(); # two exchangerates, with fx_gain_loss
82 81

  
83
{ local $TODO = "currently this test fails because the code writing the invoice is buggy, the calculation of skonto is correct";
84
  my ($acc_trans_sum)  = selectfirst_array_query($::form, $currency->db->dbh, 'SELECT SUM(amount) FROM acc_trans'); is($acc_trans_sum, '0.00000', "sum of all acc_trans is 0");
82
is(SL::DB::Manager::Invoice->get_all_count(), 21,  "number of invoices at end of tests ok");
83
TODO: {
84
  local $TODO = "currently this test fails because the code writing the invoice is buggy, the calculation of skonto is correct";
85
  my ($acc_trans_sum)  = selectfirst_array_query($::form, $currency->db->dbh, 'SELECT SUM(amount) FROM acc_trans');
86
  is($acc_trans_sum, '0.00000', "sum of all acc_trans at end of all tests is 0");
85 87
}
86 88

  
87 89
# remove all created data at end of test
88
# clear_up();
90
clear_up();
89 91

  
90 92
done_testing();
91 93

  
......
103 105
  SL::DB::Manager::Currency->delete_all(where => [ name => 'CUR' ]);
104 106
};
105 107

  
106
sub reset_state {
108
sub init_state {
107 109
  my %params = @_;
108 110

  
109
  return if $reset_state_counter;
110

  
111
  $params{$_} ||= {} for qw(buchungsgruppe unit customer part tax vendor);
112

  
113 111
  clear_up();
114 112

  
115 113
  $transdate1 = DateTime->today;
......
117 115
  $transdate3 = DateTime->today->add(days => 2);
118 116
  $transdate4 = DateTime->today->add(days => 3);
119 117

  
120
  $buchungsgruppe  = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 19%', %{ $params{buchungsgruppe} }) || croak "No accounting group";
121
  $buchungsgruppe7 = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 7%')                                || croak "No accounting group for 7\%";
122
  $unit            = SL::DB::Manager::Unit->find_by(name => 'kg', %{ $params{unit} })                                      || croak "No unit";
123
  $employee        = SL::DB::Manager::Employee->current                                                                    || croak "No employee";
124
  $tax             = SL::DB::Manager::Tax->find_by(taxkey => 3, rate => 0.19, %{ $params{tax} })                           || croak "No tax";
125
  $tax7            = SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.07)                                              || croak "No tax for 7\%";
126
  $taxzone         = SL::DB::Manager::TaxZone->find_by( description => 'Inland')                                           || croak "No taxzone";
127
  $tax_9           = SL::DB::Manager::Tax->find_by(taxkey => 9, rate => 0.19, %{ $params{tax} })                           || croak "No tax";
128
  # $tax7            = SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.07)                                              || croak "No tax for 7\%";
118
  $buchungsgruppe  = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 19%') || croak "No accounting group";
119
  $buchungsgruppe7 = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 7%')  || croak "No accounting group for 7\%";
120
  $unit            = SL::DB::Manager::Unit->find_by(name => 'kg')                            || croak "No unit";
121
  $employee        = SL::DB::Manager::Employee->current                                      || croak "No employee";
122
  $tax             = SL::DB::Manager::Tax->find_by(taxkey => 3, rate => 0.19)                || croak "No tax";
123
  $tax7            = SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.07)                || croak "No tax for 7\%";
124
  $taxzone         = SL::DB::Manager::TaxZone->find_by( description => 'Inland')             || croak "No taxzone";
125
  $tax_9           = SL::DB::Manager::Tax->find_by(taxkey => 9, rate => 0.19)                || croak "No tax";
126
  # $tax7            = SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.07)                || croak "No tax for 7\%";
129 127

  
130 128
  $currency_id     = $::instance_conf->get_currency_id;
131 129

  
......
238 236
  $bank            = SL::DB::Manager::Chart->find_by( accno => '1200' ); # Bank
239 237
  $ar_amount_chart = SL::DB::Manager::Chart->find_by( accno => '8400' ); # Erlöse
240 238
  $ap_amount_chart = SL::DB::Manager::Chart->find_by( accno => '3400' ); # Wareneingang 19%
241

  
242
  $reset_state_counter++;
243 239
}
244 240

  
245 241
sub new_purchase_invoice {
......
352 348

  
353 349
# test 1
354 350
sub test_default_invoice_one_item_19_without_skonto() {
355
  reset_state() if $ALWAYS_RESET;
356

  
351
  my $title = 'default invoice, one item, 19% tax, without_skonto';
357 352
  my $item    = create_invoice_item(part => $parts[0], qty => 2.5);
358 353
  my $invoice = create_sales_invoice(
359 354
    taxincluded  => 0,
......
376 371
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
377 372
  my $total = total_amount($invoice);
378 373

  
379
  my $title = 'default invoice, one item, 19% tax, without_skonto';
380

  
381 374
  is($invoice->netamount,   5.85,      "${title}: netamount");
382 375
  is($invoice->amount,      6.96,      "${title}: amount");
383 376
  is($paid_amount,         -6.96,      "${title}: paid amount");
......
388 381
}
389 382

  
390 383
sub test_default_invoice_one_item_19_without_skonto_overpaid() {
391
  reset_state() if $ALWAYS_RESET;
384
  my $title = 'default invoice, one item, 19% tax, without_skonto';
392 385

  
393 386
  my $item    = create_invoice_item(part => $parts[0], qty => 2.5);
394 387
  my $invoice = create_sales_invoice(
......
415 408
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
416 409
  my $total = total_amount($invoice);
417 410

  
418
  my $title = 'default invoice, one item, 19% tax, without_skonto';
419

  
420 411
  is($invoice->netamount,   5.85,      "${title}: netamount");
421 412
  is($invoice->amount,      6.96,      "${title}: amount");
422 413
  is($paid_amount,         -6.96,      "${title}: paid amount");
......
429 420

  
430 421
# test 2
431 422
sub test_default_invoice_two_items_19_7_tax_with_skonto() {
432
  reset_state() if $ALWAYS_RESET;
423
  my $title = 'default invoice, two items, 19/7% tax with_skonto_pt';
433 424

  
434 425
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
435 426
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
......
452 443
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
453 444
  my $total = total_amount($invoice);
454 445

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

  
457 446
  is($invoice->netamount,  5.85 + 11.66,   "${title}: netamount");
458 447
  is($invoice->amount,     6.96 + 12.48,   "${title}: amount");
459 448
  is($paid_amount,               -19.44,   "${title}: paid amount");
......
463 452
}
464 453

  
465 454
sub test_default_invoice_two_items_19_7_tax_with_skonto_tax_included() {
466
  reset_state() if $ALWAYS_RESET;
455
  my $title = 'default invoice, two items, 19/7% tax with_skonto_pt';
467 456

  
468 457
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
469 458
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
......
486 475
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
487 476
  my $total = total_amount($invoice);
488 477

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

  
491 478
  is($invoice->netamount,         15.82,   "${title}: netamount");
492 479
  is($invoice->amount,            17.51,   "${title}: amount");
493 480
  is($paid_amount,               -17.51,   "${title}: paid amount");
494 481
  is($invoice->paid,              17.51,   "${title}: paid");
495 482
  is($number_of_payments,             3,   "${title}: 3 AR_paid bookings");
496
  { local $TODO = "currently this test fails because the code writing the invoice is buggy, the calculation of skonto is correct";
483

  
484
TODO: {
485
  local $TODO = "currently this test fails because the code writing the invoice is buggy, the calculation of skonto is correct";
497 486
  is($total,                          0,   "${title}: even balance");
498 487
  }
499 488
}
500 489

  
501 490
# test 3 : two items, without skonto
502 491
sub test_default_invoice_two_items_19_7_without_skonto() {
503
  reset_state() if $ALWAYS_RESET;
492
  my $title = 'default invoice, two items, 19/7% tax without skonto';
504 493

  
505 494
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
506 495
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
......
523 512
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
524 513
  my $total = total_amount($invoice);
525 514

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

  
528 515
  is($invoice->netamount,     5.85 + 11.66,     "${title}: netamount");
529 516
  is($invoice->amount,        6.96 + 12.48,     "${title}: amount");
530 517
  is($paid_amount,                  -19.44,     "${title}: paid amount");
......
535 522

  
536 523
# test 4
537 524
sub test_default_invoice_two_items_19_7_without_skonto_incomplete_payment() {
538
  reset_state() if $ALWAYS_RESET;
525
  my $title = 'default invoice, two items, 19/7% tax without skonto incomplete payment';
539 526

  
540 527
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
541 528
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
......
554 541
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
555 542
  my $total = total_amount($invoice);
556 543

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

  
559 544
  is($invoice->netamount,        5.85 + 11.66,     "${title}: netamount");
560 545
  is($invoice->amount,           6.96 + 12.48,     "${title}: amount");
561 546
  is($paid_amount,              -9.44,             "${title}: paid amount");
......
566 551

  
567 552
# test 5
568 553
sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments() {
569
  reset_state() if $ALWAYS_RESET;
554
  my $title = 'default invoice, two items, 19/7% tax not included';
570 555

  
571 556
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
572 557
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
......
589 574
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
590 575
  my $total = total_amount($invoice);
591 576

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

  
594 577
  is($invoice->netamount,        5.85 + 11.66,     "${title}: netamount");
595 578
  is($invoice->amount,           6.96 + 12.48,     "${title}: amount");
596 579
  is($paid_amount,                     -19.44,     "${title}: paid amount");
......
602 585

  
603 586
# test 6
604 587
sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto() {
605
  reset_state() if $ALWAYS_RESET;
588
  my $title = 'default invoice, two items, 19/7% tax not included';
606 589

  
607 590
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
608 591
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
......
631 614
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
632 615
  my $total = total_amount($invoice);
633 616

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

  
636 617
  is($invoice->netamount,        5.85 + 11.66,     "${title}: netamount");
637 618
  is($invoice->amount,           6.96 + 12.48,     "${title}: amount");
638 619
  is($paid_amount,                     -19.44,     "${title}: paid amount");
......
643 624
}
644 625

  
645 626
sub  test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto_1cent() {
646
  reset_state() if $ALWAYS_RESET;
627
  my $title = 'default invoice, two items, 19/7% tax not included';
647 628

  
648 629
  # if there is only one cent left there can only be one skonto booking, the
649 630
  # error handling should choose the highest amount, which is the 7% account
......
672 653
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
673 654
  my $total = total_amount($invoice);
674 655

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

  
677 656
  is($invoice->netamount,        5.85 + 11.66,     "${title}: netamount");
678 657
  is($invoice->amount,           6.96 + 12.48,     "${title}: amount");
679 658
  is($paid_amount,                     -19.44,     "${title}: paid amount");
......
684 663
}
685 664

  
686 665
sub test_default_invoice_two_items_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto_2cent() {
687
  reset_state() if $ALWAYS_RESET;
666
  my $title = 'default invoice, two items, 19/7% tax not included';
688 667

  
689 668
  # if there are two cents left there will be two skonto bookings, 1 cent each
690 669
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
......
709 688
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
710 689
  my $total = total_amount($invoice);
711 690

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

  
714 691
  is($invoice->netamount,        5.85 + 11.66,     "${title}: netamount");
715 692
  is($invoice->amount,           6.96 + 12.48,     "${title}: amount");
716 693
  is($paid_amount,                     -19.44,     "${title}: paid amount");
......
721 698
}
722 699

  
723 700
sub test_default_invoice_one_item_19_multiple_payment_final_difference_as_skonto() {
724
  reset_state() if $ALWAYS_RESET;
701
  my $title = 'default invoice, one item, 19% tax, without_skonto';
725 702

  
726 703
  my $item    = create_invoice_item(part => $parts[0], qty => 2.5);
727 704
  my $invoice = create_sales_invoice(
......
750 727
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
751 728
  my $total = total_amount($invoice);
752 729

  
753
  my $title = 'default invoice, one item, 19% tax, without_skonto';
754

  
755 730
  is($invoice->netamount,       5.85,     "${title}: netamount");
756 731
  is($invoice->amount,          6.96,     "${title}: amount");
757 732
  is($paid_amount,             -6.96,     "${title}: paid amount");
......
762 737
}
763 738

  
764 739
sub test_default_invoice_one_item_19_multiple_payment_final_difference_as_skonto_1cent() {
765
  reset_state() if $ALWAYS_RESET;
740
  my $title = 'default invoice, one item, 19% tax, without_skonto';
766 741

  
767 742
  my $item    = create_invoice_item(part => $parts[0], qty => 2.5);
768 743
  my $invoice = create_sales_invoice(
......
787 762
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
788 763
  my $total = total_amount($invoice);
789 764

  
790
  my $title = 'default invoice, one item, 19% tax, without_skonto';
791

  
792 765
  is($invoice->netamount,       5.85,     "${title}: netamount");
793 766
  is($invoice->amount,          6.96,     "${title}: amount");
794 767
  is($paid_amount,             -6.96,     "${title}: paid amount");
......
800 773

  
801 774
# test 3 : two items, without skonto
802 775
sub test_default_purchase_invoice_two_charts_19_7_without_skonto() {
803
  reset_state() if $ALWAYS_RESET;
776
  my $title = 'default invoice, two items, 19/7% tax without skonto';
804 777

  
805 778
  my $purchase_invoice = new_purchase_invoice();
806 779

  
......
816 789
  my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice);
817 790
  my $total = total_amount($purchase_invoice);
818 791

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

  
821 792
  is($paid_amount,         226,     "${title}: paid amount");
822 793
  is($number_of_payments,    1,     "${title}: 1 AP_paid bookings");
823 794
  is($total,                 0,     "${title}: even balance");
......
825 796
}
826 797

  
827 798
sub test_default_purchase_invoice_two_charts_19_7_with_skonto() {
828
  reset_state() if $ALWAYS_RESET;
799
  my $title = 'default invoice, two items, 19/7% tax without skonto';
829 800

  
830 801
  my $purchase_invoice = new_purchase_invoice();
831 802

  
......
841 812
  my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice);
842 813
  my $total = total_amount($purchase_invoice);
843 814

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

  
846 815
  is($paid_amount,         226,     "${title}: paid amount");
847 816
  is($number_of_payments,    3,     "${title}: 1 AP_paid bookings");
848 817
  is($total,                 0,     "${title}: even balance");
......
850 819
}
851 820

  
852 821
sub test_default_purchase_invoice_two_charts_19_7_tax_partial_unrounded_payment_without_skonto() {
822
  my $title = 'default purchase_invoice, two charts, 19/7% tax multiple payments with final difference as skonto';
823

  
853 824
  # check whether unrounded amounts passed via $params{amount} are rounded for without_skonto case
854
  reset_state() if $ALWAYS_RESET;
855 825
  my $purchase_invoice = new_purchase_invoice();
856 826
  $purchase_invoice->pay_invoice(
857 827
                          amount       => ( $purchase_invoice->amount / 3 * 2),
......
862 832
  my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice);
863 833
  my $total = total_amount($purchase_invoice);
864 834

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

  
867 835
  is($paid_amount,         150.67,   "${title}: paid amount");
868 836
  is($number_of_payments,       1,   "${title}: 1 AP_paid bookings");
869 837
  is($total,                    0,   "${title}: even balance");
......
871 839

  
872 840

  
873 841
sub test_default_purchase_invoice_two_charts_19_7_tax_without_skonto_multiple_payments_final_difference_as_skonto() {
874
  reset_state() if $ALWAYS_RESET;
842
  my $title = 'default purchase_invoice, two charts, 19/7% tax multiple payments with final difference as skonto';
875 843

  
876 844
  my $purchase_invoice = new_purchase_invoice();
877 845

  
......
897 865
  my ($number_of_payments, $paid_amount) = number_of_payments($purchase_invoice);
898 866
  my $total = total_amount($purchase_invoice);
899 867

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

  
902 868
  is($paid_amount,         226, "${title}: paid amount");
903 869
  is($number_of_payments,    4, "${title}: 1 AP_paid bookings");
904 870
  is($total,                 0, "${title}: even balance");
......
907 873

  
908 874
# test
909 875
sub test_default_invoice_two_items_19_7_tax_with_skonto_50_50() {
910
  reset_state() if $ALWAYS_RESET;
876
  my $title = 'default invoice, two items, 19/7% tax with_skonto_pt 50/50';
911 877

  
912 878
  my $item1   = create_invoice_item(part => $parts[2], qty => 1);
913 879
  my $item2   = create_invoice_item(part => $parts[3], qty => 1);
......
930 896
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
931 897
  my $total = total_amount($invoice);
932 898

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

  
935 899
  is($invoice->netamount,        100,     "${title}: netamount");
936 900
  is($invoice->amount,           113,     "${title}: amount");
937 901
  is($paid_amount,              -113,     "${title}: paid amount");
......
942 906

  
943 907
# test
944 908
sub test_default_invoice_four_items_19_7_tax_with_skonto_4x_25() {
945
  reset_state() if $ALWAYS_RESET;
909
  my $title = 'default invoice, four items, 19/7% tax with_skonto_pt 4x25';
946 910

  
947 911
  my $item1   = create_invoice_item(part => $parts[2], qty => 0.5);
948 912
  my $item2   = create_invoice_item(part => $parts[3], qty => 0.5);
......
967 931
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
968 932
  my $total = total_amount($invoice);
969 933

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

  
972 934
  is($invoice->netamount , 100  , "${title}: netamount");
973 935
  is($invoice->amount    , 113  , "${title}: amount");
974 936
  is($paid_amount        , -113 , "${title}: paid amount");
......
978 940
}
979 941

  
980 942
sub test_default_invoice_four_items_19_7_tax_with_skonto_4x_25_tax_included() {
981
  reset_state() if $ALWAYS_RESET;
943
  my $title = 'default invoice, four items, 19/7% tax with_skonto_pt 4x25';
982 944

  
983 945
  my $item1   = create_invoice_item(part => $parts[2], qty => 0.5);
984 946
  my $item2   = create_invoice_item(part => $parts[3], qty => 0.5);
......
1003 965
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
1004 966
  my $total = total_amount($invoice);
1005 967

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

  
1008 968
  is($invoice->netamount,   88.75,    "${title}: netamount");
1009 969
  is($invoice->amount,        100,    "${title}: amount");
1010 970
  is($paid_amount,           -100,    "${title}: paid amount");
1011 971
  is($invoice->paid,          100,    "${title}: paid");
1012 972
  is($number_of_payments,       3,    "${title}: 3 AR_paid bookings");
1013
  { local $TODO = "currently this test fails because the code writing the invoice is buggy, the calculation of skonto is correct";
973
TODO: {
974
  local $TODO = "currently this test fails because the code writing the invoice is buggy, the calculation of skonto is correct";
1014 975
  is($total,                    0,    "${title}: even balance");
1015 976
  }
1016 977
}
1017 978

  
1018 979
sub test_default_invoice_four_items_19_7_tax_with_skonto_4x_25_multiple() {
1019
  reset_state() if $ALWAYS_RESET;
980
  my $title = 'default invoice, four items, 19/7% tax with_skonto_pt 4x25';
1020 981

  
1021 982
  my $item1   = create_invoice_item(part => $parts[2], qty => 0.5);
1022 983
  my $item2   = create_invoice_item(part => $parts[3], qty => 0.5);
......
1041 1002
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
1042 1003
  my $total = total_amount($invoice);
1043 1004

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

  
1046 1005
  is($invoice->netamount,  100,     "${title}: netamount");
1047 1006
  is($invoice->amount,     113,     "${title}: amount");
1048 1007
  is($paid_amount,        -113,     "${title}: paid amount");
......
1052 1011
}
1053 1012

  
1054 1013
sub test_ar_currency_tax_not_included_and_payment {
1014
  my $title = 'test_ar_currency_tax_not_included_and_payment_2';
1015

  
1055 1016
  my $netamount = $::form->round_amount(75 * $exchangerate->sell,2); #  75 in CUR, 100.00 in EUR
1056 1017
  my $amount    = $::form->round_amount($netamount * 1.19,2);        # 100 in CUR, 119.00 in EUR
1057 1018
  my $invoice   = SL::DB::Invoice->new(
......
1102 1063
};
1103 1064

  
1104 1065
sub test_ar_currency_tax_included {
1066
  my $title = 'test_ar_currency_tax_included';
1067

  
1105 1068
  # we want the acc_trans amount to be 100
1106 1069
  my $amount    = $::form->round_amount(75 * $exchangerate->sell * 1.19);
1107 1070
  my $netamount = $::form->round_amount($amount / 1.19,2);
......
1141 1104
};
1142 1105

  
1143 1106
sub test_ap_currency_tax_not_included_and_payment {
1107
  my $title = 'test_ap_currency_tax_not_included_and_payment';
1108

  
1144 1109
  my $netamount = $::form->round_amount(75 * $exchangerate->buy,2); #  75 in CUR, 100.00 in EUR
1145 1110
  my $amount    = $::form->round_amount($netamount * 1.19,2);        # 100 in CUR, 119.00 in EUR
1146 1111
  my $invoice   = SL::DB::PurchaseInvoice->new(
......
1187 1152
};
1188 1153

  
1189 1154
sub test_ap_currency_tax_included {
1155
  my $title = 'test_ap_currency_tax_included';
1156

  
1190 1157
  # we want the acc_trans amount to be 100
1191 1158
  my $amount    = $::form->round_amount(75 * $exchangerate->buy * 1.19);
1192 1159
  my $netamount = $::form->round_amount($amount / 1.19,2);
......
1228 1195

  
1229 1196
sub test_ar_currency_tax_not_included_and_payment_2 {
1230 1197
  my $title = 'test_ar_currency_tax_not_included_and_payment_2';
1198

  
1231 1199
  my $netamount = $::form->round_amount(125 * $exchangerate2->sell,2); # 125.00 in CUR, 100.00 in EUR
1232 1200
  my $amount    = $::form->round_amount($netamount * 1.19,2);          # 148.75 in CUR, 119.00 in EUR
1233 1201
  my $invoice   = SL::DB::Invoice->new(
......
1287 1255
};
1288 1256

  
1289 1257
sub test_ar_currency_tax_not_included_and_payment_2_credit_note {
1258
  my $title = 'test_ar_currency_tax_not_included_and_payment_2_credit_note';
1259

  
1290 1260
  my $netamount = $::form->round_amount(-125 * $exchangerate2->sell,2); # 125.00 in CUR, 100.00 in EUR
1291 1261
  my $amount    = $::form->round_amount($netamount * 1.19,2);          # 148.75 in CUR, 119.00 in EUR
1292 1262
  my $invoice   = SL::DB::Invoice->new(
......
1338 1308

  
1339 1309
sub test_ap_currency_tax_not_included_and_payment_2 {
1340 1310
  my $title = 'test_ap_currency_tax_not_included_and_payment_2';
1311

  
1341 1312
  my $netamount = $::form->round_amount(125 * $exchangerate2->sell,2); # 125.00 in CUR, 100.00 in EUR
1342 1313
  my $amount    = $::form->round_amount($netamount * 1.19,2);          # 148.75 in CUR, 119.00 in EUR
1343 1314
  my $invoice   = SL::DB::PurchaseInvoice->new(
......
1402 1373

  
1403 1374
sub test_ap_currency_tax_not_included_and_payment_2_credit_note {
1404 1375
  my $title = 'test_ap_currency_tax_not_included_and_payment_2_credit_note';
1376

  
1405 1377
  my $netamount = $::form->round_amount(-125 * $exchangerate2->sell,2); # 125.00 in CUR, 100.00 in EUR
1406 1378
  my $amount    = $::form->round_amount($netamount * 1.19,2);          # 148.75 in CUR, 119.00 in EUR
1407 1379
  my $invoice   = SL::DB::PurchaseInvoice->new(
......
1462 1434
  is(total_amount($invoice), 0,   "$title: even balance");
1463 1435
};
1464 1436

  
1465
sub test_credit_note_two_items_19_7_tax_tax_not_included() {
1466
  reset_state() if $ALWAYS_RESET;
1437
sub test_credit_note_two_items_19_7_tax_tax_not_included {
1438
  my $title = 'test_credit_note_two_items_19_7_tax_tax_not_included';
1467 1439

  
1468 1440
  my $item1   = create_invoice_item(part => $parts[0], qty => 5);
1469 1441
  my $item2   = create_invoice_item(part => $parts[1], qty => 3);
......
1485 1457
  my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
1486 1458
  my $total = total_amount($invoice);
1487 1459

  
1488
  my $title = 'credit_note, two items, 19/7%, tax not included';
1489

  
1490 1460
  is($invoice->netamount,        -40.84,   "${title}: netamount");
1491 1461
  is($invoice->amount,           -45.10,   "${title}: amount");
1492 1462
  is($paid_amount,                45.10,   "${title}: paid amount according to acc_trans is positive (Haben)");

Auch abrufbar als: Unified diff