Revision 9a5f5b0e
Von Jan Büren vor etwa 2 Jahren hinzugefügt
t/db_helper/payment.t | ||
---|---|---|
1 | 1 |
use strict; |
2 |
use Test::More tests => 258;
|
|
2 |
use Test::More tests => 264;
|
|
3 | 3 |
|
4 | 4 |
use strict; |
5 | 5 |
|
... | ... | |
82 | 82 |
test_ap_currency_tax_not_included_and_payment_2(); # two exchangerates, with fx_gain_loss |
83 | 83 |
test_ap_currency_tax_not_included_and_payment_2_credit_note(); # two exchangerates, with fx_gain_loss |
84 | 84 |
|
85 |
is(SL::DB::Manager::Invoice->get_all_count(), 21, "number of invoices at end of tests ok"); |
|
85 |
test_error_codes_within_skonto(); |
|
86 |
is(SL::DB::Manager::Invoice->get_all_count(), 23, "number of invoices at end of tests ok"); |
|
86 | 87 |
TODO: { |
87 | 88 |
local $TODO = "currently this test fails because the code writing the invoice is buggy, the calculation of skonto is correct"; |
88 | 89 |
my ($acc_trans_sum) = selectfirst_array_query($::form, $currency->db->dbh, 'SELECT SUM(amount) FROM acc_trans'); |
... | ... | |
1623 | 1624 |
is($total, 0, "${title}: even balance"); |
1624 | 1625 |
} |
1625 | 1626 |
|
1627 |
sub test_error_codes_within_skonto { |
|
1628 |
my $title = 'test within_skonto_period'; |
|
1629 |
my $item1 = create_invoice_item(part => $parts[0], qty => 2.5); |
|
1630 |
my $item2 = create_invoice_item(part => $parts[1], qty => 1.2); |
|
1631 |
# no skonto payment terms at all |
|
1632 |
my $invoice = create_sales_invoice( |
|
1633 |
transdate => $transdate1, |
|
1634 |
taxincluded => 1, |
|
1635 |
invoiceitems => [ $item1, $item2 ], |
|
1636 |
); |
|
1637 |
# has skonto payment terms |
|
1638 |
my $invoice2 = create_sales_invoice( |
|
1639 |
transdate => $transdate1, |
|
1640 |
taxincluded => 1, |
|
1641 |
invoiceitems => [ $item1, $item2 ], |
|
1642 |
payment_id => $payment_terms->id, |
|
1643 |
); |
|
1644 |
|
|
1645 |
throws_ok{ |
|
1646 |
$invoice->within_skonto_period(); |
|
1647 |
} qr/Mandatory parameter 'transdate' missing in call to SL::DB::Helper::Payment::within_skonto_period/, "call without parameter throws correct error message"; |
|
1648 |
|
|
1649 |
throws_ok{ |
|
1650 |
$invoice->within_skonto_period(transdate => 'Kaese'); |
|
1651 |
} qr/The 'transdate' parameter \("Kaese"\) to SL::DB::Helper::Payment::within_skonto_period was not a 'DateTime' \(it is a Kaese\)/, "call with parameter Käse throws correct error message"; |
|
1652 |
|
|
1653 |
throws_ok{ |
|
1654 |
$invoice->within_skonto_period(transdate => DateTime->now()); |
|
1655 |
} qr /The 'transdate' parameter .* to SL::DB::Helper::Payment::within_skonto_period did not pass the 'self has a skonto date' callback/, "call to invoice withount skonto throws correct error message"; |
|
1656 |
|
|
1657 |
is($invoice2->within_skonto_period(transdate => DateTime->now()->add(days => 1)), 1, "one day after invdate is skontoable"); |
|
1658 |
is($invoice2->within_skonto_period(transdate => DateTime->now()->add(days => 4)), 1, "four days after invdate is skontoable"); |
|
1659 |
|
|
1660 |
throws_ok{ |
|
1661 |
$invoice2->within_skonto_period(transdate => DateTime->now()->add(days => 6)); |
|
1662 |
} qr /The 'transdate' parameter .* to SL::DB::Helper::Payment::within_skonto_period did not pass the 'is within skonto period' callback/, "One day after skonto date throws correct error message"; |
|
1663 |
|
|
1664 |
} |
|
1665 |
|
|
1626 | 1666 |
1; |
Auch abrufbar als: Unified diff
Testfälle für Payment::within_skonto_period