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

(-)a/C4/Circulation.pm (-2 / +25 lines)
Lines 989-994 sub CanBookBeIssued { Link Here
989
989
990
    if ( $rentalConfirmation ){
990
    if ( $rentalConfirmation ){
991
        my ($rentalCharge) = GetIssuingCharges( $item->itemnumber, $patron->borrowernumber );
991
        my ($rentalCharge) = GetIssuingCharges( $item->itemnumber, $patron->borrowernumber );
992
        my $itemtype = Koha::ItemTypes->find( $item->itype ); # GetItem sets effective itemtype
993
        $rentalCharge += $itemtype->calc_rental_charge_daily( { from => dt_from_string(), to => $duedate } );
992
        if ( $rentalCharge > 0 ){
994
        if ( $rentalCharge > 0 ){
993
            $needsconfirmation{RENTALCHARGE} = $rentalCharge;
995
            $needsconfirmation{RENTALCHARGE} = $rentalCharge;
994
        }
996
        }
Lines 1437-1442 sub AddIssue { Link Here
1437
                AddIssuingCharge( $issue, $charge, $description );
1439
                AddIssuingCharge( $issue, $charge, $description );
1438
            }
1440
            }
1439
1441
1442
            my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype );
1443
            if ( $itemtype ) {
1444
                my $daily_charge = $itemtype->calc_rental_charge_daily( { from => $issuedate, to => $datedue } );
1445
                if ( $daily_charge > 0 ) {
1446
                    AddIssuingCharge( $issue, $daily_charge, 'Daily rental' ) if $daily_charge > 0;
1447
                    $charge += $daily_charge;
1448
                    $item->{charge} = $charge;
1449
                }
1450
            }
1451
1440
            # Record the fact that this book was issued.
1452
            # Record the fact that this book was issued.
1441
            &UpdateStats(
1453
            &UpdateStats(
1442
                {
1454
                {
Lines 2859-2871 sub AddRenewal { Link Here
2859
    $renews = $item->renewals + 1;
2871
    $renews = $item->renewals + 1;
2860
    ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->biblionumber, $itemnumber, { log_action => 0 } );
2872
    ModItem( { renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $item->biblionumber, $itemnumber, { log_action => 0 } );
2861
2873
2862
    # Charge a new rental fee, if applicable?
2874
    # Charge a new rental fee, if applicable
2863
    my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
2875
    my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
2864
    if ( $charge > 0 ) {
2876
    if ( $charge > 0 ) {
2865
        my $description = "Renewal of Rental Item " . $biblio->title . " " .$item->barcode;
2877
        my $description = "Renewal of Rental Item " . $biblio->title . " " .$item->barcode;
2866
        AddIssuingCharge($issue, $charge, $description);
2878
        AddIssuingCharge($issue, $charge, $description);
2867
    }
2879
    }
2868
2880
2881
    # Charge a new daily rental fee, if applicable
2882
    my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype );
2883
    if ( $itemtype ) {
2884
        my $daily_charge = $itemtype->calc_rental_charge_daily( { from => dt_from_string($lastreneweddate), to => $datedue } );
2885
        if ( $daily_charge > 0 ) {
2886
            my $type_desc = "Renewal of Daily Rental Item " . $biblio->title . " $item->{'barcode'}";
2887
            AddIssuingCharge( $issue, $daily_charge, $type_desc )
2888
        }
2889
        $charge += $daily_charge;
2890
    }
2891
2869
    # Send a renewal slip according to checkout alert preferencei
2892
    # Send a renewal slip according to checkout alert preferencei
2870
    if ( C4::Context->preference('RenewalSendNotice') eq '1' ) {
2893
    if ( C4::Context->preference('RenewalSendNotice') eq '1' ) {
2871
        my $circulation_alert = 'C4::ItemCirculationAlertPreference';
2894
        my $circulation_alert = 'C4::ItemCirculationAlertPreference';
Lines 3183-3189 sub _get_discount_from_rule { Link Here
3183
3206
3184
=head2 AddIssuingCharge
3207
=head2 AddIssuingCharge
3185
3208
3186
  &AddIssuingCharge( $checkout, $charge )
3209
  &AddIssuingCharge( $checkout, $charge, [$description] )
3187
3210
3188
=cut
3211
=cut
3189
3212
(-)a/Koha/ItemType.pm (+33 lines)
Lines 90-95 sub translated_descriptions { Link Here
90
    } @translated_descriptions ];
90
    } @translated_descriptions ];
91
}
91
}
92
92
93
=head3 calc_rental_charge_daily
94
95
    my $fee = $itemtype->calc_rental_charge_daily( { from => $dt_from, to => $dt_to } );
96
97
    This method calculates the daily rental fee for a given itemtype for a given
98
    period of time passed in as a pair of DateTime objects.
99
100
=cut
101
102
sub calc_rental_charge_daily {
103
    my ( $self, $params ) = @_;
104
105
    my $rental_charge_daily = $self->rental_charge_daily;
106
    return 0 unless $rental_charge_daily;
107
108
    my $from_dt = $params->{from};
109
    my $to_dt   = $params->{to};
110
111
    my $duration;
112
    if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) {
113
        my $branchcode = C4::Context->userenv->{branch};
114
        my $calendar = Koha::Calendar->new( branchcode => $branchcode );
115
        $duration = $calendar->days_between( $from_dt, $to_dt );
116
    }
117
    else {
118
        $duration = $to_dt->delta_days($from_dt);
119
    }
120
    my $days = $duration->in_units('days');
121
122
    my $charge = $rental_charge_daily * $days;
123
124
    return $charge;
125
}
93
126
94
127
95
=head3 can_be_deleted
128
=head3 can_be_deleted
(-)a/admin/itemtypes.pl (-13 / +17 lines)
Lines 72-77 if ( $op eq 'add_form' ) { Link Here
72
    my $itemtype     = Koha::ItemTypes->find($itemtype_code);
72
    my $itemtype     = Koha::ItemTypes->find($itemtype_code);
73
    my $description  = $input->param('description');
73
    my $description  = $input->param('description');
74
    my $rentalcharge = $input->param('rentalcharge');
74
    my $rentalcharge = $input->param('rentalcharge');
75
    my $rental_charge_daily = $input->param('rental_charge_daily');
75
    my $defaultreplacecost = $input->param('defaultreplacecost');
76
    my $defaultreplacecost = $input->param('defaultreplacecost');
76
    my $processfee = $input->param('processfee');
77
    my $processfee = $input->param('processfee');
77
    my $image = $input->param('image') || q||;
78
    my $image = $input->param('image') || q||;
Lines 92-97 if ( $op eq 'add_form' ) { Link Here
92
    if ( $itemtype and $is_a_modif ) {    # it's a modification
93
    if ( $itemtype and $is_a_modif ) {    # it's a modification
93
        $itemtype->description($description);
94
        $itemtype->description($description);
94
        $itemtype->rentalcharge($rentalcharge);
95
        $itemtype->rentalcharge($rentalcharge);
96
        $itemtype->rental_charge_daily($rental_charge_daily);
95
        $itemtype->defaultreplacecost($defaultreplacecost);
97
        $itemtype->defaultreplacecost($defaultreplacecost);
96
        $itemtype->processfee($processfee);
98
        $itemtype->processfee($processfee);
97
        $itemtype->notforloan($notforloan);
99
        $itemtype->notforloan($notforloan);
Lines 112-130 if ( $op eq 'add_form' ) { Link Here
112
        }
114
        }
113
    } elsif ( not $itemtype and not $is_a_modif ) {
115
    } elsif ( not $itemtype and not $is_a_modif ) {
114
        my $itemtype = Koha::ItemType->new(
116
        my $itemtype = Koha::ItemType->new(
115
            {   itemtype           => $itemtype_code,
117
            {
116
                description        => $description,
118
                itemtype            => $itemtype_code,
117
                rentalcharge       => $rentalcharge,
119
                description         => $description,
118
                defaultreplacecost => $defaultreplacecost,
120
                rentalcharge        => $rentalcharge,
119
                processfee         => $processfee,
121
                rental_charge_daily => $rental_charge_daily,
120
                notforloan         => $notforloan,
122
                defaultreplacecost  => $defaultreplacecost,
121
                imageurl           => $imageurl,
123
                processfee          => $processfee,
122
                summary            => $summary,
124
                notforloan          => $notforloan,
123
                checkinmsg         => $checkinmsg,
125
                imageurl            => $imageurl,
124
                checkinmsgtype     => $checkinmsgtype,
126
                summary             => $summary,
125
                sip_media_type     => $sip_media_type,
127
                checkinmsg          => $checkinmsg,
126
                hideinopac         => $hideinopac,
128
                checkinmsgtype      => $checkinmsgtype,
127
                searchcategory     => $searchcategory,
129
                sip_media_type      => $sip_media_type,
130
                hideinopac          => $hideinopac,
131
                searchcategory      => $searchcategory,
128
            }
132
            }
129
        );
133
        );
130
        eval { $itemtype->store; };
134
        eval { $itemtype->store; };
(-)a/catalogue/moredetail.pl (-1 lines)
Lines 128-134 my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_l Link Here
128
128
129
$data->{'itemtypename'} = $itemtypes->{ $data->{'itemtype'} }->{'translated_description'}
129
$data->{'itemtypename'} = $itemtypes->{ $data->{'itemtype'} }->{'translated_description'}
130
  if $data->{itemtype} && exists $itemtypes->{ $data->{itemtype} };
130
  if $data->{itemtype} && exists $itemtypes->{ $data->{itemtype} };
131
$data->{'rentalcharge'} = $data->{'rentalcharge'};
132
foreach ( keys %{$data} ) {
131
foreach ( keys %{$data} ) {
133
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
132
    $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' );
134
}
133
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt (-5 / +17 lines)
Lines 137-143 Item types administration Link Here
137
                            [% END %]
137
                            [% END %]
138
                        [% END %]
138
                        [% END %]
139
                    </select>
139
                    </select>
140
                    (Options are defined as the authorized values for the ITEMTYPECAT category)
140
                    <span class="hint">Options are defined as the authorized values for the ITEMTYPECAT category.</span>
141
                </li>
141
                </li>
142
                [% IF Koha.Preference('noItemTypeImages') %]
142
                [% IF Koha.Preference('noItemTypeImages') %]
143
                    <li>
143
                    <li>
Lines 217-223 Item types administration Link Here
217
                    [% ELSE %]
217
                    [% ELSE %]
218
                        <input type="checkbox" id="hideinopac" name="hideinopac" value="1" />
218
                        <input type="checkbox" id="hideinopac" name="hideinopac" value="1" />
219
                    [% END %]
219
                    [% END %]
220
                    (if checked, items of this type will be hidden as filters in OPAC's advanced search)
220
                    <span class="hint">If checked, items of this type will be hidden as filters in OPAC's advanced search.</span>
221
                </li>
221
                </li>
222
                <li>
222
                <li>
223
                    <label for="notforloan">Not for loan: </label>
223
                    <label for="notforloan">Not for loan: </label>
Lines 226-236 Item types administration Link Here
226
                        [% ELSE %]
226
                        [% ELSE %]
227
                            <input type="checkbox" id="notforloan" name="notforloan" value="1" />
227
                            <input type="checkbox" id="notforloan" name="notforloan" value="1" />
228
                        [% END %]
228
                        [% END %]
229
                      (if checked, no item of this type can be issued. If not checked, every item of this type can be issued unless notforloan is set for a specific item)
229
                        <span class="hint">If checked, no item of this type can be issued. If not checked, every item of this type can be issued unless notforloan is set for a specific item.</span>
230
                </li>
230
                </li>
231
                <li>
231
                <li>
232
                    <label for="rentalcharge">Rental charge: </label>
232
                    <label for="rentalcharge">Rental charge: </label>
233
                    <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% itemtype.rentalcharge | html %]" />
233
                    <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% itemtype.rentalcharge | $Price %]" />
234
                    <span class="hint">This fee is charged once per checkout/renewal per item</span>
235
                </li>
236
                <li>
237
                    <label for="rental_charge_daily">Daily rental charge: </label>
238
                    <input type="text" id="rental_charge_daily" name="rental_charge_daily" size="10" value="[% itemtype.rental_charge_daily | $Price %]" />
239
                    <span class="hint">This fee is charged a checkout/renewal time for each day between the checkout/renewal date and due date.</span>
234
                </li>
240
                </li>
235
                <li>
241
                <li>
236
                    <label for="defaultreplacecost">Default replacement cost: </label>
242
                    <label for="defaultreplacecost">Default replacement cost: </label>
Lines 329-335 Item types administration Link Here
329
            <th>Search category</th>
335
            <th>Search category</th>
330
            <th>Not for loan</th>
336
            <th>Not for loan</th>
331
            <th>Hide in OPAC</th>
337
            <th>Hide in OPAC</th>
332
            <th>Charge</th>
338
            <th>Rental charge</th>
339
            <th>Daily rental charge</th>
333
            <th>Default replacement cost</th>
340
            <th>Default replacement cost</th>
334
            <th>Processing fee (when lost)</th>
341
            <th>Processing fee (when lost)</th>
335
            <th>Checkin message</th>
342
            <th>Checkin message</th>
Lines 371-376 Item types administration Link Here
371
              [% itemtype.rentalcharge | $Price %]
378
              [% itemtype.rentalcharge | $Price %]
372
            [% END %]
379
            [% END %]
373
            </td>
380
            </td>
381
            <td>
382
            [% UNLESS ( itemtype.notforloan ) %]
383
              [% itemtype.rental_charge_daily | $Price %]
384
            [% END %]
385
            </td>
374
            <td>[% itemtype.defaultreplacecost | $Price %]</td>
386
            <td>[% itemtype.defaultreplacecost | $Price %]</td>
375
            <td>[% itemtype.processfee | $Price %]</td>
387
            <td>[% itemtype.processfee | $Price %]</td>
376
            <td>[% itemtype.checkinmsg | html_line_break | $raw %]</td>
388
            <td>[% itemtype.checkinmsg | html_line_break | $raw %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt (+2 lines)
Lines 1-4 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Price %]
2
[% USE Asset %]
3
[% USE Asset %]
3
[% USE Koha %]
4
[% USE Koha %]
4
[% USE Branches %]
5
[% USE Branches %]
Lines 34-39 Link Here
34
        <li><span class="label">Item type:</span> [% itemtypename | html %]&nbsp;</li>
35
        <li><span class="label">Item type:</span> [% itemtypename | html %]&nbsp;</li>
35
        [% END %]
36
        [% END %]
36
        [% IF ( rentalcharge ) %]<li><span class="label">Rental charge:</span>[% rentalcharge | $Price %]&nbsp;</li>[% END %]
37
        [% IF ( rentalcharge ) %]<li><span class="label">Rental charge:</span>[% rentalcharge | $Price %]&nbsp;</li>[% END %]
38
        [% IF ( rental_charge_daily ) %]<li><span class="label">Daily rental charge:</span>[% rental_charge_daily | $Price %]&nbsp;</li>[% END %]
37
        <li><span class="label">ISBN:</span> [% isbn | html %]&nbsp;</li>
39
        <li><span class="label">ISBN:</span> [% isbn | html %]&nbsp;</li>
38
        <li><span class="label">Publisher:</span>[% place | html %] [% publishercode | html %] [% publicationyear | html %]&nbsp;</li>
40
        <li><span class="label">Publisher:</span>[% place | html %] [% publishercode | html %] [% publicationyear | html %]&nbsp;</li>
39
        [% IF ( volumeddesc ) %]<li><span class="label">Volume:</span> [% volumeddesc | html %]</li>[% END %]
41
        [% IF ( volumeddesc ) %]<li><span class="label">Volume:</span> [% volumeddesc | html %]</li>[% END %]
(-)a/t/db_dependent/Circulation.t (-3 / +102 lines)
Lines 70-77 my $library2 = $builder->build({ Link Here
70
    source => 'Branch',
70
    source => 'Branch',
71
});
71
});
72
my $itemtype = $builder->build(
72
my $itemtype = $builder->build(
73
    {   source => 'Itemtype',
73
    {
74
        value  => { notforloan => undef, rentalcharge => 0, defaultreplacecost => undef, processfee => undef }
74
        source => 'Itemtype',
75
        value  => {
76
            notforloan          => undef,
77
            rentalcharge        => 0,
78
            rental_charge_daily => 0,
79
            defaultreplacecost  => undef,
80
            processfee          => undef
81
        }
75
    }
82
    }
76
)->{itemtype};
83
)->{itemtype};
77
my $patron_category = $builder->build(
84
my $patron_category = $builder->build(
Lines 2993-2996 sub test_debarment_on_checkout { Link Here
2993
        $expected_expiration_date, 'Test at line ' . $line_number );
3000
        $expected_expiration_date, 'Test at line ' . $line_number );
2994
    Koha::Patron::Debarments::DelUniqueDebarment(
3001
    Koha::Patron::Debarments::DelUniqueDebarment(
2995
        { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
3002
        { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
2996
}
3003
};
3004
3005
subtest 'Koha::ItemType::calc_rental_charge_daily tests' => sub {
3006
    plan tests => 8;
3007
3008
    t::lib::Mocks::mock_preference('item-level_itypes', 1);
3009
3010
    my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store;
3011
3012
    my $module = new Test::MockModule('C4::Context');
3013
    $module->mock('userenv', sub { { branch => $library->id } });
3014
3015
    my $patron = $builder->build_object(
3016
        {
3017
            class => 'Koha::Patrons',
3018
            value => { categorycode => $patron_category->{categorycode} }
3019
        }
3020
    )->store;
3021
3022
    my $itemtype = $builder->build_object(
3023
        {
3024
            class => 'Koha::ItemTypes',
3025
            value  => {
3026
                notforloan          => undef,
3027
                rentalcharge        => 0,
3028
                rental_charge_daily => 1.000000
3029
            }
3030
        }
3031
    )->store;
3032
3033
    my $biblioitem = $builder->build( { source => 'Biblioitem' } );
3034
    my $item = $builder->build_object(
3035
        {
3036
            class => 'Koha::Items',
3037
            value => {
3038
                homebranch       => $library->id,
3039
                holdingbranch    => $library->id,
3040
                notforloan       => 0,
3041
                itemlost         => 0,
3042
                withdrawn        => 0,
3043
                itype            => $itemtype->id,
3044
                biblionumber     => $biblioitem->{biblionumber},
3045
                biblioitemnumber => $biblioitem->{biblioitemnumber},
3046
            }
3047
        }
3048
    )->store;
3049
3050
    is( $itemtype->rental_charge_daily, '1.000000', 'Daily rental charge stored and retreived correctly' );
3051
    is( $item->effective_itemtype, $itemtype->id, "Itemtype set correctly for item");
3052
3053
    my $dt_from = dt_from_string();
3054
    my $dt_to = dt_from_string()->add( days => 7 );
3055
    my $dt_to_renew = dt_from_string()->add( days => 13 );
3056
3057
    t::lib::Mocks::mock_preference('finesCalendar', 'ignoreCalendar');
3058
    my $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3059
    my $accountline = Koha::Account::Lines->find({ itemnumber => $item->id });
3060
    is( $accountline->amount, '7.000000', "Daily rental charge calulated correctly with finesCalendar = ignoreCalendar" );
3061
    $accountline->delete();
3062
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3063
    $accountline = Koha::Account::Lines->find({ itemnumber => $item->id });
3064
    is( $accountline->amount, '6.000000', "Daily rental charge calulated correctly with finesCalendar = ignoreCalendar, for renewal" );
3065
    $accountline->delete();
3066
    $issue->delete();
3067
3068
    t::lib::Mocks::mock_preference('finesCalendar', 'noFinesWhenClosed');
3069
    $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3070
    $accountline = Koha::Account::Lines->find({ itemnumber => $item->id });
3071
    is( $accountline->amount, '7.000000', "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed" );
3072
    $accountline->delete();
3073
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3074
    $accountline = Koha::Account::Lines->find({ itemnumber => $item->id });
3075
    is( $accountline->amount, '6.000000', "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed, for renewal" );
3076
    $accountline->delete();
3077
    $issue->delete();
3078
3079
    my $calendar = C4::Calendar->new( branchcode => $library->id );
3080
    $calendar->insert_week_day_holiday(
3081
        weekday     => 3,
3082
        title       => 'Test holiday',
3083
        description => 'Test holiday'
3084
    );
3085
    $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
3086
    $accountline = Koha::Account::Lines->find({ itemnumber => $item->id });
3087
    is( $accountline->amount, '6.000000', "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays" );
3088
    $accountline->delete();
3089
    AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to );
3090
    $accountline = Koha::Account::Lines->find({ itemnumber => $item->id });
3091
    is( $accountline->amount, '5.000000', "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays, for renewal" );
3092
    $accountline->delete();
3093
    $issue->delete();
3094
3095
};
(-)a/t/db_dependent/Koha/ItemTypes.t (-5 / +48 lines)
Lines 19-32 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 24;
23
use Data::Dumper;
22
use Data::Dumper;
24
use Koha::Database;
23
use Test::More tests => 25;
24
25
use t::lib::Mocks;
25
use t::lib::Mocks;
26
use Koha::Items;
27
use Koha::Biblioitems;
28
use t::lib::TestBuilder;
26
use t::lib::TestBuilder;
29
27
28
use C4::Calendar;
29
use Koha::Biblioitems;
30
use Koha::Libraries;
31
use Koha::Database;
32
use Koha::DateUtils qw(dt_from_string);;
33
use Koha::Items;
34
30
BEGIN {
35
BEGIN {
31
    use_ok('Koha::ItemType');
36
    use_ok('Koha::ItemType');
32
    use_ok('Koha::ItemTypes');
37
    use_ok('Koha::ItemTypes');
Lines 144-147 $biblioitem->delete; Link Here
144
149
145
is ( $item_type->can_be_deleted, 1, 'The item type that was being used by the removed item and biblioitem can now be deleted' );
150
is ( $item_type->can_be_deleted, 1, 'The item type that was being used by the removed item and biblioitem can now be deleted' );
146
151
152
subtest 'Koha::ItemType::calc_rental_charge_daily tests' => sub {
153
    plan tests => 4;
154
155
    my $library = Koha::Libraries->search()->next();
156
    my $module = new Test::MockModule('C4::Context');
157
    $module->mock('userenv', sub { { branch => $library->id } });
158
159
    my $itemtype = Koha::ItemType->new(
160
        {
161
            itemtype            => 'type4',
162
            description         => 'description',
163
            rental_charge_daily => 1.00,
164
        }
165
    )->store;
166
167
    is( $itemtype->rental_charge_daily, 1.00, 'Daily rental charge stored and retreived correctly' );
168
169
    my $dt_from = dt_from_string();
170
    my $dt_to = dt_from_string()->add( days => 7 );
171
172
    t::lib::Mocks::mock_preference('finesCalendar', 'ignoreCalendar');
173
    my $charge = $itemtype->calc_rental_charge_daily( { from => $dt_from, to => $dt_to } );
174
    is( $charge, 7.00, "Daily rental charge calulated correctly with finesCalendar = ignoreCalendar" );
175
176
    t::lib::Mocks::mock_preference('finesCalendar', 'noFinesWhenClosed');
177
    $charge = $itemtype->calc_rental_charge_daily( { from => $dt_from, to => $dt_to } );
178
    is( $charge, 7.00, "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed" );
179
180
    my $calendar = C4::Calendar->new( branchcode => $library->id );
181
    $calendar->insert_week_day_holiday(
182
        weekday     => 3,
183
        title       => 'Test holiday',
184
        description => 'Test holiday'
185
    );
186
    $charge = $itemtype->calc_rental_charge_daily( { from => $dt_from, to => $dt_to } );
187
    is( $charge, 6.00, "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays" );
188
189
};
190
147
$schema->txn_rollback;
191
$schema->txn_rollback;
148
- 

Return to bug 20912