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

(-)a/t/db_dependent/Overdues.t (-2 / +31 lines)
Lines 132-138 $schema->storage->txn_rollback; Link Here
132
132
133
subtest 'UpdateFine tests' => sub {
133
subtest 'UpdateFine tests' => sub {
134
134
135
    plan tests => 59;
135
    plan tests => 68;
136
136
137
    $schema->storage->txn_begin;
137
    $schema->storage->txn_begin;
138
138
Lines 242-247 subtest 'UpdateFine tests' => sub { Link Here
242
    # Total : Outstanding : MaxFine
242
    # Total : Outstanding : MaxFine
243
    #  100  :     100     :   100
243
    #  100  :     100     :   100
244
244
245
    # A day passes, the item is still overdue, update fine is called again
246
    # we don't expect to increase above MaxFine of 100
247
    UpdateFine(
248
        {
249
            issue_id       => $checkout2->issue_id,
250
            itemnumber     => $item2->itemnumber,
251
            borrowernumber => $patron->borrowernumber,
252
            amount         => '40',
253
            due            => $checkout2->date_due
254
        }
255
    );
256
257
    $fines = Koha::Account::Lines->search(
258
        { borrowernumber => $patron->borrowernumber },
259
        { order_by       => { '-asc' => 'accountlines_id' } }
260
    );
261
    is( $fines->count,        2,    "Existing fine updated for second checkout, no new fine added" );
262
    $fine = $fines->next;
263
    is( $fine->amount+0, 80, "First fine amount unchanged" );
264
    is( $fine->amountoutstanding+0, 80, "First fine amountoutstanding unchanged" );
265
    my $fine2 = $fines->next;
266
    is( $fine2->amount+0, 20, "Second fine capped at '20' by MaxFine" );
267
    is( $fine2->amountoutstanding+0, 20, "Second fine amountoutstanding capped at '20' by MaxFine" );
268
    is( $fine2->issue_id, $checkout2->issue_id, "Second fine is associated with the correct issue" );
269
    is( $fine2->itemnumber, $checkout2->itemnumber, "Second fine is associated with the correct item" );
270
    is( $fine->amount + $fine2->amount, '100', "Total fines = 100" );
271
    is( $fine->amountoutstanding + $fine2->amountoutstanding, '100', "Total outstanding = 100" );
272
    # Total : Outstanding : MaxFine
273
    #  100  :     100     :   100
274
245
    # Partial pay fine 1
275
    # Partial pay fine 1
246
    $fine->amountoutstanding(50)->store;
276
    $fine->amountoutstanding(50)->store;
247
    # Total : Outstanding : MaxFine
277
    # Total : Outstanding : MaxFine
248
- 

Return to bug 25123