Revision da35c4e7
Von G. Richardson vor mehr als 4 Jahren hinzugefügt
t/db_helper/payment.t | ||
---|---|---|
110 | 110 |
|
111 | 111 |
clear_up(); |
112 | 112 |
|
113 |
$transdate1 = DateTime->today; |
|
114 |
$transdate2 = DateTime->today->add(days => 1); |
|
115 |
$transdate3 = DateTime->today->add(days => 2); |
|
116 |
$transdate4 = DateTime->today->add(days => 3); |
|
113 |
$transdate1 = DateTime->today_local; |
|
114 |
$transdate1->set_year(2019) if $transdate1->year == 2020; # hardcode for 2019 in 2020, because of tax rate change in Germany |
|
115 |
$transdate2 = $transdate1->clone->add(days => 1); |
|
116 |
$transdate3 = $transdate1->clone->add(days => 2); |
|
117 |
$transdate4 = $transdate1->clone->add(days => 3); |
|
117 | 118 |
|
118 | 119 |
$buchungsgruppe = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 19%') || croak "No accounting group"; |
119 | 120 |
$buchungsgruppe7 = SL::DB::Manager::Buchungsgruppe->find_by(description => 'Standard 7%') || croak "No accounting group for 7\%"; |
... | ... | |
294 | 295 |
my $title = 'default invoice, one item, 19% tax, without_skonto'; |
295 | 296 |
my $item = create_invoice_item(part => $parts[0], qty => 2.5); |
296 | 297 |
my $invoice = create_sales_invoice( |
298 |
transdate => $transdate1, |
|
297 | 299 |
taxincluded => 0, |
298 | 300 |
invoiceitems => [ $item ], |
299 | 301 |
payment_id => $payment_terms->id, |
... | ... | |
303 | 305 |
|
304 | 306 |
# default values |
305 | 307 |
my %params = ( chart_id => $bank_account->chart_id, |
306 |
transdate => DateTime->today_local->to_kivitendo
|
|
308 |
transdate => $transdate1,
|
|
307 | 309 |
); |
308 | 310 |
|
309 | 311 |
$params{amount} = '6.96'; |
... | ... | |
329 | 331 |
my $item = create_invoice_item(part => $parts[0], qty => 2.5); |
330 | 332 |
my $invoice = create_sales_invoice( |
331 | 333 |
taxincluded => 0, |
334 |
transdate => $transdate1, |
|
332 | 335 |
invoiceitems => [ $item ], |
333 | 336 |
payment_id => $payment_terms->id, |
334 | 337 |
); |
... | ... | |
338 | 341 |
|
339 | 342 |
# default values |
340 | 343 |
my %params = ( chart_id => $bank_account->chart_id, |
341 |
transdate => DateTime->today_local->to_kivitendo
|
|
344 |
transdate => $transdate1,
|
|
342 | 345 |
); |
343 | 346 |
|
344 | 347 |
$params{amount} = '16.96'; |
... | ... | |
369 | 372 |
my $item2 = create_invoice_item(part => $parts[1], qty => 1.2); |
370 | 373 |
my $invoice = create_sales_invoice( |
371 | 374 |
taxincluded => 0, |
375 |
transdate => $transdate1, |
|
372 | 376 |
invoiceitems => [ $item1, $item2 ], |
373 | 377 |
payment_id => $payment_terms->id, |
374 | 378 |
); |
375 | 379 |
|
376 | 380 |
# default values |
377 | 381 |
my %params = ( chart_id => $bank_account->chart_id, |
378 |
transdate => DateTime->today_local->to_kivitendo
|
|
382 |
transdate => $transdate1,
|
|
379 | 383 |
); |
380 | 384 |
|
381 | 385 |
$params{payment_type} = 'with_skonto_pt'; |
... | ... | |
400 | 404 |
my $item1 = create_invoice_item(part => $parts[0], qty => 2.5); |
401 | 405 |
my $item2 = create_invoice_item(part => $parts[1], qty => 1.2); |
402 | 406 |
my $invoice = create_sales_invoice( |
407 |
transdate => $transdate1, |
|
403 | 408 |
taxincluded => 1, |
404 | 409 |
invoiceitems => [ $item1, $item2 ], |
405 | 410 |
payment_id => $payment_terms->id, |
... | ... | |
407 | 412 |
|
408 | 413 |
# default values |
409 | 414 |
my %params = ( chart_id => $bank_account->chart_id, |
410 |
transdate => DateTime->today_local->to_kivitendo
|
|
415 |
transdate => $transdate1,
|
|
411 | 416 |
); |
412 | 417 |
|
413 | 418 |
$params{payment_type} = 'with_skonto_pt'; |
... | ... | |
437 | 442 |
my $item1 = create_invoice_item(part => $parts[0], qty => 2.5); |
438 | 443 |
my $item2 = create_invoice_item(part => $parts[1], qty => 1.2); |
439 | 444 |
my $invoice = create_sales_invoice( |
445 |
transdate => $transdate1, |
|
440 | 446 |
taxincluded => 0, |
441 | 447 |
invoiceitems => [ $item1, $item2 ], |
442 | 448 |
payment_id => $payment_terms->id, |
... | ... | |
444 | 450 |
|
445 | 451 |
# default values |
446 | 452 |
my %params = ( chart_id => $bank_account->chart_id, |
447 |
transdate => DateTime->today_local->to_kivitendo
|
|
453 |
transdate => $transdate1,
|
|
448 | 454 |
); |
449 | 455 |
|
450 | 456 |
$params{amount} = '19.44'; # pass full amount |
... | ... | |
471 | 477 |
my $item2 = create_invoice_item(part => $parts[1], qty => 1.2); |
472 | 478 |
my $invoice = create_sales_invoice( |
473 | 479 |
taxincluded => 0, |
480 |
transdate => $transdate1, |
|
474 | 481 |
invoiceitems => [ $item1, $item2 ], |
475 | 482 |
payment_id => $payment_terms->id, |
476 | 483 |
); |
... | ... | |
478 | 485 |
$invoice->pay_invoice( amount => '9.44', |
479 | 486 |
payment_type => 'without_skonto', |
480 | 487 |
chart_id => $bank_account->chart_id, |
481 |
transdate => DateTime->today_local->to_kivitendo,
|
|
488 |
transdate => $transdate1,
|
|
482 | 489 |
); |
483 | 490 |
|
484 | 491 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice); |
... | ... | |
499 | 506 |
my $item1 = create_invoice_item(part => $parts[0], qty => 2.5); |
500 | 507 |
my $item2 = create_invoice_item(part => $parts[1], qty => 1.2); |
501 | 508 |
my $invoice = create_sales_invoice( |
509 |
transdate => $transdate1, |
|
502 | 510 |
taxincluded => 0, |
503 | 511 |
invoiceitems => [ $item1, $item2 ], |
504 | 512 |
payment_id => $payment_terms->id, |
... | ... | |
507 | 515 |
$invoice->pay_invoice( amount => '9.44', |
508 | 516 |
payment_type => 'without_skonto', |
509 | 517 |
chart_id => $bank_account->chart_id, |
510 |
transdate => DateTime->today_local->to_kivitendo
|
|
518 |
transdate => $transdate1,
|
|
511 | 519 |
); |
512 | 520 |
$invoice->pay_invoice( amount => '10.00', |
513 | 521 |
chart_id => $bank_account->chart_id, |
514 |
transdate => DateTime->today_local->to_kivitendo
|
|
522 |
transdate => $transdate1,
|
|
515 | 523 |
); |
516 | 524 |
|
517 | 525 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice); |
... | ... | |
534 | 542 |
my $item2 = create_invoice_item(part => $parts[1], qty => 1.2); |
535 | 543 |
my $invoice = create_sales_invoice( |
536 | 544 |
taxincluded => 0, |
545 |
transdate => $transdate1, |
|
537 | 546 |
invoiceitems => [ $item1, $item2 ], |
538 | 547 |
payment_id => $payment_terms->id, |
539 | 548 |
); |
... | ... | |
541 | 550 |
$invoice->pay_invoice( amount => '9.44', |
542 | 551 |
payment_type => 'without_skonto', |
543 | 552 |
chart_id => $bank_account->chart_id, |
544 |
transdate => DateTime->today_local->to_kivitendo
|
|
553 |
transdate => $transdate1,
|
|
545 | 554 |
); |
546 | 555 |
$invoice->pay_invoice( amount => '8.73', |
547 | 556 |
payment_type => 'without_skonto', |
548 | 557 |
chart_id => $bank_account->chart_id, |
549 |
transdate => DateTime->today_local->to_kivitendo
|
|
558 |
transdate => $transdate1,
|
|
550 | 559 |
); |
551 | 560 |
$invoice->pay_invoice( amount => $invoice->open_amount, |
552 | 561 |
payment_type => 'difference_as_skonto', |
553 | 562 |
chart_id => $bank_account->chart_id, |
554 |
transdate => DateTime->today_local->to_kivitendo
|
|
563 |
transdate => $transdate1,
|
|
555 | 564 |
); |
556 | 565 |
|
557 | 566 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice); |
... | ... | |
578 | 587 |
my $item2 = create_invoice_item(part => $parts[1], qty => 1.2); |
579 | 588 |
my $invoice = create_sales_invoice( |
580 | 589 |
taxincluded => 0, |
590 |
transdate => $transdate1, |
|
581 | 591 |
invoiceitems => [ $item1, $item2 ], |
582 | 592 |
payment_id => $payment_terms->id, |
583 | 593 |
); |
... | ... | |
585 | 595 |
$invoice->pay_invoice( amount => '19.42', |
586 | 596 |
payment_type => 'without_skonto', |
587 | 597 |
chart_id => $bank_account->chart_id, |
588 |
transdate => DateTime->today_local->to_kivitendo
|
|
598 |
transdate => $transdate1,
|
|
589 | 599 |
); |
590 | 600 |
$invoice->pay_invoice( amount => $invoice->open_amount, |
591 | 601 |
payment_type => 'difference_as_skonto', |
592 | 602 |
chart_id => $bank_account->chart_id, |
593 |
transdate => DateTime->today_local->to_kivitendo
|
|
603 |
transdate => $transdate1,
|
|
594 | 604 |
); |
595 | 605 |
|
596 | 606 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice); |
... | ... | |
613 | 623 |
my $item2 = create_invoice_item(part => $parts[1], qty => 1.2); |
614 | 624 |
my $invoice = create_sales_invoice( |
615 | 625 |
taxincluded => 0, |
626 |
transdate => $transdate1, |
|
616 | 627 |
invoiceitems => [ $item1, $item2 ], |
617 | 628 |
payment_id => $payment_terms->id, |
618 | 629 |
); |
... | ... | |
620 | 631 |
$invoice->pay_invoice( amount => '19.42', |
621 | 632 |
payment_type => 'without_skonto', |
622 | 633 |
chart_id => $bank_account->chart_id, |
623 |
transdate => DateTime->today_local->to_kivitendo
|
|
634 |
transdate => $transdate1,
|
|
624 | 635 |
); |
625 | 636 |
$invoice->pay_invoice( amount => $invoice->open_amount, |
626 | 637 |
payment_type => 'difference_as_skonto', |
627 | 638 |
chart_id => $bank_account->chart_id, |
628 |
transdate => DateTime->today_local->to_kivitendo
|
|
639 |
transdate => $transdate1,
|
|
629 | 640 |
); |
630 | 641 |
|
631 | 642 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice); |
... | ... | |
646 | 657 |
my $item = create_invoice_item(part => $parts[0], qty => 2.5); |
647 | 658 |
my $invoice = create_sales_invoice( |
648 | 659 |
taxincluded => 0, |
660 |
transdate => $transdate1, |
|
649 | 661 |
invoiceitems => [ $item ], |
650 | 662 |
payment_id => $payment_terms->id, |
651 | 663 |
); |
652 | 664 |
|
653 | 665 |
# default values |
654 | 666 |
my %params = ( chart_id => $bank_account->chart_id, |
655 |
transdate => DateTime->today_local->to_kivitendo
|
|
667 |
transdate => $transdate1,
|
|
656 | 668 |
); |
657 | 669 |
|
658 | 670 |
$params{amount} = '2.32'; |
... | ... | |
685 | 697 |
my $item = create_invoice_item(part => $parts[0], qty => 2.5); |
686 | 698 |
my $invoice = create_sales_invoice( |
687 | 699 |
taxincluded => 0, |
700 |
transdate => $transdate1, |
|
688 | 701 |
invoiceitems => [ $item ], |
689 | 702 |
payment_id => $payment_terms->id, |
690 | 703 |
); |
691 | 704 |
|
692 | 705 |
# default values |
693 | 706 |
my %params = ( chart_id => $bank_account->chart_id, |
694 |
transdate => DateTime->today_local->to_kivitendo
|
|
707 |
transdate => $transdate1,
|
|
695 | 708 |
); |
696 | 709 |
|
697 | 710 |
$params{amount} = '6.95'; |
... | ... | |
721 | 734 |
my $ap_transaction = new_ap_transaction(); |
722 | 735 |
|
723 | 736 |
my %params = ( chart_id => $bank_account->chart_id, |
724 |
transdate => DateTime->today_local->to_kivitendo
|
|
737 |
transdate => $transdate1,
|
|
725 | 738 |
); |
726 | 739 |
|
727 | 740 |
$params{amount} = '226'; # pass full amount |
... | ... | |
744 | 757 |
my $ap_transaction = new_ap_transaction(); |
745 | 758 |
|
746 | 759 |
my %params = ( chart_id => $bank_account->chart_id, |
747 |
transdate => DateTime->today_local->to_kivitendo
|
|
760 |
transdate => $transdate1,
|
|
748 | 761 |
); |
749 | 762 |
|
750 | 763 |
# $params{amount} = '226'; # pass full amount |
... | ... | |
770 | 783 |
amount => ( $ap_transaction->amount / 3 * 2), |
771 | 784 |
payment_type => 'without_skonto', |
772 | 785 |
chart_id => $bank_account->chart_id, |
773 |
transdate => DateTime->today_local->to_kivitendo
|
|
786 |
transdate => $transdate1,
|
|
774 | 787 |
); |
775 | 788 |
my ($number_of_payments, $paid_amount) = number_of_payments($ap_transaction); |
776 | 789 |
my $total = total_amount($ap_transaction); |
... | ... | |
791 | 804 |
amount => ( $ap_transaction->amount / 3 * 2), |
792 | 805 |
payment_type => 'without_skonto', |
793 | 806 |
chart_id => $bank_account->chart_id, |
794 |
transdate => DateTime->today_local->to_kivitendo
|
|
807 |
transdate => $transdate1,
|
|
795 | 808 |
); |
796 | 809 |
$ap_transaction->pay_invoice( |
797 | 810 |
amount => ( $ap_transaction->amount / 5 ), |
798 | 811 |
payment_type => 'without_skonto', |
799 | 812 |
chart_id => $bank_account->chart_id, |
800 |
transdate => DateTime->today_local->to_kivitendo
|
|
813 |
transdate => $transdate1,
|
|
801 | 814 |
); |
802 | 815 |
$ap_transaction->pay_invoice( |
803 | 816 |
payment_type => 'difference_as_skonto', |
804 | 817 |
chart_id => $bank_account->chart_id, |
805 |
transdate => DateTime->today_local->to_kivitendo
|
|
818 |
transdate => $transdate1,
|
|
806 | 819 |
); |
807 | 820 |
|
808 | 821 |
my ($number_of_payments, $paid_amount) = number_of_payments($ap_transaction); |
... | ... | |
822 | 835 |
my $item2 = create_invoice_item(part => $parts[3], qty => 1); |
823 | 836 |
my $invoice = create_sales_invoice( |
824 | 837 |
taxincluded => 0, |
838 |
transdate => $transdate1, |
|
825 | 839 |
invoiceitems => [ $item1, $item2 ], |
826 | 840 |
payment_id => $payment_terms->id, |
827 | 841 |
); |
828 | 842 |
|
829 | 843 |
# default values |
830 | 844 |
my %params = ( chart_id => $bank_account->chart_id, |
831 |
transdate => DateTime->today_local->to_kivitendo
|
|
845 |
transdate => $transdate1,
|
|
832 | 846 |
); |
833 | 847 |
|
834 | 848 |
$params{amount} = $invoice->amount_less_skonto; |
... | ... | |
857 | 871 |
my $item4 = create_invoice_item(part => $parts[3], qty => 0.5); |
858 | 872 |
my $invoice = create_sales_invoice( |
859 | 873 |
taxincluded => 0, |
874 |
transdate => $transdate1, |
|
860 | 875 |
invoiceitems => [ $item1, $item2, $item3, $item4 ], |
861 | 876 |
payment_id => $payment_terms->id, |
862 | 877 |
); |
863 | 878 |
|
864 | 879 |
# default values |
865 | 880 |
my %params = ( chart_id => $bank_account->chart_id, |
866 |
transdate => DateTime->today_local->to_kivitendo
|
|
881 |
transdate => $transdate1,
|
|
867 | 882 |
); |
868 | 883 |
|
869 | 884 |
$params{amount} = $invoice->amount_less_skonto; |
... | ... | |
891 | 906 |
my $item4 = create_invoice_item(part => $parts[3], qty => 0.5); |
892 | 907 |
my $invoice = create_sales_invoice( |
893 | 908 |
taxincluded => 1, |
909 |
transdate => $transdate1, |
|
894 | 910 |
invoiceitems => [ $item1, $item2, $item3, $item4 ], |
895 | 911 |
payment_id => $payment_terms->id, |
896 | 912 |
); |
897 | 913 |
|
898 | 914 |
# default values |
899 | 915 |
my %params = ( chart_id => $bank_account->chart_id, |
900 |
transdate => DateTime->today_local->to_kivitendo
|
|
916 |
transdate => $transdate1,
|
|
901 | 917 |
); |
902 | 918 |
|
903 | 919 |
$params{amount} = $invoice->amount_less_skonto; |
... | ... | |
928 | 944 |
my $item4 = create_invoice_item(part => $parts[3], qty => 0.5); |
929 | 945 |
my $invoice = create_sales_invoice( |
930 | 946 |
taxincluded => 0, |
947 |
transdate => $transdate1, |
|
931 | 948 |
invoiceitems => [ $item1, $item2, $item3, $item4 ], |
932 | 949 |
payment_id => $payment_terms->id, |
933 | 950 |
); |
... | ... | |
935 | 952 |
$invoice->pay_invoice( amount => '90', |
936 | 953 |
payment_type => 'without_skonto', |
937 | 954 |
chart_id => $bank_account->chart_id, |
938 |
transdate => DateTime->today_local->to_kivitendo
|
|
955 |
transdate => $transdate1,
|
|
939 | 956 |
); |
940 | 957 |
$invoice->pay_invoice( payment_type => 'difference_as_skonto', |
941 | 958 |
chart_id => $bank_account->chart_id, |
942 |
transdate => DateTime->today_local->to_kivitendo
|
|
959 |
transdate => $transdate1,
|
|
943 | 960 |
); |
944 | 961 |
|
945 | 962 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice); |
... | ... | |
1384 | 1401 |
my $item2 = create_invoice_item(part => $parts[1], qty => 3); |
1385 | 1402 |
my $invoice = create_credit_note( |
1386 | 1403 |
invnumber => 'cn1', |
1404 |
transdate => $transdate1, |
|
1387 | 1405 |
taxincluded => 0, |
1388 | 1406 |
invoiceitems => [ $item1, $item2 ], |
1389 | 1407 |
); |
1390 | 1408 |
|
1391 | 1409 |
# default values |
1392 | 1410 |
my %params = ( chart_id => $bank_account->chart_id, |
1393 |
transdate => DateTime->today_local->to_kivitendo,
|
|
1411 |
transdate => $transdate1,
|
|
1394 | 1412 |
); |
1395 | 1413 |
|
1396 | 1414 |
$params{amount} = $invoice->amount, |
Auch abrufbar als: Unified diff
payment.t - in 2020 das Jahr 2019 nehmen
und außerdem bei payments Datum immer als DateTime-Objekt übergeben.