Lines 68-75
my $library2 = $builder->build({
Link Here
|
68 |
source => 'Branch', |
68 |
source => 'Branch', |
69 |
}); |
69 |
}); |
70 |
my $itemtype = $builder->build( |
70 |
my $itemtype = $builder->build( |
71 |
{ source => 'Itemtype', |
71 |
{ |
72 |
value => { notforloan => undef, rentalcharge => 0, defaultreplacecost => undef, processfee => undef } |
72 |
source => 'Itemtype', |
|
|
73 |
value => { |
74 |
notforloan => undef, |
75 |
rentalcharge => 0, |
76 |
rental_charge_daily => 0, |
77 |
defaultreplacecost => undef, |
78 |
processfee => undef |
79 |
} |
73 |
} |
80 |
} |
74 |
)->{itemtype}; |
81 |
)->{itemtype}; |
75 |
my $patron_category = $builder->build( |
82 |
my $patron_category = $builder->build( |
Lines 2980-2983
sub test_debarment_on_checkout {
Link Here
|
2980 |
$expected_expiration_date, 'Test at line ' . $line_number ); |
2987 |
$expected_expiration_date, 'Test at line ' . $line_number ); |
2981 |
Koha::Patron::Debarments::DelUniqueDebarment( |
2988 |
Koha::Patron::Debarments::DelUniqueDebarment( |
2982 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2989 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
2983 |
} |
2990 |
}; |
|
|
2991 |
|
2992 |
subtest 'Koha::ItemType::calc_rental_charge_daily tests' => sub { |
2993 |
plan tests => 8; |
2994 |
|
2995 |
t::lib::Mocks::mock_preference('item-level_itypes', 1); |
2996 |
|
2997 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store; |
2998 |
|
2999 |
my $module = new Test::MockModule('C4::Context'); |
3000 |
$module->mock('userenv', sub { { branch => $library->id } }); |
3001 |
|
3002 |
my $patron = $builder->build_object( |
3003 |
{ |
3004 |
class => 'Koha::Patrons', |
3005 |
value => { categorycode => $patron_category->{categorycode} } |
3006 |
} |
3007 |
)->store; |
3008 |
|
3009 |
my $itemtype = $builder->build_object( |
3010 |
{ |
3011 |
class => 'Koha::ItemTypes', |
3012 |
value => { |
3013 |
notforloan => undef, |
3014 |
rentalcharge => 0, |
3015 |
rental_charge_daily => 1.000000 |
3016 |
} |
3017 |
} |
3018 |
)->store; |
3019 |
|
3020 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
3021 |
my $item = $builder->build_object( |
3022 |
{ |
3023 |
class => 'Koha::Items', |
3024 |
value => { |
3025 |
homebranch => $library->id, |
3026 |
holdingbranch => $library->id, |
3027 |
notforloan => 0, |
3028 |
itemlost => 0, |
3029 |
withdrawn => 0, |
3030 |
itype => $itemtype->id, |
3031 |
biblionumber => $biblioitem->{biblionumber}, |
3032 |
biblioitemnumber => $biblioitem->{biblioitemnumber}, |
3033 |
} |
3034 |
} |
3035 |
)->store; |
3036 |
|
3037 |
is( $itemtype->rental_charge_daily, '1.000000', 'Daily rental charge stored and retreived correctly' ); |
3038 |
is( $item->effective_itemtype, $itemtype->id, "Itemtype set correctly for item"); |
3039 |
|
3040 |
my $dt_from = dt_from_string(); |
3041 |
my $dt_to = dt_from_string()->add( days => 7 ); |
3042 |
my $dt_to_renew = dt_from_string()->add( days => 13 ); |
3043 |
|
3044 |
t::lib::Mocks::mock_preference('finesCalendar', 'ignoreCalendar'); |
3045 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3046 |
my $accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); |
3047 |
is( $accountline->amount, '7.000000', "Daily rental charge calulated correctly with finesCalendar = ignoreCalendar" ); |
3048 |
$accountline->delete(); |
3049 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
3050 |
$accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); |
3051 |
is( $accountline->amount, '6.000000', "Daily rental charge calulated correctly with finesCalendar = ignoreCalendar, for renewal" ); |
3052 |
$accountline->delete(); |
3053 |
$issue->delete(); |
3054 |
|
3055 |
t::lib::Mocks::mock_preference('finesCalendar', 'noFinesWhenClosed'); |
3056 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3057 |
$accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); |
3058 |
is( $accountline->amount, '7.000000', "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed" ); |
3059 |
$accountline->delete(); |
3060 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
3061 |
$accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); |
3062 |
is( $accountline->amount, '6.000000', "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed, for renewal" ); |
3063 |
$accountline->delete(); |
3064 |
$issue->delete(); |
3065 |
|
3066 |
my $calendar = C4::Calendar->new( branchcode => $library->id ); |
3067 |
$calendar->insert_week_day_holiday( |
3068 |
weekday => 3, |
3069 |
title => 'Test holiday', |
3070 |
description => 'Test holiday' |
3071 |
); |
3072 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3073 |
$accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); |
3074 |
is( $accountline->amount, '6.000000', "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays" ); |
3075 |
$accountline->delete(); |
3076 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
3077 |
$accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); |
3078 |
is( $accountline->amount, '5.000000', "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays, for renewal" ); |
3079 |
$accountline->delete(); |
3080 |
$issue->delete(); |
3081 |
|
3082 |
}; |