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

(-)a/C4/Overdues.pm (-47 / +52 lines)
Lines 24-29 use strict; Link Here
24
use Date::Calc qw/Today Date_to_Days/;
24
use Date::Calc qw/Today Date_to_Days/;
25
use Date::Manip qw/UnixDate/;
25
use Date::Manip qw/UnixDate/;
26
use List::MoreUtils qw( uniq );
26
use List::MoreUtils qw( uniq );
27
use POSIX qw( floor ceil );
28
use Readonly;
27
29
28
use C4::Circulation;
30
use C4::Circulation;
29
use C4::Context;
31
use C4::Context;
Lines 33-78 use C4::Debug; Link Here
33
35
34
use vars qw($VERSION @ISA @EXPORT);
36
use vars qw($VERSION @ISA @EXPORT);
35
37
38
Readonly::Scalar our $INTERVAL_START => 1;
39
Readonly::Scalar our $INTERVAL_END   => 0;
40
36
BEGIN {
41
BEGIN {
37
	# set the version for version checking
42
    # set the version for version checking
38
    $VERSION = 3.07.00.049;
43
    $VERSION = 3.07.00.049;
39
	require Exporter;
44
    require Exporter;
40
	@ISA    = qw(Exporter);
45
    @ISA = qw(Exporter);
41
	# subs to rename (and maybe merge some...)
46
42
	push @EXPORT, qw(
47
    # subs to rename (and maybe merge some...)
43
        &CalcFine
48
    push @EXPORT, qw(
44
        &Getoverdues
49
      &CalcFine
45
        &checkoverdues
50
      &Getoverdues
46
        &NumberNotifyId
51
      &checkoverdues
47
        &AmountNotify
52
      &NumberNotifyId
48
        &UpdateFine
53
      &AmountNotify
49
        &GetFine
54
      &UpdateFine
50
        &get_chargeable_units
55
      &GetFine
51
        &CheckItemNotify
56
      &get_chargeable_units
52
        &GetOverduesForBranch
57
      &CheckItemNotify
53
        &RemoveNotifyLine
58
      &GetOverduesForBranch
54
        &AddNotifyLine
59
      &RemoveNotifyLine
55
        &GetOverdueMessageTransportTypes
60
      &AddNotifyLine
56
	);
61
      &GetOverdueMessageTransportTypes
57
	# subs to remove
62
    );
58
	push @EXPORT, qw(
63
59
        &BorType
64
    # subs to remove
60
	);
65
    push @EXPORT, qw(
61
66
      &BorType
62
	# check that an equivalent don't exist already before moving
67
    );
63
68
64
	# subs to move to Circulation.pm
69
    # check that an equivalent don't exist already before moving
65
	push @EXPORT, qw(
70
66
        &GetIssuesIteminfo
71
    # subs to move to Circulation.pm
67
	);
72
    push @EXPORT, qw(
68
73
      &GetIssuesIteminfo
69
     # &GetIssuingRules - delete.
74
    );
70
   # use C4::Circulation::GetIssuingRule instead.
75
71
76
    # &GetIssuingRules - delete.
72
	# subs to move to Biblio.pm
77
    # use C4::Circulation::GetIssuingRule instead.
73
	push @EXPORT, qw(
78
74
        &GetItems
79
    # subs to move to Biblio.pm
75
	);
80
    push @EXPORT, qw(
81
      &GetItems
82
    );
76
}
83
}
77
84
78
=head1 NAME
85
=head1 NAME
Lines 251-265 sub CalcFine { Link Here
251
    my $chargeable_units = get_chargeable_units($fine_unit, $start_date, $end_date, $branchcode);
258
    my $chargeable_units = get_chargeable_units($fine_unit, $start_date, $end_date, $branchcode);
252
    my $units_minus_grace = $chargeable_units - $data->{firstremind};
259
    my $units_minus_grace = $chargeable_units - $data->{firstremind};
253
    my $amount = 0;
260
    my $amount = 0;
254
    if ($data->{'chargeperiod'}  && ($units_minus_grace > 0)  ) {
261
    if ( $data->{'chargeperiod'} && ( $units_minus_grace > 0 ) ) {
255
        if ( C4::Context->preference('FinesIncludeGracePeriod') ) {
262
        my $units = C4::Context->preference('FinesIncludeGracePeriod') ? $chargeable_units : $units_minus_grace;
256
            $amount = int($chargeable_units / $data->{'chargeperiod'}) * $data->{'fine'};# TODO fine calc should be in cents
263
        my $charge_periods = $units / $data->{'chargeperiod'};
257
        } else {
264
        $charge_periods = $data->{'chargeperiod_charge_at'} == $INTERVAL_START ? ceil($charge_periods) : floor($charge_periods);
258
            $amount = int($units_minus_grace / $data->{'chargeperiod'}) * $data->{'fine'};
265
        $amount = $charge_periods * $data->{'fine'};
259
        }
266
    } # else { # a zero (or null) chargeperiod or negative units_minus_grace value means no charge. }
260
    } else {
267
261
        # a zero (or null) chargeperiod or negative units_minus_grace value means no charge.
262
    }
263
    $amount = $data->{overduefinescap} if $data->{overduefinescap} && $amount > $data->{overduefinescap};
268
    $amount = $data->{overduefinescap} if $data->{overduefinescap} && $amount > $data->{overduefinescap};
264
    $debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);
