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

(-)a/t/db_dependent/Circulation.t (-19 / +19 lines)
Lines 3506-3514 subtest 'Incremented fee tests' => sub { Link Here
3506
        {
3506
        {
3507
            class => 'Koha::ItemTypes',
3507
            class => 'Koha::ItemTypes',
3508
            value => {
3508
            value => {
3509
                notforloan         => undef,
3509
                notforloan                   => undef,
3510
                rentalcharge       => 0,
3510
                rentalcharge                 => 0,
3511
                rentalcharge_daily => 1,
3511
                rentalcharge_daily           => 1,
3512
                rentalcharge_daily_calendar  => 0
3512
            }
3513
            }
3513
        }
3514
        }
3514
    )->store;
3515
    )->store;
Lines 3531-3564 subtest 'Incremented fee tests' => sub { Link Here
3531
    my $dt_to_renew = $now->clone->add( days => 13 );
3532
    my $dt_to_renew = $now->clone->add( days => 13 );
3532
3533
3533
    # Daily Tests
3534
    # Daily Tests
3534
    t::lib::Mocks::mock_preference( 'finesCalendar', 'ignoreCalendar' );
3535
    my $issue =
3535
    my $issue =
3536
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3536
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3537
    my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3537
    my $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3538
    is( $accountline->amount+0, 7,
3538
    is( $accountline->amount+0, 7,
3539
"Daily rental charge calculated correctly with finesCalendar = ignoreCalendar"
3539
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0"
3540
    );
3540
    );
3541
    $accountline->delete();
3541
    $accountline->delete();
3542
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3542
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3543
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3543
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3544
    is( $accountline->amount+0, 6,
3544
    is( $accountline->amount+0, 6,
3545
"Daily rental charge calculated correctly with finesCalendar = ignoreCalendar, for renewal"
3545
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 0, for renewal"
3546
    );
3546
    );
3547
    $accountline->delete();
3547
    $accountline->delete();
3548
    $issue->delete();
3548
    $issue->delete();
3549
3549
3550
    t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' );
3550
    t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' );
3551
    $itemtype->rentalcharge_daily_calendar(1)->store();
3551
    $issue =
3552
    $issue =
3552
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3553
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3553
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3554
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3554
    is( $accountline->amount+0, 7,
3555
    is( $accountline->amount+0, 7,
3555
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed"
3556
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1"
3556
    );
3557
    );
3557
    $accountline->delete();
3558
    $accountline->delete();
3558
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3559
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3559
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3560
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3560
    is( $accountline->amount+0, 6,
3561
    is( $accountline->amount+0, 6,
3561
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed, for renewal"
3562
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1, for renewal"
3562
    );
3563
    );
3563
    $accountline->delete();
3564
    $accountline->delete();
3564
    $issue->delete();
3565
    $issue->delete();
Lines 3579-3591 subtest 'Incremented fee tests' => sub { Link Here
3579
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3580
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3580
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3581
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3581
    is( $accountline->amount+0, 6,
3582
    is( $accountline->amount+0, 6,
3582
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed $closed_day_name"
3583
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name"
3583
    );
3584
    );
3584
    $accountline->delete();
3585
    $accountline->delete();
3585
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3586
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3586
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3587
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3587
    is( $accountline->amount+0, 5,
3588
    is( $accountline->amount+0, 5,
3588
"Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed $closed_day_name, for renewal"
3589
"Daily rental charge calculated correctly with rentalcharge_daily_calendar = 1 and closed $closed_day_name, for renewal"
3589
    );
3590
    );
3590
    $accountline->delete();
3591
    $accountline->delete();
3591
    $issue->delete();
3592
    $issue->delete();
Lines 3628-3658 subtest 'Incremented fee tests' => sub { Link Here
3628
    $dt_to       = $now->clone->add( hours => 168 );
3629
    $dt_to       = $now->clone->add( hours => 168 );
3629
    $dt_to_renew = $now->clone->add( hours => 312 );
3630
    $dt_to_renew = $now->clone->add( hours => 312 );
3630
3631
3631
    t::lib::Mocks::mock_preference( 'finesCalendar', 'ignoreCalendar' );
3632
    $itemtype->rentalcharge_hourly_calendar(0)->store();
3632
    $issue =
3633
    $issue =
3633
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3634
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3634
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3635
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3635
    is( $accountline->amount + 0, 42,
3636
    is( $accountline->amount + 0, 42,
3636
        "Hourly rental charge calculated correctly with finesCalendar = ignoreCalendar (168h * 0.25u)" );
3637
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0 (168h * 0.25u)" );
3637
    $accountline->delete();
3638
    $accountline->delete();
3638
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3639
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3639
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3640
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3640
    is( $accountline->amount + 0, 36,
3641
    is( $accountline->amount + 0, 36,
3641
        "Hourly rental charge calculated correctly with finesCalendar = ignoreCalendar, for renewal (312h - 168h * 0.25u)" );
3642
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 0, for renewal (312h - 168h * 0.25u)" );
3642
    $accountline->delete();
3643
    $accountline->delete();
3643
    $issue->delete();
3644
    $issue->delete();
3644
3645
3645
    t::lib::Mocks::mock_preference( 'finesCalendar', 'noFinesWhenClosed' );
3646
    $itemtype->rentalcharge_hourly_calendar(1)->store();
3646
    $issue =
3647
    $issue =
3647
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3648
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3648
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3649
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3649
    is( $accountline->amount + 0, 36,
3650
    is( $accountline->amount + 0, 36,
3650
        "Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed $closed_day_name (168h - 24h * 0.25u)" );
3651
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name (168h - 24h * 0.25u)" );
3651
    $accountline->delete();
3652
    $accountline->delete();
3652
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3653
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3653
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3654
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3654
    is( $accountline->amount + 0, 30,
3655
    is( $accountline->amount + 0, 30,
3655
        "Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed $closed_day_name, for renewal (312h - 168h - 24h * 0.25u" );
3656
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 and closed $closed_day_name, for renewal (312h - 168h - 24h * 0.25u" );
3656
    $accountline->delete();
3657
    $accountline->delete();
3657
    $issue->delete();
3658
    $issue->delete();
3658
3659
Lines 3661-3672 subtest 'Incremented fee tests' => sub { Link Here
3661
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3662
      AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3662
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3663
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3663
    is( $accountline->amount + 0, 42,
3664
    is( $accountline->amount + 0, 42,
3664
        "Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed (168h - 0h * 0.25u" );
3665
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1 (168h - 0h * 0.25u" );
3665
    $accountline->delete();
3666
    $accountline->delete();
3666
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3667
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3667
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3668
    $accountline = Koha::Account::Lines->find( { itemnumber => $item->id } );
3668
    is( $accountline->amount + 0, 36,
3669
    is( $accountline->amount + 0, 36,
3669
        "Hourly rental charge calculated correctly with finesCalendar = noFinesWhenClosed, for renewal (312h - 168h - 0h * 0.25u)" );
3670
        "Hourly rental charge calculated correctly with rentalcharge_hourly_calendar = 1, for renewal (312h - 168h - 0h * 0.25u)" );
3670
    $accountline->delete();
3671
    $accountline->delete();
3671
    $issue->delete();
3672
    $issue->delete();
3672
    Time::Fake->reset;
3673
    Time::Fake->reset;
3673
- 

Return to bug 21443