Lines 252-272
$builder->build(
Link Here
|
252 |
} |
252 |
} |
253 |
); |
253 |
); |
254 |
|
254 |
|
255 |
my $borrowernumber4 = Koha::Patron->new( |
255 |
my $patron4 = Koha::Patron->new( |
256 |
{ |
256 |
{ |
257 |
firstname => 'First', |
257 |
firstname => 'First', |
258 |
surname => 'Sur', |
258 |
surname => 'Sur', |
259 |
categorycode => $patron_category->{categorycode}, |
259 |
categorycode => $patron_category->{categorycode}, |
260 |
branchcode => $library->{branchcode}, |
260 |
branchcode => $library->{branchcode}, |
261 |
} |
261 |
} |
262 |
)->store->borrowernumber; |
262 |
)->store; |
263 |
|
263 |
|
264 |
my $account = Koha::Account->new({ patron_id => $borrowernumber4 }); |
264 |
my $account = $patron4->account; |
265 |
my $line1 = $account->add_debit({ type => 'ACCOUNT', amount => 10, interface => 'commandline' }); |
265 |
my $line1 = $account->add_debit({ type => 'ACCOUNT', amount => 10, interface => 'commandline' }); |
266 |
|
266 |
|
267 |
Koha::Patron::Debarments::AddDebarment( |
267 |
Koha::Patron::Debarments::AddDebarment( |
268 |
{ |
268 |
{ |
269 |
borrowernumber => $borrowernumber4, |
269 |
borrowernumber => $patron4->borrowernumber, |
270 |
expiration => '9999-06-10', |
270 |
expiration => '9999-06-10', |
271 |
type => 'TEST', |
271 |
type => 'TEST', |
272 |
comment => 'Test delete' |
272 |
comment => 'Test delete' |
Lines 275-297
Koha::Patron::Debarments::AddDebarment(
Link Here
|
275 |
|
275 |
|
276 |
Koha::Patron::Debarments::AddDebarment( |
276 |
Koha::Patron::Debarments::AddDebarment( |
277 |
{ |
277 |
{ |
278 |
borrowernumber => $borrowernumber4, |
278 |
borrowernumber => $patron4->borrowernumber, |
279 |
expiration => '9999-10-10', |
279 |
expiration => '9999-10-10', |
280 |
type => 'TEST2', |
280 |
type => 'TEST2', |
281 |
comment => 'Test delete again', |
281 |
comment => 'Test delete again', |
282 |
} |
282 |
} |
283 |
); |
283 |
); |
284 |
|
284 |
|
285 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber4 }); |
285 |
$restrictions = $patron4->restrictions; |
286 |
|
286 |
|
287 |
is( @$debarments, 2, "GetDebarments returns 2 debarments before payment" ); |
287 |
is( $restrictions->count, 2, "->restrictions returns 2 restrictions before payment" ); |
288 |
|
288 |
|
289 |
$account->pay({amount => 5}); |
289 |
$account->pay({amount => 5}); |
290 |
|
290 |
$restrictions = $patron4->restrictions; |
291 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber4 }); |
291 |
is( $restrictions->count, 1, "->restrictions returns 1 restriction after paying half of the fee" ); |
292 |
is( @$debarments, 1, "GetDebarments returns 1 debarment after paying half of the fee" ); |
292 |
is( $restrictions->next->type->code, "TEST2", "Restriction left has type value 'TEST2'" ); |
293 |
is( @$debarments[0]->{type}, "TEST2", "Debarment left has type value 'TEST2'" ); |
|
|
294 |
|
293 |
|
295 |
$account->pay({amount => 5}); |
294 |
$account->pay({amount => 5}); |
296 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber4 }); |
295 |
$restrictions = $patron4->restrictions; |
297 |
is( @$debarments, 0, "GetDebarments returns 0 debarments after paying all fees" ); |
296 |
is( $restrictions->count, 0, "->restrictions returns 0 restrictions after paying all fees" ); |
298 |
- |
|
|