Lines 22-27
use Modern::Perl;
Link Here
|
22 |
use Test::More tests => 7; |
22 |
use Test::More tests => 7; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
|
24 |
|
|
|
25 |
use C4::Circulation qw/AddIssue AddReturn/; |
25 |
use Koha::Account; |
26 |
use Koha::Account; |
26 |
use Koha::Account::Lines; |
27 |
use Koha::Account::Lines; |
27 |
use Koha::Account::Offsets; |
28 |
use Koha::Account::Offsets; |
Lines 419-450
subtest 'checkout() tests' => sub {
Link Here
|
419 |
|
420 |
|
420 |
$schema->storage->txn_begin; |
421 |
$schema->storage->txn_begin; |
421 |
|
422 |
|
422 |
my $library = $builder->build( { source => 'Branch' } ); |
423 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
423 |
my $patron = $builder->build( { source => 'Borrower' } ); |
424 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
424 |
my $item = $builder->build( { source => 'Item' } ); |
425 |
my $item = $builder->build_sample_item; |
|
|
426 |
my $account = $patron->account; |
425 |
|
427 |
|
426 |
my $checkout = Koha::Checkout->new( |
428 |
t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode }); |
427 |
{ borrowernumber => $patron->{borrowernumber}, |
429 |
my $checkout = AddIssue( $patron->unblessed, $item->barcode ); |
428 |
itemnumber => $item->{itemnumber}, |
|
|
429 |
branchcode => $library->{branchcode}, |
430 |
})->store; |
431 |
|
430 |
|
432 |
my $line = Koha::Account::Line->new( |
431 |
my $line = $account->add_debit({ |
433 |
{ |
432 |
amount => 10, |
434 |
borrowernumber => $patron->{borrowernumber}, |
433 |
item_id => $item->itemnumber, |
435 |
itemnumber => $item->{itemnumber}, |
434 |
issue_id => $checkout->issue_id, |
436 |
issue_id => $checkout->issue_id, |
435 |
type => 'fine', |
437 |
accounttype => "F", |
436 |
}); |
438 |
amount => 10, |
|
|
439 |
})->store; |
440 |
|
437 |
|
441 |
my $line_checkout = $line->checkout; |
438 |
my $line_checkout = $line->checkout; |
442 |
is( ref($line_checkout), 'Koha::Checkout', 'Result type is correct' ); |
439 |
is( ref($line_checkout), 'Koha::Checkout', 'Result type is correct' ); |
443 |
is( $line_checkout->issue_id, $checkout->issue_id, 'Koha::Account::Line->checkout should return the correct checkout'); |
440 |
is( $line_checkout->issue_id, $checkout->issue_id, 'Koha::Account::Line->checkout should return the correct checkout'); |
444 |
|
441 |
|
445 |
my ( $returned, undef, $old_checkout) = C4::Circulation::AddReturn( $item->{barcode} ,$library->{branchcode} ); |
442 |
my ( $returned, undef, $old_checkout) = C4::Circulation::AddReturn( $item->barcode, $library->branchcode ); |
446 |
is( $returned, 1, 'The item should have been returned' ); |
443 |
is( $returned, 1, 'The item should have been returned' ); |
447 |
|
444 |
|
|
|
445 |
$line = $line->get_from_storage; |
448 |
my $old_line_checkout = $line->checkout; |
446 |
my $old_line_checkout = $line->checkout; |
449 |
is( ref($old_line_checkout), 'Koha::Old::Checkout', 'Result type is correct' ); |
447 |
is( ref($old_line_checkout), 'Koha::Old::Checkout', 'Result type is correct' ); |
450 |
is( $old_line_checkout->issue_id, $old_checkout->issue_id, 'Koha::Account::Line->checkout should return the correct old_checkout' ); |
448 |
is( $old_line_checkout->issue_id, $old_checkout->issue_id, 'Koha::Account::Line->checkout should return the correct old_checkout' ); |
451 |
- |
|
|