use Modern::Perl;
-use Test::More tests => 31;
+use Test::More tests => 32;
use DateTime::Duration;
use t::lib::Mocks;
use C4::Circulation;
use C4::Context;
use C4::Items;
-use C4::Members;
use C4::Reserves;
+use Koha::Checkouts;
use Koha::Database;
use Koha::DateUtils;
use Koha::Holds;
my $item_id2 = $sampleitem2[2];
#Add borrower
-my $borrower_id1 = C4::Members::AddMember(
+my $borrower_id1 = Koha::Patron->new({
firstname => 'firstname1',
surname => 'surname1 ',
categorycode => $categorycode,
branchcode => $branchcode_1
-);
+})->store->borrowernumber;
my $borrower_1 = Koha::Patrons->find( $borrower_id1 )->unblessed;
-my $borrower_id2 = C4::Members::AddMember(
+my $borrower_id2 = Koha::Patron->new({
firstname => 'firstname2',
surname => 'surname2 ',
categorycode => $categorycode,
branchcode => $branchcode_2,
-);
+})->store->borrowernumber;
my $borrower_2 = Koha::Patrons->find( $borrower_id2 )->unblessed;
my @USERENV = (
qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
"Koha::Schema::Result::Issue->date_due() returns a date"
);
-my $issue_id1 = $dbh->last_insert_id( undef, undef, 'issues', undef );
+my $issue_id1 = $issue1->issue_id;
my $issue2 = C4::Circulation::AddIssue( $borrower_1, 'nonexistent_barcode' );
is( $issue2, undef, "AddIssue returns undef if no datedue is specified" );
-my $issue_id2 = $dbh->last_insert_id( undef, undef, 'issues', undef );
$sth->execute;
$countissue = $sth -> fetchrow_array;
$sth->execute;
my $countaccount = $sth -> fetchrow_array;
is ($countaccount,0,"0 accountline exists");
-is( ref( C4::Circulation::AddIssuingCharge( $item_id1, $borrower_id1, 10 ) ),
- 'Koha::Account::Offset', "An issuing charge has been added" );
+my $checkout = Koha::Checkouts->find( $issue_id1 );
+my $offset = C4::Circulation::AddIssuingCharge( $checkout, 10 );
+is( ref( $offset ), 'Koha::Account::Offset', "An issuing charge has been added" );
+my $charge = Koha::Account::Lines->find( $offset->debit_id );
+is( $charge->issue_id, $issue_id1, 'Issue id is set correctly for issuing charge' );
my $account_id = $dbh->last_insert_id( undef, undef, 'accountlines', undef );
$sth->execute;
$countaccount = $sth -> fetchrow_array;