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

(-)a/C4/Overdues.pm (+1 lines)
Lines 258-263 sub CalcFine { Link Here
258
        # a zero (or null) chargeperiod or negative units_minus_grace value means no charge.
258
        # a zero (or null) chargeperiod or negative units_minus_grace value means no charge.
259
    }
259
    }
260
    $amount = $data->{overduefinescap} if $data->{overduefinescap} && $amount > $data->{overduefinescap};
260
    $amount = $data->{overduefinescap} if $data->{overduefinescap} && $amount > $data->{overduefinescap};
261
    $amount = $item->{'replacementprice'} if ( $data->{cap_fine_to_replacement_price} && $item->{'replacementprice'} && $amount > $item->{'replacementprice'} );
261
    $debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);
262
    $debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);
262
    return ($amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);
263
    return ($amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);
263
    # FIXME: chargename is NEVER populated anywhere.
264
    # 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 1154-1159 CREATE TABLE `issuingrules` ( -- circulation and fine rules Link Here
1154
  `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
1154
  `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
1155
  `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
1155
  `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
1156
  overduefinescap decimal(28,6) default NULL, -- the maximum amount of an overdue fine
1156
  overduefinescap decimal(28,6) default NULL, -- the maximum amount of an overdue fine
1157
  cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT '0', -- flag to set the max amount of an overdue fine to the replacement price
1157
  PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
1158
  PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
1158
  KEY `categorycode` (`categorycode`),
1159
  KEY `categorycode` (`categorycode`),
1159
  KEY `itemtype` (`itemtype`)
1160
  KEY `itemtype` (`itemtype`)
(-)a/installer/data/mysql/updatedatabase.pl (+9 lines)
Lines 7778-7783 if(CheckVersion($DBversion)) { Link Here
7778
    SetVersion($DBversion);
7778
    SetVersion($DBversion);
7779
}
7779
}
7780
7780
7781
$DBversion = "3.13.00.XXX";
7782
if ( CheckVersion($DBversion) ) {
7783
    $dbh->do(q{
7784
        ALTER TABLE issuingrules ADD cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT  '0' AFTER overduefinescap
7785
    });
7786
    print "Upgrade to $DBversion done (Bug 9129 - Add the ability to set the maximum fine for an item to its replacement price )\n";
7787
    SetVersion($DBversion);
7788
}
7789
7781
=head1 FUNCTIONS
7790
=head1 FUNCTIONS
7782
7791
7783
=head2 TableExists($table)
7792
=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