Revision 665741c4
Von Jan Büren vor fast 6 Jahren hinzugefügt
t/bank/bank_transactions.t | ||
---|---|---|
1 |
use Test::More tests => 208;
|
|
1 |
use Test::More tests => 211;
|
|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
... | ... | |
11 | 11 |
use List::Util qw(sum); |
12 | 12 |
|
13 | 13 |
use SL::DB::AccTransaction; |
14 |
use SL::DB::BankTransactionAccTrans; |
|
14 | 15 |
use SL::DB::Buchungsgruppe; |
15 | 16 |
use SL::DB::Currency; |
16 | 17 |
use SL::DB::Customer; |
... | ... | |
34 | 35 |
|
35 | 36 |
sub clear_up { |
36 | 37 |
|
38 |
SL::DB::Manager::BankTransactionAccTrans->delete_all(all => 1); |
|
37 | 39 |
SL::DB::Manager::BankTransaction->delete_all(all => 1); |
38 | 40 |
SL::DB::Manager::InvoiceItem->delete_all(all => 1); |
39 | 41 |
SL::DB::Manager::InvoiceItem->delete_all(all => 1); |
... | ... | |
442 | 444 |
$ar_transaction->load; |
443 | 445 |
$bt->load; |
444 | 446 |
|
445 |
is($ar_transaction->paid , '135.00000' , "$testname: 'salesinv overpaid' was overpaid");
|
|
446 |
is($bt->invoice_amount , '135.00000' , "$testname: bt invoice amount was assigned overpaid amount");
|
|
447 |
is($ar_transaction->paid , '119.00000' , "$testname: 'salesinv overpaid' was not overpaid");
|
|
448 |
is($bt->invoice_amount , '119.00000' , "$testname: bt invoice amount was not fully assigned with the overpaid amount");
|
|
447 | 449 |
{ local $TODO = 'this currently fails because closed ignores over-payments, see commit d90966c7'; |
448 | 450 |
is($ar_transaction->closed , 0 , "$testname: 'salesinv overpaid' is open (via 'closed' method')"); |
449 | 451 |
} |
450 |
is($ar_transaction->open_amount == 0 ? 1 : 0 , 0 , "$testname: 'salesinv overpaid is open (via amount-paid)");
|
|
452 |
is($ar_transaction->open_amount == 0 ? 1 : 0 , 1 , "$testname: 'salesinv overpaid is closed (via amount-paid)");
|
|
451 | 453 |
|
452 | 454 |
}; |
453 | 455 |
|
454 | 456 |
sub test_overpayment_with_partialpayment { |
455 | 457 |
|
456 |
# two payments on different days, 10 and 119. If there is only one invoice we want it be overpaid. |
|
458 |
# two payments on different days, 10 and 119. If there is only one invoice we |
|
459 |
# don't want it to be overpaid. |
|
457 | 460 |
my $testname = 'test_overpayment_with_partialpayment'; |
458 | 461 |
|
459 | 462 |
$ar_transaction = test_ar_transaction(invnumber => 'salesinv overpaid partial'); |
... | ... | |
473 | 476 |
}; |
474 | 477 |
save_btcontroller_to_string(); |
475 | 478 |
|
479 |
$bt_1->load; |
|
480 |
is($bt_1->invoice_amount , '10.00000' , "$testname: bt_1 invoice amount was fully assigned"); |
|
476 | 481 |
$::form->{invoice_ids} = { |
477 | 482 |
$bt_2->id => [ $ar_transaction->id ] |
478 | 483 |
}; |
479 | 484 |
save_btcontroller_to_string(); |
480 | 485 |
|
481 | 486 |
$ar_transaction->load; |
482 |
$bt_1->load; |
|
483 | 487 |
$bt_2->load; |
484 | 488 |
|
485 |
is($ar_transaction->paid , '129.00000' , "$testname: 'salesinv overpaid partial' was overpaid");
|
|
486 |
is($bt_1->invoice_amount , '10.00000' , "$testname: bt_1 invoice amount was assigned overpaid amount");
|
|
487 |
is($bt_2->invoice_amount , '119.00000' , "$testname: bt_2 invoice amount was assigned overpaid amount");
|
|
489 |
is($bt_1->invoice_amount , '10.00000' , "$testname: bt_1 invoice amount was fully assigned");
|
|
490 |
is($ar_transaction->paid , '119.00000' , "$testname: 'salesinv overpaid partial' was not overpaid");
|
|
491 |
is($bt_2->invoice_amount , '109.00000' , "$testname: bt_2 invoice amount was partly assigned");
|
|
488 | 492 |
|
489 | 493 |
}; |
490 | 494 |
|
... | ... | |
585 | 589 |
bank_chart_id => $bank->id, |
586 | 590 |
transdate => DateTime->today->add(days => 10), |
587 | 591 |
); |
592 |
|
|
588 | 593 |
my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($invoice); |
589 | 594 |
is($agreement, 15, "points for negative ap transaction ok"); |
590 | 595 |
|
... | ... | |
601 | 606 |
is($invoice->netamount, '-20.00000', "$testname: netamount ok"); |
602 | 607 |
is($invoice->paid , '-23.80000', "$testname: paid ok"); |
603 | 608 |
is($bt->invoice_amount, '23.80000', "$testname: bt invoice amount for ap was assigned"); |
609 |
is($bt->amount, '23.80000', "$testname: bt amount for ap was assigned"); |
|
604 | 610 |
|
605 | 611 |
return $invoice; |
606 | 612 |
}; |
Auch abrufbar als: Unified diff
BankTransaction: save_single_bank_transaction API-Änderung
S.a. POD und devel-Liste
Testfälle angepasst