Bugzilla – Attachment 23305 Details for
Bug 9129
Add the ability to set the maximum fine for an item to its replacement price
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9129 - Add the ability to set the maximum fine for an item to its replacement price
Bug-9129---Add-the-ability-to-set-the-maximum-fine.patch (text/plain), 13.35 KB, created by
Kyle M Hall (khall)
on 2013-12-04 17:28:58 UTC
(
hide
)
Description:
Bug 9129 - Add the ability to set the maximum fine for an item to its replacement price
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-12-04 17:28:58 UTC
Size:
13.35 KB
patch
obsolete
>From 10d0d6d1acf87446888c02b42777c4899254ed93 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 4 Jun 2013 11:37:15 -0400 >Subject: [PATCH] Bug 9129 - Add the ability to set the maximum fine for an item to its replacement price > >This patch adds the ability to set the maximum fine for a given item to >its replacement price ( assuming the replacement price is set ). If >overduefinescap is also set, the fine will be the lesser of the two, if >both apply to the given overdue checkout. > >To enable this new limit, create or edit your circulation rules and >check the checkbox for "Cap fines at replacement price" > >Test Plan: >1) Apply this patch >2) Run updatedatabase.pl >3) Pick an item, and set it's replacement price to 3.99 >4) Edit the circulation rule that would apply to this item > and the patron you will check it out to. >5) Check out the item to the patron, and backdate the due date > such that the fine generated would be more than 3.99 >6) Enable CalculateFinesOnReturn >7) Return the item, and view the fine generated, it should be 3.99 >--- > C4/Overdues.pm | 1 + > admin/smart-rules.pl | 78 ++++++++++++++++++-- > installer/data/mysql/kohastructure.sql | 1 + > installer/data/mysql/updatedatabase.pl | 9 ++ > .../prog/en/modules/admin/smart-rules.tt | 40 +++++++--- > 5 files changed, 111 insertions(+), 18 deletions(-) > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 33dbd98..7e4a62d 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -258,6 +258,7 @@ sub CalcFine { > # a zero (or null) chargeperiod or negative units_minus_grace value means no charge. > } > $amount = $data->{overduefinescap} if $data->{overduefinescap} && $amount > $data->{overduefinescap}; >+ $amount = $item->{'replacementprice'} if ( $data->{cap_fine_to_replacement_price} && $item->{'replacementprice'} && $amount > $item->{'replacementprice'} ); > $debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units); > return ($amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units); > # FIXME: chargename is NEVER populated anywhere. >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index 5d4166d..280880a 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -101,8 +101,52 @@ 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, renewalperiod, reservesallowed, issuelength, lengthunit, hardduedate, hardduedatecompare, fine, finedays, firstremind, chargeperiod,rentaldiscount, overduefinescap) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'); >- my $sth_update=$dbh->prepare("UPDATE issuingrules SET fine=?, finedays=?, firstremind=?, chargeperiod=?, maxissueqty=?, renewalsallowed=?, renewalperiod=?, reservesallowed=?, issuelength=?, lengthunit = ?, hardduedate=?, hardduedatecompare=?, rentaldiscount=?, overduefinescap=? WHERE branchcode=? AND categorycode=? AND itemtype=?"); >+ >+ my $sth_insert = $dbh->prepare(' >+ INSERT INTO issuingrules ( >+ branchcode, >+ categorycode, >+ itemtype, >+ maxissueqty, >+ renewalsallowed, >+ renewalperiod, >+ reservesallowed, >+ issuelength, >+ lengthunit, >+ hardduedate, >+ hardduedatecompare, >+ fine, >+ finedays, >+ firstremind, >+ chargeperiod, >+ rentaldiscount, >+ overduefinescap, >+ cap_fine_to_replacement_price >+ ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) >+ '); >+ >+ my $sth_update=$dbh->prepare(' >+ UPDATE issuingrules >+ SET >+ fine = ?, >+ finedays = ?, >+ firstremind = ?, >+ chargeperiod = ?, >+ maxissueqty = ?, >+ renewalsallowed = ?, >+ renewalperiod = ?, >+ reservesallowed = ?, >+ issuelength = ?, >+ lengthunit = ?, >+ hardduedate = ?, >+ hardduedatecompare = ?, >+ rentaldiscount = ?, >+ overduefinescap = ?, >+ cap_fine_to_replacement_price = ? >+ WHERE branchcode=? >+ AND categorycode=? >+ AND itemtype=? >+ '); > > my $br = $branch; # branch > my $bor = $input->param('categorycode'); # borrower category >@@ -124,14 +168,36 @@ elsif ($op eq 'add') { > my $hardduedatecompare = $input->param('hardduedatecompare'); > my $rentaldiscount = $input->param('rentaldiscount'); > my $overduefinescap = $input->param('overduefinescap') || undef; >+ my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on'; > $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, $renewalperiod, $reservesallowed, $issuelength,$lengthunit, $hardduedate,$hardduedatecompare,$rentaldiscount,$overduefinescap, $br,$bor,$cat); >- } else { >- $sth_insert->execute($br,$bor,$cat,$maxissueqty,$renewalsallowed, $renewalperiod, $reservesallowed,$issuelength,$lengthunit,$hardduedate,$hardduedatecompare,$fine,$finedays,$firstremind,$chargeperiod,$rentaldiscount,$overduefinescap); >+ if ( $res->{total} ) { >+ $sth_update->execute( >+ $fine, $finedays, >+ $firstremind, $chargeperiod, >+ $maxissueqty, $renewalsallowed, >+ $renewalperiod, $reservesallowed, >+ $issuelength, $lengthunit, >+ $hardduedate, $hardduedatecompare, >+ $rentaldiscount, $overduefinescap, >+ $cap_fine_to_replacement_price, $br, >+ $bor, $cat >+ ); >+ } >+ else { >+ $sth_insert->execute( >+ $br, $bor, >+ $cat, $maxissueqty, >+ $renewalsallowed, $renewalperiod, >+ $reservesallowed, $issuelength, >+ $lengthunit, $hardduedate, >+ $hardduedatecompare, $fine, >+ $finedays, $firstremind, >+ $chargeperiod, $rentaldiscount, >+ $overduefinescap, $cap_fine_to_replacement_price >+ ); > } > } > elsif ($op eq "set-branch-defaults") { >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 07160c8..1571add 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1154,6 +1154,7 @@ CREATE TABLE `issuingrules` ( -- circulation and fine rules > `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed > `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode) > overduefinescap decimal(28,6) default NULL, -- the maximum amount of an overdue fine >+ cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT '0', -- flag to set the max amount of an overdue fine to the replacement price > PRIMARY KEY (`branchcode`,`categorycode`,`itemtype`), > KEY `categorycode` (`categorycode`), > KEY `itemtype` (`itemtype`) >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index a9bfbbf..19c6218 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7778,6 +7778,15 @@ if(CheckVersion($DBversion)) { > SetVersion($DBversion); > } > >+$DBversion = "3.13.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do(q{ >+ ALTER TABLE issuingrules ADD cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT '0' AFTER overduefinescap >+ }); >+ print "Upgrade to $DBversion done (Bug 9129 - Add the ability to set the maximum fine for an item to its replacement price )\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >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 1c83cc0..702f772 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 >@@ -16,6 +16,9 @@ function clear_edit(){ > $(this).val(""); > $(this).removeAttr("disabled"); > } >+ if ( type == "checkbox" ) { >+ $(this).attr('checked', false); >+ } > }); > $(edit_row).find("select").removeAttr("disabled"); > $(edit_row).find("select option:first").attr("selected", "selected"); >@@ -38,7 +41,22 @@ $(document).ready(function() { > itm = $(this).text(); > itm = itm.replace(/^\s*|\s*$/g,''); > var current_column = $("#edit_row td:eq("+i+")"); >- if ( i != 5 ) { >+ if ( i == 5 ) { >+ // specific processing for the Hard due date column >+ var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val(); >+ var input_value = ''; >+ if (typeof select_value === 'undefined'){ >+ select_value = '-1'; >+ }else { >+ input_value = itm.split(' ')[1]; >+ } >+ $(current_column).find("input[type='text']").val(input_value); >+ $(current_column).find("select").val(select_value); >+ } else if ( i == 10 ) { >+ // specific processing for cap_fine_to_replacement_price >+ var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']"); >+ $('#cap_fine_to_replacement_price').attr('checked', cap_fine_to_replacement_price.is(':checked') ); >+ } else { > $(current_column).find("input[type='text']").val(itm); > // select the corresponding option > $(current_column).find("select option").each(function(){ >@@ -64,17 +82,6 @@ $(document).ready(function() { > $(current_column).find("input[type='text']").val(""); > } > } >- } else { >- // specific processing for the Hard due date column >- var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val(); >- var input_value = ''; >- if (typeof select_value === 'undefined'){ >- select_value = '-1'; >- }else { >- input_value = itm.split(' ')[1]; >- } >- $(current_column).find("input[type='text']").val(input_value); >- $(current_column).find("select").val(select_value); > } > }); > $("#default-circulation-rules tr:last td:eq(0) select").attr('disabled', 'disabled'); >@@ -147,6 +154,7 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde > <th>Fine charging interval</th> > <th>Fine grace period (day)</th> > <th>Overdue fines cap (amount)</th> >+ <th>Cap fine at replacement price</th> > <th>Suspension in days (day)</th> > <th>Renewals allowed (count)</th> > <th>Renewal period</th> >@@ -204,6 +212,13 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde > <td>[% rule.chargeperiod %]</td> > <td>[% rule.firstremind %]</td> > <td>[% rule.overduefinescap FILTER format("%.2f") %]</td> >+ <td> >+ [% IF rule.cap_fine_to_replacement_price %] >+ <input type="checkbox" checked="checked" disabled="disabled" /> >+ [% ELSE %] >+ <input type="checkbox" disabled="disabled" /> >+ [% END %] >+ </td> > <td>[% rule.finedays %]</td> > <td>[% rule.renewalsallowed %]</td> > <td>[% rule.renewalperiod %]</td> >@@ -253,6 +268,7 @@ for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde > <td><input type="text" name="chargeperiod" id="chargeperiod" size="2" /></td> > <td><input type="text" name="firstremind" id="firstremind" size="2" /> </td> > <td><input type="text" name="overduefinescap" id="overduefinescap" size="6" /> </td> >+ <td><input type="checkbox" name="cap_fine_to_replacement_price" id="cap_fine_to_replacement_price" /></td> > <td><input type="text" name="finedays" id="fined" size="3" /> </td> > <td><input type="text" name="renewalsallowed" id="renewalsallowed" size="2" /></td> > <td><input type="text" name="renewalperiod" id="renewalperiod" size="3" /></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 9129
:
13612
|
13614
|
13615
|
13616
|
14553
|
16197
|
17989
|
17990
|
17991
|
17992
|
18366
|
18367
|
18368
|
18370
|
18371
|
18642
|
18643
|
23305
|
43252
|
43253
|
43298
|
43592
|
43685
|
43686
|
43688
|
43689
|
43745
|
43746
|
43747
|
43781
|
43782
|
43783
|
43784
|
46157