Revision 63410aa6
Von Sven Schöling vor mehr als 7 Jahren hinzugefügt
t/bank/bank_transactions.t | ||
---|---|---|
23 | 23 |
use SL::DB::PurchaseInvoice; |
24 | 24 |
use SL::DB::BankTransaction; |
25 | 25 |
use SL::Controller::BankTransaction; |
26 |
use SL::Dev::ALL; |
|
26 |
use SL::Dev::ALL qw(:ALL);
|
|
27 | 27 |
use Data::Dumper; |
28 | 28 |
|
29 | 29 |
my ($customer, $vendor, $currency_id, $unit, $tax, $tax7, $tax_9, $payment_terms, $bank_account); |
... | ... | |
117 | 117 |
name => SL::DB::Manager::Chart->find_by(description => 'Bank')->description, |
118 | 118 |
)->save; |
119 | 119 |
|
120 |
$customer = SL::Dev::CustomerVendor::create_customer(
|
|
120 |
$customer = new_customer(
|
|
121 | 121 |
name => 'Test Customer', |
122 | 122 |
iban => 'DE12500105170648489890', |
123 | 123 |
bic => 'TESTBIC', |
... | ... | |
130 | 130 |
customernumber => 'CUST1704', |
131 | 131 |
)->save; |
132 | 132 |
|
133 |
$payment_terms = SL::Dev::Payment::create_payment_terms;
|
|
133 |
$payment_terms = create_payment_terms();
|
|
134 | 134 |
|
135 |
$vendor = SL::Dev::CustomerVendor::create_vendor(
|
|
135 |
$vendor = new_vendor(
|
|
136 | 136 |
name => 'Test Vendor', |
137 | 137 |
payment_id => $payment_terms->id, |
138 | 138 |
iban => 'DE12500105170648489890', |
... | ... | |
237 | 237 |
|
238 | 238 |
$ar_transaction = test_ar_transaction(invnumber => 'salesinv1'); |
239 | 239 |
|
240 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
|
|
240 |
my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction"; |
|
241 | 241 |
|
242 | 242 |
$::form->{invoice_ids} = { |
243 | 243 |
$bt->id => [ $ar_transaction->id ] |
... | ... | |
261 | 261 |
payment_id => $payment_terms->id, |
262 | 262 |
); |
263 | 263 |
|
264 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
|
|
265 |
bank_chart_id => $bank->id,
|
|
266 |
amount => $ar_transaction->amount_less_skonto
|
|
267 |
) or die "Couldn't create bank_transaction";
|
|
264 |
my $bt = create_bank_transaction(record => $ar_transaction, |
|
265 |
bank_chart_id => $bank->id, |
|
266 |
amount => $ar_transaction->amount_less_skonto |
|
267 |
) or die "Couldn't create bank_transaction"; |
|
268 | 268 |
|
269 | 269 |
$::form->{invoice_ids} = { |
270 | 270 |
$bt->id => [ $ar_transaction->id ] |
... | ... | |
290 | 290 |
my $ar_transaction_1 = test_ar_transaction(invnumber => 'salesinv_1'); |
291 | 291 |
my $ar_transaction_2 = test_ar_transaction(invnumber => 'salesinv_2'); |
292 | 292 |
|
293 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction_1,
|
|
294 |
amount => ($ar_transaction_1->amount + $ar_transaction_2->amount),
|
|
295 |
purpose => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber,
|
|
296 |
bank_chart_id => $bank->id,
|
|
297 |
) or die "Couldn't create bank_transaction";
|
|
293 |
my $bt = create_bank_transaction(record => $ar_transaction_1, |
|
294 |
amount => ($ar_transaction_1->amount + $ar_transaction_2->amount), |
|
295 |
purpose => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber, |
|
296 |
bank_chart_id => $bank->id, |
|
297 |
) or die "Couldn't create bank_transaction"; |
|
298 | 298 |
|
299 | 299 |
my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($ar_transaction_1); |
300 | 300 |
is($agreement, 16, "points for ar_transaction_1 in test_two_invoices ok"); |
... | ... | |
324 | 324 |
$ar_transaction = test_ar_transaction(invnumber => 'salesinv overpaid'); |
325 | 325 |
|
326 | 326 |
# amount 135 > 119 |
327 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
|
|
328 |
bank_chart_id => $bank->id,
|
|
329 |
amount => 135
|
|
330 |
) or die "Couldn't create bank_transaction";
|
|
327 |
my $bt = create_bank_transaction(record => $ar_transaction, |
|
328 |
bank_chart_id => $bank->id, |
|
329 |
amount => 135 |
|
330 |
) or die "Couldn't create bank_transaction"; |
|
331 | 331 |
|
332 | 332 |
$::form->{invoice_ids} = { |
333 | 333 |
$bt->id => [ $ar_transaction->id ] |
... | ... | |
354 | 354 |
|
355 | 355 |
$ar_transaction = test_ar_transaction(invnumber => 'salesinv overpaid partial'); |
356 | 356 |
|
357 |
my $bt_1 = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
|
|
358 |
bank_chart_id => $bank->id,
|
|
359 |
amount => 10
|
|
360 |
) or die "Couldn't create bank_transaction";
|
|
361 |
my $bt_2 = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
|
|
362 |
amount => 119,
|
|
363 |
transdate => DateTime->today->add(days => 5),
|
|
364 |
bank_chart_id => $bank->id,
|
|
365 |
) or die "Couldn't create bank_transaction";
|
|
357 |
my $bt_1 = create_bank_transaction(record => $ar_transaction, |
|
358 |
bank_chart_id => $bank->id, |
|
359 |
amount => 10 |
|
360 |
) or die "Couldn't create bank_transaction"; |
|
361 |
my $bt_2 = create_bank_transaction(record => $ar_transaction, |
|
362 |
amount => 119, |
|
363 |
transdate => DateTime->today->add(days => 5), |
|
364 |
bank_chart_id => $bank->id, |
|
365 |
) or die "Couldn't create bank_transaction"; |
|
366 | 366 |
|
367 | 367 |
$::form->{invoice_ids} = { |
368 | 368 |
$bt_1->id => [ $ar_transaction->id ] |
... | ... | |
391 | 391 |
$ar_transaction = test_ar_transaction(invnumber => 'salesinv partial payment'); |
392 | 392 |
|
393 | 393 |
# amount 100 < 119 |
394 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction,
|
|
395 |
bank_chart_id => $bank->id,
|
|
396 |
amount => 100
|
|
397 |
) or die "Couldn't create bank_transaction";
|
|
394 |
my $bt = create_bank_transaction(record => $ar_transaction, |
|
395 |
bank_chart_id => $bank->id, |
|
396 |
amount => 100 |
|
397 |
) or die "Couldn't create bank_transaction"; |
|
398 | 398 |
|
399 | 399 |
$::form->{invoice_ids} = { |
400 | 400 |
$bt->id => [ $ar_transaction->id ] |
... | ... | |
414 | 414 |
|
415 | 415 |
my $testname = 'test_credit_note'; |
416 | 416 |
|
417 |
my $part1 = SL::Dev::Part::create_part( partnumber => 'T4254')->save;
|
|
418 |
my $part2 = SL::Dev::Part::create_service(partnumber => 'Serv1')->save;
|
|
419 |
my $credit_note = SL::Dev::Record::create_credit_note(
|
|
417 |
my $part1 = new_part( partnumber => 'T4254')->save;
|
|
418 |
my $part2 = new_service(partnumber => 'Serv1')->save;
|
|
419 |
my $credit_note = create_credit_note( |
|
420 | 420 |
invnumber => 'cn 1', |
421 | 421 |
customer => $customer, |
422 | 422 |
taxincluded => 0, |
423 |
invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 3, sellprice => 70),
|
|
424 |
SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => 50),
|
|
423 |
invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70), |
|
424 |
create_invoice_item(part => $part2, qty => 10, sellprice => 50), |
|
425 | 425 |
] |
426 | 426 |
); |
427 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $credit_note,
|
|
427 |
my $bt = create_bank_transaction(record => $credit_note, |
|
428 | 428 |
amount => $credit_note->amount, |
429 | 429 |
bank_chart_id => $bank->id, |
430 | 430 |
transdate => DateTime->today->add(days => 10), |
... | ... | |
476 | 476 |
is($invoice->netamount, -20 , "$testname: netamount ok"); |
477 | 477 |
is($invoice->amount , -23.8, "$testname: amount ok"); |
478 | 478 |
|
479 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $invoice,
|
|
480 |
amount => $invoice->amount,
|
|
481 |
bank_chart_id => $bank->id,
|
|
482 |
transdate => DateTime->today->add(days => 10),
|
|
479 |
my $bt = create_bank_transaction(record => $invoice, |
|
480 |
amount => $invoice->amount, |
|
481 |
bank_chart_id => $bank->id, |
|
482 |
transdate => DateTime->today->add(days => 10), |
|
483 | 483 |
); |
484 | 484 |
my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($invoice); |
485 | 485 |
is($agreement, 15, "points for negative ap transaction ok"); |
... | ... | |
531 | 531 |
is($invoice->netamount, 115 , "$testname: netamount ok"); |
532 | 532 |
is($invoice->amount , 136.85, "$testname: amount ok"); |
533 | 533 |
|
534 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $invoice,
|
|
535 |
amount => $invoice->amount,
|
|
536 |
bank_chart_id => $bank->id,
|
|
537 |
transdate => DateTime->today->add(days => 10),
|
|
538 |
);
|
|
534 |
my $bt = create_bank_transaction(record => $invoice, |
|
535 |
amount => $invoice->amount, |
|
536 |
bank_chart_id => $bank->id, |
|
537 |
transdate => DateTime->today->add(days => 10), |
|
538 |
); |
|
539 | 539 |
$::form->{invoice_ids} = { |
540 | 540 |
$bt->id => [ $invoice->id ] |
541 | 541 |
}; |
... | ... | |
584 | 584 |
is($invoice->netamount, 115 , "$testname: netamount ok"); |
585 | 585 |
is($invoice->amount , 136.85, "$testname: amount ok"); |
586 | 586 |
|
587 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $invoice,
|
|
588 |
amount => $invoice->amount-100,
|
|
589 |
bank_chart_id => $bank->id,
|
|
590 |
transdate => DateTime->today->add(days => 10),
|
|
591 |
);
|
|
587 |
my $bt = create_bank_transaction(record => $invoice, |
|
588 |
amount => $invoice->amount-100, |
|
589 |
bank_chart_id => $bank->id, |
|
590 |
transdate => DateTime->today->add(days => 10), |
|
591 |
); |
|
592 | 592 |
$::form->{invoice_ids} = { |
593 | 593 |
$bt->id => [ $invoice->id ] |
594 | 594 |
}; |
... | ... | |
604 | 604 |
is($invoice->paid , '36.85000', "$testname: paid ok"); |
605 | 605 |
is($bt->invoice_amount, '-36.85000', "$testname: bt invoice amount for ap was assigned"); |
606 | 606 |
|
607 |
my $bt2 = SL::Dev::Payment::create_bank_transaction(record => $invoice,
|
|
608 |
amount => 100,
|
|
609 |
bank_chart_id => $bank->id,
|
|
610 |
transdate => DateTime->today->add(days => 10),
|
|
611 |
);
|
|
607 |
my $bt2 = create_bank_transaction(record => $invoice, |
|
608 |
amount => 100, |
|
609 |
bank_chart_id => $bank->id, |
|
610 |
transdate => DateTime->today->add(days => 10), |
|
611 |
); |
|
612 | 612 |
$::form->{invoice_ids} = { |
613 | 613 |
$bt2->id => [ $invoice->id ] |
614 | 614 |
}; |
... | ... | |
630 | 630 |
|
631 | 631 |
my $testname = 'test_neg_sales_invoice'; |
632 | 632 |
|
633 |
my $part1 = SL::Dev::Part::create_part( partnumber => 'Funkenhaube öhm')->save;
|
|
634 |
my $part2 = SL::Dev::Part::create_service(partnumber => 'Service-Pauschale Pasch!')->save;
|
|
633 |
my $part1 = new_part( partnumber => 'Funkenhaube öhm')->save;
|
|
634 |
my $part2 = new_service(partnumber => 'Service-Pauschale Pasch!')->save;
|
|
635 | 635 |
|
636 |
my $neg_sales_inv = SL::Dev::Record::create_sales_invoice(
|
|
636 |
my $neg_sales_inv = create_sales_invoice( |
|
637 | 637 |
invnumber => '20172201', |
638 | 638 |
customer => $customer, |
639 | 639 |
taxincluded => 0, |
640 |
invoiceitems => [ SL::Dev::Record::create_invoice_item(part => $part1, qty => 3, sellprice => 70),
|
|
641 |
SL::Dev::Record::create_invoice_item(part => $part2, qty => 10, sellprice => -50),
|
|
640 |
invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70), |
|
641 |
create_invoice_item(part => $part2, qty => 10, sellprice => -50), |
|
642 | 642 |
] |
643 | 643 |
); |
644 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $neg_sales_inv,
|
|
644 |
my $bt = create_bank_transaction(record => $neg_sales_inv, |
|
645 | 645 |
amount => $neg_sales_inv->amount, |
646 | 646 |
bank_chart_id => $bank->id, |
647 | 647 |
transdate => DateTime->today, |
... | ... | |
667 | 667 |
|
668 | 668 |
$ar_transaction = test_ar_transaction(invnumber => 'bt_rule1'); |
669 | 669 |
|
670 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
|
|
670 |
my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction"; |
|
671 | 671 |
|
672 | 672 |
$ar_transaction->load; |
673 | 673 |
$bt->load; |
... | ... | |
697 | 697 |
|
698 | 698 |
$ar_transaction = test_ar_transaction(invnumber => 'sepa1'); |
699 | 699 |
|
700 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction";
|
|
701 |
my $se = SL::Dev::Payment::create_sepa_export();
|
|
702 |
my $sei = SL::Dev::Payment::create_sepa_export_item(
|
|
700 |
my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction"; |
|
701 |
my $se = create_sepa_export(); |
|
702 |
my $sei = create_sepa_export_item( |
|
703 | 703 |
chart_id => $bank->id, |
704 | 704 |
ar_id => $ar_transaction->id, |
705 | 705 |
sepa_export_id => $se->id, |
Auch abrufbar als: Unified diff
Tests: SL::Dev Änderungen übernommen