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

(-)a/t/db_dependent/Circulation.t (-1 / +31 lines)
Lines 25-31 use C4::Members; Link Here
25
use C4::Reserves;
25
use C4::Reserves;
26
use Koha::DateUtils;
26
use Koha::DateUtils;
27
27
28
use Test::More tests => 49;
28
use Test::More tests => 53;
29
29
30
BEGIN {
30
BEGIN {
31
    use_ok('C4::Circulation');
31
    use_ok('C4::Circulation');
Lines 149-158 $dbh->do( Link Here
149
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed,
149
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed,
150
                                maxissueqty, issuelength, lengthunit,
150
                                maxissueqty, issuelength, lengthunit,
151
                                renewalsallowed, renewalperiod,
151
                                renewalsallowed, renewalperiod,
152
                                norenewalbefore, auto_renew,
152
                                fine, chargeperiod)
153
                                fine, chargeperiod)
153
      VALUES (?, ?, ?, ?,
154
      VALUES (?, ?, ?, ?,
154
              ?, ?, ?,
155
              ?, ?, ?,
155
              ?, ?,
156
              ?, ?,
157
              ?, ?,
156
              ?, ?
158
              ?, ?
157
             )
159
             )
158
    },
160
    },
Lines 160-165 $dbh->do( Link Here
160
    '*', '*', '*', 25,
162
    '*', '*', '*', 25,
161
    20, 14, 'days',
163
    20, 14, 'days',
162
    1, 7,
164
    1, 7,
165
    '', 0,
163
    .10, 1
166
    .10, 1
164
);
167
);
165
168
Lines 321-326 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
321
    $reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber});
324
    $reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber});
322
    CancelReserve({ reserve_id => $reserveid });
325
    CancelReserve({ reserve_id => $reserveid });
323
326
327
    # Test automatic renewal before value for "norenewalbefore" in policy is set
328
    my $barcode4 = '11235813';
329
    my ( $item_bibnum4, $item_bibitemnum4, $itemnumber4 ) = AddItem(
330
        {
331
            homebranch       => $branch,
332
            holdingbranch    => $branch,
333
            barcode          => $barcode4,
334
            replacementprice => 16.00
335
        },
336
        $biblionumber
337
    );
338
339
    AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, 1 );
340
    ( $renewokay, $error ) =
341
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
342
    is( $renewokay, 0, 'Cannot renew, renewal is automatic' );
343
    is( $error, 'auto_renew',
344
        'Cannot renew, renewal is automatic (returned code is auto_renew)' );
345
324
    # set policy to require that loans cannot be
346
    # set policy to require that loans cannot be
325
    # renewed until seven days prior to the due date
347
    # renewed until seven days prior to the due date
326
    $dbh->do('UPDATE issuingrules SET norenewalbefore = 7');
348
    $dbh->do('UPDATE issuingrules SET norenewalbefore = 7');
Lines 333-338 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
333
        'renewals permitted 7 days before due date, as expected',
355
        'renewals permitted 7 days before due date, as expected',
334
    );
356
    );
335
357
358
    # Test automatic renewal again
359
    ( $renewokay, $error ) =
360
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
361
    is( $renewokay, 0, 'Cannot renew, renewal is automatic and premature' );
362
    is( $error, 'auto_too_soon',
363
'Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)'
364
    );
365
336
    # Too many renewals
366
    # Too many renewals
337
367
338
    # set policy to forbid renewals
368
    # set policy to forbid renewals
