Revision 280b772d
Von Kivitendo Admin vor fast 8 Jahren hinzugefügt
t/bank/bank_transactions.t | ||
---|---|---|
16 | 16 |
use SL::DB::Vendor; |
17 | 17 |
use SL::DB::Invoice; |
18 | 18 |
use SL::DB::Unit; |
19 |
use SL::DB::Part; |
|
19 | 20 |
use SL::DB::TaxZone; |
20 | 21 |
use SL::DB::BankAccount; |
21 | 22 |
use SL::DB::PaymentTerm; |
... | ... | |
37 | 38 |
SL::DB::Manager::InvoiceItem->delete_all(all => 1); |
38 | 39 |
SL::DB::Manager::Invoice->delete_all(all => 1); |
39 | 40 |
SL::DB::Manager::PurchaseInvoice->delete_all(all => 1); |
41 |
SL::DB::Manager::Part->delete_all(all => 1); |
|
40 | 42 |
SL::DB::Manager::Customer->delete_all(all => 1); |
41 | 43 |
SL::DB::Manager::Vendor->delete_all(all => 1); |
42 | 44 |
SL::DB::Manager::BankAccount->delete_all(all => 1); |
... | ... | |
56 | 58 |
test_skonto_exact(); |
57 | 59 |
test_two_invoices(); |
58 | 60 |
test_partial_payment(); |
61 |
test_credit_note(); |
|
59 | 62 |
|
60 | 63 |
# remove all created data at end of test |
61 | 64 |
clear_up(); |
... | ... | |
383 | 386 |
|
384 | 387 |
}; |
385 | 388 |
|
389 |
sub test_credit_note { |
|
390 |
|
|
391 |
my $testname = 'test_credit_note'; |
|
392 |
|
|
393 |
my $part1 = SL::Dev::Part::create_part( partnumber => 'T4254')->save; |
|
394 |
my $part2 = SL::Dev::Part::create_service(partnumber => 'Serv1')->save; |
|
395 |
my $credit_note = SL::Dev::Record::create_credit_note( |
|
396 |
invnumber => 'cn 1', |
|
397 |
customer => $customer, |
|
398 |
taxincluded => 0, |
|
399 |
invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 3, sellprice => 70), |
|
400 |
SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50), |
|
401 |
] |
|
402 |
); |
|
403 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $credit_note, |
|
404 |
amount => $credit_note->amount, |
|
405 |
bank_chart_id => $bank->id, |
|
406 |
transdate => DateTime->today->add(days => 10), |
|
407 |
); |
|
408 |
my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($credit_note); |
|
409 |
is($agreement, 13, "points for credit note ok"); |
|
410 |
is($rule_matches, 'remote_account_number(3) exact_amount(4) wrong_sign(-1) depositor_matches(2) remote_name(2) payment_within_30_days(1) datebonus14(2) ', "rules_matches for credit note ok"); |
|
411 |
|
|
412 |
$::form->{invoice_ids} = { |
|
413 |
$bt->id => [ $credit_note->id ] |
|
414 |
}; |
|
415 |
|
|
416 |
my $bt_controller = SL::Controller::BankTransaction->new; |
|
417 |
$bt_controller->action_save_invoices; |
|
418 |
|
|
419 |
$credit_note->load; |
|
420 |
$bt->load; |
|
421 |
is($credit_note->amount , '-844.90000', "$testname: amount ok"); |
|
422 |
is($credit_note->netamount, '-710.00000', "$testname: netamount ok"); |
|
423 |
is($credit_note->paid , '-844.90000', "$testname: paid ok"); |
|
424 |
} |
|
425 |
|
|
386 | 426 |
1; |
Auch abrufbar als: Unified diff
bank_transaction.t - neuer Test für credit_note