269
    $debug and warn sprintf("CalcFine returning (%s, %s, %s, %s)", $amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);
265
    return ($amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);
270
    return ($amount, $data->{'chargename'}, $units_minus_grace, $chargeable_units);
(-)a/Koha/Schema/Result/Issuingrule.pm (+8 lines)
Lines 80-85 __PACKAGE__->table("issuingrules"); Link Here
80
  data_type: 'integer'
80
  data_type: 'integer'
81
  is_nullable: 1
81
  is_nullable: 1
82
82
83
=head2 chargeperiod_charge_at
84
85
  data_type: 'tinyint'
86
  default_value: 0
87
  is_nullable: 0
88
83
=head2 accountsent
89
=head2 accountsent
84
90
85
  data_type: 'integer'
91
  data_type: 'integer'
Lines 197-202 __PACKAGE__->add_columns( Link Here
197
  { data_type => "integer", is_nullable => 1 },
203
  { data_type => "integer", is_nullable => 1 },
198
  "chargeperiod",
204
  "chargeperiod",
199
  { data_type => "integer", is_nullable => 1 },
205
  { data_type => "integer", is_nullable => 1 },
206
  "chargeperiod_charge_at",
207
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
200
  "accountsent",
208
  "accountsent",
201
  { data_type => "integer", is_nullable => 1 },
209
  { data_type => "integer", is_nullable => 1 },
202
  "chargename",
210
  "chargename",
(-)a/admin/smart-rules.pl (-22 / +24 lines)
Lines 110-115 elsif ($op eq 'add') { Link Here
110
    $maxsuspensiondays = undef if $maxsuspensiondays eq q||;
110
    $maxsuspensiondays = undef if $maxsuspensiondays eq q||;
111
    my $firstremind  = $input->param('firstremind');
111
    my $firstremind  = $input->param('firstremind');
112
    my $chargeperiod = $input->param('chargeperiod');
112
    my $chargeperiod = $input->param('chargeperiod');
113
    my $chargeperiod_charge_at = $input->param('chargeperiod_charge_at');
113
    my $maxissueqty  = $input->param('maxissueqty');
114
    my $maxissueqty  = $input->param('maxissueqty');
114
    my $renewalsallowed  = $input->param('renewalsallowed');
115
    my $renewalsallowed  = $input->param('renewalsallowed');
115
    my $renewalperiod    = $input->param('renewalperiod');
116
    my $renewalperiod    = $input->param('renewalperiod');
Lines 134-161 elsif ($op eq 'add') { Link Here
134
    my $rs = $schema->resultset('Issuingrule');
135
    my $rs = $schema->resultset('Issuingrule');
135
136
136
    my $params = {
137
    my $params = {
137
        branchcode         => $br,
138
        branchcode             => $br,
138
        categorycode       => $bor,
139
        categorycode           => $bor,
139
        itemtype           => $itemtype,
140
        itemtype               => $itemtype,
140
        fine               => $fine,
141
        fine                   => $fine,
141
        finedays           => $finedays,
142
        finedays               => $finedays,
142
        maxsuspensiondays  => $maxsuspensiondays,
143
        maxsuspensiondays      => $maxsuspensiondays,
143
        firstremind        => $firstremind,
144
        firstremind            => $firstremind,
144
        chargeperiod       => $chargeperiod,
145
        chargeperiod           => $chargeperiod,
145
        maxissueqty        => $maxissueqty,
146
        chargeperiod_charge_at => $chargeperiod_charge_at,
146
        renewalsallowed    => $renewalsallowed,
147
        maxissueqty            => $maxissueqty,
147
        renewalperiod      => $renewalperiod,
148
        renewalsallowed        => $renewalsallowed,
148
        norenewalbefore    => $norenewalbefore,
149
        renewalperiod          => $renewalperiod,
149
        auto_renew         => $auto_renew,
150
        norenewalbefore        => $norenewalbefore,
150
        reservesallowed    => $reservesallowed,
151
        auto_renew             => $auto_renew,
151
        issuelength        => $issuelength,
152
        reservesallowed        => $reservesallowed,
152
        lengthunit         => $lengthunit,
153
        issuelength            => $issuelength,
153
        hardduedate        => $hardduedate,
154
        lengthunit             => $lengthunit,
154
        hardduedatecompare => $hardduedatecompare,
155
        hardduedate            => $hardduedate,
155
        rentaldiscount     => $rentaldiscount,
156
        hardduedatecompare     => $hardduedatecompare,
156
        onshelfholds       => $onshelfholds,
157
        rentaldiscount         => $rentaldiscount,
157
        opacitemholds      => $opacitemholds,
158
        onshelfholds           => $onshelfholds,
158
        overduefinescap    => $overduefinescap,
159
        opacitemholds          => $opacitemholds,
160
        overduefinescap        => $overduefinescap,
159
    };
161
    };
160
162
161
    $rs->update_or_create($params);
163
    $rs->update_or_create($params);
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 1176-1181 CREATE TABLE `issuingrules` ( -- circulation and fine rules Link Here
1176
  `maxsuspensiondays` int(11) default NULL, -- max suspension days
1176
  `maxsuspensiondays` int(11) default NULL, -- max suspension days
1177
  `firstremind` int(11) default NULL, -- fine grace period
1177
  `firstremind` int(11) default NULL, -- fine grace period
1178
  `chargeperiod` int(11) default NULL, -- how often the fine amount is charged
1178
  `chargeperiod` int(11) default NULL, -- how often the fine amount is charged
1179
  `chargeperiod_charge_at` tinyint(1) NOT NULL DEFAULT '0', -- Should fine be given at the start ( 1 ) or the end ( 0 ) of the period
1179
  `accountsent` int(11) default NULL, -- not used? always NULL
1180
  `accountsent` int(11) default NULL, -- not used? always NULL
1180
  `chargename` varchar(100) default NULL, -- not used? always NULL
1181
  `chargename` varchar(100) default NULL, -- not used? always NULL
1181
  `maxissueqty` int(4) default NULL, -- total number of checkouts allowed
1182
  `maxissueqty` int(4) default NULL, -- total number of checkouts allowed
(-)a/installer/data/mysql/updatedatabase.pl (+8 lines)
Lines 10025-10030 if ( CheckVersion($DBversion) ) { Link Here
10025
    SetVersion ($DBversion);
10025
    SetVersion ($DBversion);
10026
}
10026
}
10027
10027
10028
$DBversion = "3.19.00.XXX";
10029
if ( CheckVersion($DBversion) ) {
10030
    $dbh->do("ALTER TABLE issuingrules ADD chargeperiod_charge_at BOOLEAN NOT NULL DEFAULT  '0' AFTER chargeperiod");
10031
10032
    print "Upgrade to $DBversion done (Bug 13590 - Add ability to charge fines at start of charge period)\n";
10033
    SetVersion ($DBversion);
10034
}
10035
10028
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10036
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10029
# SEE bug 13068
10037
# SEE bug 13068
10030
# if there is anything in the atomicupdate, read and execute it.
10038
# if there is anything in the atomicupdate, read and execute it.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (+8 lines)
Lines 147-152 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
147
                <th>Hard due date</th>
147
                <th>Hard due date</th>
148
                <th>Fine amount</th>
148
                <th>Fine amount</th>
149
                <th>Fine charging interval</th>
149
                <th>Fine charging interval</th>
150
                <th>Charge when?</th>
150
                <th>Fine grace period (day)</th>
151
                <th>Fine grace period (day)</th>
151
                <th>Overdue fines cap (amount)</th>
152
                <th>Overdue fines cap (amount)</th>
152
                <th>Suspension in days (day)</th>
153
                <th>Suspension in days (day)</th>
Lines 205-210 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
205
                            </td>
206
                            </td>
206
							<td>[% rule.fine %]</td>
207
							<td>[% rule.fine %]</td>
207
							<td>[% rule.chargeperiod %]</td>
208
							<td>[% rule.chargeperiod %]</td>
209
                <td>[% IF rule.chargeperiod_charge_at %]Start of interval[% ELSE %]End of interval[% END %]</td>
208
							<td>[% rule.firstremind %]</td>
210
							<td>[% rule.firstremind %]</td>
209
                            <td>[% rule.overduefinescap FILTER format("%.2f") %]</td>
211
                            <td>[% rule.overduefinescap FILTER format("%.2f") %]</td>
210
							<td>[% rule.finedays %]</td>
212
							<td>[% rule.finedays %]</td>
Lines 265-270 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
265
                    </td>
267
                    </td>
266
                    <td><input type="text" name="fine" id="fine" size="4" /></td>
268
                    <td><input type="text" name="fine" id="fine" size="4" /></td>
267
                    <td><input type="text" name="chargeperiod" id="chargeperiod" size="2" /></td>
269
                    <td><input type="text" name="chargeperiod" id="chargeperiod" size="2" /></td>
270
                    <td>
271
                        <select name="chargeperiod_charge_at" id="chargeperiod_charge_at">
272
                           <option value="0">End of interval</option>
273
                           <option value="1">Start of interval</option>
274
                        </select>
275
                    </td>
268
                    <td><input type="text" name="firstremind" id="firstremind" size="2" /> </td>
276
                    <td><input type="text" name="firstremind" id="firstremind" size="2" /> </td>
269
                    <td><input type="text" name="overduefinescap" id="overduefinescap" size="6" /> </td>
277
                    <td><input type="text" name="overduefinescap" id="overduefinescap" size="6" /> </td>
270
                    <td><input type="text" name="finedays" id="fined" size="3" /> </td>
278
                    <td><input type="text" name="finedays" id="fined" size="3" /> </td>
(-)a/t/db_dependent/Circulation_Issuingrule.t (-79 / +86 lines)
Lines 108-195 $dbh->do( Link Here
108
108
109
#Test GetIssuingRule
109
#Test GetIssuingRule
110
my $sampleissuingrule1 = {
110
my $sampleissuingrule1 = {
111
    reservecharge      => '0.000000',
111
    reservecharge          => '0.000000',
112
    chargename         => 'Null',
112
    chargename             => 'Null',
113
    restrictedtype     => 0,
113
    restrictedtype         => 0,
114
    accountsent        => 0,
114
    accountsent            => 0,
115
    maxissueqty        => 5,
115
    maxissueqty            => 5,
116
    finedays           => 0,
116
    finedays               => 0,
117
    lengthunit         => 'Null',
117
    lengthunit             => 'Null',
118
    renewalperiod      => 5,
118
    renewalperiod          => 5,
119
    norenewalbefore    => 6,
119
    norenewalbefore        => 6,
120
    auto_renew         => 0,
120
    auto_renew             => 0,
121
    issuelength        => 5,
121
    issuelength            => 5,
122
    chargeperiod       => 0,
122
    chargeperiod           => 0,
123
    rentaldiscount     => '2.000000',
123
    chargeperiod_charge_at => 0,
124
    reservesallowed    => 0,
124
    rentaldiscount         => '2.000000',
125
    hardduedate        => '2013-01-01',
125
    reservesallowed        => 0,
126
    branchcode         => $samplebranch1->{branchcode},
126
    hardduedate            => '2013-01-01',
127
    fine               => '0.000000',
127
    branchcode             => $samplebranch1->{branchcode},
128
    hardduedatecompare => 5,
128
    fine                   => '0.000000',
129
    overduefinescap    => '0.000000',
129
    hardduedatecompare     => 5,
130
    renewalsallowed    => 0,
130
    overduefinescap        => '0.000000',
131
    firstremind        => 0,
131
    renewalsallowed        => 0,
132
    itemtype           => 'BOOK',
132
    firstremind            => 0,
133
    categorycode       => $samplecat->{categorycode},
133
    itemtype               => 'BOOK',
134
    maxsuspensiondays  => 0,
134
    categorycode           => $samplecat->{categorycode},
135
    onshelfholds       => 0,
135
    maxsuspensiondays      => 0,
136
    opacitemholds      => 'N',
136
    onshelfholds           => 0,
137
    opacitemholds          => 'N',
137
};
138
};
138
my $sampleissuingrule2 = {
139
my $sampleissuingrule2 = {
139
    branchcode         => $samplebranch2->{branchcode},
140
    branchcode             => $samplebranch2->{branchcode},
140
    categorycode       => $samplecat->{categorycode},
141
    categorycode           => $samplecat->{categorycode},
141
    itemtype           => 'BOOK',
142
    itemtype               => 'BOOK',
142
    maxissueqty        => 2,
143
    maxissueqty            => 2,
143
    renewalsallowed    => 'Null',
144
    renewalsallowed        => 'Null',
144
    renewalperiod      => 2,
145
    renewalperiod          => 2,
145
    norenewalbefore    => 7,
146
    norenewalbefore        => 7,
146
    auto_renew         => 0,
147
    auto_renew             => 0,
147
    reservesallowed    => 'Null',
148
    reservesallowed        => 'Null',
148
    issuelength        => 2,
149
    issuelength            => 2,
149
    lengthunit         => 'Null',
150
    lengthunit             => 'Null',
150
    hardduedate        => 2,
151
    hardduedate            => 2,
151
    hardduedatecompare => 'Null',
152
    hardduedatecompare     => 'Null',
152
    fine               => 'Null',
153
    fine                   => 'Null',
153
    finedays           => 'Null',
154
    finedays               => 'Null',
154
    firstremind        => 'Null',
155
    firstremind            => 'Null',
155
    chargeperiod       => 'Null',
156
    chargeperiod           => 'Null',
156
    rentaldiscount     => 2.00,
157
    chargeperiod_charge_at => 0,
157
    overduefinescap    => 'Null',
158
    rentaldiscount         => 2.00,
158
    accountsent        => 'Null',
159
    overduefinescap        => 'Null',
159
    reservecharge      => 'Null',
160
    accountsent            => 'Null',
160
    chargename         => 'Null',
161
    reservecharge          => 'Null',
161
    restrictedtype     => 'Null',
162
    chargename             => 'Null',
162
    maxsuspensiondays  => 0,
163
    restrictedtype         => 'Null',
163
    onshelfholds       => 1,
164
    maxsuspensiondays      => 0,
164
    opacitemholds      => 'Y',
165
    onshelfholds           => 1,
166
    opacitemholds          => 'Y',
165
};
167
};
166
my $sampleissuingrule3 = {
168
my $sampleissuingrule3 = {
167
    branchcode         => $samplebranch1->{branchcode},
169
    branchcode             => $samplebranch1->{branchcode},
168
    categorycode       => $samplecat->{categorycode},
170
    categorycode           => $samplecat->{categorycode},
169
    itemtype           => 'DVD',
171
    itemtype               => 'DVD',
170
    maxissueqty        => 3,
172
    maxissueqty            => 3,
171
    renewalsallowed    => 'Null',
173
    renewalsallowed        => 'Null',
172
    renewalperiod      => 3,
174
    renewalperiod          => 3,
173
    norenewalbefore    => 8,
175
    norenewalbefore        => 8,
174
    auto_renew         => 0,
176
    auto_renew             => 0,
175
    reservesallowed    => 'Null',
177
    reservesallowed        => 'Null',
176
    issuelength        => 3,
178
    issuelength            => 3,
177
    lengthunit         => 'Null',
179
    lengthunit             => 'Null',
178
    hardduedate        => 3,
180
    hardduedate            => 3,
179
    hardduedatecompare => 'Null',
181
    hardduedatecompare     => 'Null',
180
    fine               => 'Null',
182
    fine                   => 'Null',
181
    finedays           => 'Null',
183
    finedays               => 'Null',
182
    firstremind        => 'Null',
184
    firstremind            => 'Null',
183
    chargeperiod       => 'Null',
185
    chargeperiod           => 'Null',
184
    rentaldiscount     => 3.00,
186
    chargeperiod_charge_at => 0,
185
    overduefinescap    => 'Null',
187
    rentaldiscount         => 3.00,
186
    accountsent        => 'Null',
188
    overduefinescap        => 'Null',
187
    reservecharge      => 'Null',
189
    accountsent            => 'Null',
188
    chargename         => 'Null',
190
    reservecharge          => 'Null',
189
    restrictedtype     => 'Null',
191
    chargename             => 'Null',
190
    maxsuspensiondays  => 0,
192
    restrictedtype         => 'Null',
191
    onshelfholds       => 1,
193
    maxsuspensiondays      => 0,
192
    opacitemholds      => 'F',
194
    onshelfholds           => 1,
195
    opacitemholds          => 'F',
193
};
196
};
194
$query = 'INSERT INTO issuingrules (
197
$query = 'INSERT INTO issuingrules (
195
                branchcode,
198
                branchcode,
Lines 209-214 $query = 'INSERT INTO issuingrules ( Link Here
209
                finedays,
212
                finedays,
210
                firstremind,
213
                firstremind,
211
                chargeperiod,
214
                chargeperiod,
215
                chargeperiod_charge_at,
212
                rentaldiscount,
216
                rentaldiscount,
213
                overduefinescap,
217
                overduefinescap,
214
                accountsent,
218
                accountsent,
Lines 216-222 $query = 'INSERT INTO issuingrules ( Link Here
216
                chargename,
220
                chargename,
217
                restrictedtype,
221
                restrictedtype,
218
                maxsuspensiondays
222
                maxsuspensiondays
219
                ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
223
                ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
220
my $sth = $dbh->prepare($query);
224
my $sth = $dbh->prepare($query);
221
$sth->execute(
225
$sth->execute(
222
    $sampleissuingrule1->{branchcode},
226
    $sampleissuingrule1->{branchcode},
Lines 236-241 $sth->execute( Link Here
236
    $sampleissuingrule1->{finedays},
240
    $sampleissuingrule1->{finedays},
237
    $sampleissuingrule1->{firstremind},
241
    $sampleissuingrule1->{firstremind},
238
    $sampleissuingrule1->{chargeperiod},
242
    $sampleissuingrule1->{chargeperiod},
243
    $sampleissuingrule1->{chargeperiod_charge_at},
239
    $sampleissuingrule1->{rentaldiscount},
244
    $sampleissuingrule1->{rentaldiscount},
240
    $sampleissuingrule1->{overduefinescap},
245
    $sampleissuingrule1->{overduefinescap},
241
    $sampleissuingrule1->{accountsent},
246
    $sampleissuingrule1->{accountsent},
Lines 262-267 $sth->execute( Link Here
262
    $sampleissuingrule2->{finedays},
267
    $sampleissuingrule2->{finedays},
263
    $sampleissuingrule2->{firstremind},
268
    $sampleissuingrule2->{firstremind},
264
    $sampleissuingrule2->{chargeperiod},
269
    $sampleissuingrule2->{chargeperiod},
270
    $sampleissuingrule2->{chargeperiod_charge_at},
265
    $sampleissuingrule2->{rentaldiscount},
271
    $sampleissuingrule2->{rentaldiscount},
266
    $sampleissuingrule2->{overduefinescap},
272
    $sampleissuingrule2->{overduefinescap},
267
    $sampleissuingrule2->{accountsent},
273
    $sampleissuingrule2->{accountsent},
Lines 288-293 $sth->execute( Link Here
288
    $sampleissuingrule3->{finedays},
294
    $sampleissuingrule3->{finedays},
289
    $sampleissuingrule3->{firstremind},
295
    $sampleissuingrule3->{firstremind},
290
    $sampleissuingrule3->{chargeperiod},
296
    $sampleissuingrule3->{chargeperiod},
297
    $sampleissuingrule3->{chargeperiod_charge_at},
291
    $sampleissuingrule3->{rentaldiscount},
298
    $sampleissuingrule3->{rentaldiscount},
292
    $sampleissuingrule3->{overduefinescap},
299
    $sampleissuingrule3->{overduefinescap},
293
    $sampleissuingrule3->{accountsent},
300
    $sampleissuingrule3->{accountsent},
(-)a/t/db_dependent/Fines.t (-1 / +56 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use C4::Context;
6
use C4::Overdues;
7
use Koha::Database;
8
use Koha::DateUtils;
9
10
use Test::More tests => 5;
11
12
#Start transaction
13
my $dbh = C4::Context->dbh;
14
my $schema = Koha::Database->new()->schema();
15
16
$dbh->{RaiseError} = 1;
17
$dbh->{AutoCommit} = 0;
18
19
$dbh->do(q|DELETE FROM issuingrules|);
20
21
my $issuingrule = $schema->resultset('Issuingrule')->create(
22
    {
23
        categorycode           => '*',
24
        itemtype               => '*',
25
        branchcode             => '*',
26
        fine                   => 1,
27
        finedays               => 0,
28
        chargeperiod           => 7,
29
        chargeperiod_charge_at => 0,
30
        lengthunit             => 'days',
31
        issuelength            => 1,
32
    }
33
);
34
35
ok( $issuingrule, 'Issuing rule created' );
36
37
my $period_start = dt_from_string('2000-01-01');
38
my $period_end = dt_from_string('2000-01-05');
39
40
my ( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
41
is( $fine, 0, '4 days overdue, charge period 7 days, charge at end of interval gives fine of $0' );
42
43
$period_end = dt_from_string('2000-01-10');
44
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
45
is( $fine, 1, '9 days overdue, charge period 7 days, charge at end of interval gives fine of $1' );
46
47
# Test charging fine at the *beginning* of each charge period
48
$issuingrule->update( { chargeperiod_charge_at => 1 } );
49
50
$period_end = dt_from_string('2000-01-05');
51
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
52
is( $fine, 1, '4 days overdue, charge period 7 days, charge at start of interval gives fine of $1' );
53
54
$period_end = dt_from_string('2000-01-10');
55
( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );
56
is( $fine, 2, '9 days overdue, charge period 7 days, charge at start of interval gives fine of $2' );

Return to bug 13590