1 |
|
use Test::More;
|
|
1 |
use Test::More tests => 74;
|
2 |
2 |
|
3 |
3 |
use strict;
|
4 |
4 |
|
... | ... | |
46 |
46 |
SL::DB::Manager::Currency->delete_all(where => [ name => 'CUR' ]);
|
47 |
47 |
};
|
48 |
48 |
|
|
49 |
sub save_btcontroller_to_string {
|
|
50 |
my $output;
|
|
51 |
open(my $outputFH, '>', \$output) or die;
|
|
52 |
my $oldFH = select $outputFH;
|
|
53 |
|
|
54 |
my $bt_controller = SL::Controller::BankTransaction->new;
|
|
55 |
$bt_controller->action_save_invoices;
|
|
56 |
|
|
57 |
select $oldFH;
|
|
58 |
close $outputFH;
|
|
59 |
return $output;
|
|
60 |
}
|
49 |
61 |
|
50 |
62 |
# starting test:
|
51 |
63 |
Support::TestSetup::login();
|
52 |
64 |
|
|
65 |
clear_up();
|
53 |
66 |
reset_state(); # initialise customers/vendors/bank/currency/...
|
54 |
67 |
|
55 |
68 |
test1();
|
... | ... | |
59 |
72 |
test_two_invoices();
|
60 |
73 |
test_partial_payment();
|
61 |
74 |
test_credit_note();
|
|
75 |
test_neg_ap_transaction();
|
62 |
76 |
|
63 |
77 |
# remove all created data at end of test
|
64 |
78 |
clear_up();
|
... | ... | |
215 |
229 |
$bt->id => [ $ar_transaction->id ]
|
216 |
230 |
};
|
217 |
231 |
|
218 |
|
my $bt_controller = SL::Controller::BankTransaction->new;
|
219 |
|
$bt_controller->action_save_invoices;
|
|
232 |
save_btcontroller_to_string();
|
220 |
233 |
|
221 |
234 |
$ar_transaction->load;
|
222 |
235 |
$bt->load;
|
... | ... | |
246 |
259 |
$bt->id => [ 'with_skonto_pt' ]
|
247 |
260 |
};
|
248 |
261 |
|
249 |
|
my $bt_controller = SL::Controller::BankTransaction->new;
|
250 |
|
$bt_controller->action_save_invoices;
|
|
262 |
save_btcontroller_to_string();
|
251 |
263 |
|
252 |
264 |
$ar_transaction->load;
|
253 |
265 |
$bt->load;
|
... | ... | |
277 |
289 |
$bt->id => [ $ar_transaction_1->id, $ar_transaction_2->id ]
|
278 |
290 |
};
|
279 |
291 |
|
280 |
|
my $bt_controller = SL::Controller::BankTransaction->new;
|
281 |
|
$bt_controller->action_save_invoices;
|
|
292 |
save_btcontroller_to_string();
|
282 |
293 |
|
283 |
294 |
$ar_transaction_1->load;
|
284 |
295 |
$ar_transaction_2->load;
|
... | ... | |
308 |
319 |
$bt->id => [ $ar_transaction->id ]
|
309 |
320 |
};
|
310 |
321 |
|
311 |
|
my $bt_controller = SL::Controller::BankTransaction->new;
|
312 |
|
$bt_controller->action_save_invoices;
|
|
322 |
save_btcontroller_to_string();
|
313 |
323 |
|
314 |
324 |
$ar_transaction->load;
|
315 |
325 |
$bt->load;
|
... | ... | |
343 |
353 |
$::form->{invoice_ids} = {
|
344 |
354 |
$bt_1->id => [ $ar_transaction->id ]
|
345 |
355 |
};
|
346 |
|
my $bt_controller_1 = SL::Controller::BankTransaction->new;
|
347 |
|
$bt_controller_1->action_save_invoices;
|
|
356 |
save_btcontroller_to_string();
|
348 |
357 |
|
349 |
358 |
$::form->{invoice_ids} = {
|
350 |
359 |
$bt_2->id => [ $ar_transaction->id ]
|
351 |
360 |
};
|
352 |
|
my $bt_controller_2 = SL::Controller::BankTransaction->new;
|
353 |
|
$bt_controller_2->action_save_invoices;
|
|
361 |
save_btcontroller_to_string();
|
354 |
362 |
|
355 |
363 |
$ar_transaction->load;
|
356 |
364 |
$bt_1->load;
|
... | ... | |
378 |
386 |
$bt->id => [ $ar_transaction->id ]
|
379 |
387 |
};
|
380 |
388 |
|
381 |
|
my $bt_controller = SL::Controller::BankTransaction->new;
|
382 |
|
$bt_controller->action_save_invoices;
|
|
389 |
save_btcontroller_to_string();
|
383 |
390 |
|
384 |
391 |
$ar_transaction->load;
|
385 |
392 |
$bt->load;
|
... | ... | |
416 |
423 |
$bt->id => [ $credit_note->id ]
|
417 |
424 |
};
|
418 |
425 |
|
419 |
|
my $bt_controller = SL::Controller::BankTransaction->new;
|
420 |
|
$bt_controller->action_save_invoices;
|
|
426 |
save_btcontroller_to_string();
|
421 |
427 |
|
422 |
428 |
$credit_note->load;
|
423 |
429 |
$bt->load;
|
... | ... | |
426 |
432 |
is($credit_note->paid , '-844.90000', "$testname: paid ok");
|
427 |
433 |
}
|
428 |
434 |
|
|
435 |
sub test_neg_ap_transaction {
|
|
436 |
my (%params) = @_;
|
|
437 |
my $testname = 'test_neg_ap_transaction';
|
|
438 |
my $netamount = -20;
|
|
439 |
my $amount = $::form->round_amount($netamount * 1.19,2);
|
|
440 |
my $invoice = SL::DB::PurchaseInvoice->new(
|
|
441 |
invoice => 0,
|
|
442 |
invnumber => $params{invnumber} || 'test_neg_ap_transaction',
|
|
443 |
amount => $amount,
|
|
444 |
netamount => $netamount,
|
|
445 |
transdate => $transdate1,
|
|
446 |
taxincluded => 0,
|
|
447 |
vendor_id => $vendor->id,
|
|
448 |
taxzone_id => $vendor->taxzone_id,
|
|
449 |
currency_id => $currency_id,
|
|
450 |
transactions => [],
|
|
451 |
notes => 'test_neg_ap_transaction',
|
|
452 |
);
|
|
453 |
$invoice->add_ap_amount_row(
|
|
454 |
amount => $invoice->netamount,
|
|
455 |
chart => $ap_amount_chart,
|
|
456 |
tax_id => $tax_9->id,
|
|
457 |
);
|
|
458 |
|
|
459 |
$invoice->create_ap_row(chart => $ap_chart);
|
|
460 |
$invoice->save;
|
|
461 |
|
|
462 |
is($invoice->netamount , -20 , "$testname: netamount ok");
|
|
463 |
is($invoice->amount , -23.8 , "$testname: amount ok");
|
|
464 |
|
|
465 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $invoice,
|
|
466 |
amount => $invoice->amount,
|
|
467 |
bank_chart_id => $bank->id,
|
|
468 |
transdate => DateTime->today->add(days => 10),
|
|
469 |
);
|
|
470 |
my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($invoice);
|
|
471 |
is($agreement, 15, "points for negative ap transaction ok");
|
|
472 |
|
|
473 |
$::form->{invoice_ids} = {
|
|
474 |
$bt->id => [ $invoice->id ]
|
|
475 |
};
|
|
476 |
|
|
477 |
save_btcontroller_to_string();
|
|
478 |
|
|
479 |
$invoice->load;
|
|
480 |
|
|
481 |
is($invoice->amount , '-23.80000', "$testname: amount ok");
|
|
482 |
is($invoice->netamount, '-20.00000', "$testname: netamount ok");
|
|
483 |
is($invoice->paid , '-23.80000', "$testname: paid ok");
|
|
484 |
|
|
485 |
return $invoice;
|
|
486 |
};
|
|
487 |
|
|
488 |
|
429 |
489 |
1;
|
Kontoauszug verbuchen: Lieferantengutschrift buchen
Nun wird eine negativen Kreditorenbuchung (Lieferantengutschrift) richtig verbucht.
t/bank/bank_transactions.t um einen Test erweitert
und Stdout des Controllers (HTML) in String umgelenkt.