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

(-)a/t/db_dependent/Circulation.t (-13 / +58 lines)
Lines 9-15 use C4::Items; Link Here
9
use C4::Members;
9
use C4::Members;
10
use C4::Reserves;
10
use C4::Reserves;
11
11
12
use Test::More tests => 30;
12
use Test::More tests => 32;
13
13
14
BEGIN {
14
BEGIN {
15
    use_ok('C4::Circulation');
15
    use_ok('C4::Circulation');
Lines 129-144 $dbh->do('DELETE FROM issuingrules'); Link Here
129
$dbh->do(
129
$dbh->do(
130
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed,
130
    q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed,
131
                                maxissueqty, issuelength, lengthunit,
131
                                maxissueqty, issuelength, lengthunit,
132
                                renewalsallowed, renewalperiod)
132
                                renewalsallowed, renewalperiod,
133
                                fine, chargeperiod)
133
      VALUES (?, ?, ?, ?,
134
      VALUES (?, ?, ?, ?,
134
              ?, ?, ?,
135
              ?, ?, ?,
136
              ?, ?,
135
              ?, ?
137
              ?, ?
136
             )
138
             )
137
    },
139
    },
138
    {},
140
    {},
139
    '*', '*', '*', 25,
141
    '*', '*', '*', 25,
140
    20, 14, 'days',
142
    20, 14, 'days',
141
    1, 7
143
    1, 7,
144
    .10, 1
142
);
145
);
143
146
144
# Test C4::Circulation::ProcessOfflinePayment
147
# Test C4::Circulation::ProcessOfflinePayment
Lines 157-163 ok( $new_count == $original_count + 1, 'ProcessOfflinePayment makes payment cor Link Here
157
160
158
C4::Context->dbh->do("DELETE FROM accountlines WHERE borrowernumber IN ( SELECT borrowernumber FROM borrowers WHERE cardnumber = '99999999999' )");
161
C4::Context->dbh->do("DELETE FROM accountlines WHERE borrowernumber IN ( SELECT borrowernumber FROM borrowers WHERE cardnumber = '99999999999' )");
159
C4::Context->dbh->do("DELETE FROM borrowers WHERE cardnumber = '99999999999'");
162
C4::Context->dbh->do("DELETE FROM borrowers WHERE cardnumber = '99999999999'");
160
163
C4::Context->dbh->do("DELETE FROM accountlines");
161
{
164
{
162
# CanBookBeRenewed tests
165
# CanBookBeRenewed tests
163
166
Lines 174-189 C4::Context->dbh->do("DELETE FROM borrowers WHERE cardnumber = '99999999999'"); Link Here
174
    my $barcode = 'R00000342';
177
    my $barcode = 'R00000342';
175
    my $branch = 'MPL';
178
    my $branch = 'MPL';
176
179
177
    my ($item_bibnum, $item_bibitemnum, $itemnumber) =
180
    my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem(
178
        AddItem({ homebranch => $branch,
181
        {
179
                  holdingbranch => $branch,
182
            homebranch       => $branch,
180
                  barcode => $barcode, } , $biblionumber);
183
            holdingbranch    => $branch,
184
            barcode          => $barcode,
185
            replacementprice => 12.00
186
        },
187
        $biblionumber
188
    );
181
189
182
    my $barcode2 = 'R00000343';
190
    my $barcode2 = 'R00000343';
183
    my ($item_bibnum2, $item_bibitemnum2, $itemnumber2) =
191
    my ( $item_bibnum2, $item_bibitemnum2, $itemnumber2 ) = AddItem(
184
        AddItem({ homebranch => $branch,
192
        {
185
                  holdingbranch => $branch,
193
            homebranch       => $branch,
186
                  barcode => $barcode2, } , $biblionumber);
194
            holdingbranch    => $branch,
195
            barcode          => $barcode2,
196
            replacementprice => 23.00
197
        },
198
        $biblionumber
199
    );
187
200
188
    # Create 2 borrowers
201
    # Create 2 borrowers
189
    my %renewing_borrower_data = (
202
    my %renewing_borrower_data = (
Lines 281-286 C4::Context->dbh->do("DELETE FROM borrowers WHERE cardnumber = '99999999999'"); Link Here
281
    is( $renewokay, 0, 'Cannot renew, 0 renewals allowed');
294
    is( $renewokay, 0, 'Cannot renew, 0 renewals allowed');
282
    is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)');
295
    is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)');
283
296
297
    # Test WhenLostForgiveFine and WhenLostChargeReplacementFee
298
    diag("WhenLostForgiveFine and WhenLostChargeReplacementFee");
299
    C4::Context->set_preference('WhenLostForgiveFine','1');
300
    C4::Context->set_preference('WhenLostChargeReplacementFee','1');
301
302
    C4::Overdues::UpdateFine( $itemnumber, $renewing_borrower->{borrowernumber},
303
        15.00, q{}, Koha::DateUtils::output_pref($datedue) );
304
305
    LostItem( $itemnumber, 1 );
306
307
    my $total_due = $dbh->selectrow_array(
308
        'SELECT SUM( amountoutstanding ) FROM accountlines WHERE borrowernumber = ?',
309
        undef, $renewing_borrower->{borrowernumber}
310
    );
311
312
    ok( $total_due == 12, 'Borrower only charged replacement fee with both WhenLostForgiveFine and WhenLostChargeReplacementFee enabled' );
313
314
    C4::Context->dbh->do("DELETE FROM accountlines");
315
316
    C4::Context->set_preference('WhenLostForgiveFine','0');
317
    C4::Context->set_preference('WhenLostChargeReplacementFee','0');
318
319
    C4::Overdues::UpdateFine( $itemnumber2, $renewing_borrower->{borrowernumber},
320
        15.00, q{}, Koha::DateUtils::output_pref($datedue) );
321
322
    LostItem( $itemnumber2, 1 );
323
324
    my $total_due = $dbh->selectrow_array(
325
        'SELECT SUM( amountoutstanding ) FROM accountlines WHERE borrowernumber = ?',
326
        undef, $renewing_borrower->{borrowernumber}
327
    );
328
329
    ok( $total_due == 15, 'Borrower only charged fine with both WhenLostForgiveFine and WhenLostChargeReplacementFee disabled' );
284
}
330
}
285
331
286
$dbh->rollback;
332
$dbh->rollback;
287
- 

Return to bug 7639