Lines 16-22
Link Here
|
16 |
|
16 |
|
17 |
use Modern::Perl; |
17 |
use Modern::Perl; |
18 |
|
18 |
|
19 |
use Test::More tests => 23; |
19 |
use Test::More tests => 32; |
20 |
|
20 |
|
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
Lines 89-98
$builder->build_sample_item(
Link Here
|
89 |
); |
89 |
); |
90 |
|
90 |
|
91 |
AddIssue( $patron, $barcode ); |
91 |
AddIssue( $patron, $barcode ); |
92 |
is( |
92 |
my ( $can, $problems ) = Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ); |
93 |
Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ), 0, |
93 |
is( $can, 0, 'A patron with issues cannot be discharged' ); |
94 |
'A patron with issues cannot be discharged' |
94 |
is( $problems->{checkouts}, 1, "Patron has checkouts" ); |
95 |
); |
95 |
is( $problems->{debt}, undef, "Patron has no debt" ); |
96 |
|
96 |
|
97 |
is( |
97 |
is( |
98 |
Koha::Patron::Discharge::request( { borrowernumber => $patron->borrowernumber } ), undef, |
98 |
Koha::Patron::Discharge::request( { borrowernumber => $patron->borrowernumber } ), undef, |
Lines 105-117
is(
Link Here
|
105 |
is_deeply( [Koha::Patron::Discharge::get_pendings], [], 'There is no pending discharge request' ); |
105 |
is_deeply( [Koha::Patron::Discharge::get_pendings], [], 'There is no pending discharge request' ); |
106 |
is_deeply( [Koha::Patron::Discharge::get_validated], [], 'There is no validated discharge' ); |
106 |
is_deeply( [Koha::Patron::Discharge::get_validated], [], 'There is no validated discharge' ); |
107 |
|
107 |
|
|
|
108 |
# Discharge not possible with issues and fines |
109 |
$patron->account->add_debit( |
110 |
{ |
111 |
amount => 0.1, |
112 |
interface => C4::Context->interface, |
113 |
type => 'OVERDUE' |
114 |
} |
115 |
); |
116 |
|
117 |
( $can, $problems ) = Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ); |
118 |
is( |
119 |
$can, 0, |
120 |
'A patron with fines and checkouts cannot be discharged' |
121 |
); |
122 |
is( $problems->{checkouts}, 1, "Patron has checkouts" ); |
123 |
is( $problems->{debt}, 0.1, "Patron has debt" ); |
124 |
|
108 |
AddReturn($barcode); |
125 |
AddReturn($barcode); |
109 |
|
126 |
|
110 |
# Discharge possible without issue |
127 |
( $can, $problems ) = Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ); |
|
|
128 |
is( |
129 |
$can, 0, |
130 |
'A patron with fines cannot be discharged' |
131 |
); |
132 |
is( $problems->{checkouts}, undef, "Patron has checkouts" ); |
133 |
is( $problems->{debt}, 0.1, "Patron has debt" ); |
134 |
|
135 |
$patron->account->pay( |
136 |
{ |
137 |
amount => 0.1, |
138 |
} |
139 |
); |
140 |
|
141 |
# Discharge possible without issue or fine |
142 |
( $can, $problems ) = Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ); |
111 |
is( |
143 |
is( |
112 |
Koha::Patron::Discharge::can_be_discharged( { borrowernumber => $patron->borrowernumber } ), 1, |
144 |
$can, 1, |
113 |
'A patron without issues can be discharged' |
145 |
'A patron without issues or fines can be discharged' |
114 |
); |
146 |
); |
|
|
147 |
is( scalar keys %$problems, 0, "No dishcharge problems found" ); |
115 |
|
148 |
|
116 |
is( Koha::Patron::Discharge::generate_as_pdf, undef, "Confirm failure when lacking borrower number" ); |
149 |
is( Koha::Patron::Discharge::generate_as_pdf, undef, "Confirm failure when lacking borrower number" ); |
117 |
|
150 |
|
118 |
- |
|
|