Bugzilla – Attachment 178653 Details for
Bug 10190
Overdue notice triggers based on item type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10190: Update GetBranchcodesWithOverdueRules to use CirculationRules
Bug-10190-Update-GetBranchcodesWithOverdueRules-to.patch (text/plain), 5.14 KB, created by
Martin Renvoize (ashimema)
on 2025-02-25 11:57:29 UTC
(
hide
)
Description:
Bug 10190: Update GetBranchcodesWithOverdueRules to use CirculationRules
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-02-25 11:57:29 UTC
Size:
5.14 KB
patch
obsolete
>From 0c74b730568ff9450d41ffdfb0afb6da22e70671 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 8 Aug 2024 10:34:22 +0100 >Subject: [PATCH] Bug 10190: Update GetBranchcodesWithOverdueRules to use > CirculationRules > >This patch updates the C4::Overdues method >GetBranchecodesWithOverdueRules to refer to the new location of these >rules in the circulation rules table. We also update the unit tests to >move the mocked data into the right location. > >We could perhaps migrate this method in Koha::CirculationRules at a >later date? > >Sponsored-by: Glasgow Colleges Library Group <https://library.cityofglasgowcollege.ac.uk> >Signed-off-by: George Harkins <George.Harkins@cityofglasgowcollege.ac.uk> >--- > C4/Overdues.pm | 26 ++++++++++++-------------- > t/db_dependent/Overdues.t | 32 ++++++++++++++++---------------- > 2 files changed, 28 insertions(+), 30 deletions(-) > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 4d6e50f27a8..fe4d9b46d82 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -687,21 +687,19 @@ returns a list of branch codes for branches with overdue rules defined. > =cut > > sub GetBranchcodesWithOverdueRules { >- my $dbh = C4::Context->dbh; >- my $branchcodes = $dbh->selectcol_arrayref( >- q| >- SELECT DISTINCT(branchcode) >- FROM overduerules >- WHERE delay1 IS NOT NULL >- ORDER BY branchcode >- | >- ); >- if ( defined $branchcodes->[0] && $branchcodes->[0] eq '' ) { >- >- # If a default rule exists, all branches should be returned >- return Koha::Libraries->search( {}, { order_by => 'branchname' } )->get_column('branchcode'); >+ my @branchcodes = Koha::CirculationRules->search( >+ { rule_name => 'overdue_1_delay' }, >+ { >+ order_by => 'branchcode', >+ columns => ['branchcode'], >+ distinct => 1, >+ } >+ )->get_column('branchcode'); >+ if ( !$branchcodes[0] ) { >+ @branchcodes = Koha::Libraries->search( {}, { order_by => 'branchname' } )->get_column('branchcode'); > } >- return @$branchcodes; >+ >+ return @branchcodes; > } > > =head2 GetOverduesForBranch >diff --git a/t/db_dependent/Overdues.t b/t/db_dependent/Overdues.t >index 979f378a25f..a656b95ff0e 100755 >--- a/t/db_dependent/Overdues.t >+++ b/t/db_dependent/Overdues.t >@@ -95,7 +95,7 @@ is_deeply( > ); > > # Test GetBranchcodesWithOverdueRules >-$dbh->do(q|DELETE FROM overduerules|); >+$dbh->do(q|DELETE FROM circulation_rules WHERE rule_name LIKE 'overdue_%' |); > > my @overdue_branches; > warnings_are { @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); } [], >@@ -103,10 +103,10 @@ warnings_are { @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules( > > $dbh->do( > q| >- INSERT INTO overduerules >- ( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) >+ INSERT INTO circulation_rules >+ ( branchcode, categorycode, itemtype, rule_name, rule_value ) > VALUES >- ( '', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) >+ ( NULL, NULL, NULL, 'overdue_1_delay', 1 ) > | > ); > >@@ -120,10 +120,10 @@ is_deeply( > > $dbh->do( > q| >- INSERT INTO overduerules >- ( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) >+ INSERT INTO circulation_rules >+ ( branchcode, categorycode, itemtype, rule_name, rule_value ) > VALUES >- ( 'CPL', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) >+ ( 'CPL', NULL, NULL, 'overdue_1_delay', 1 ) > | > ); > >@@ -133,27 +133,27 @@ is_deeply( > 'If a default rule exists and a specific rule exists, all branches should be returned' > ); > >-$dbh->do(q|DELETE FROM overduerules|); >+$dbh->do(q|DELETE FROM circulation_rules WHERE rule_name LIKE 'overdue_%' |); > $dbh->do( > q| >- INSERT INTO overduerules >- ( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) >+ INSERT INTO circulation_rules >+ ( branchcode, categorycode, itemtype, rule_name, rule_value ) > VALUES >- ( 'CPL', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) >+ ( 'CPL', NULL, NULL, 'overdue_1_delay', 1 ) > | > ); > > @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); > is_deeply( \@overdue_branches, ['CPL'], 'If only a specific rule exist, only 1 branch should be returned' ); > >-$dbh->do(q|DELETE FROM overduerules|); >+$dbh->do(q|DELETE FROM circulation_rules WHERE rule_name LIKE 'overdue_%' |); > $dbh->do( > q| >- INSERT INTO overduerules >- ( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) >+ INSERT INTO circulation_rules >+ ( branchcode, categorycode, itemtype, rule_name, rule_value ) > VALUES >- ( 'CPL', '', 1, 'LETTER_CODE1_CPL', 1, 5, 'LETTER_CODE2_CPL', 1, 10, 'LETTER_CODE3_CPL', 1 ), >- ( 'MPL', '', 1, 'LETTER_CODE1_MPL', 1, 5, 'LETTER_CODE2_MPL', 1, 10, 'LETTER_CODE3_MPL', 1 ) >+ ( 'CPL', NULL, NULL, 'overdue_1_delay', 1 ), >+ ( 'MPL', NULL, NULL, 'overdue_1_delay', 1 ) > | > ); > >-- >2.48.1
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 10190
:
170357
|
170358
|
170359
|
170360
|
170361
|
170362
|
170363
|
170364
|
170365
|
170366
|
170367
|
170368
|
170369
|
170370
|
170371
|
170372
|
170373
|
170374
|
170375
|
170376
|
170380
|
170449
|
171727
|
171728
|
171729
|
171730
|
171731
|
171732
|
171733
|
171734
|
171735
|
171736
|
171737
|
171738
|
171739
|
171740
|
171741
|
171742
|
171743
|
171744
|
171745
|
171746
|
171747
|
171748
|
171749
|
171750
|
171751
|
171752
|
171753
|
171754
|
171755
|
172588
|
172589
|
172590
|
172591
|
172592
|
172593
|
172594
|
172595
|
172596
|
172597
|
172598
|
172599
|
172600
|
172601
|
172602
|
172603
|
172604
|
172605
|
172606
|
172607
|
172608
|
172609
|
172612
|
172614
|
172617
|
172619
|
172621
|
172622
|
172623
|
172624
|
172625
|
172626
|
172630
|
172631
|
172632
|
172633
|
172634
|
172635
|
172636
|
172637
|
172638
|
172639
|
172640
|
172641
|
172642
|
172643
|
172644
|
172645
|
172646
|
172647
|
172648
|
172649
|
172650
|
172651
|
172652
|
172653
|
172654
|
172655
|
172656
|
172657
|
172658
|
172659
|
172660
|
172661
|
172662
|
172663
|
178643
|
178644
|
178645
|
178646
|
178647
|
178648
|
178649
|
178650
|
178651
|
178652
| 178653 |
178654
|
178655
|
178656
|
178657
|
178658
|
178659
|
178660
|
178661
|
178662
|
178663
|
178664
|
178665
|
178666
|
178667
|
178668
|
178669
|
178670
|
178671
|
178672
|
178673
|
178674
|
178675