Bugzilla – Attachment 7487 Details for
Bug 7420
Add max fines to circulation matrix
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
bug_7420: Added overduefinescap to issuingrules
bug7420-Added-overduefinescap-to-issuingrules.patch (text/plain), 12.78 KB, created by
Kyle M Hall
on 2012-02-07 17:40:54 UTC
(
hide
)
Description:
bug_7420: Added overduefinescap to issuingrules
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2012-02-07 17:40:54 UTC
Size:
12.78 KB
patch
obsolete
>From 531e60c0394ac5b24e170844019fb8a5156d31e0 Mon Sep 17 00:00:00 2001 >From: Srdjan Jankovic <srdjan@catalyst.net.nz> >Date: Tue, 7 Feb 2012 12:36:19 -0500 >Subject: [PATCH] bug_7420: Added overduefinescap to issuingrules > >Replaced existing MaxFine syspref logic with overduefinescap. >Repurposed MaxFine to be the overall overdue limit for all items >overdue. Implemented new MaxFine logic in UpdateFine(). > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Patch didn't apply cleanly to updatadatabase, simple fix. > >http://bugs.koha-community.org/show_bug.cgi?id=7287 >--- > C4/Overdues.pm | 35 ++++++++++++++++---- > admin/smart-rules.pl | 9 +++-- > installer/data/mysql/kohastructure.sql | 1 + > installer/data/mysql/sysprefs.sql | 2 +- > installer/data/mysql/updatedatabase.pl | 23 +++++++++++++ > .../prog/en/modules/admin/preferences/patrons.pref | 3 +- > .../prog/en/modules/admin/smart-rules.tt | 3 ++ > 7 files changed, 63 insertions(+), 13 deletions(-) > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 660e10b..03192c0 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -298,7 +298,7 @@ sub CalcFine { > } else { > # a zero (or null) chargeperiod means no charge. > } >- $amount = C4::Context->preference('maxFine') if(C4::Context->preference('maxFine') && ( $amount > C4::Context->preference('maxFine'))); >+ $amount = $data->{overduefinescap} if $data->{overduefinescap} && $amount > $data->{overduefinescap}; > $debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $data->{'chargename'}, $days_minus_grace, $daystocharge); > return ($amount, $data->{'chargename'}, $days_minus_grace, $daystocharge); > # FIXME: chargename is NEVER populated anywhere. >@@ -508,14 +508,35 @@ sub UpdateFine { > # "REF" is Cash Refund > my $sth = $dbh->prepare( > "SELECT * FROM accountlines >- WHERE itemnumber=? >- AND borrowernumber=? >- AND accounttype IN ('FU','O','F','M') >- AND description like ? " >+ WHERE borrowernumber=? >+ AND accounttype IN ('FU','O','F','M')" > ); >- $sth->execute( $itemnum, $borrowernumber, "%$due%" ); >+ $sth->execute( $borrowernumber ); >+ my $data; >+ my $total_amount_other = 0.00; >+ my $due_qr = qr/$due/; >+ while (my $rec = $sth->fetchrow_hashref) { >+ if ($rec->{itemnumber} == $itemnum && $rec->{description} =~ /$due_qr/) { >+ if ($data) { >+ warn "Not a unique accountlines record for item $itemnum borrower $borrowernumber"; >+ } else { >+ $data = $rec; >+ next; >+ } >+ } >+ $total_amount_other += $rec->{'amount'}; >+ } >+ if (my $maxfine = C4::Context->preference('MaxFine')) { >+ if ($total_amount_other + $amount > $maxfine) { >+ my $new_amount = $maxfine - $total_amount_other; >+ warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached"; >+ return if $new_amount <= 0.00; >+ >+ $amount = $new_amount; >+ } >+ } > >- if ( my $data = $sth->fetchrow_hashref ) { >+ if ( $data ) { > > # we're updating an existing fine. Only modify if amount changed > # Note that in the current implementation, you cannot pay against an accruing fine >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index f290934..dc6bb52 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -101,8 +101,8 @@ elsif ($op eq 'delete-branch-item') { > # save the values entered > elsif ($op eq 'add') { > my $sth_search = $dbh->prepare("SELECT COUNT(*) AS total FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?"); >- my $sth_insert = $dbh->prepare("INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, renewalsallowed, reservesallowed, issuelength, hardduedate, hardduedatecompare, fine, finedays, firstremind, chargeperiod,rentaldiscount) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); >- my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, finedays=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, reservesallowed=?, issuelength=?, hardduedate=?, hardduedatecompare=?, rentaldiscount=? WHERE branchcode=? AND categorycode=? AND itemtype=?"); >+ my $sth_insert = $dbh->prepare("INSERT INTO issuingrules (branchcode, categorycode, itemtype, maxissueqty, renewalsallowed, reservesallowed, issuelength, hardduedate, hardduedatecompare, fine, finedays, firstremind, chargeperiod,rentaldiscount,overduefinescap) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); >+ my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, finedays=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, reservesallowed=?, issuelength=?, hardduedate=?, hardduedatecompare=?, rentaldiscount=?, overduefinescap=? WHERE branchcode=? AND categorycode=? AND itemtype=?"); > > my $br = $branch; # branch > my $bor = $input->param('categorycode'); # borrower category >@@ -121,14 +121,15 @@ elsif ($op eq 'add') { > $hardduedate = format_date_in_iso($hardduedate); > my $hardduedatecompare = $input->param('hardduedatecompare'); > my $rentaldiscount = $input->param('rentaldiscount'); >+ my $overduefinescap = $input->param('overduefinescap') || undef; > $debug and warn "Adding $br, $bor, $cat, $fine, $maxissueqty"; > > $sth_search->execute($br,$bor,$cat); > my $res = $sth_search->fetchrow_hashref(); > if ($res->{total}) { >- $sth_update->execute($fine, $finedays,$firstremind, $chargeperiod, $maxissueqty, $renewalsallowed,$reservesallowed, $issuelength,$hardduedate,$hardduedatecompare,$rentaldiscount, $br,$bor,$cat); >+ $sth_update->execute($fine, $finedays,$firstremind, $chargeperiod, $maxissueqty, $renewalsallowed,$reservesallowed, $issuelength,$hardduedate,$hardduedatecompare,$rentaldiscount,$overduefinescap, $br,$bor,$cat); > } else { >- $sth_insert->execute($br,$bor,$cat,$maxissueqty,$renewalsallowed,$reservesallowed,$issuelength,$hardduedate,$hardduedatecompare,$fine,$finedays,$firstremind,$chargeperiod,$rentaldiscount); >+ $sth_insert->execute($br,$bor,$cat,$maxissueqty,$renewalsallowed,$reservesallowed,$issuelength,$hardduedate,$hardduedatecompare,$fine,$finedays,$firstremind,$chargeperiod,$rentaldiscount,$overduefinescap); > } > } > elsif ($op eq "set-branch-defaults") { >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 37113c2..124db80 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -988,6 +988,7 @@ CREATE TABLE `issuingrules` ( > `renewalsallowed` smallint(6) NOT NULL default "0", > `reservesallowed` smallint(6) NOT NULL default "0", > `branchcode` varchar(10) NOT NULL default '', >+ overduefinescap decimal default NULL, > PRIMARY KEY (`branchcode`,`categorycode`,`itemtype`), > KEY `categorycode` (`categorycode`), > KEY `itemtype` (`itemtype`) >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 5e3d79d..c0d4a95 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -62,7 +62,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES > -- this is selected by the web installer now > -- INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('marcflavour','MARC21','Define global MARC flavor (MARC21 or UNIMARC) used for character encoding','MARC21|UNIMARC','Choice'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MARCOrgCode','OSt','Define MARC Organization Code - http://www.loc.gov/marc/organizations/orgshome.html','','free'); >-INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MaxFine',9999,'Maximum fine a patron can have for a single late return','','Integer'); >+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('MAXFINE',NULL,'Maximum fine a patron can have for all late returns at one moment. Single item caps are specified in the circulation rules matrix.','','Integer'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxoutstanding',5,'maximum amount withstanding to be able make holds','','Integer'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxreserves',50,'Define maximum number of holds a patron can place','','Integer'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('maxItemsInSearchResults',20,'Specify the maximum number of items to display for each result on a page of results',NULL,'free'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 099dfb9..c1da427 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -4663,6 +4663,29 @@ ENDOFRENEWAL > print "Upgrade to $DBversion done (Added a system preference to allow renewal of Patron account either from todays date or from existing expiry date in the patrons account.)\n"; > SetVersion($DBversion); > } >+ >+###### XXX space ######## >+# This is an attempt to make .XXX versions mergeable with master version >+# Please keep new XXX patches between XXX space markers >+# Master submitters: when making a real version, please push patch outside >+# (above) the markers and leave the markers with this instructions in the file >+ >+$DBversion = '3.07.00.XXX'; >+if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >+ $dbh->do("ALTER TABLE issuingrules ADD overduefinescap decimal DEFAULT NULL"); >+ my $maxfine = C4::Context->preference('MaxFine'); >+ if ($maxfine && $maxfine < 900) { # an arbitrary value that tells us it's not "some huge value" >+ $dbh->do("UPDATE issuingrules SET overduefinescap=?",undef,$maxfine); >+ $dbh->do("UPDATE systempreferences SET value = NULL WHERE variable = 'MaxFine'"); >+ } >+ $dbh->do("UPDATE systempreferences SET explanation = 'Maximum fine a patron can have for all late returns at one moment. Single item caps are specified in the circulation rules matrix.' WHERE variable = 'MaxFine'"); >+ print "Upgrade to $DBversion done (Bug 7420 add overduefinescap to circulation matrix)\n"; >+ SetVersion ($DBversion); >+} >+ >+###### XXX space ######## >+ >+ > =head1 FUNCTIONS > > =head2 DropAllForeignKeys($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >index 3d88883..a438435 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref >@@ -73,10 +73,11 @@ Patrons: > no: "Don't allow" > - "staff to access a patron's checkout history (it is stored regardless)." > - >- - The late fine for a specific checkout will only go up to >+ - The late fine for all checkouts will only go up to > - pref: MaxFine > class: currency > - '[% local_currency %].' >+ - Empty value means no limit. Single item caps are specified in the circulation rules matrix. > - > - pref: memberofinstitution > choices: >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index d2f314f..28a6b61 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -77,6 +77,7 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde > <th>Fine Amount</th> > <th>Fine Charging Interval</th> > <th>Fine Grace period (day)</th> >+ <th>Overdue Fines Cap ($)</th> > <th>Suspension in Days (day)</th> > <th>Renewals Allowed (count)</th> > <th>Holds Allowed (count)</th> >@@ -118,6 +119,7 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde > <td>[% rule.fine %]</td> > <td>[% rule.chargeperiod %]</td> > <td>[% rule.firstremind %]</td> >+ <td>[% rule.overduefinescap FILTER format("%.2f") %]</td> > <td>[% rule.finedays %]</td> > <td>[% rule.renewalsallowed %]</td> > <td>[% rule.reservesallowed %]</td> >@@ -172,6 +174,7 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde > <td><input name="fine" size="4" /></td> > <td><input name="chargeperiod" size="2" /></td> > <td><input name="firstremind" size="2" /> </td> >+ <td><input name="overduefinescap" size="6" /> </td> > <td><input name="finedays" size="3" /> </td> > <td><input name="renewalsallowed" size="2" /></td> > <td><input name="reservesallowed" size="2" /></td> >-- >1.7.2.5
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 7420
:
7106
|
7287
|
7487
|
7489
|
7491
|
7782
|
8327
|
8748
|
8749
|
9469
|
9853
|
10772
|
11083