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

(-)a/t/db_dependent/Circulation.t (-10 / +38 lines)
Lines 3074-3080 subtest 'ProcessOfflinePayment() tests' => sub { Link Here
3074
};
3074
};
3075
3075
3076
subtest 'Incremented fee tests' => sub {
3076
subtest 'Incremented fee tests' => sub {
3077
    plan tests => 16;
3077
    plan tests => 20;
3078
3078
3079
    my $dt = dt_from_string();
3079
    my $dt = dt_from_string();
3080
    Time::Fake->offset( $dt->epoch );
3080
    Time::Fake->offset( $dt->epoch );
Lines 3207-3230 subtest 'Incremented fee tests' => sub { Link Here
3207
    is( $issuingrule->lengthunit, 'hours',
3207
    is( $issuingrule->lengthunit, 'hours',
3208
        'Issuingrule updated and retrieved correctly' );
3208
        'Issuingrule updated and retrieved correctly' );
3209
3209
3210
    $itemtype->rentalcharge_hourly('2.500000')->store();
3210
    $itemtype->rentalcharge_hourly('0.25')->store();
3211
    is( $itemtype->rentalcharge_hourly,
3211
    is( $itemtype->rentalcharge_hourly,
3212
        '2.500000', 'Hourly rental charge stored and retreived correctly' );
3212
        '0.25', 'Hourly rental charge stored and retreived correctly' );
3213
3213
3214
    $dt_to       = dt_from_string()->add( hours => 4 );
3214
    $dt_to       = dt_from_string()->add( hours => 168 );
3215
    $dt_to_renew = dt_from_string()->add( hours => 6 );
3215
    $dt_to_renew = dt_from_string()->add( hours => 312 );
3216
    $calendar->delete_holiday( weekday => 3);
3217
3216
3217
    t::lib::Mocks::mock_preference( 'finesCalendar', 'ignoreCalendar' );
3218
    $issue =
3218
    $issue =
3219
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3219
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3220
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3220
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3221
    is( $accountline->amount, '10.000000',
3221
    is( $accountline->amount + 0, 42,
3222
        "Hourly rental charge calculated correctly" );
3222
        "Hourly rental charge calculated correctly with finesCalendar = ignoreCalendar (168h * 0.25u)" );
3223
    $accountline->delete();
3223
    $accountline->delete();
3224
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3224
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3225
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3225
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3226
    is( $accountline->amount, '5.000000',
3226
    is( $accountline->amount + 0, 36,
3227
        "Hourly rental charge calculated correctly, for renewal" );
3227
        "Hourly rental charge calculated correctly with finesCalendar = ignoreCalendar, for renewal (312h - 168h * 0.25u)" );
3228
    $accountline->delete();
3229
    $issue->delete();
3230
3231
    t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' );
3232
    $issue =
3233
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3234
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3235
    is( $accountline->amount + 0, 36,
3236
        "Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays (168h - 24h * 0.25u)" );
3237
    $accountline->delete();
3238
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3239
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3240
    is( $accountline->amount + 0, 30,
3241
        "Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays, for renewal (312h - 168h - 24h * 0.25u" );
3242
    $accountline->delete();
3243
    $issue->delete();
3244
3245
    $calendar->delete_holiday( weekday => 3 );
3246
    $issue =
3247
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3248
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3249
    is( $accountline->amount + 0, 42,
3250
        "Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed (168h - 0h * 0.25u" );
3251
    $accountline->delete();
3252
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3253
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3254
    is( $accountline->amount + 0, 36,
3255
        "Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed, for renewal (312h - 168h - 0h * 0.25u)" );
3228
    $accountline->delete();
3256
    $accountline->delete();
3229
    $issue->delete();
3257
    $issue->delete();
3230
    $issuingrule->lengthunit('days')->store();
3258
    $issuingrule->lengthunit('days')->store();
(-)a/t/db_dependent/Koha/Charges/Fees.t (-6 / +16 lines)
Lines 307-313 subtest 'from_date accessor' => sub { Link Here
307
};
307
};
308
308
309
subtest 'accumulate_rentalcharge tests' => sub {
309
subtest 'accumulate_rentalcharge tests' => sub {
310
    plan tests => 5;
310
    plan tests => 7;
311
311
312
    my $fees = Koha::Charges::Fees->new(
312
    my $fees = Koha::Charges::Fees->new(
313
        {
313
        {
Lines 358-367 subtest 'accumulate_rentalcharge tests' => sub { Link Here
358
    );
358
    );
359
    $issuingrule->lengthunit('hours');
359
    $issuingrule->lengthunit('hours');
360
    $issuingrule->store();
360
    $issuingrule->store();
361
    $itemtype->rentalcharge_hourly("2.50");
361
    $itemtype->rentalcharge_hourly("0.25");
362
    $itemtype->store();
362
    $itemtype->store();
363
    $dt_from = dt_from_string();
363
364
    $dt_to   = dt_from_string()->add( hours => 4 );
364
    $dt_to   = $dt_from->clone->add( hours => 96 );
365
    $fees    = Koha::Charges::Fees->new(
365
    $fees    = Koha::Charges::Fees->new(
366
        {
366
        {
367
            patron    => $patron,
367
            patron    => $patron,
Lines 372-379 subtest 'accumulate_rentalcharge tests' => sub { Link Here
372
        }
372
        }
373
    );
373
    );
374
374
375
    t::lib::Mocks::mock_preference( 'finesCalendar', 'ignoreCalendar' );
376
    $charge = $fees->accumulate_rentalcharge();
377
    is( $charge, 24.00, 'Hourly rental charge calculated correctly (96h * 0.25u)' );
378
379
    t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' );
380
    $charge = $fees->accumulate_rentalcharge();
381
    is( $charge, 18.00,
382
'Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays (96h - 24h * 0.25u)'
383
    );
384
385
    $calendar->delete_holiday( weekday => 3);
375
    $charge = $fees->accumulate_rentalcharge();
386
    $charge = $fees->accumulate_rentalcharge();
376
    is( $charge, 10.00, 'Hourly rental charge calculated correctly' );
387
    is( $charge, 24.00, 'Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed (96h - 0h * 0.25u)' );
377
};
388
};
378
389
379
$schema->storage->txn_rollback;
390
$schema->storage->txn_rollback;
380
- 

Return to bug 23382