View | Details | Raw Unified | Return to bug 9129
Collapse All | Expand All

(-)a/C4/Overdues.pm (+1 lines)
Lines 269-274 sub CalcFine { Link Here
269
        # a zero (or null) chargeperiod or negative units_minus_grace value means no charge.
269
        # a zero (or null) chargeperiod or negative units_minus_grace value means no charge.
270
    }
270
    }
271
    $amount = $data->{overduefinescap} if $data->{overduefinescap} && $amount > $data->{overduefinescap};
271
    $amount = $data->{overduefinescap} if $data->{overduefinescap} && $amount > $data->{overduefinescap};
272
    $amount = $item->{'replacementprice'} if ( $data->{cap_fine_to_replacement_price} && $item->{'replacementprice'} && $amount > $item->{'replacementprice'} );
272
    $debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);
273
    $debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);
273
    return ($amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);
274
    return ($amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);
274
    # FIXME: chargename is NEVER populated anywhere.
275
    # FIXME: chargename is NEVER populated anywhere.
(-)a/admin/smart-rules.pl (-6 / +72 lines)
Lines 101-108 elsif ($op eq 'delete-branch-item') { Link Here
101
# save the values entered
101
# save the values entered
102
elsif ($op eq 'add') {
102
elsif ($op eq 'add') {
103
    my $sth_search = $dbh->prepare('SELECT COUNT(*) AS total FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?');
103
    my $sth_search = $dbh->prepare('SELECT COUNT(*) AS total FROM issuingrules WHERE branchcode=? AND categorycode=? AND itemtype=?');
104
    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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)');
104
105
    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=?");
105
    my $sth_insert = $dbh->prepare('
106
        INSERT INTO issuingrules (
107
            branchcode, 
108
            categorycode, 
109
            itemtype, 
110
            maxissueqty, 
111
            renewalsallowed, 
112
            renewalperiod, 
113
            reservesallowed, 
114
            issuelength, 
115
            lengthunit, 
116
            hardduedate, 
117
            hardduedatecompare, 
118
            fine, 
119
            finedays, 
120
            firstremind, 
121
            chargeperiod,
122
            rentaldiscount, 
123
            overduefinescap, 
124
            cap_fine_to_replacement_price 
125
        ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
126
    ');
127
128
    my $sth_update=$dbh->prepare('
129
        UPDATE issuingrules 
130
        SET 
131
            fine = ?, 
132
            finedays = ?, 
133
            firstremind = ?, 
134
            chargeperiod = ?, 
135
            maxissueqty = ?, 
136
            renewalsallowed = ?, 
137
            renewalperiod = ?, 
138
            reservesallowed = ?, 
139
            issuelength = ?, 
140
            lengthunit = ?, 
141
            hardduedate = ?, 
142
            hardduedatecompare = ?, 
143
            rentaldiscount = ?, 
144
            overduefinescap = ?, 
145
            cap_fine_to_replacement_price = ?  
146
        WHERE branchcode=? 
147
          AND categorycode=? 
148
          AND itemtype=?
149
    ');
106
    
150
    
107
    my $br = $branch; # branch
151
    my $br = $branch; # branch
108
    my $bor  = $input->param('categorycode'); # borrower category
152
    my $bor  = $input->param('categorycode'); # borrower category
Lines 124-137 elsif ($op eq 'add') { Link Here
124
    my $hardduedatecompare = $input->param('hardduedatecompare');
168
    my $hardduedatecompare = $input->param('hardduedatecompare');
125
    my $rentaldiscount = $input->param('rentaldiscount');
169
    my $rentaldiscount = $input->param('rentaldiscount');
126
    my $overduefinescap = $input->param('overduefinescap') || undef;
170
    my $overduefinescap = $input->param('overduefinescap') || undef;
171
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
127
    $debug and warn "Adding $br, $bor, $cat, $fine, $maxissueqty";
172
    $debug and warn "Adding $br, $bor, $cat, $fine, $maxissueqty";
128
173
129
    $sth_search->execute($br,$bor,$cat);
174
    $sth_search->execute($br,$bor,$cat);
130
    my $res = $sth_search->fetchrow_hashref();
175
    my $res = $sth_search->fetchrow_hashref();
131
    if ($res->{total}) {
176
    if ( $res->{total} ) {
132
        $sth_update->execute($fine, $finedays,$firstremind, $chargeperiod, $maxissueqty, $renewalsallowed, $renewalperiod, $reservesallowed, $issuelength,$lengthunit, $hardduedate,$hardduedatecompare,$rentaldiscount,$overduefinescap, $br,$bor,$cat);
177
        $sth_update->execute(
133
    } else {
178
            $fine,                          $finedays,
134
        $sth_insert->execute($br,$bor,$cat,$maxissueqty,$renewalsallowed, $renewalperiod, $reservesallowed,$issuelength,$lengthunit,$hardduedate,$hardduedatecompare,$fine,$finedays,$firstremind,$chargeperiod,$rentaldiscount,$overduefinescap);
179
            $firstremind,                   $chargeperiod,
180
            $maxissueqty,                   $renewalsallowed,
181
            $renewalperiod,                 $reservesallowed,
182
            $issuelength,                   $lengthunit,
183
            $hardduedate,                   $hardduedatecompare,
184
            $rentaldiscount,                $overduefinescap,
185
            $cap_fine_to_replacement_price, $br,
186
            $bor,                           $cat
187
        );
188
    }
189
    else {
190
        $sth_insert->execute(
191
            $br,                 $bor,
192
            $cat,                $maxissueqty,
193
            $renewalsallowed,    $renewalperiod,
194
            $reservesallowed,    $issuelength,
195
            $lengthunit,         $hardduedate,
196
            $hardduedatecompare, $fine,
197
            $finedays,           $firstremind,
198
            $chargeperiod,       $rentaldiscount,
199
            $overduefinescap,    $cap_fine_to_replacement_price
200
        );
135
    }
201
    }
136
} 
202
} 
137
elsif ($op eq "set-branch-defaults") {
203
elsif ($op eq "set-branch-defaults") {
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 1131-1136 CREATE TABLE `issuingrules` ( -- circulation and fine rules Link Here
1131
  `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
1131
  `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
1132
  `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
1132
  `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
1133
  overduefinescap decimal default NULL, -- the maximum amount of an overdue fine
1133
  overduefinescap decimal default NULL, -- the maximum amount of an overdue fine
1134
  cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT '0', -- flag to set the max amount of an overdue fine to the replacement price
1134
  PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
1135
  PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
1135
  KEY `categorycode` (`categorycode`),
1136
  KEY `categorycode` (`categorycode`),
1136
  KEY `itemtype` (`itemtype`)
1137
  KEY `itemtype` (`itemtype`)
(-)a/installer/data/mysql/updatedatabase.pl (+9 lines)
Lines 6984-6989 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( Link Here
6984
}
6984
}
6985
6985
6986
6986
6987
$DBversion = "3.13.00.XXX";
6988
if ( CheckVersion($DBversion) ) {
6989
    $dbh->do(q{
6990
        ALTER TABLE issuingrules ADD cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT  '0' AFTER overduefinescap
6991
    });
6992
    print "Upgrade to $DBversion done (Bug 9129 - Add the ability to set the maximum fine for an item to its replacement price )\n";
6993
    SetVersion($DBversion);
6994
}
6995
6987
=head1 FUNCTIONS
6996
=head1 FUNCTIONS
6988
6997
6989
=head2 TableExists($table)
6998
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-13 / +28 lines)
Lines 16-21 function clear_edit(){ Link Here
16
            $(this).val("");
16
            $(this).val("");
17
            $(this).removeAttr("disabled");
17
            $(this).removeAttr("disabled");
18
        }
18
        }
19
        if ( type == "checkbox" ) {
20
            $(this).attr('checked', false);
21
        }
19
    });
22
    });
