Lines 5-14
use Modern::Perl;
Link Here
|
5 |
use C4::Context; |
5 |
use C4::Context; |
6 |
use Koha::Database; |
6 |
use Koha::Database; |
7 |
use Koha::Patrons; |
7 |
use Koha::Patrons; |
|
|
8 |
use Koha::Account; |
8 |
|
9 |
|
9 |
use t::lib::TestBuilder; |
10 |
use t::lib::TestBuilder; |
10 |
|
11 |
|
11 |
use Test::More tests => 34; |
12 |
use Test::More tests => 38; |
12 |
|
13 |
|
13 |
use_ok('Koha::Patron::Debarments'); |
14 |
use_ok('Koha::Patron::Debarments'); |
14 |
|
15 |
|
Lines 221-223
is( Koha::Patrons->find($borrowernumber3)->debarred,
Link Here
|
221 |
$debarreddate2, 'Koha::Patron->merge_with() transfers well debarred' ); |
222 |
$debarreddate2, 'Koha::Patron->merge_with() transfers well debarred' ); |
222 |
is( Koha::Patrons->find($borrowernumber3)->debarredcomment, |
223 |
is( Koha::Patrons->find($borrowernumber3)->debarredcomment, |
223 |
$debarredcomment2, 'Koha::Patron->merge_with() transfers well debarredcomment' ); |
224 |
$debarredcomment2, 'Koha::Patron->merge_with() transfers well debarredcomment' ); |
224 |
- |
225 |
|
|
|
226 |
# Test removing debartments after payment |
227 |
$builder->build( |
228 |
{ |
229 |
source => 'RestrictionType', |
230 |
value => { |
231 |
code => 'TEST', |
232 |
display_text => 'This is a test.', |
233 |
is_system => 0, |
234 |
is_default => 0, |
235 |
lift_after_payment => 1, |
236 |
fee_limit => 5 |
237 |
} |
238 |
} |
239 |
); |
240 |
|
241 |
$builder->build( |
242 |
{ |
243 |
source => 'RestrictionType', |
244 |
value => { |
245 |
code => 'TEST2', |
246 |
display_text => 'This too is a test.', |
247 |
is_system => 0, |
248 |
is_default => 0, |
249 |
lift_after_payment => 1, |
250 |
fee_limit => 0 |
251 |
} |
252 |
} |
253 |
); |
254 |
|
255 |
my $borrowernumber4 = Koha::Patron->new( |
256 |
{ |
257 |
firstname => 'First', |
258 |
surname => 'Sur', |
259 |
categorycode => $patron_category->{categorycode}, |
260 |
branchcode => $library->{branchcode}, |
261 |
} |
262 |
)->store->borrowernumber; |
263 |
|
264 |
my $account = Koha::Account->new({ patron_id => $borrowernumber4 }); |
265 |
my $line1 = $account->add_debit({ type => 'ACCOUNT', amount => 10, interface => 'commandline' }); |
266 |
|
267 |
Koha::Patron::Debarments::AddDebarment( |
268 |
{ |
269 |
borrowernumber => $borrowernumber4, |
270 |
expiration => '9999-06-10', |
271 |
type => 'TEST', |
272 |
comment => 'Test delete' |
273 |
} |
274 |
); |
275 |
|
276 |
Koha::Patron::Debarments::AddDebarment( |
277 |
{ |
278 |
borrowernumber => $borrowernumber4, |
279 |
expiration => '9999-10-10', |
280 |
type => 'TEST2', |
281 |
comment => 'Test delete again', |
282 |
} |
283 |
); |
284 |
|
285 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber4 }); |
286 |
|
287 |
is( @$debarments, 2, "GetDebarments returns 2 debarments before payment" ); |
288 |
|
289 |
$account->pay({amount => 5}); |
290 |
|
291 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber4 }); |
292 |
is( @$debarments, 1, "GetDebarments returns 1 debarment after paying half of the fee" ); |
293 |
is( @$debarments[0]->{type}, "TEST2", "Debarment left has type value 'TEST2'" ); |
294 |
|
295 |
$account->pay({amount => 5}); |
296 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber4 }); |
297 |
is( @$debarments, 0, "GetDebarments returns 0 debarments after paying all fees" ); |