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

(-)a/t/db_dependent/Circulation.t (-1 / +31 lines)
Lines 26-32 use C4::Reserves; Link Here
26
use Koha::DateUtils;
26
use Koha::DateUtils;
27
use Koha::Database;
27
use Koha::Database;
28
28
29
use Test::More tests => 51;
29
use Test::More tests => 55;
30
30
31
BEGIN {
31
BEGIN {
32
    use_ok('C4::Circulation');
32
    use_ok('C4::Circulation');
Lines 151-160 $dbh->do( Link Here
151
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed,
151
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed,
152
                                maxissueqty, issuelength, lengthunit,
152
                                maxissueqty, issuelength, lengthunit,
153
                                renewalsallowed, renewalperiod,
153
                                renewalsallowed, renewalperiod,
154
                                norenewalbefore, auto_renew,
154
                                fine, chargeperiod)
155
                                fine, chargeperiod)
155
      VALUES (?, ?, ?, ?,
156
      VALUES (?, ?, ?, ?,
156
              ?, ?, ?,
157
              ?, ?, ?,
157
              ?, ?,
158
              ?, ?,
159
              ?, ?,
158
              ?, ?
160
              ?, ?
159
             )
161
             )
160
    },
162
    },
Lines 162-167 $dbh->do( Link Here
162
    '*', '*', '*', 25,
164
    '*', '*', '*', 25,
163
    20, 14, 'days',
165
    20, 14, 'days',
164
    1, 7,
166
    1, 7,
167
    '', 0,
165
    .10, 1
168
    .10, 1
166
);
169
);
167
170
Lines 323-328 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
323
    $reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber});
326
    $reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber});
324
    CancelReserve({ reserve_id => $reserveid });
327
    CancelReserve({ reserve_id => $reserveid });
325
328
329
    # Test automatic renewal before value for "norenewalbefore" in policy is set
330
    my $barcode4 = '11235813';
331
    my ( $item_bibnum4, $item_bibitemnum4, $itemnumber4 ) = AddItem(
332
        {
333
            homebranch       => $branch,
334
            holdingbranch    => $branch,
335
            barcode          => $barcode4,
336
            replacementprice => 16.00
337
        },
338
        $biblionumber
339
    );
340
341
    AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, 1 );
342
    ( $renewokay, $error ) =
343
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
344
    is( $renewokay, 0, 'Cannot renew, renewal is automatic' );
345
    is( $error, 'auto_renew',
346
        'Cannot renew, renewal is automatic (returned code is auto_renew)' );
347
326
    # set policy to require that loans cannot be
348
    # set policy to require that loans cannot be
327
    # renewed until seven days prior to the due date
349
    # renewed until seven days prior to the due date
328
    $dbh->do('UPDATE issuingrules SET norenewalbefore = 7');
350
    $dbh->do('UPDATE issuingrules SET norenewalbefore = 7');
Lines 335-340 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
335
        'renewals permitted 7 days before due date, as expected',
357
        'renewals permitted 7 days before due date, as expected',
336
    );
358
    );
337
359
360
    # Test automatic renewal again
361
    ( $renewokay, $error ) =
362
      CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
363
    is( $renewokay, 0, 'Cannot renew, renewal is automatic and premature' );
364
    is( $error, 'auto_too_soon',
365
'Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)'
366
    );
367
338
    # Too many renewals
368
    # Too many renewals
339
369
340
    # set policy to forbid renewals
370
    # 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