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