Bugzilla – Attachment 172635 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: Add support for incrementable circulation rules
Bug-10190-Add-support-for-incrementable-circulatio.patch (text/plain), 5.33 KB, created by
Martin Renvoize (ashimema)
on 2024-10-10 16:19:45 UTC
(
hide
)
Description:
Bug 10190: Add support for incrementable circulation rules
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-10-10 16:19:45 UTC
Size:
5.33 KB
patch
obsolete
>From a40796cac12765f92083f78a4b47e4ed94f7824e Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 7 Aug 2024 17:15:28 +0100 >Subject: [PATCH] Bug 10190: Add support for incrementable circulation rules > >This patch adds support for _X_ grouped circulation rules to both the >internal and external API's for handling circulation rules. > >This allows us to group overdue_X_rulename rules by an 'X' integer so we >can have triggers incremented and grouped together. > >We also add the new overdue_x_* rule definition here for overdue trigger >rules. > >Sponsored-by: Glasgow Colleges Library Group <https://library.cityofglasgowcollege.ac.uk> >Signed-off-by: George Harkins <George.Harkins@cityofglasgowcollege.ac.uk> >--- > Koha/CirculationRules.pm | 19 +++++++++- > Koha/REST/V1/CirculationRules.pm | 65 ++++++++++++++++++++++++++++---- > 2 files changed, 76 insertions(+), 8 deletions(-) > >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index c45d2ccc5aa..55993c56ad0 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -169,6 +169,22 @@ our $RULE_KINDS = { > is_monetary => 1, > can_be_blank => 1, > }, >+ overdue_X_delay => { >+ scope => [ 'branchcode', 'categorycode', 'itemtype' ], >+ can_be_blank => 0, >+ }, >+ overdue_X_mtt => { >+ scope => [ 'branchcode', 'categorycode', 'itemtype' ], >+ can_be_blank => 1, >+ }, >+ overdue_X_notice => { >+ scope => [ 'branchcode', 'categorycode', 'itemtype' ], >+ can_be_blank => 1, >+ }, >+ overdue_X_restrict => { >+ scope => [ 'branchcode', 'categorycode', 'itemtype' ], >+ can_be_blank => 0, >+ }, > renewalperiod => { > scope => [ 'branchcode', 'categorycode', 'itemtype' ], > }, >@@ -371,7 +387,8 @@ sub set_rule { > unless exists $params->{$mandatory_parameter}; > } > >- my $kind_info = $RULE_KINDS->{ $params->{rule_name} }; >+ ( my $rule_key = $params->{rule_name} ) =~ s/_\d_/_X_/; >+ my $kind_info = $RULE_KINDS->{$rule_key}; > Koha::Exceptions::MissingParameter->throw( > "set_rule given unknown rule '$params->{rule_name}'!") > unless defined $kind_info; >diff --git a/Koha/REST/V1/CirculationRules.pm b/Koha/REST/V1/CirculationRules.pm >index 74c54b813d6..0c927feebe9 100644 >--- a/Koha/REST/V1/CirculationRules.pm >+++ b/Koha/REST/V1/CirculationRules.pm >@@ -50,11 +50,7 @@ sub list_rules { > my $c = shift->openapi->valid_input or return; > > return try { >- my $effective = $c->param('effective') // 1; >- my $kinds = >- defined( $c->param('rules') ) >- ? [ split /\s*,\s*/, $c->param('rules') ] >- : [ keys %{ Koha::CirculationRules->rule_kinds } ]; >+ my $effective = $c->param('effective') // 1; > my $item_type = $c->param('item_type_id'); > my $branchcode = $c->param('library_id'); > my $patron_category = $c->param('patron_category_id'); >@@ -114,6 +110,26 @@ sub list_rules { > } > } > >+ my $kinds; >+ if ( defined( $c->param('rules') ) ) { >+ $kinds = [ split /\s*,\s*/, $c->param('rules') ]; >+ my $valid_kinds = Koha::CirculationRules->rule_kinds; >+ for my $rule ( @{$kinds} ) { >+ ( my $rule_key = $rule ) =~ s/_\d_/_X_/; >+ return $c->render_invalid_parameter_value( >+ { >+ path => '/query/rules', >+ values => { >+ uri => '/api/v1/kinds', >+ field => 'rule_name' >+ } >+ } >+ ) unless $valid_kinds->{$rule_key}; >+ } >+ } else { >+ $kinds = _all_kinds(); >+ } >+ > my $rules; > if ($effective) { > >@@ -125,7 +141,7 @@ sub list_rules { > rules => $kinds > } > ) // {}; >- my $return; >+ my $return = {}; > for my $kind ( @{$kinds} ) { > $return->{$kind} = $effective_rules->{$kind}; > } >@@ -155,7 +171,6 @@ sub list_rules { > order_by => [ 'branchcode', 'categorycode', 'itemtype' ], > } > )->unblessed; >- > } > > # Map context into rules >@@ -265,4 +280,40 @@ sub set_rules { > } > } > >+=head3 _all_kinds >+ >+Utility function to get a list of all valid rule kinds including those that are repeatable >+ >+=cut >+ >+sub _all_kinds { >+ my @all_valid_kinds; >+ my @distinct_kinds = Koha::CirculationRules->search( >+ {}, >+ { >+ columns => ['rule_name'], >+ distinct => 1, >+ } >+ )->get_column('rule_name'); >+ >+ my %seen; >+ my $valid_kinds = Koha::CirculationRules->rule_kinds; >+ for my $kind (@distinct_kinds) { >+ ( my $kind_key = $kind ) =~ s/_\d_/_X_/; >+ if ( exists $valid_kinds->{$kind_key} && !$seen{$kind} ) { >+ push @all_valid_kinds, $kind; >+ $seen{$kind} = 1; >+ } >+ } >+ >+ # Add in any unset but valid rules >+ for my $valid_kind ( keys %{$valid_kinds} ) { >+ if ( $valid_kind !~ /_X_/ && !$seen{$valid_kind} ) { >+ push @all_valid_kinds, $valid_kind; >+ $seen{$valid_kind} = 1; >+ } >+ } >+ return \@all_valid_kinds; >+} >+ > 1; >-- >2.47.0
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