20
    $(edit_row).find("select").removeAttr("disabled");
23
    $(edit_row).find("select").removeAttr("disabled");
21
    $(edit_row).find("select option:first").attr("selected", "selected");
24
    $(edit_row).find("select option:first").attr("selected", "selected");
Lines 38-44 $(document).ready(function() { Link Here
38
                itm = $(this).text();
41
                itm = $(this).text();
39
                itm = itm.replace(/^\s*|\s*$/g,'');
42
                itm = itm.replace(/^\s*|\s*$/g,'');
40
                var current_column = $("#edit_row td:eq("+i+")");
43
                var current_column = $("#edit_row td:eq("+i+")");
41
                if ( i != 5 ) {
44
                if ( i == 5 ) {
45
                    // specific processing for the Hard due date column
46
                    var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
47
                    var input_value = '';
48
                    if (typeof select_value === 'undefined'){
49
                        select_value = '-1';
50
                    }else {
51
                        input_value = itm.split(' ')[1];
52
                    }
53
                    $(current_column).find("input[type='text']").val(input_value);
54
                    $(current_column).find("select").val(select_value);
55
                } else if ( i == 10 ) {
56
                    // specific processing for cap_fine_to_replacement_price
57
                    var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']"); 
58
                    $('#cap_fine_to_replacement_price').attr('checked', cap_fine_to_replacement_price.is(':checked') );
59
                } else {
42
                    $(current_column).find("input[type='text']").val(itm);
60
                    $(current_column).find("input[type='text']").val(itm);
43
                    // select the corresponding option
61
                    // select the corresponding option
44
                    $(current_column).find("select option").each(function(){
62
                    $(current_column).find("select option").each(function(){
Lines 64-80 $(document).ready(function() { Link Here
64
                            $(current_column).find("input[type='text']").val("");
82
                            $(current_column).find("input[type='text']").val("");
65
                        }
83
                        }
66
                    }
84
                    }
67
                } else {
68
                    // specific processing for the Hard due date column
69
                    var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val();
70
                    var input_value = '';
71
                    if (typeof select_value === 'undefined'){
72
                        select_value = '-1';
73
                    }else {
74
                        input_value = itm.split(' ')[1];
75
                    }
76
                    $(current_column).find("input[type='text']").val(input_value);
77
                    $(current_column).find("select").val(select_value);
78
                }
85
                }
79
            });
86
            });