(-)a/t/db_dependent/Circulation_Issuingrule.t (-2 / +8 lines)
Lines 117-122 my $sampleissuingrule1 = { Link Here
117
    lengthunit         => 'Null',
117
    lengthunit         => 'Null',
118
    renewalperiod      => 5,
118
    renewalperiod      => 5,
119
    norenewalbefore    => 6,
119
    norenewalbefore    => 6,
120
    auto_renew         => 0,
120
    issuelength        => 5,
121
    issuelength        => 5,
121
    chargeperiod       => 0,
122
    chargeperiod       => 0,
122
    rentaldiscount     => '2.000000',
123
    rentaldiscount     => '2.000000',
Lines 140-145 my $sampleissuingrule2 = { Link Here
140
    renewalsallowed    => 'Null',
141
    renewalsallowed    => 'Null',
141
    renewalperiod      => 2,
142
    renewalperiod      => 2,
142
    norenewalbefore    => 7,
143
    norenewalbefore    => 7,
144
    auto_renew         => 0,
143
    reservesallowed    => 'Null',
145
    reservesallowed    => 'Null',
144
    issuelength        => 2,
146
    issuelength        => 2,
145
    lengthunit         => 'Null',
147
    lengthunit         => 'Null',
Lines 165-170 my $sampleissuingrule3 = { Link Here
165
    renewalsallowed    => 'Null',
167
    renewalsallowed    => 'Null',
166
    renewalperiod      => 3,
168
    renewalperiod      => 3,
167
    norenewalbefore    => 8,
169
    norenewalbefore    => 8,
170
    auto_renew         => 0,
168
    reservesallowed    => 'Null',
171
    reservesallowed    => 'Null',
169
    issuelength        => 3,
172
    issuelength        => 3,
170
    lengthunit         => 'Null',
173
    lengthunit         => 'Null',
Lines 190-195 $query = 'INSERT INTO issuingrules ( Link Here
190
                renewalsallowed,
193
                renewalsallowed,
191
                renewalperiod,
194
                renewalperiod,
192
                norenewalbefore,
195
                norenewalbefore,
196
                auto_renew,
193
                reservesallowed,
197
                reservesallowed,
194
                issuelength,
198
                issuelength,
195
                lengthunit,
199
                lengthunit,
Lines 206-212 $query = 'INSERT INTO issuingrules ( Link Here
206
                chargename,
210
                chargename,
207
                restrictedtype,
211
                restrictedtype,
208
                maxsuspensiondays
212
                maxsuspensiondays
209
                ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
213
                ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
210
my $sth = $dbh->prepare($query);
214
my $sth = $dbh->prepare($query);
211
$sth->execute(
215
$sth->execute(
212
    $sampleissuingrule1->{branchcode},
216
    $sampleissuingrule1->{branchcode},
Lines 216-221 $sth->execute( Link Here
216
    $sampleissuingrule1->{renewalsallowed},
220
    $sampleissuingrule1->{renewalsallowed},
217
    $sampleissuingrule1->{renewalperiod},
221
    $sampleissuingrule1->{renewalperiod},
218
    $sampleissuingrule1->{norenewalbefore},
222
    $sampleissuingrule1->{norenewalbefore},
223
    $sampleissuingrule1->{auto_renew},
219
    $sampleissuingrule1->{reservesallowed},
224
    $sampleissuingrule1->{reservesallowed},
220
    $sampleissuingrule1->{issuelength},
225
    $sampleissuingrule1->{issuelength},
221
    $sampleissuingrule1->{lengthunit},
226
    $sampleissuingrule1->{lengthunit},
Lines 241-246 $sth->execute( Link Here
241
    $sampleissuingrule2->{renewalsallowed},
246
    $sampleissuingrule2->{renewalsallowed},
242
    $sampleissuingrule2->{renewalperiod},
247
    $sampleissuingrule2->{renewalperiod},
243
    $sampleissuingrule2->{norenewalbefore},
248
    $sampleissuingrule2->{norenewalbefore},
249
    $sampleissuingrule1->{auto_renew},
244
    $sampleissuingrule2->{reservesallowed},
250
    $sampleissuingrule2->{reservesallowed},
245
    $sampleissuingrule2->{issuelength},
251
    $sampleissuingrule2->{issuelength},
246
    $sampleissuingrule2->{lengthunit},
252
    $sampleissuingrule2->{lengthunit},
Lines 266-271 $sth->execute( Link Here
266
    $sampleissuingrule3->{renewalsallowed},
272
    $sampleissuingrule3->{renewalsallowed},
267
    $sampleissuingrule3->{renewalperiod},
273
    $sampleissuingrule3->{renewalperiod},
268
    $sampleissuingrule3->{norenewalbefore},
274
    $sampleissuingrule3->{norenewalbefore},
275
    $sampleissuingrule1->{auto_renew},
269
    $sampleissuingrule3->{reservesallowed},
276
    $sampleissuingrule3->{reservesallowed},
270
    $sampleissuingrule3->{issuelength},
277
    $sampleissuingrule3->{issuelength},
271
    $sampleissuingrule3->{lengthunit},
278
    $sampleissuingrule3->{lengthunit},
272
- 

Return to bug 11577