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

(-)a/t/db_dependent/Koha/Charges/Fees.t (-6 / +37 lines)
Lines 34-40 BEGIN { Link Here
34
    use_ok('Koha::Charges::Fees');
34
    use_ok('Koha::Charges::Fees');
35
}
35
}
36
36
37
my $schema  = Koha::Database->new->schema;
37
my $builder = t::lib::TestBuilder->new();
38
my $builder = t::lib::TestBuilder->new();
39
$schema->storage->txn_begin;
38
40
39
my $patron_category = $builder->build_object(
41
my $patron_category = $builder->build_object(
40
    {
42
    {
Lines 59-68 my $itemtype = $builder->build_object( Link Here
59
    {
61
    {
60
        class => 'Koha::ItemTypes',
62
        class => 'Koha::ItemTypes',
61
        value => {
63
        value => {
62
            rentalcharge_daily => '0.00',
64
            rentalcharge_daily  => '0.00',
63
            rentalcharge       => '0.00',
65
            rentalcharge_hourly => '0.00',
64
            processfee         => '0.00',
66
            rentalcharge        => '0.00',
65
            defaultreplacecost => '0.00',
67
            processfee          => '0.00',
68
            defaultreplacecost  => '0.00',
66
        },
69
        },
67
    }
70
    }
68
);
71
);
Lines 304-310 subtest 'from_date accessor' => sub { Link Here
304
};
307
};
305
308
306
subtest 'accumulate_rentalcharge tests' => sub {
309
subtest 'accumulate_rentalcharge tests' => sub {
307
    plan tests => 4;
310
    plan tests => 5;
308
311
309
    my $fees = Koha::Charges::Fees->new(
312
    my $fees = Koha::Charges::Fees->new(
310
        {
313
        {
Lines 316-321 subtest 'accumulate_rentalcharge tests' => sub { Link Here
316
        }
319
        }
317
    );
320
    );
318
321
322
    # Daily tests
319
    $itemtype->rentalcharge_daily(1.00);
323
    $itemtype->rentalcharge_daily(1.00);
320
    $itemtype->store();
324
    $itemtype->store();
321
    is( $itemtype->rentalcharge_daily,
325
    is( $itemtype->rentalcharge_daily,
Lines 343-348 subtest 'accumulate_rentalcharge tests' => sub { Link Here
343
    is( $charge, 5.00,
347
    is( $charge, 5.00,
344
'Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays'
348
'Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays'
345
    );
349
    );
350
351
    # Hourly tests
352
    my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule(
353
        {
354
            categorycode => $patron->categorycode,
355
            itemtype     => $itemtype->id,
356
            branchcode   => $library->id
357
        }
358
    );
359
    $issuingrule->lengthunit('hours');
360
    $issuingrule->store();
361
    $itemtype->rentalcharge_hourly("2.50");
362
    $itemtype->store();
363
    $dt_from = dt_from_string();
364
    $dt_to   = dt_from_string()->add( hours => 4 );
365
    $fees    = Koha::Charges::Fees->new(
366
        {
367
            patron    => $patron,
368
            library   => $library,
369
            item      => $item,
370
            to_date   => $dt_to,
371
            from_date => $dt_from,
372
        }
373
    );
374
375
    $charge = $fees->accumulate_rentalcharge();
376
    is( $charge, 10.00, 'Hourly rental charge calculated correctly' );
346
};
377
};
347
378
379
$schema->storage->txn_rollback;
348
Time::Fake->reset;
380
Time::Fake->reset;
349
- 

Return to bug 23382