Lines 19-28
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 8; |
22 |
use Test::More tests => 9; |
23 |
use Test::Warn; |
23 |
use Test::Warn; |
24 |
|
24 |
|
25 |
use C4::Circulation; |
25 |
use C4::Members; |
|
|
26 |
|
26 |
use Koha::Patron; |
27 |
use Koha::Patron; |
27 |
use Koha::Patrons; |
28 |
use Koha::Patrons; |
28 |
use Koha::Database; |
29 |
use Koha::Database; |
Lines 207-212
subtest 'renew_account' => sub {
Link Here
|
207 |
$retrieved_patron->delete; |
208 |
$retrieved_patron->delete; |
208 |
}; |
209 |
}; |
209 |
|
210 |
|
|
|
211 |
subtest 'add_enrolment_fee_if_needed' => sub { |
212 |
plan tests => 4; |
213 |
|
214 |
my $enrolmentfee_K = 5; |
215 |
my $enrolmentfee_J = 10; |
216 |
my $enrolmentfee_YA = 20; |
217 |
|
218 |
$builder->build( { source => 'Category', value => { categorycode => 'K', enrolmentfee => $enrolmentfee_K } } ); |
219 |
$builder->build( { source => 'Category', value => { categorycode => 'J', enrolmentfee => $enrolmentfee_J } } ); |
220 |
$builder->build( { source => 'Category', value => { categorycode => 'YA', enrolmentfee => $enrolmentfee_YA } } ); |
221 |
|
222 |
my %borrower_data = ( |
223 |
firstname => 'my firstname', |
224 |
surname => 'my surname', |
225 |
categorycode => 'K', |
226 |
branchcode => $library->{branchcode}, |
227 |
); |
228 |
|
229 |
my $borrowernumber = C4::Members::AddMember(%borrower_data); |
230 |
$borrower_data{borrowernumber} = $borrowernumber; |
231 |
|
232 |
my ($total) = C4::Members::GetMemberAccountRecords($borrowernumber); |
233 |
is( $total, $enrolmentfee_K, "New kid pay $enrolmentfee_K" ); |
234 |
|
235 |
t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 0 ); |
236 |
$borrower_data{categorycode} = 'J'; |
237 |
C4::Members::ModMember(%borrower_data); |
238 |
($total) = C4::Members::GetMemberAccountRecords($borrowernumber); |
239 |
is( $total, $enrolmentfee_K, "Kid growing and become a juvenile, but shouldn't pay for the upgrade " ); |
240 |
|
241 |
$borrower_data{categorycode} = 'K'; |
242 |
C4::Members::ModMember(%borrower_data); |
243 |
t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 1 ); |
244 |
|
245 |
$borrower_data{categorycode} = 'J'; |
246 |
C4::Members::ModMember(%borrower_data); |
247 |
($total) = C4::Members::GetMemberAccountRecords($borrowernumber); |
248 |
is( $total, $enrolmentfee_K + $enrolmentfee_J, "Kid growing and become a juvenile, he should pay " . ( $enrolmentfee_K + $enrolmentfee_J ) ); |
249 |
|
250 |
# Check with calling directly Koha::Patron->get_enrolment_fee_if_needed |
251 |
my $patron = Koha::Patrons->find($borrowernumber); |
252 |
$patron->categorycode('YA')->store; |
253 |
my $fee = $patron->add_enrolment_fee_if_needed; |
254 |
($total) = C4::Members::GetMemberAccountRecords($borrowernumber); |
255 |
is( $total, |
256 |
$enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA, |
257 |
"Juvenile growing and become an young adult, he should pay " . ( $enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA ) |
258 |
); |
259 |
|
260 |
$patron->delete; |
261 |
}; |
262 |
|
210 |
$retrieved_patron_1->delete; |
263 |
$retrieved_patron_1->delete; |
211 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
264 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
212 |
|
265 |
|