Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f8013b9c

Von Jan Büren vor mehr als 2 Jahren hinzugefügt

  • ID f8013b9c3a57b8da20cee2df92ffcc34e90d1022
  • Vorgänger e78ebdb9
  • Nachfolger 8a638ac5

Testfälle für Payment::within_skonto_period

Unterschiede anzeigen:

t/db_helper/payment.t
1 1
use strict;
2
use Test::More tests => 197;
2
use Test::More tests => 203;
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');
......
1470 1471
  is($total,                          0,   "${title}: even balance");
1471 1472
}
1472 1473

  
1474
sub test_error_codes_within_skonto {
1475
  my $title   = 'test within_skonto_period';
1476
  my $item1   = create_invoice_item(part => $parts[0], qty => 2.5);
1477
  my $item2   = create_invoice_item(part => $parts[1], qty => 1.2);
1478
  # no skonto payment terms at all
1479
  my $invoice = create_sales_invoice(
1480
    transdate    => $transdate1,
1481
    taxincluded  => 1,
1482
    invoiceitems => [ $item1, $item2 ],
1483
  );
1484
  # has skonto payment terms
1485
  my $invoice2 = create_sales_invoice(
1486
    transdate    => $transdate1,
1487
    taxincluded  => 1,
1488
    invoiceitems => [ $item1, $item2 ],
1489
    payment_id   => $payment_terms->id,
1490
  );
1491

  
1492
  throws_ok{
1493
    $invoice->within_skonto_period();
1494
   } qr/Mandatory parameter 'transdate' missing in call to SL::DB::Helper::Payment::within_skonto_period/, "call without parameter throws correct error message";
1495

  
1496
  throws_ok{
1497
    $invoice->within_skonto_period(transdate => 'Kaese');
1498
   } 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";
1499

  
1500
  throws_ok{
1501
    $invoice->within_skonto_period(transdate => DateTime->now());
1502
  } 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";
1503

  
1504
  is($invoice2->within_skonto_period(transdate => DateTime->now()->add(days => 1)), 1, "one day after invdate is skontoable");
1505
  is($invoice2->within_skonto_period(transdate => DateTime->now()->add(days => 4)), 1, "four days after invdate is skontoable");
1506

  
1507
  throws_ok{
1508
    $invoice2->within_skonto_period(transdate => DateTime->now()->add(days => 6));
1509
  } 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";
1510

  
1511
}
1512

  
1473 1513
1;

Auch abrufbar als: Unified diff