Lines 197-218
is( Koha::Patrons->find($borrowernumber3)->debarredcomment,
Link Here
|
197 |
|
197 |
|
198 |
# Test removing debartments after payment |
198 |
# Test removing debartments after payment |
199 |
my $debarmentsRulesPref = C4::Context->preference("DebarmentsToLiftAfterPayment"); |
199 |
my $debarmentsRulesPref = C4::Context->preference("DebarmentsToLiftAfterPayment"); |
200 |
C4::Context->set_preference("DebarmentsToLiftAfterPayment", "Test debarment:\n outstanding: 0\nTest debarment 2:"); |
200 |
C4::Context->set_preference("DebarmentsToLiftAfterPayment", "Test debarment:\n outstanding: 0\nTest debarment 2:\n outstanding: 2"); |
201 |
|
201 |
|
202 |
AddDebarment({ |
202 |
my $register = $builder->build_object( { class => 'Koha::Cash::Registers' } ); |
203 |
borrowernumber => $borrowernumber, |
203 |
my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } ); |
|
|
204 |
my $account = $patron2->account; |
205 |
my $fine = $account->add_debit( |
206 |
{ |
207 |
amount => '5.00', |
208 |
type => 'OVERDUE', |
209 |
interface => 'cron' |
210 |
} |
211 |
); |
212 |
|
213 |
Koha::Patron::Debarments::AddDebarment({ |
214 |
borrowernumber => $patron2->borrowernumber, |
204 |
comment => 'Test debarment', |
215 |
comment => 'Test debarment', |
205 |
}); |
216 |
}); |
206 |
AddDebarment({ |
217 |
Koha::Patron::Debarments::AddDebarment({ |
207 |
borrowernumber => $borrowernumber, |
218 |
borrowernumber => $patron2->borrowernumber, |
208 |
comment => 'Test debarment 2', |
219 |
comment => 'Test debarment 2', |
209 |
}); |
220 |
}); |
210 |
|
221 |
|
211 |
$debarments = GetDebarments({ borrowernumber => $borrowernumber }); |
222 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron2->borrowernumber }); |
212 |
is( @$debarments, 2, "GetDebarments returns 2 debarments before payment" ); |
223 |
is( @$debarments, 2, "GetDebarments returns 2 debarments before payment" ); |
213 |
|
224 |
|
214 |
DelDebarmentsAfterPayment({ borrowernumber => $borrowernumber }); |
225 |
my $payment1 = $account->pay( |
215 |
C4::Context->set_preference("DebarmentsToLiftAfterPayment", $debarmentsRulesPref); |
226 |
{ |
|
|
227 |
cash_register => $register->id, |
228 |
amount => '4.00', |
229 |
credit_type => 'PAYMENT', |
230 |
lines => [$fine] |
231 |
} |
232 |
); |
233 |
|
234 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron2->borrowernumber }); |
235 |
is( @$debarments, 1, "GetDebarments returns 1 debarment after first payment" ); |
236 |
my $debarment_comment; |
237 |
foreach my $debarment (@$debarments){ |
238 |
$debarment_comment = $debarment->{comment}; |
239 |
} |
240 |
is( $debarment_comment, "Test debarment", "Returned debartments comment is 'Test debarment'" ); |
241 |
|
242 |
my $payment2 = $account->pay( |
243 |
{ |
244 |
cash_register => $register->id, |
245 |
amount => '1.00', |
246 |
credit_type => 'PAYMENT', |
247 |
lines => [$fine] |
248 |
} |
249 |
); |
250 |
|
251 |
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $patron2->borrowernumber }); |
252 |
is( @$debarments, 0, "GetDebarments returns 0 debarments after second payment" ); |
216 |
|
253 |
|
217 |
$debarments = GetDebarments({ borrowernumber => $borrowernumber }); |
254 |
=cut |
218 |
is( @$debarments, 0, "GetDebarments returns 0 debarments after payment" ); |
|
|
219 |
- |
|
|