Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 6; |
22 |
use Test::More tests => 7; |
23 |
|
23 |
|
24 |
use C4::Members; |
24 |
use C4::Members; |
25 |
|
25 |
|
Lines 147-152
subtest 'extend_subscription' => sub {
Link Here
|
147 |
$retrieved_patron->delete; |
147 |
$retrieved_patron->delete; |
148 |
}; |
148 |
}; |
149 |
|
149 |
|
|
|
150 |
subtest 'add_enrolment_fee_if_needed' => sub { |
151 |
plan tests => 4; |
152 |
|
153 |
my $enrolmentfee_K = 5; |
154 |
my $enrolmentfee_J = 10; |
155 |
my $enrolmentfee_YA = 20; |
156 |
|
157 |
$builder->build( { source => 'Category', value => { categorycode => 'K', enrolmentfee => $enrolmentfee_K } } ); |
158 |
$builder->build( { source => 'Category', value => { categorycode => 'J', enrolmentfee => $enrolmentfee_J } } ); |
159 |
$builder->build( { source => 'Category', value => { categorycode => 'YA', enrolmentfee => $enrolmentfee_YA } } ); |
160 |
|
161 |
my %borrower_data = ( |
162 |
firstname => 'my firstname', |
163 |
surname => 'my surname', |
164 |
categorycode => 'K', |
165 |
branchcode => $library->{branchcode}, |
166 |
); |
167 |
|
168 |
my $borrowernumber = C4::Members::AddMember(%borrower_data); |
169 |
$borrower_data{borrowernumber} = $borrowernumber; |
170 |
|
171 |
my ($total) = C4::Members::GetMemberAccountRecords($borrowernumber); |
172 |
is( $total, $enrolmentfee_K, "New kid pay $enrolmentfee_K" ); |
173 |
|
174 |
t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 0 ); |
175 |
$borrower_data{categorycode} = 'J'; |
176 |
C4::Members::ModMember(%borrower_data); |
177 |
($total) = C4::Members::GetMemberAccountRecords($borrowernumber); |
178 |
is( $total, $enrolmentfee_K, "Kid growing and become a juvenile, but shouldn't pay for the upgrade " ); |
179 |
|
180 |
$borrower_data{categorycode} = 'K'; |
181 |
C4::Members::ModMember(%borrower_data); |
182 |
t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 1 ); |
183 |
|
184 |
$borrower_data{categorycode} = 'J'; |
185 |
C4::Members::ModMember(%borrower_data); |
186 |
($total) = C4::Members::GetMemberAccountRecords($borrowernumber); |
187 |
is( $total, $enrolmentfee_K + $enrolmentfee_J, "Kid growing and become a juvenile, he should pay " . ( $enrolmentfee_K + $enrolmentfee_J ) ); |
188 |
|
189 |
# Check with calling directly Koha::Patron->get_enrolment_fee_if_needed |
190 |
my $patron = Koha::Patrons->find($borrowernumber); |
191 |
$patron->categorycode('YA')->store; |
192 |
my $fee = $patron->add_enrolment_fee_if_needed; |
193 |
($total) = C4::Members::GetMemberAccountRecords($borrowernumber); |
194 |
is( $total, |
195 |
$enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA, |
196 |
"Juvenile growing and become an young adult, he should pay " . ( $enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA ) |
197 |
); |
198 |
|
199 |
$patron->delete; |
200 |
}; |
201 |
|
150 |
$retrieved_patron_1->delete; |
202 |
$retrieved_patron_1->delete; |
151 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
203 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
152 |
|
204 |
|