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

(-)a/t/db_dependent/Circulation.t (-35 / +98 lines)
Lines 3201-3214 subtest 'ProcessOfflinePayment() tests' => sub { Link Here
3201
};
3201
};
3202
3202
3203
subtest 'Incremented fee tests' => sub {
3203
subtest 'Incremented fee tests' => sub {
3204
    plan tests => 11;
3204
    plan tests => 16;
3205
3205
3206
    t::lib::Mocks::mock_preference('item-level_itypes', 1);
3206
    my $dt = dt_from_string();
3207
    Time::Fake->offset( $dt->epoch );
3207
3208
3208
    my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store;
3209
    t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
3210
3211
    my $library =
3212
      $builder->build_object( { class => 'Koha::Libraries' } )->store;
3209
3213
3210
    my $module = new Test::MockModule('C4::Context');
3214
    my $module = new Test::MockModule('C4::Context');
3211
    $module->mock('userenv', sub { { branch => $library->id } });
3215
    $module->mock( 'userenv', sub { { branch => $library->id } } );
3212
3216
3213
    my $patron = $builder->build_object(
3217
    my $patron = $builder->build_object(
3214
        {
3218
        {
Lines 3220-3228 subtest 'Incremented fee tests' => sub { Link Here
3220
    my $itemtype = $builder->build_object(
3224
    my $itemtype = $builder->build_object(
3221
        {
3225
        {
3222
            class => 'Koha::ItemTypes',
3226
            class => 'Koha::ItemTypes',
3223
            value  => {
3227
            value => {
3224
                notforloan          => undef,
3228
                notforloan         => undef,
3225
                rentalcharge        => 0,
3229
                rentalcharge       => 0,
3226
                rentalcharge_daily => 1.000000
3230
                rentalcharge_daily => 1.000000
3227
            }
3231
            }
3228
        }
3232
        }
Lines 3245-3276 subtest 'Incremented fee tests' => sub { Link Here
3245
        }
3249
        }
3246
    )->store;
3250
    )->store;
3247
3251
3248
    is( $itemtype->rentalcharge_daily, '1.000000', 'Daily rental charge stored and retreived correctly' );
3252
    is( $itemtype->rentalcharge_daily,
3249
    is( $item->effective_itemtype, $itemtype->id, "Itemtype set correctly for item");
3253
        '1.000000', 'Daily rental charge stored and retreived correctly' );
3254
    is( $item->effective_itemtype, $itemtype->id,
3255
        "Itemtype set correctly for item" );
3250
3256
3251
    my $dt_from = dt_from_string();
3257
    my $dt_from     = dt_from_string();
3252
    my $dt_to = dt_from_string()->add( days => 7 );
3258
    my $dt_to       = dt_from_string()->add( days => 7 );
3253
    my $dt_to_renew = dt_from_string()->add( days => 13 );
3259
    my $dt_to_renew = dt_from_string()->add( days => 13 );
3254
3260
3255
    t::lib::Mocks::mock_preference('finesCalendar', 'ignoreCalendar');
3261
    # Daily Tests
3256
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3262
    t::lib::Mocks::mock_preference( 'finesCalendar', 'ignoreCalendar' );
3257
    my $accountline = Koha::Account::Lines->find({ itemnumber => $item->id });
3263
    my $issue =
3258
    is( $accountline->amount, '7.000000', "Daily rental charge calculated correctly with finesCalendar = ignoreCalendar" );
3264
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3265
    my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3266
    is( $accountline->amount, '7.000000',
3267
"Daily rental charge calculated correctly with finesCalendar = ignoreCalendar"
3268
    );
3259
    $accountline->delete();
3269
    $accountline->delete();
3260
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3270
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3261
    $accountline = Koha::Account::Lines->find({ itemnumber => $item->id });
3271
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3262
    is( $accountline->amount, '6.000000', "Daily rental charge calculated correctly with finesCalendar = ignoreCalendar, for renewal" );
3272
    is( $accountline->amount, '6.000000',
3273
"Daily rental charge calculated correctly with finesCalendar = ignoreCalendar, for renewal"
3274
    );
3263
    $accountline->delete();
3275
    $accountline->delete();
3264
    $issue->delete();
3276
    $issue->delete();
3265
3277
3266
    t::lib::Mocks::mock_preference('finesCalendar', 'noFinesWhenClosed');
3278
    t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' );
3267
    $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3279
    $issue =
3268
    $accountline = Koha::Account::Lines->find({ itemnumber => $item->id });
3280
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3269
    is( $accountline->amount, '7.000000', "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed" );
3281
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3282
    is( $accountline->amount, '7.000000',
3283
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed"
3284
    );
3270
    $accountline->delete();
3285
    $accountline->delete();
3271
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3286
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3272
    $accountline = Koha::Account::Lines->find({ itemnumber => $item->id });
3287
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3273
    is( $accountline->amount, '6.000000', "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed, for renewal" );
3288
    is( $accountline->amount, '6.000000',
3289
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed, for renewal"
3290
    );
3274
    $accountline->delete();
3291
    $accountline->delete();
3275
    $issue->delete();
3292
    $issue->delete();
3276
3293
Lines 3280-3306 subtest 'Incremented fee tests' => sub { Link Here
3280
        title       => 'Test holiday',
3297
        title       => 'Test holiday',
3281
        description => 'Test holiday'
3298
        description => 'Test holiday'
3282
    );
3299
    );
3283
    $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3300
    $issue =
3284
    $accountline = Koha::Account::Lines->find({ itemnumber => $item->id });
3301
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3285
    is( $accountline->amount, '6.000000', "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays" );
3302
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3303
    is( $accountline->amount, '6.000000',
3304
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays"
3305
    );
3286
    $accountline->delete();
3306
    $accountline->delete();
3287
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3307
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3288
    $accountline = Koha::Account::Lines->find({ itemnumber => $item->id });
3308
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3289
    is( $accountline->amount, '5.000000', "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays, for renewal" );
3309
    is( $accountline->amount, '5.000000',
3310
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays, for renewal"
3311
    );
3290
    $accountline->delete();
3312
    $accountline->delete();
3291
    $issue->delete();
3313
    $issue->delete();
3292
3314
3293
    $itemtype->rentalcharge('2.000000')->store;
3315
    $itemtype->rentalcharge('2.000000')->store;
3294
    is( $itemtype->rentalcharge, '2.000000', 'Rental charge updated and retreived correctly' );
3316
    is( $itemtype->rentalcharge, '2.000000',
3295
    $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from);
3317
        'Rental charge updated and retreived correctly' );
3296
    my $accountlines = Koha::Account::Lines->search({ itemnumber => $item->id });
3318
    $issue =
3297
    is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly");
3319
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3320
    my $accountlines =
3321
      Koha::Account::Lines->search( { itemnumber => $item->id } );
3322
    is( $accountlines->count, '2',
3323
        "Fixed charge and accrued charge recorded distinctly" );
3298
    $accountlines->delete();
3324
    $accountlines->delete();
3299
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3325
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3300
    $accountlines = Koha::Account::Lines->search({ itemnumber => $item->id });
3326
    $accountlines = Koha::Account::Lines->search( { itemnumber => $item->id } );
3301
    is( $accountlines->count, '2', "Fixed charge and accrued charge recorded distinctly, for renewal");
3327
    is( $accountlines->count, '2',
3328
        "Fixed charge and accrued charge recorded distinctly, for renewal" );
3302
    $accountlines->delete();
3329
    $accountlines->delete();
3303
    $issue->delete();
3330
    $issue->delete();
3331
    $itemtype->rentalcharge('00.000000')->store;
3332
    is( $itemtype->rentalcharge, '00.000000',
3333
        'Rental charge reset and retreived correctly' );
3334
3335
    # Hourly
3336
    my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule(
3337
        {
3338
            categorycode => $patron->categorycode,
3339
            itemtype     => $itemtype->id,
3340
            branchcode   => $library->id
3341
        }
3342
    );
3343
    $issuingrule->lengthunit('hours')->store();
3344
    is( $issuingrule->lengthunit, 'hours',
3345
        'Issuingrule updated and retrieved correctly' );
3346
3347
    $itemtype->rentalcharge_hourly('2.500000')->store();
3348
    is( $itemtype->rentalcharge_hourly,
3349
        '2.500000', 'Hourly rental charge stored and retreived correctly' );
3350
3351
    $dt_to       = dt_from_string()->add( hours => 4 );
3352
    $dt_to_renew = dt_from_string()->add( hours => 6 );
3353
3354
    $issue =
3355
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3356
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3357
    is( $accountline->amount, '10.000000',
3358
        "Hourly rental charge calculated correctly" );
3359
    $accountline->delete();
3360
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3361
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3362
    is( $accountline->amount, '5.000000',
3363
        "Hourly rental charge calculated correctly, for renewal" );
3364
    $accountline->delete();
3365
    $issue->delete();
3366
    $issuingrule->lengthunit('days')->store();
3367
    Time::Fake->reset;
3304
};
3368
};
3305
3369
3306
subtest 'CanBookBeIssued & RentalFeesCheckoutConfirmation' => sub {
3370
subtest 'CanBookBeIssued & RentalFeesCheckoutConfirmation' => sub {
3307
- 

Return to bug 23382