@@ -, +, @@ --- C4/Overdues.pm | 16 +++++++++++++++- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 6 ++++++ .../prog/en/modules/admin/preferences/patrons.pref | 6 ++++++ 4 files changed, 28 insertions(+), 1 deletions(-) --- a/C4/Overdues.pm +++ a/C4/Overdues.pm @@ -268,8 +268,12 @@ sub CalcFine { } else { # 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 ( C4::Context->preference('MaxFineIsReplacementPrice') && $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. } @@ -542,16 +546,26 @@ sub UpdateFine { } $total_amount_other += $rec->{'amount'}; } + + if ( C4::Context->preference('MaxFineIsReplacementPrice') ) { + my $item = C4::Items::GetItem( $itemnum ); + if ( $item->{'replacementprice'} && $amount > $item->{'replacementprice'} ) { + $debug && warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $item->{'replacementprice'} - Fine exceeds replacement price"; + $amount = $item->{'replacementprice'}; + } + } + 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"; + $debug && 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 ( $data ) { # we're updating an existing fine. Only modify if amount changed --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -424,3 +424,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES(' INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('HighlightOwnItemsOnOPACWhich','PatronBranch','PatronBranch|OpacURLBranch','Decides which branch''s items to emphasize. If PatronBranch, emphasize the logged in user''s library''s items. If OpacURLBranch, highlight the items of the Apache var BRANCHCODE defined in Koha''s Apache configuration file.','Choice'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UniqueItemFields', 'barcode', 'Space-separated list of fields that should be unique (used in acquisition module for item creation). Fields must be valid SQL column names of items table', '', 'Free'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('MaxFineIsReplacementPrice',0,'Make the replacement price a second max fine ceiling.',NULL,'YesNo'); --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -6784,6 +6784,12 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "3.11.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('MaxFineIsReplacementPrice',0,'Make the replacement price a second max fine ceiling.',NULL,'YesNo')"); + print "Upgrade to $DBversion done (Bug 9129: Add syspref MaxFineIsReplacementPrice)\n"; + SetVersion ($DBversion); +} =head1 FUNCTIONS --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -80,6 +80,12 @@ Patrons: - '[% local_currency %].' - Empty value means no limit. Single item caps are specified in the circulation rules matrix. - + - pref: MaxFineIsReplacementPrice + choices: + yes: Allow + no: "Don't allow" + - the maximum fine for an item to exceed the replacement price for that item. + - - pref: memberofinstitution choices: yes: Do --