80
            $("#default-circulation-rules tr:last td:eq(0) select").attr('disabled', 'disabled');
87
            $("#default-circulation-rules tr:last td:eq(0) select").attr('disabled', 'disabled');
Lines 147-152 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
147
                <th>Fine charging interval</th>
154
                <th>Fine charging interval</th>
148
                <th>Fine grace period (day)</th>
155
                <th>Fine grace period (day)</th>
149
                <th>Overdue fines cap (amount)</th>
156
                <th>Overdue fines cap (amount)</th>
157
                <th>Cap fine at replacement price</th>
150
                <th>Suspension in days (day)</th>
158
                <th>Suspension in days (day)</th>
151
                <th>Renewals allowed (count)</th>
159
                <th>Renewals allowed (count)</th>
152
                <th>Renewal period</th>
160
                <th>Renewal period</th>
Lines 204-209 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
204
							<td>[% rule.chargeperiod %]</td>
212
							<td>[% rule.chargeperiod %]</td>
205
							<td>[% rule.firstremind %]</td>
213
							<td>[% rule.firstremind %]</td>
206
                            <td>[% rule.overduefinescap FILTER format("%.2f") %]</td>
214
                            <td>[% rule.overduefinescap FILTER format("%.2f") %]</td>
215
                            <td>
216
                                [% IF rule.cap_fine_to_replacement_price %]
217
                                    <input type="checkbox" checked="checked" disabled="disabled" />
218
                                [% ELSE %]
219
                                    <input type="checkbox" disabled="disabled" />
220
                                [% END %]
221
                            </td>
207
							<td>[% rule.finedays %]</td>
222
							<td>[% rule.finedays %]</td>
208
							<td>[% rule.renewalsallowed %]</td>
223
							<td>[% rule.renewalsallowed %]</td>
209
                            <td>[% rule.renewalperiod %]</td>
224
                            <td>[% rule.renewalperiod %]</td>
Lines 253-258 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
253
                    <td><input type="text" name="chargeperiod" id="chargeperiod" size="2" /></td>
268
                    <td><input type="text" name="chargeperiod" id="chargeperiod" size="2" /></td>
254
                    <td><input type="text" name="firstremind" id="firstremind" size="2" /> </td>
269
                    <td><input type="text" name="firstremind" id="firstremind" size="2" /> </td>
255
                    <td><input type="text" name="overduefinescap" id="overduefinescap" size="6" /> </td>
270
                    <td><input type="text" name="overduefinescap" id="overduefinescap" size="6" /> </td>
271
                    <td><input type="checkbox" name="cap_fine_to_replacement_price" id="cap_fine_to_replacement_price" /></td>
256
                    <td><input type="text" name="finedays" id="fined" size="3" /> </td>
272
                    <td><input type="text" name="finedays" id="fined" size="3" /> </td>
257
                    <td><input type="text" name="renewalsallowed" id="renewalsallowed" size="2" /></td>
273
                    <td><input type="text" name="renewalsallowed" id="renewalsallowed" size="2" /></td>
258
                    <td><input type="text" name="renewalperiod" id="renewalperiod" size="3" /></td>
274
                    <td><input type="text" name="renewalperiod" id="renewalperiod" size="3" /></td>
259
- 

Return to bug 9129