Bugzilla – Attachment 74866 Details for
Bug 17015
New Koha Calendar
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17015: Updated patch after bug 19204
Bug-17015-Updated-patch-after-bug-19204.patch (text/plain), 9.19 KB, created by
David Bourgault
on 2018-04-25 20:26:50 UTC
(
hide
)
Description:
Bug 17015: Updated patch after bug 19204
Filename:
MIME Type:
Creator:
David Bourgault
Created:
2018-04-25 20:26:50 UTC
Size:
9.19 KB
patch
obsolete
>From 6ba23f113dc40e90cdef9e1e6a620ec2bb9ae06e Mon Sep 17 00:00:00 2001 >From: David Bourgault <dav.bour@gmail.com> >Date: Wed, 25 Apr 2018 16:15:42 -0400 >Subject: [PATCH] Bug 17015: Updated patch after bug 19204 > >This is a small modification to bring the patch up-to-date with current master after the changes made in 19204. Tests in db_dependent/Circulation.thave been changed slightly since DiscreteCalendar strictly prevents changing holidays in the past. This patch requires 20660. >--- > C4/Circulation.pm | 4 +-- > Koha/DiscreteCalendar.pm | 2 +- > t/db_dependent/Circulation.t | 74 +++++++++++++++++++++----------------------- > 3 files changed, 39 insertions(+), 41 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 191c2f1..5549bd5 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2250,10 +2250,10 @@ sub _debar_user_on_return { > my $new_debar_dt; > # Use the calendar or not to calculate the debarment date > if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) { >- my $calendar = Koha::Calendar->new( >+ my $calendar = Koha::DiscreteCalendar->new( { > branchcode => $branchcode, > days_mode => 'Calendar' >- ); >+ } ); > $new_debar_dt = $calendar->addDate( $return_date, $suspension_days ); > } > else { >diff --git a/Koha/DiscreteCalendar.pm b/Koha/DiscreteCalendar.pm >index 8dee776..1ea5b12 100644 >--- a/Koha/DiscreteCalendar.pm >+++ b/Koha/DiscreteCalendar.pm >@@ -90,7 +90,7 @@ sub new { > > sub _init { > my $self = shift; >- $self->{days_mode} = C4::Context->preference('useDaysMode'); >+ $self->{days_mode} ||= C4::Context->preference('useDaysMode'); > #If the branchcode doesn't exist we use the default calendar. > my $schema = Koha::Database->new->schema; > my $branchcode = $self->{branchcode}; >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 99d1ae0..04478e4 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -24,7 +24,6 @@ use POSIX qw( floor ); > use t::lib::Mocks; > use t::lib::TestBuilder; > >-use C4::Calendar; > use C4::Circulation; > use C4::Biblio; > use C4::Items; >@@ -34,6 +33,7 @@ use C4::Reserves; > use C4::Overdues qw(UpdateFine CalcFine); > use Koha::DateUtils; > use Koha::Database; >+use Koha::DiscreteCalendar; > use Koha::IssuingRules; > use Koha::Checkouts; > use Koha::Patrons; >@@ -1802,16 +1802,16 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > ); > $rule->store(); > >- my $five_days_ago = dt_from_string->subtract( days => 5 ); >+ my $in_five_days = dt_from_string->add( days => 5 ); > # We want to charge 2 days every day, without grace > # With 5 days of overdue: 5 * Z >- my $expected_expiration = dt_from_string->add( days => ( 5 * 2 ) / 1 ); >+ my $expected_expiration = dt_from_string->add( days => 5 + ( 5 * 2 ) / 1 ); > test_debarment_on_checkout( > { > item => $item_1, > library => $library, > patron => $patron, >- due_date => $five_days_ago, >+ return_date => $in_five_days, > expiration_date => $expected_expiration, > } > ); >@@ -1819,13 +1819,13 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > # We want to charge 2 days every 2 days, without grace > # With 5 days of overdue: (5 * 2) / 2 > $rule->suspension_chargeperiod(2)->store; >- $expected_expiration = dt_from_string->add( days => floor( 5 * 2 ) / 2 ); >+ $expected_expiration = dt_from_string->add( days => 5 + floor( 5 * 2 ) / 2 ); > test_debarment_on_checkout( > { > item => $item_1, > library => $library, > patron => $patron, >- due_date => $five_days_ago, >+ return_date => $in_five_days, > expiration_date => $expected_expiration, > } > ); >@@ -1834,13 +1834,13 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > # With 5 days of overdue: ((5-1) / 3 ) * 2 > $rule->suspension_chargeperiod(3)->store; > $rule->firstremind(1)->store; >- $expected_expiration = dt_from_string->add( days => floor( ( ( 5 - 1 ) / 3 ) * 2 ) ); >+ $expected_expiration = dt_from_string->add( days => 5 + floor( ( ( 5 - 1 ) / 3 ) * 2 ) ); > test_debarment_on_checkout( > { > item => $item_1, > library => $library, > patron => $patron, >- due_date => $five_days_ago, >+ return_date => $in_five_days, > expiration_date => $expected_expiration, > } > ); >@@ -1853,65 +1853,63 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > t::lib::Mocks::mock_preference('finesCalendar', 'noFinesWhenClosed'); > > # Adding a holiday 2 days ago >- my $calendar = C4::Calendar->new(branchcode => $library->{branchcode}); >- my $two_days_ago = dt_from_string->subtract( days => 2 ); >- $calendar->insert_single_holiday( >- day => $two_days_ago->day, >- month => $two_days_ago->month, >- year => $two_days_ago->year, >- title => 'holidayTest-2d', >- description => 'holidayDesc 2 days ago' >- ); >+ my $calendar = Koha::DiscreteCalendar->new( { branchcode => $library->{branchcode} } ); >+ my $in_two_days = dt_from_string->add( days => 2 ); >+ $calendar->edit_holiday( { >+ title => 'holidayTest+2d', >+ holiday_type => $Koha::DiscreteCalendar::HOLIDAYS->{EXCEPTION},, >+ start_date => $in_two_days, >+ end_date => $in_two_days, >+ } ); > # With 5 days of overdue, only 4 (x finedays=2) days must charged (one was an holiday) >- $expected_expiration = dt_from_string->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) ); >+ $expected_expiration = dt_from_string->add( days => 5 + floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) ); > test_debarment_on_checkout( > { > item => $item_1, > library => $library, > patron => $patron, >- due_date => $five_days_ago, >+ return_date => $in_five_days, > expiration_date => $expected_expiration, > } > ); > > # Adding a holiday 2 days ahead, with finesCalendar=noFinesWhenClosed it should be skipped >- my $two_days_ahead = dt_from_string->add( days => 2 ); >- $calendar->insert_single_holiday( >- day => $two_days_ahead->day, >- month => $two_days_ahead->month, >- year => $two_days_ahead->year, >- title => 'holidayTest+2d', >- description => 'holidayDesc 2 days ahead' >- ); >+ my $in_seven_days = dt_from_string->add( days => 7 ); >+ $calendar->edit_holiday( { >+ title => 'holidayTest+7d', >+ holiday_type => $Koha::DiscreteCalendar::HOLIDAYS->{EXCEPTION}, >+ start_date => $in_seven_days, >+ end_date => $in_seven_days, >+ } ); > > # Same as above, but we should skip D+2 >- $expected_expiration = dt_from_string->add( days => floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) + 1 ); >+ $expected_expiration = dt_from_string->add( days => 5 + floor( ( ( 5 - 0 - 1 ) / 1 ) * 2 ) + 1 ); > test_debarment_on_checkout( > { > item => $item_1, > library => $library, > patron => $patron, >- due_date => $five_days_ago, >+ return_date => $in_five_days, > expiration_date => $expected_expiration, > } > ); > > # Adding another holiday, day of expiration date > my $expected_expiration_dt = dt_from_string($expected_expiration); >- $calendar->insert_single_holiday( >- day => $expected_expiration_dt->day, >- month => $expected_expiration_dt->month, >- year => $expected_expiration_dt->year, >- title => 'holidayTest_exp', >- description => 'holidayDesc on expiration date' >- ); >+ $calendar->edit_holiday( { >+ title => 'holidayTest+expected_expiration', >+ holiday_type => $Koha::DiscreteCalendar::HOLIDAYS->{EXCEPTION}, >+ start_date => $expected_expiration_dt, >+ end_date => $expected_expiration_dt, >+ } ); >+ > # Expiration date will be the day after > test_debarment_on_checkout( > { > item => $item_1, > library => $library, > patron => $patron, >- due_date => $five_days_ago, >+ return_date => $in_five_days, > expiration_date => $expected_expiration_dt->clone->add( days => 1 ), > } > ); >@@ -1922,7 +1920,7 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > library => $library, > patron => $patron, > return_date => dt_from_string->add(days => 5), >- expiration_date => dt_from_string->add(days => 5 + (5 * 2 - 1) ), >+ expiration_date => dt_from_string->add(days => 5 + (5 * 2 - 1) + 1 ), # We add an extra +1 because of the holiday > } > ); > }; >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17015
:
53859
|
54318
|
54419
|
59166
|
59167
|
59168
|
59169
|
59170
|
59171
|
59267
|
59268
|
59269
|
59270
|
59271
|
59463
|
59516
|
59517
|
59518
|
59519
|
59520
|
59561
|
59562
|
59586
|
59587
|
59888
|
59889
|
60902
|
60903
|
60904
|
60905
|
60906
|
60986
|
61737
|
62375
|
62376
|
62380
|
63257
|
63282
|
63362
|
63363
|
63364
|
63365
|
63366
|
63367
|
64235
|
65073
|
65074
|
65075
|
65076
|
65077
|
67721
|
67722
|
67723
|
67724
|
67725
|
67879
|
67929
|
67930
|
67931
|
67932
|
67933
|
67934
|
68392
|
68393
|
68394
|
68395
|
68396
|
68397
|
71634
|
71635
|
71636
|
71637
|
71638
|
72890
|
73145
|
74859
|
74860
|
74861
|
74862
|
74863
|
74864
|
74865
|
74866
|
75444
|
75479
|
76594
|
77249
|
77250
|
77607
|
77608
|
77609
|
77610
|
77611
|
77612
|
77613
|
77770
|
77771
|
77772
|
77773
|
77774
|
79035
|
80523
|
80524
|
80525
|
80526
|
80527
|
80528
|
80529
|
80530
|
80531
|
80532
|
80533
|
80534
|
80535
|
83547
|
85394
|
85677
|
85678
|
85679
|
85680
|
85681
|
85682
|
85683
|
85684
|
85685
|
85686
|
85687
|
85688
|
85689
|
85690
|
85691
|
92595
|
92596
|
92597
|
92598
|
100079
|
110383
|
110384
|
110386
|
110387
|
110388
|
110389
|
113541
|
113905
|
115501
|
115502
|
115503
|
115504
|
115505
|
115506
|
115507
|
115508
|
115509
|
115510
|
115511
|
118554
|
118555
|
118556
|
118557
|
118558
|
118559
|
119095
|
119097
|
119099
|
119100
|
119101
|
119102
|
131619
|
131620
|
131621
|
131622
|
131623
|
131624
|
131625
|
131626
|
131634
|
131635
|
131636
|
131637
|
131638
|
131639
|
131640
|
131641
|
131667
|
132199
|
133596
|
133597
|
133598
|
133599
|
133600
|
133601
|
133602
|
133603
|
133604
|
133605
|
133678
|
137219
|
137220
|
137221
|
137222
|
137223
|
137224
|
137225
|
137226
|
137227
|
137228
|
137229
|
139378
|
139379
|
139380
|
139381
|
139382
|
139599
|
139600
|
139601
|
139602
|
139603
|
139851
|
140150
|
141176
|
144257
|
144258
|
144259
|
144260
|
144261
|
144262
|
144264
|
144268
|
144269
|
144270
|
144271
|
144272
|
144273
|
151438
|
151439
|
151440
|
151441
|
151442
|
151443
|
151444
|
151445
|
151446
|
151447
|
151448
|
151449
|
151450
|
156340
|
156341
|
156342
|
156343
|
156344
|
156345
|
156346
|
156347
|
156348
|
156349
|
156350
|
156351
|
156352
|
156353
|
156354
|
156355
|
157656
|
157657
|
157658
|
157659
|
157660
|
157661
|
157662
|
157663
|
157664
|
157665
|
157666
|
157667
|
157668
|
157669
|
157670
|
157671
|
157672
|
167805
|
167806
|
167807
|
167808
|
167809