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 => 33; |
12 |
use Test::More tests => 37; |
12 |
|
13 |
|
13 |
use_ok('Koha::Patron::Debarments'); |
14 |
use_ok('Koha::Patron::Debarments'); |
14 |
|
15 |
|
Lines 194-196
is( Koha::Patrons->find($borrowernumber3)->debarred,
Link Here
|
194 |
$debarreddate2, 'Koha::Patron->merge_with() transfers well debarred' ); |
195 |
$debarreddate2, 'Koha::Patron->merge_with() transfers well debarred' ); |
195 |
is( Koha::Patrons->find($borrowernumber3)->debarredcomment, |
196 |
is( Koha::Patrons->find($borrowernumber3)->debarredcomment, |
196 |
$debarredcomment2, 'Koha::Patron->merge_with() transfers well debarredcomment' ); |
197 |
$debarredcomment2, 'Koha::Patron->merge_with() transfers well debarredcomment' ); |
197 |
- |
198 |
|
|
|
199 |
# Test removing debartments after payment |
200 |
$builder->build( |
201 |
{ |
202 |
source => 'RestrictionType', |
203 |
value => { |
204 |
code => 'TEST', |
205 |
display_text => 'This is a test.', |
206 |
is_system => 0, |
207 |
is_default => 0, |
208 |
lift_after_payment => 1, |
209 |
fee_limit => 5 |
210 |
} |
211 |
} |
212 |
); |
213 |
|
214 |
$builder->build( |
215 |
{ |
216 |
source => 'RestrictionType', |
217 |
value => { |
218 |
code => 'TEST2', |
219 |
display_text => 'This too is a test.', |
220 |
is_system => 0, |
221 |
is_default => 0, |
222 |
lift_after_payment => 1, |
223 |
fee_limit => 0 |
224 |
} |
225 |
} |
226 |
); |
227 |
|
228 |
my $borrowernumber4 = Koha::Patron->new( |
229 |
{ |
230 |
firstname => 'First', |
231 |
surname => 'Sur', |
232 |
categorycode => $patron_category->{categorycode}, |
233 |
branchcode => $library->{branchcode}, |
234 |
} |
235 |
)->store->borrowernumber; |
236 |
|
237 |
my $account = Koha::Account->new({ patron_id => $borrowernumber4 }); |
238 |
my $line1 = $account->add_debit({ type => 'ACCOUNT', amount => 10, interface => 'commandline' }); |
239 |
|
240 |
Koha::Patron::Debarments::AddDebarment( |
241 |
{ |
242 |
borrowernumber => $borrowernumber4, |
243 |
expiration => '9999-06-10', |
244 |
type => 'TEST', |
245 |
comment => 'Test delete' |
246 |
} |
247 |
); |
248 |
|
249 |
Koha::Patron::Debarments::AddDebarment( |
250 |
{ |
251 |
borrowernumber => $borrowernumber4, |
252 |
expiration => '9999-10-10', |
253 |
type => 'TEST2', |
254 |
comment => 'Test delete again', |
255 |
} |
256 |
); |
257 |
|
258 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber4 }); |
259 |
|
260 |
is( @$debarments, 2, "GetDebarments returns 2 debarments before payment" ); |
261 |
|
262 |
$account->pay({amount => 5}); |
263 |
|
264 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber4 }); |
265 |
is( @$debarments, 1, "GetDebarments returns 1 debarment after paying half of the fee" ); |
266 |
is( @$debarments[0]->{type}, "TEST2", "Debarment left has type value 'TEST2'" ); |
267 |
|
268 |
$account->pay({amount => 5}); |
269 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber4 }); |
270 |
is( @$debarments, 0, "GetDebarments returns 0 debarments after paying all fees" ); |