317 |
317 |
payment_id => $payment_terms->id,
|
318 |
318 |
);
|
319 |
319 |
|
320 |
|
my $ap_transaction = new_ap_transaction();
|
321 |
|
|
322 |
320 |
# default values
|
323 |
321 |
my %params = ( chart_id => $bank_account->chart_id,
|
324 |
322 |
transdate => $transdate1,
|
... | ... | |
327 |
325 |
$params{amount} = '6.96';
|
328 |
326 |
$params{payment_type} = 'without_skonto';
|
329 |
327 |
|
330 |
|
$invoice->pay_invoice( %params );
|
331 |
|
|
|
328 |
my @ret = $invoice->pay_invoice( %params );
|
|
329 |
my $bank_amount = shift @ret;
|
332 |
330 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
333 |
331 |
my $total = total_amount($invoice);
|
334 |
|
|
|
332 |
my $exp_invoice_amount = $invoice->amount > 0 ? $params{amount} : $params{amount} * -1;
|
335 |
333 |
is($invoice->netamount, 5.85, "${title}: netamount");
|
336 |
334 |
is($invoice->amount, 6.96, "${title}: amount");
|
337 |
335 |
is($paid_amount, -6.96, "${title}: paid amount");
|
338 |
336 |
is($number_of_payments, 1, "${title}: 1 AR_paid booking");
|
339 |
337 |
is($invoice->paid, 6.96, "${title}: paid");
|
340 |
338 |
is($total, 0, "${title}: even balance");
|
341 |
|
|
|
339 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
340 |
is($bank_amount->{return_bank_amount} > 0, 1, "${title}: bank invoice_amount is positive");
|
|
341 |
is($invoice->paid, $bank_amount->{return_bank_amount}, "${title}: paid eq invoice_amount");
|
342 |
342 |
}
|
343 |
343 |
|
344 |
344 |
sub test_default_invoice_one_item_19_without_skonto_overpaid {
|
... | ... | |
362 |
362 |
|
363 |
363 |
$params{amount} = '16.96';
|
364 |
364 |
$params{payment_type} = 'without_skonto';
|
365 |
|
$invoice->pay_invoice( %params );
|
|
365 |
my @ret = $invoice->pay_invoice( %params );
|
|
366 |
my $bank_amount = shift @ret;
|
|
367 |
|
|
368 |
my $exp_invoice_amount = $invoice->amount > 0 ? $params{amount} : $params{amount} * -1;
|
|
369 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
370 |
is($exp_invoice_amount > 0, 1, "${title}: bank invoice_amount is positive");
|
|
371 |
my $bt_invoice_amount = $exp_invoice_amount;
|
|
372 |
|
|
373 |
$params{amount} = -10.00;
|
|
374 |
@ret = $invoice->pay_invoice( %params );
|
|
375 |
|
|
376 |
$bank_amount = shift @ret;
|
|
377 |
$exp_invoice_amount = $invoice->amount > 0 ? $params{amount} : $params{amount} * -1;
|
|
378 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
379 |
is($exp_invoice_amount < 0, 1, "${title}: bank invoice_amount is negative");
|
|
380 |
$bt_invoice_amount += $exp_invoice_amount;
|
366 |
381 |
|
367 |
|
$params{amount} = '-10.00';
|
368 |
|
$invoice->pay_invoice( %params );
|
369 |
382 |
|
370 |
383 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
371 |
384 |
my $total = total_amount($invoice);
|
... | ... | |
376 |
389 |
is($number_of_payments, 2, "${title}: 1 AR_paid booking");
|
377 |
390 |
is($invoice->paid, 6.96, "${title}: paid");
|
378 |
391 |
is($total, 0, "${title}: even balance");
|
|
392 |
is($invoice->paid, $bt_invoice_amount, "${title}: invoice paid equals bt invoice_amount");
|
379 |
393 |
|
380 |
394 |
}
|
381 |
395 |
|
... | ... | |
402 |
416 |
$params{payment_type} = 'with_skonto_pt';
|
403 |
417 |
$params{amount} = $invoice->amount_less_skonto;
|
404 |
418 |
|
405 |
|
$invoice->pay_invoice( %params );
|
|
419 |
my @ret = $invoice->pay_invoice( %params );
|
|
420 |
my $bank_amount = shift @ret;
|
|
421 |
my $exp_invoice_amount = $invoice->amount > 0 ? $params{amount} : $params{amount} * -1;
|
|
422 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
406 |
423 |
|
407 |
424 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
408 |
425 |
my $total = total_amount($invoice);
|
... | ... | |
436 |
453 |
$params{payment_type} = 'with_skonto_pt';
|
437 |
454 |
$params{amount} = $invoice->amount_less_skonto;
|
438 |
455 |
|
439 |
|
$invoice->pay_invoice( %params );
|
|
456 |
my @ret = $invoice->pay_invoice( %params );
|
|
457 |
my $bank_amount = shift @ret;
|
|
458 |
my $exp_invoice_amount = $invoice->amount > 0 ? $params{amount} : $params{amount} * -1;
|
|
459 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
460 |
is($bank_amount->{return_bank_amount} > 0, 1, "${title}: bank invoice_amount is positive");
|
440 |
461 |
|
441 |
462 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
442 |
463 |
my $total = total_amount($invoice);
|
... | ... | |
446 |
467 |
is($paid_amount, -17.51, "${title}: paid amount");
|
447 |
468 |
is($invoice->paid, 17.51, "${title}: paid");
|
448 |
469 |
is($number_of_payments, 3, "${title}: 3 AR_paid bookings");
|
|
470 |
is($invoice->paid != $bank_amount->{return_bank_amount}, 1, "${title}: paid does not equal bank invoice_amount");
|
449 |
471 |
|
450 |
472 |
TODO: {
|
451 |
473 |
local $TODO = "currently this test fails because the code writing the invoice is buggy, the calculation of skonto is correct";
|
... | ... | |
474 |
496 |
$params{amount} = '19.44'; # pass full amount
|
475 |
497 |
$params{payment_type} = 'without_skonto';
|
476 |
498 |
|
477 |
|
$invoice->pay_invoice( %params );
|
|
499 |
my @ret = $invoice->pay_invoice( %params );
|
|
500 |
my $bank_amount = shift @ret;
|
|
501 |
my $exp_invoice_amount = $invoice->amount > 0 ? $params{amount} : $params{amount} * -1;
|
|
502 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
503 |
is($bank_amount->{return_bank_amount} > 0, 1, "${title}: bank invoice_amount is positive");
|
478 |
504 |
|
479 |
505 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
480 |
506 |
my $total = total_amount($invoice);
|
... | ... | |
485 |
511 |
is($invoice->paid, 19.44, "${title}: paid");
|
486 |
512 |
is($number_of_payments, 1, "${title}: 1 AR_paid bookings");
|
487 |
513 |
is($total, 0, "${title}: even balance");
|
|
514 |
is($invoice->paid, $bank_amount->{return_bank_amount}, "${title}: paid equals bt.invoice_amount");
|
488 |
515 |
}
|
489 |
516 |
|
490 |
517 |
# test 4
|
... | ... | |
500 |
527 |
payment_id => $payment_terms->id,
|
501 |
528 |
);
|
502 |
529 |
|
503 |
|
$invoice->pay_invoice( amount => '9.44',
|
504 |
|
payment_type => 'without_skonto',
|
505 |
|
chart_id => $bank_account->chart_id,
|
506 |
|
transdate => $transdate1,
|
507 |
|
);
|
|
530 |
my @ret = $invoice->pay_invoice( amount => '9.44',
|
|
531 |
payment_type => 'without_skonto',
|
|
532 |
chart_id => $bank_account->chart_id,
|
|
533 |
transdate => $transdate1,
|
|
534 |
);
|
|
535 |
my $bank_amount = shift @ret;
|
|
536 |
my $exp_invoice_amount = $invoice->amount > 0 ? 9.44 : 9.44 * -1;
|
|
537 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
538 |
is($bank_amount->{return_bank_amount} > 0, 1, "${title}: bank invoice_amount is positive");
|
508 |
539 |
|
509 |
540 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
510 |
541 |
my $total = total_amount($invoice);
|
... | ... | |
515 |
546 |
is($invoice->paid, 9.44, "${title}: paid");
|
516 |
547 |
is($number_of_payments, 1, "${title}: 1 AR_paid bookings");
|
517 |
548 |
is($total, 0, "${title}: even balance");
|
|
549 |
is($invoice->paid, $bank_amount->{return_bank_amount}, "${title}: paid equals bt.invoice_amount");
|
518 |
550 |
}
|
519 |
551 |
|
520 |
552 |
# test 5
|
... | ... | |
529 |
561 |
invoiceitems => [ $item1, $item2 ],
|
530 |
562 |
payment_id => $payment_terms->id,
|
531 |
563 |
);
|
532 |
|
|
533 |
|
$invoice->pay_invoice( amount => '9.44',
|
534 |
|
payment_type => 'without_skonto',
|
535 |
|
chart_id => $bank_account->chart_id,
|
536 |
|
transdate => $transdate1,
|
|
564 |
my @ret;
|
|
565 |
@ret = $invoice->pay_invoice( amount => '9.44',
|
|
566 |
payment_type => 'without_skonto',
|
|
567 |
chart_id => $bank_account->chart_id,
|
|
568 |
transdate => $transdate1,
|
537 |
569 |
);
|
538 |
|
$invoice->pay_invoice( amount => '10.00',
|
539 |
|
chart_id => $bank_account->chart_id,
|
540 |
|
transdate => $transdate1,
|
|
570 |
|
|
571 |
my $bank_amount = shift @ret;
|
|
572 |
my $exp_invoice_amount = $invoice->amount > 0 ? 9.44 : 9.44 * -1;
|
|
573 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
574 |
is($bank_amount->{return_bank_amount} > 0, 1, "${title}: bank invoice_amount is positive");
|
|
575 |
my $bank_invoice_amount = $bank_amount->{return_bank_amount};
|
|
576 |
|
|
577 |
@ret = $invoice->pay_invoice( amount => '10.00',
|
|
578 |
chart_id => $bank_account->chart_id,
|
|
579 |
transdate => $transdate1,
|
541 |
580 |
);
|
|
581 |
$bank_amount = shift @ret;
|
|
582 |
$exp_invoice_amount = $invoice->amount > 0 ? 10 : 10 * -1;
|
|
583 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
584 |
is($bank_amount->{return_bank_amount} > 0, 1, "${title}: bank invoice_amount is positive");
|
|
585 |
$bank_invoice_amount += $bank_amount->{return_bank_amount};
|
542 |
586 |
|
543 |
587 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
544 |
588 |
my $total = total_amount($invoice);
|
... | ... | |
549 |
593 |
is($invoice->paid, 19.44, "${title}: paid");
|
550 |
594 |
is($number_of_payments, 2, "${title}: 2 AR_paid bookings");
|
551 |
595 |
is($total, 0, "${title}: even balance");
|
|
596 |
is($invoice->paid, $bank_invoice_amount, "${title}: paid eq bank invoice_amount");
|
552 |
597 |
|
553 |
598 |
}
|
554 |
599 |
|
... | ... | |
565 |
610 |
payment_id => $payment_terms->id,
|
566 |
611 |
);
|
567 |
612 |
|
568 |
|
$invoice->pay_invoice( amount => '9.44',
|
569 |
|
payment_type => 'without_skonto',
|
570 |
|
chart_id => $bank_account->chart_id,
|
571 |
|
transdate => $transdate1,
|
572 |
|
);
|
573 |
|
$invoice->pay_invoice( amount => '8.73',
|
574 |
|
payment_type => 'without_skonto',
|
575 |
|
chart_id => $bank_account->chart_id,
|
576 |
|
transdate => $transdate1,
|
577 |
|
);
|
|
613 |
my (@ret, $bank_amount, $exp_invoice_amount);
|
|
614 |
@ret = $invoice->pay_invoice( amount => '9.44',
|
|
615 |
payment_type => 'without_skonto',
|
|
616 |
chart_id => $bank_account->chart_id,
|
|
617 |
transdate => $transdate1,
|
|
618 |
);
|
|
619 |
$bank_amount = shift @ret;
|
|
620 |
my $amount = 9.44;
|
|
621 |
$exp_invoice_amount = $invoice->amount > 0 ? $amount : $amount * -1;
|
|
622 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
623 |
|
|
624 |
@ret = $invoice->pay_invoice( amount => '8.73',
|
|
625 |
payment_type => 'without_skonto',
|
|
626 |
chart_id => $bank_account->chart_id,
|
|
627 |
transdate => $transdate1,
|
|
628 |
);
|
|
629 |
$bank_amount = shift @ret;
|
|
630 |
$amount = 8.73;
|
|
631 |
$exp_invoice_amount = $invoice->amount > 0 ? $amount : $amount * -1;
|
|
632 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
633 |
|
578 |
634 |
# free_skonto does:
|
579 |
635 |
# my $open_amount = $payment_type eq 'with_skonto_pt' ? $invoice->amount_less_skonto : $invoice->open_amount;
|
580 |
636 |
# $open_amount = abs($open_amount);
|
581 |
637 |
# $open_amount -= $free_skonto_amount if ($payment_type eq 'free_skonto');
|
582 |
638 |
|
583 |
|
$invoice->pay_invoice( skonto_amount => $invoice->open_amount,
|
|
639 |
@ret = $invoice->pay_invoice( skonto_amount => $invoice->open_amount,
|
584 |
640 |
amount => 0,
|
585 |
641 |
payment_type => 'free_skonto',
|
586 |
642 |
chart_id => $bank_account->chart_id,
|
587 |
643 |
transdate => $transdate1,
|
588 |
644 |
bt_id => $bt->id,
|
589 |
645 |
);
|
|
646 |
$bank_amount = shift @ret;
|
|
647 |
$amount = 0;
|
|
648 |
$exp_invoice_amount = $invoice->amount < 0 ? $amount : $amount * -1;
|
|
649 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
650 |
|
590 |
651 |
|
591 |
652 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
592 |
653 |
my $total = total_amount($invoice);
|
... | ... | |
618 |
679 |
payment_id => $payment_terms->id,
|
619 |
680 |
);
|
620 |
681 |
|
621 |
|
$invoice->pay_invoice( amount => '19.42',
|
622 |
|
payment_type => 'without_skonto',
|
623 |
|
chart_id => $bank_account->chart_id,
|
624 |
|
transdate => $transdate1,
|
625 |
|
);
|
626 |
|
$invoice->pay_invoice( skonto_amount => $invoice->open_amount,
|
627 |
|
amount => 0,
|
628 |
|
payment_type => 'free_skonto',
|
629 |
|
chart_id => $bank_account->chart_id,
|
630 |
|
transdate => $transdate1,
|
631 |
|
bt_id => $bt->id,
|
632 |
|
);
|
|
682 |
my (@ret, $bank_amount, $exp_invoice_amount);
|
|
683 |
@ret = $invoice->pay_invoice( amount => '19.42',
|
|
684 |
payment_type => 'without_skonto',
|
|
685 |
chart_id => $bank_account->chart_id,
|
|
686 |
transdate => $transdate1,
|
|
687 |
);
|
|
688 |
$bank_amount = shift @ret;
|
|
689 |
my $amount = 19.42;
|
|
690 |
$exp_invoice_amount = $invoice->amount > 0 ? $amount : $amount * -1;
|
|
691 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
692 |
is($bank_amount->{return_bank_amount} > 0, 1, "${title}: bank invoice_amount is positive");
|
|
693 |
|
|
694 |
@ret = $invoice->pay_invoice( skonto_amount => $invoice->open_amount,
|
|
695 |
amount => 0,
|
|
696 |
payment_type => 'free_skonto',
|
|
697 |
chart_id => $bank_account->chart_id,
|
|
698 |
transdate => $transdate1,
|
|
699 |
bt_id => $bt->id,
|
|
700 |
);
|
|
701 |
$bank_amount = shift @ret;
|
|
702 |
$amount = 0;
|
|
703 |
$exp_invoice_amount = $invoice->amount < 0 ? $amount : $amount * -1;
|
|
704 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
705 |
|
633 |
706 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
634 |
707 |
my $total = total_amount($invoice);
|
635 |
708 |
|
... | ... | |
654 |
727 |
payment_id => $payment_terms->id,
|
655 |
728 |
);
|
656 |
729 |
|
657 |
|
$invoice->pay_invoice( amount => '19.42',
|
|
730 |
my (@ret, $bank_amount, $exp_invoice_amount);
|
|
731 |
@ret = $invoice->pay_invoice( amount => '19.42',
|
658 |
732 |
payment_type => 'without_skonto',
|
659 |
733 |
chart_id => $bank_account->chart_id,
|
660 |
734 |
transdate => $transdate1,
|
661 |
735 |
);
|
662 |
|
$invoice->pay_invoice( skonto_amount => $invoice->open_amount,
|
|
736 |
$bank_amount = shift @ret;
|
|
737 |
my $amount = 19.42;
|
|
738 |
$exp_invoice_amount = $invoice->amount > 0 ? $amount : $amount * -1;
|
|
739 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
740 |
is($bank_amount->{return_bank_amount} > 0, 1, "${title}: bank invoice_amount is positive");
|
|
741 |
|
|
742 |
@ret = $invoice->pay_invoice( skonto_amount => $invoice->open_amount,
|
663 |
743 |
amount => 0,
|
664 |
744 |
payment_type => 'free_skonto',
|
665 |
745 |
chart_id => $bank_account->chart_id,
|
666 |
746 |
transdate => $transdate1,
|
667 |
747 |
bt_id => $bt->id,
|
668 |
748 |
);
|
|
749 |
$bank_amount = shift @ret;
|
|
750 |
$amount = 0;
|
|
751 |
$exp_invoice_amount = $invoice->amount > 0 ? $amount : $amount * -1;
|
|
752 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
753 |
is($bank_amount->{return_bank_amount} == 0, 1, "${title}: bank invoice_amount is zero");
|
669 |
754 |
|
670 |
755 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
671 |
756 |
my $total = total_amount($invoice);
|
... | ... | |
698 |
783 |
|
699 |
784 |
$params{amount} = '2.32';
|
700 |
785 |
$params{payment_type} = 'without_skonto';
|
701 |
|
$invoice->pay_invoice( %params );
|
|
786 |
my @ret = $invoice->pay_invoice( %params );
|
|
787 |
my $bank_amount = shift @ret;
|
|
788 |
my $exp_invoice_amount = $invoice->amount > 0 ? $params{amount} : $params{amount} * -1;
|
|
789 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
790 |
is($bank_amount->{return_bank_amount} > 0, 1, "${title}: bank invoice_amount is positive");
|
|
791 |
|
702 |
792 |
|
703 |
793 |
$params{amount} = '3.81';
|
704 |
794 |
$params{payment_type} = 'without_skonto';
|
705 |
|
$invoice->pay_invoice( %params );
|
|
795 |
@ret = $invoice->pay_invoice( %params );
|
|
796 |
$bank_amount = shift @ret;
|
|
797 |
$exp_invoice_amount = $invoice->amount > 0 ? $params{amount} : $params{amount} * -1;
|
|
798 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
799 |
is($bank_amount->{return_bank_amount} > 0, 1, "${title}: bank invoice_amount is positive");
|
|
800 |
|
|
801 |
|
706 |
802 |
|
707 |
803 |
$params{skonto_amount} = $invoice->open_amount; # set amount, otherwise previous 3.81 is used
|
708 |
804 |
$params{amount} = 0,
|
709 |
805 |
$params{payment_type} = 'free_skonto';
|
710 |
|
$invoice->pay_invoice( %params );
|
|
806 |
@ret = $invoice->pay_invoice( %params );
|
|
807 |
$bank_amount = shift @ret;
|
|
808 |
$exp_invoice_amount = $invoice->amount > 0 ? $params{amount} : $params{amount} * -1;
|
|
809 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
810 |
is($bank_amount->{return_bank_amount} == 0, 1, "${title}: bank invoice_amount is zero");
|
|
811 |
|
711 |
812 |
|
712 |
813 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
713 |
814 |
my $total = total_amount($invoice);
|
... | ... | |
740 |
841 |
|
741 |
842 |
$params{amount} = '6.95';
|
742 |
843 |
$params{payment_type} = 'without_skonto';
|
743 |
|
$invoice->pay_invoice( %params );
|
|
844 |
my @ret = $invoice->pay_invoice( %params );
|
|
845 |
my $bank_amount = shift @ret;
|
|
846 |
my $exp_invoice_amount = $invoice->amount > 0 ? $params{amount} : $params{amount} * -1;
|
|
847 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
848 |
is($bank_amount->{return_bank_amount} > 0, 1, "${title}: bank invoice_amount is positive");
|
744 |
849 |
|
745 |
850 |
$params{skonto_amount} = $invoice->open_amount;
|
746 |
851 |
$params{amount} = 0,
|
747 |
852 |
$params{payment_type} = 'free_skonto';
|
748 |
|
$invoice->pay_invoice( %params );
|
|
853 |
@ret = $invoice->pay_invoice( %params );
|
|
854 |
$bank_amount = shift @ret;
|
|
855 |
$exp_invoice_amount = $invoice->amount > 0 ? $params{amount} : $params{amount} * -1;
|
|
856 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
857 |
|
749 |
858 |
|
750 |
859 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
751 |
860 |
my $total = total_amount($invoice);
|
... | ... | |
761 |
870 |
|
762 |
871 |
# test 3 : two items, without skonto
|
763 |
872 |
sub test_default_ap_transaction_two_charts_19_7_without_skonto {
|
764 |
|
my $title = 'default invoice, two items, 19/7% tax without skonto';
|
|
873 |
my $title = 'default ap_transaction, two items, 19/7% tax without skonto';
|
765 |
874 |
|
766 |
875 |
my $ap_transaction = new_ap_transaction();
|
767 |
876 |
|
... | ... | |
769 |
878 |
transdate => $transdate1,
|
770 |
879 |
);
|
771 |
880 |
|
772 |
|
$params{amount} = '226'; # pass full amount
|
|
881 |
$params{amount} = 226; # pass full amount
|
773 |
882 |
$params{payment_type} = 'without_skonto';
|
774 |
883 |
|
775 |
|
$ap_transaction->pay_invoice( %params );
|
|
884 |
my @ret = $ap_transaction->pay_invoice( %params );
|
|
885 |
my $bank_amount = shift @ret;
|
|
886 |
my $exp_invoice_amount = $ap_transaction->amount < 0 ? $params{amount} : $params{amount} * -1;
|
|
887 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
888 |
is($bank_amount->{return_bank_amount} < 0, 1, "${title}: bank invoice_amount is negative");
|
776 |
889 |
|
777 |
890 |
my ($number_of_payments, $paid_amount) = number_of_payments($ap_transaction);
|
778 |
891 |
my $total = total_amount($ap_transaction);
|
779 |
892 |
|
780 |
|
is($paid_amount, 226, "${title}: paid amount");
|
781 |
|
is($number_of_payments, 1, "${title}: 1 AP_paid bookings");
|
782 |
|
is($total, 0, "${title}: even balance");
|
|
893 |
is($paid_amount, 226, "${title}: paid amount");
|
|
894 |
is($ap_transaction->paid, 226, "${title}: ap.paid amount");
|
|
895 |
is($number_of_payments, 1, "${title}: 1 AP_paid bookings");
|
|
896 |
is($total, 0, "${title}: even balance");
|
783 |
897 |
|
784 |
898 |
}
|
785 |
899 |
|
... | ... | |
798 |
912 |
$params{amount} = $ap_transaction->amount_less_skonto; # pass calculated skonto amount
|
799 |
913 |
$params{payment_type} = 'with_skonto_pt';
|
800 |
914 |
|
801 |
|
$ap_transaction->pay_invoice( %params );
|
|
915 |
my @ret = $ap_transaction->pay_invoice( %params );
|
|
916 |
my $bank_amount = shift @ret;
|
|
917 |
my $exp_invoice_amount = $ap_transaction->amount < 0 ? $params{amount} : $params{amount} * -1;
|
|
918 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
919 |
is($bank_amount->{return_bank_amount} < 0, 1, "${title}: bank invoice_amount is negative");
|
802 |
920 |
|
803 |
921 |
my ($number_of_payments, $paid_amount) = number_of_payments($ap_transaction);
|
804 |
922 |
my $total = total_amount($ap_transaction);
|
805 |
923 |
|
806 |
|
is($paid_amount, 226, "${title}: paid amount");
|
807 |
|
is($number_of_payments, 3, "${title}: 1 AP_paid bookings");
|
808 |
|
is($total, 0, "${title}: even balance");
|
|
924 |
is($paid_amount, 226, "${title}: paid amount");
|
|
925 |
is($ap_transaction->paid, 226, "${title}: paid amount");
|
|
926 |
is($number_of_payments, 3, "${title}: 1 AP_paid bookings");
|
|
927 |
is($total, 0, "${title}: even balance");
|
809 |
928 |
|
810 |
929 |
}
|
811 |
930 |
|
... | ... | |
814 |
933 |
|
815 |
934 |
# check whether unrounded amounts passed via $params{amount} are rounded for without_skonto case
|
816 |
935 |
my $ap_transaction = new_ap_transaction();
|
817 |
|
$ap_transaction->pay_invoice(
|
818 |
|
amount => ( $ap_transaction->amount / 3 * 2),
|
819 |
|
payment_type => 'without_skonto',
|
820 |
|
chart_id => $bank_account->chart_id,
|
821 |
|
transdate => $transdate1,
|
822 |
|
);
|
|
936 |
my @ret = $ap_transaction->pay_invoice(
|
|
937 |
amount => ( $ap_transaction->amount / 3 * 2),
|
|
938 |
payment_type => 'without_skonto',
|
|
939 |
chart_id => $bank_account->chart_id,
|
|
940 |
transdate => $transdate1,
|
|
941 |
);
|
|
942 |
my $bank_amount = shift @ret;
|
|
943 |
my $amount = $::form->round_amount( $ap_transaction->amount / 3 * 2, 2);
|
|
944 |
my $exp_invoice_amount = $ap_transaction->amount < 0 ? $amount : $amount * -1;
|
|
945 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
946 |
is($bank_amount->{return_bank_amount} < 0, 1, "${title}: bank invoice_amount is negative");
|
|
947 |
|
|
948 |
|
823 |
949 |
my ($number_of_payments, $paid_amount) = number_of_payments($ap_transaction);
|
824 |
950 |
my $total = total_amount($ap_transaction);
|
825 |
951 |
|
826 |
|
is($paid_amount, 150.67, "${title}: paid amount");
|
827 |
|
is($number_of_payments, 1, "${title}: 1 AP_paid bookings");
|
828 |
|
is($total, 0, "${title}: even balance");
|
|
952 |
is($paid_amount, 150.67, "${title}: paid amount");
|
|
953 |
is($ap_transaction->paid, 150.67, "${title}: paid amount");
|
|
954 |
is($number_of_payments, 1, "${title}: 1 AP_paid bookings");
|
|
955 |
is($total, 0, "${title}: even balance");
|
829 |
956 |
};
|
830 |
957 |
|
831 |
958 |
|
... | ... | |
835 |
962 |
my $ap_transaction = new_ap_transaction();
|
836 |
963 |
|
837 |
964 |
# pay 2/3 and 1/5, leaves 3.83% to be used as Skonto
|
838 |
|
$ap_transaction->pay_invoice(
|
|
965 |
my @ret = $ap_transaction->pay_invoice(
|
839 |
966 |
amount => ( $ap_transaction->amount / 3 * 2),
|
840 |
967 |
payment_type => 'without_skonto',
|
841 |
968 |
chart_id => $bank_account->chart_id,
|
842 |
969 |
transdate => $transdate1,
|
843 |
970 |
);
|
844 |
|
$ap_transaction->pay_invoice(
|
|
971 |
my $bank_amount = shift @ret;
|
|
972 |
my $amount = $::form->round_amount( $ap_transaction->amount / 3 * 2, 2);
|
|
973 |
my $exp_invoice_amount = $ap_transaction->amount < 0 ? $amount : $amount * -1;
|
|
974 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
975 |
is($bank_amount->{return_bank_amount} < 0, 1, "${title}: bank invoice_amount is negative");
|
|
976 |
|
|
977 |
@ret = $ap_transaction->pay_invoice(
|
845 |
978 |
amount => ( $ap_transaction->amount / 5 ),
|
846 |
979 |
payment_type => 'without_skonto',
|
847 |
980 |
chart_id => $bank_account->chart_id,
|
848 |
981 |
transdate => $transdate1,
|
849 |
982 |
);
|
850 |
|
$ap_transaction->pay_invoice(
|
|
983 |
$bank_amount = shift @ret;
|
|
984 |
$amount = $ap_transaction->amount / 5;
|
|
985 |
$exp_invoice_amount = $ap_transaction->amount < 0 ? $amount : $amount * -1;
|
|
986 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
987 |
is($bank_amount->{return_bank_amount} < 0, 1, "${title}: invoice_amount negative");
|
|
988 |
|
|
989 |
@ret = $ap_transaction->pay_invoice(
|
851 |
990 |
payment_type => 'free_skonto',
|
852 |
991 |
skonto_amount => $ap_transaction->open_amount,
|
853 |
992 |
amount => 0,
|
... | ... | |
855 |
994 |
transdate => $transdate1,
|
856 |
995 |
bt_id => $bt->id,
|
857 |
996 |
);
|
|
997 |
$bank_amount = shift @ret;
|
|
998 |
$amount = 0;
|
|
999 |
$exp_invoice_amount = $ap_transaction->amount < 0 ? $amount : $amount * -1;
|
|
1000 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
858 |
1001 |
|
859 |
1002 |
my ($number_of_payments, $paid_amount) = number_of_payments($ap_transaction);
|
860 |
1003 |
my $total = total_amount($ap_transaction);
|
861 |
1004 |
|
862 |
|
is($paid_amount, 226, "${title}: paid amount");
|
863 |
|
is($number_of_payments, 4, "${title}: 4 AP_paid bookings");
|
864 |
|
is($total, 0, "${title}: even balance");
|
|
1005 |
is($paid_amount, 226, "${title}: paid amount");
|
|
1006 |
is($ap_transaction->paid, 226, "${title}: ap.paid amount");
|
|
1007 |
is($number_of_payments, 4, "${title}: 4 AP_paid bookings");
|
|
1008 |
is($total, 0, "${title}: even balance");
|
865 |
1009 |
|
866 |
1010 |
}
|
867 |
1011 |
|
... | ... | |
887 |
1031 |
$params{amount} = $invoice->amount_less_skonto;
|
888 |
1032 |
$params{payment_type} = 'with_skonto_pt';
|
889 |
1033 |
|
890 |
|
$invoice->pay_invoice( %params );
|
|
1034 |
my @ret = $invoice->pay_invoice( %params );
|
|
1035 |
my $bank_amount = shift @ret;
|
|
1036 |
my $exp_invoice_amount = $invoice->amount > 0 ? $params{amount} : $params{amount} * -1;
|
|
1037 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
1038 |
is($bank_amount->{return_bank_amount} > 0, 1, "${title}: invoice_amount positive");
|
891 |
1039 |
|
892 |
1040 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
893 |
1041 |
my $total = total_amount($invoice);
|
... | ... | |
1018 |
1166 |
my $title = 'test_ar_currency_tax_not_included_and_payment_2';
|
1019 |
1167 |
|
1020 |
1168 |
my $netamount = $::form->round_amount(75 * $exchangerate->sell,2); # 75 in CUR, 100.00 in EUR
|
1021 |
|
my $amount = $::form->round_amount($netamount * 1.19,2); # 100 in CUR, 119.00 in EUR
|
|
1169 |
my $amount = $::form->round_amount($netamount * 1.19,2); # 100 in EUR, 119.00 in EUR incl. tax
|
1022 |
1170 |
my $invoice = SL::DB::Invoice->new(
|
1023 |
1171 |
invoice => 0,
|
1024 |
1172 |
amount => $amount,
|
... | ... | |
1049 |
1197 |
is(SL::DB::Manager::AccTransaction->find_by(chart_id => $ar_chart->id, trans_id => $invoice->id)->amount, '-119.00000', $ar_chart->accno . ': has been converted for currency');
|
1050 |
1198 |
|
1051 |
1199 |
$invoice->pay_invoice(chart_id => $bank->id,
|
1052 |
|
amount => 50,
|
|
1200 |
amount => 50, # amount is in default currency -> should be 37.5 in CUR
|
1053 |
1201 |
currency => 'CUR',
|
1054 |
1202 |
transdate => $transdate1->to_kivitendo,
|
1055 |
1203 |
);
|
1056 |
1204 |
$invoice->pay_invoice(chart_id => $bank->id,
|
1057 |
|
amount => 39.25,
|
|
1205 |
amount => 39.25, # amount is in default currency -> should be 29.44 in CUR
|
1058 |
1206 |
currency => 'CUR',
|
1059 |
1207 |
transdate => $transdate1->to_kivitendo,
|
1060 |
1208 |
);
|
... | ... | |
1457 |
1605 |
|
1458 |
1606 |
$params{amount} = $invoice->amount,
|
1459 |
1607 |
|
1460 |
|
$invoice->pay_invoice( %params );
|
|
1608 |
my @ret = $invoice->pay_invoice( %params );
|
|
1609 |
my $bank_amount = shift @ret;
|
|
1610 |
|
|
1611 |
my $exp_invoice_amount = $params{amount};
|
|
1612 |
is($bank_amount->{return_bank_amount}, $exp_invoice_amount, "${title}: invoice_amount");
|
|
1613 |
is($bank_amount->{return_bank_amount} < 0, 1, "${title}: bank invoice_amount is negative (credit note)");
|
1461 |
1614 |
|
1462 |
1615 |
my ($number_of_payments, $paid_amount) = number_of_payments($invoice);
|
1463 |
1616 |
my $total = total_amount($invoice);
|
Payment-Helper um Rückgabewert invoice_amount für bank_transaction ergänzt
Testfälle und Anmerkung zu exchangerate