Lines 9-15
use C4::Circulation qw( AddIssue AddReturn );
Link Here
|
9 |
use C4::Biblio qw( AddBiblio ); |
9 |
use C4::Biblio qw( AddBiblio ); |
10 |
use Koha::Database; |
10 |
use Koha::Database; |
11 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
11 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
12 |
use Koha::Patron::Debarments qw( GetDebarments DelDebarment ); |
12 |
use Koha::Patron::Debarments qw( DelDebarment ); |
13 |
use Koha::Patrons; |
13 |
use Koha::Patrons; |
14 |
|
14 |
|
15 |
use t::lib::TestBuilder; |
15 |
use t::lib::TestBuilder; |
Lines 48-54
my $borrowernumber = Koha::Patron->new({
Link Here
|
48 |
categorycode => $patron_category->{categorycode}, |
48 |
categorycode => $patron_category->{categorycode}, |
49 |
branchcode => $branchcode, |
49 |
branchcode => $branchcode, |
50 |
})->store->borrowernumber; |
50 |
})->store->borrowernumber; |
51 |
my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; |
51 |
my $patron_object = Koha::Patrons->find( $borrowernumber ); |
|
|
52 |
my $borrower = $patron_object->unblessed; |
52 |
|
53 |
|
53 |
my $record = MARC::Record->new(); |
54 |
my $record = MARC::Record->new(); |
54 |
$record->append_fields( |
55 |
$record->append_fields( |
Lines 76-88
my $daysafter40 = dt_from_string->add_duration(DateTime::Duration->new(days => 4
Link Here
|
76 |
|
77 |
|
77 |
AddIssue( $borrower, $barcode, $daysago20 ); |
78 |
AddIssue( $borrower, $barcode, $daysago20 ); |
78 |
AddReturn( $barcode, $branchcode ); |
79 |
AddReturn( $barcode, $branchcode ); |
79 |
my $debarments = GetDebarments({borrowernumber => $borrower->{borrowernumber}}); |
80 |
my $debarments = $patron_object->restrictions; |
|
|
81 |
my $THE_debarment = $debarments->next; |
80 |
is( |
82 |
is( |
81 |
$debarments->[0]->{expiration}, |
83 |
$THE_debarment->expiration, |
82 |
output_pref({ dt => $daysafter40, dateformat => 'iso', dateonly => 1 }), |
84 |
output_pref({ dt => $daysafter40, dateformat => 'iso', dateonly => 1 }), |
83 |
'calculate suspension with no maximum set' |
85 |
'calculate suspension with no maximum set' |
84 |
); |
86 |
); |
85 |
DelDebarment( $debarments->[0]->{borrower_debarment_id} ); |
87 |
DelDebarment( $THE_debarment->borrower_debarment_id ); |
86 |
|
88 |
|
87 |
# Test with maxsuspensiondays = 10 days |
89 |
# Test with maxsuspensiondays = 10 days |
88 |
Koha::CirculationRules->set_rules( |
90 |
Koha::CirculationRules->set_rules( |
Lines 99-111
Koha::CirculationRules->set_rules(
Link Here
|
99 |
my $daysafter10 = dt_from_string->add_duration(DateTime::Duration->new(days => 10)); |
101 |
my $daysafter10 = dt_from_string->add_duration(DateTime::Duration->new(days => 10)); |
100 |
AddIssue( $borrower, $barcode, $daysago20 ); |
102 |
AddIssue( $borrower, $barcode, $daysago20 ); |
101 |
AddReturn( $barcode, $branchcode ); |
103 |
AddReturn( $barcode, $branchcode ); |
102 |
$debarments = GetDebarments({borrowernumber => $borrower->{borrowernumber}}); |
104 |
$debarments = $patron_object->restrictions; |
|
|
105 |
$THE_debarment = $debarments->next; |
103 |
is( |
106 |
is( |
104 |
$debarments->[0]->{expiration}, |
107 |
$THE_debarment->expiration, |
105 |
output_pref({ dt => $daysafter10, dateformat => 'iso', dateonly => 1 }), |
108 |
output_pref({ dt => $daysafter10, dateformat => 'iso', dateonly => 1 }), |
106 |
'calculate suspension with a maximum set' |
109 |
'calculate suspension with a maximum set' |
107 |
); |
110 |
); |
108 |
DelDebarment( $debarments->[0]->{borrower_debarment_id} ); |
111 |
DelDebarment( $THE_debarment->borrower_debarment_id ); |
109 |
|
112 |
|
110 |
subtest "suspension_chargeperiod" => sub { |
113 |
subtest "suspension_chargeperiod" => sub { |
111 |
Koha::CirculationRules->set_rules( |
114 |
Koha::CirculationRules->set_rules( |
112 |
- |
|
|