Lines 53-61
my $dateexpiry = '2013-01-01';
Link Here
|
53 |
|
53 |
|
54 |
my $borrower = {categorycode => 'B', dateexpiry => $dateexpiry}; |
54 |
my $borrower = {categorycode => 'B', dateexpiry => $dateexpiry}; |
55 |
my $start_date = DateTime->new({year => 2013, month => 2, day => 9}); |
55 |
my $start_date = DateTime->new({year => 2013, month => 2, day => 9}); |
56 |
my $date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); |
56 |
my $date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); |
57 |
is($date, $dateexpiry . 'T23:59:00', 'date expiry'); |
57 |
is($date, $dateexpiry . 'T23:59:00', 'date expiry'); |
58 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); |
58 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type, 1 ); |
59 |
|
59 |
|
60 |
|
60 |
|
61 |
#Set syspref ReturnBeforeExpiry = 1 and useDaysMode != 'Days' |
61 |
#Set syspref ReturnBeforeExpiry = 1 and useDaysMode != 'Days' |
Lines 64-70
t::lib::Mocks::mock_preference('useDaysMode', 'noDays');
Link Here
|
64 |
|
64 |
|
65 |
$borrower = {categorycode => 'B', dateexpiry => $dateexpiry}; |
65 |
$borrower = {categorycode => 'B', dateexpiry => $dateexpiry}; |
66 |
$start_date = DateTime->new({year => 2013, month => 2, day => 9}); |
66 |
$start_date = DateTime->new({year => 2013, month => 2, day => 9}); |
67 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); |
67 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); |
68 |
is($date, $dateexpiry . 'T23:59:00', 'date expiry with useDaysMode to noDays'); |
68 |
is($date, $dateexpiry . 'T23:59:00', 'date expiry with useDaysMode to noDays'); |
69 |
|
69 |
|
70 |
# Let's add a special holiday on 2013-01-01. With ReturnBeforeExpiry and |
70 |
# Let's add a special holiday on 2013-01-01. With ReturnBeforeExpiry and |
Lines 77-83
$calendar->insert_single_holiday(
Link Here
|
77 |
title =>'holidayTest', |
77 |
title =>'holidayTest', |
78 |
description => 'holidayDesc' |
78 |
description => 'holidayDesc' |
79 |
); |
79 |
); |
80 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); |
80 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); |
81 |
is($date, '2012-12-31T23:59:00', 'date expiry should be 2013-01-01 -1 day'); |
81 |
is($date, '2012-12-31T23:59:00', 'date expiry should be 2013-01-01 -1 day'); |
82 |
$calendar->insert_single_holiday( |
82 |
$calendar->insert_single_holiday( |
83 |
day => 31, |
83 |
day => 31, |
Lines 86-96
$calendar->insert_single_holiday(
Link Here
|
86 |
title =>'holidayTest', |
86 |
title =>'holidayTest', |
87 |
description => 'holidayDesc' |
87 |
description => 'holidayDesc' |
88 |
); |
88 |
); |
89 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); |
89 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); |
90 |
is($date, '2012-12-30T23:59:00', 'date expiry should be 2013-01-01 -2 day'); |
90 |
is($date, '2012-12-30T23:59:00', 'date expiry should be 2013-01-01 -2 day'); |
91 |
|
91 |
|
92 |
|
92 |
|
93 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); |
93 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type, 1 ); |
94 |
|
94 |
|
95 |
|
95 |
|
96 |
#Set syspref ReturnBeforeExpiry = 0 and useDaysMode = 'Days' |
96 |
#Set syspref ReturnBeforeExpiry = 0 and useDaysMode = 'Days' |
Lines 99-108
t::lib::Mocks::mock_preference('useDaysMode', 'Days');
Link Here
|
99 |
|
99 |
|
100 |
$borrower = {categorycode => 'B', dateexpiry => $dateexpiry}; |
100 |
$borrower = {categorycode => 'B', dateexpiry => $dateexpiry}; |
101 |
$start_date = DateTime->new({year => 2013, month => 2, day => 9}); |
101 |
$start_date = DateTime->new({year => 2013, month => 2, day => 9}); |
102 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); |
102 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); |
103 |
is($date, '2013-02-' . (9 + $issuelength) . 'T23:59:00', "date expiry ( 9 + $issuelength )"); |
103 |
is($date, '2013-02-' . (9 + $issuelength) . 'T23:59:00', "date expiry ( 9 + $issuelength )"); |
104 |
|
104 |
|
105 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); |
105 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type, 1 ); |
106 |
is($date, '2013-02-' . (9 + $renewalperiod) . 'T23:59:00', "date expiry ( 9 + $renewalperiod )"); |
106 |
is($date, '2013-02-' . (9 + $renewalperiod) . 'T23:59:00', "date expiry ( 9 + $renewalperiod )"); |
107 |
|
107 |
|
108 |
|
108 |
|
Lines 116-125
t::lib::Mocks::mock_preference('ReturnBeforeExpiry', 0);
Link Here
|
116 |
t::lib::Mocks::mock_preference('useDaysMode', 'Dayweek'); |
116 |
t::lib::Mocks::mock_preference('useDaysMode', 'Dayweek'); |
117 |
|
117 |
|
118 |
# No closed day interfering, so we should get the regular due date |
118 |
# No closed day interfering, so we should get the regular due date |
119 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); |
119 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); |
120 |
is($date, '2013-02-' . (9 + $issuelength) . 'T23:59:00', "useDaysMode = Dayweek, no closed days, issue date expiry ( start + $issuelength )"); |
120 |
is($date, '2013-02-' . (9 + $issuelength) . 'T23:59:00', "useDaysMode = Dayweek, no closed days, issue date expiry ( start + $issuelength )"); |
121 |
|
121 |
|
122 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); |
122 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type, 1 ); |
123 |
is($date, '2013-02-' . (9 + $renewalperiod) . 'T23:59:00', "useDaysMode = Dayweek, no closed days, renewal date expiry ( start + $renewalperiod )"); |
123 |
is($date, '2013-02-' . (9 + $renewalperiod) . 'T23:59:00', "useDaysMode = Dayweek, no closed days, renewal date expiry ( start + $renewalperiod )"); |
124 |
|
124 |
|
125 |
# Now let's add a closed day on the expected renewal date, it should |
125 |
# Now let's add a closed day on the expected renewal date, it should |
Lines 132-138
$calendar->insert_single_holiday(
Link Here
|
132 |
title =>'DayweekTest1', |
132 |
title =>'DayweekTest1', |
133 |
description => 'DayweekTest1' |
133 |
description => 'DayweekTest1' |
134 |
); |
134 |
); |
135 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower ); |
135 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type ); |
136 |
is($date, '2013-02-' . (9 + $issuelength + 1) . 'T23:59:00', "useDaysMode = Dayweek, closed on due date, 10 day loan (should not trigger 7 day roll forward), issue date expiry ( start + $issuelength + 1 )"); |
136 |
is($date, '2013-02-' . (9 + $issuelength + 1) . 'T23:59:00', "useDaysMode = Dayweek, closed on due date, 10 day loan (should not trigger 7 day roll forward), issue date expiry ( start + $issuelength + 1 )"); |
137 |
# Remove the holiday we just created |
137 |
# Remove the holiday we just created |
138 |
$calendar->delete_holiday( |
138 |
$calendar->delete_holiday( |
Lines 149-155
$calendar->insert_single_holiday(
Link Here
|
149 |
title =>'DayweekTest2', |
149 |
title =>'DayweekTest2', |
150 |
description => 'DayweekTest2' |
150 |
description => 'DayweekTest2' |
151 |
); |
151 |
); |
152 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, 1 ); |
152 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $borrower, $checkout_type, 1 ); |
153 |
is($date, '2013-02-' . (9 + $renewalperiod + 1) . 'T23:59:00', "useDaysMode = Dayweek, closed on due date, 5 day renewal (should not trigger 7 day roll forward), renewal date expiry ( start + $renewalperiod + 1 )"); |
153 |
is($date, '2013-02-' . (9 + $renewalperiod + 1) . 'T23:59:00', "useDaysMode = Dayweek, closed on due date, 5 day renewal (should not trigger 7 day roll forward), renewal date expiry ( start + $renewalperiod + 1 )"); |
154 |
# Remove the holiday we just created |
154 |
# Remove the holiday we just created |
155 |
$calendar->delete_holiday( |
155 |
$calendar->delete_holiday( |
Lines 192-198
$calendar->insert_single_holiday(
Link Here
|
192 |
title =>'DayweekTest3', |
192 |
title =>'DayweekTest3', |
193 |
description => 'DayweekTest3' |
193 |
description => 'DayweekTest3' |
194 |
); |
194 |
); |
195 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower ); |
195 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, $checkout_type ); |
196 |
my $issue_should_add = $dayweek_issuelength + 7; |
196 |
my $issue_should_add = $dayweek_issuelength + 7; |
197 |
my $dayweek_issue_expected = $start_date->add( days => $issue_should_add ); |
197 |
my $dayweek_issue_expected = $start_date->add( days => $issue_should_add ); |
198 |
is($date, $dayweek_issue_expected->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, closed on due date, 14 day loan (should trigger 7 day roll forward), issue date expiry ( start + $issue_should_add )"); |
198 |
is($date, $dayweek_issue_expected->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, closed on due date, 14 day loan (should trigger 7 day roll forward), issue date expiry ( start + $issue_should_add )"); |
Lines 212-218
$calendar->insert_single_holiday(
Link Here
|
212 |
title => 'DayweekTest4', |
212 |
title => 'DayweekTest4', |
213 |
description => 'DayweekTest4' |
213 |
description => 'DayweekTest4' |
214 |
); |
214 |
); |
215 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, 1 ); |
215 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, $checkout_type, 1 ); |
216 |
my $renewal_should_add = $dayweek_renewalperiod + 7; |
216 |
my $renewal_should_add = $dayweek_renewalperiod + 7; |
217 |
my $dayweek_renewal_expected = $start_date->add( days => $renewal_should_add ); |
217 |
my $dayweek_renewal_expected = $start_date->add( days => $renewal_should_add ); |
218 |
is($date, $dayweek_renewal_expected->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, closed on due date, 7 day renewal (should trigger 7 day roll forward), renewal date expiry ( start + $renewal_should_add )"); |
218 |
is($date, $dayweek_renewal_expected->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, closed on due date, 7 day renewal (should trigger 7 day roll forward), renewal date expiry ( start + $renewal_should_add )"); |
Lines 253-264
$calendar->insert_single_holiday(
Link Here
|
253 |
description => 'DayweekTest7' |
253 |
description => 'DayweekTest7' |
254 |
); |
254 |
); |
255 |
# For issues... |
255 |
# For issues... |
256 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower ); |
256 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, $checkout_type ); |
257 |
$dayweek_issue_expected = $start_date->add( days => $issue_should_add ); |
257 |
$dayweek_issue_expected = $start_date->add( days => $issue_should_add ); |
258 |
is($date, $expected_rolled_date->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, closed on due date and two subequent due dates, 14 day loan (should trigger 2 x 7 day roll forward), issue date expiry ( start + 28 )"); |
258 |
is($date, $expected_rolled_date->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, closed on due date and two subequent due dates, 14 day loan (should trigger 2 x 7 day roll forward), issue date expiry ( start + 28 )"); |
259 |
# ...and for renewals... |
259 |
# ...and for renewals... |
260 |
$start_date = DateTime->new({year => 2013, month => 2, day => 9}); |
260 |
$start_date = DateTime->new({year => 2013, month => 2, day => 9}); |
261 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, 1 ); |
261 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, $checkout_type, 1 ); |
262 |
$dayweek_issue_expected = $start_date->add( days => $renewal_should_add ); |
262 |
$dayweek_issue_expected = $start_date->add( days => $renewal_should_add ); |
263 |
is($date, $expected_rolled_date->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, closed on due date and three subsequent due dates, 7 day renewal (should trigger 3 x 7 day roll forward), issue date expiry ( start + 28 )"); |
263 |
is($date, $expected_rolled_date->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, closed on due date and three subsequent due dates, 7 day renewal (should trigger 3 x 7 day roll forward), issue date expiry ( start + 28 )"); |
264 |
# Remove the holidays we just created |
264 |
# Remove the holidays we just created |
Lines 293-304
$calendar->insert_week_day_holiday(
Link Here
|
293 |
description => "Closed on Saturdays" |
293 |
description => "Closed on Saturdays" |
294 |
); |
294 |
); |
295 |
# For issues... |
295 |
# For issues... |
296 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower ); |
296 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, $checkout_type ); |
297 |
$dayweek_issue_expected = $start_date->add( days => $dayweek_issuelength + 1 ); |
297 |
$dayweek_issue_expected = $start_date->add( days => $dayweek_issuelength + 1 ); |
298 |
is($date, $dayweek_issue_expected->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, due on Saturday, closed on Saturdays, 14 day loan (should trigger 1 day roll forward), issue date expiry ( start + 15 )"); |
298 |
is($date, $dayweek_issue_expected->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, due on Saturday, closed on Saturdays, 14 day loan (should trigger 1 day roll forward), issue date expiry ( start + 15 )"); |
299 |
# ...and for renewals... |
299 |
# ...and for renewals... |
300 |
$start_date = DateTime->new({year => 2013, month => 2, day => 9}); |
300 |
$start_date = DateTime->new({year => 2013, month => 2, day => 9}); |
301 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, 1 ); |
301 |
$date = C4::Circulation::CalcDateDue( $start_date, $itemtype, $branchcode, $dayweek_borrower, $checkout_type, 1 ); |
302 |
$dayweek_renewal_expected = $start_date->add( days => $dayweek_renewalperiod + 1 ); |
302 |
$dayweek_renewal_expected = $start_date->add( days => $dayweek_renewalperiod + 1 ); |
303 |
is($date, $dayweek_renewal_expected->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, due on Saturday, closed on Saturdays, 7 day renewal (should trigger 1 day roll forward), issue date expiry ( start + 8 )"); |
303 |
is($date, $dayweek_renewal_expected->strftime('%F') . 'T23:59:00', "useDaysMode = Dayweek, due on Saturday, closed on Saturdays, 7 day renewal (should trigger 1 day roll forward), issue date expiry ( start + 8 )"); |
304 |
# Remove the holiday we just created |
304 |
# Remove the holiday we just created |