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 3064-3067
sub test_debarment_on_checkout {
Link Here
|
3064 |
$expected_expiration_date, 'Test at line ' . $line_number ); |
3071 |
$expected_expiration_date, 'Test at line ' . $line_number ); |
3065 |
Koha::Patron::Debarments::DelUniqueDebarment( |
3072 |
Koha::Patron::Debarments::DelUniqueDebarment( |
3066 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
3073 |
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); |
3067 |
} |
3074 |
}; |
|
|
3075 |
|
3076 |
subtest 'Koha::ItemType::calc_rental_charge_daily tests' => sub { |
3077 |
plan tests => 8; |
3078 |
|
3079 |
t::lib::Mocks::mock_preference('item-level_itypes', 1); |
3080 |
|
3081 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store; |
3082 |
|
3083 |
my $module = new Test::MockModule('C4::Context'); |
3084 |
$module->mock('userenv', sub { { branch => $library->id } }); |
3085 |
|
3086 |
my $patron = $builder->build_object( |
3087 |
{ |
3088 |
class => 'Koha::Patrons', |
3089 |
value => { categorycode => $patron_category->{categorycode} } |
3090 |
} |
3091 |
)->store; |
3092 |
|
3093 |
my $itemtype = $builder->build_object( |
3094 |
{ |
3095 |
class => 'Koha::ItemTypes', |
3096 |
value => { |
3097 |
notforloan => undef, |
3098 |
rentalcharge => 0, |
3099 |
rental_charge_daily => 1.000000 |
3100 |
} |
3101 |
} |
3102 |
)->store; |
3103 |
|
3104 |
my $biblioitem = $builder->build( { source => 'Biblioitem' } ); |
3105 |
my $item = $builder->build_object( |
3106 |
{ |
3107 |
class => 'Koha::Items', |
3108 |
value => { |
3109 |
homebranch => $library->id, |
3110 |
holdingbranch => $library->id, |
3111 |
notforloan => 0, |
3112 |
itemlost => 0, |
3113 |
withdrawn => 0, |
3114 |
itype => $itemtype->id, |
3115 |
biblionumber => $biblioitem->{biblionumber}, |
3116 |
biblioitemnumber => $biblioitem->{biblioitemnumber}, |
3117 |
} |
3118 |
} |
3119 |
)->store; |
3120 |
|
3121 |
is( $itemtype->rental_charge_daily, '1.000000', 'Daily rental charge stored and retreived correctly' ); |
3122 |
is( $item->effective_itemtype, $itemtype->id, "Itemtype set correctly for item"); |
3123 |
|
3124 |
my $dt_from = dt_from_string(); |
3125 |
my $dt_to = dt_from_string()->add( days => 7 ); |
3126 |
my $dt_to_renew = dt_from_string()->add( days => 13 ); |
3127 |
|
3128 |
t::lib::Mocks::mock_preference('finesCalendar', 'ignoreCalendar'); |
3129 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3130 |
my $accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); |
3131 |
is( $accountline->amount, '7.000000', "Daily rental charge calulated correctly with finesCalendar = ignoreCalendar" ); |
3132 |
$accountline->delete(); |
3133 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
3134 |
$accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); |
3135 |
is( $accountline->amount, '6.000000', "Daily rental charge calulated correctly with finesCalendar = ignoreCalendar, for renewal" ); |
3136 |
$accountline->delete(); |
3137 |
$issue->delete(); |
3138 |
|
3139 |
t::lib::Mocks::mock_preference('finesCalendar', 'noFinesWhenClosed'); |
3140 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3141 |
$accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); |
3142 |
is( $accountline->amount, '7.000000', "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed" ); |
3143 |
$accountline->delete(); |
3144 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
3145 |
$accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); |
3146 |
is( $accountline->amount, '6.000000', "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed, for renewal" ); |
3147 |
$accountline->delete(); |
3148 |
$issue->delete(); |
3149 |
|
3150 |
my $calendar = C4::Calendar->new( branchcode => $library->id ); |
3151 |
$calendar->insert_week_day_holiday( |
3152 |
weekday => 3, |
3153 |
title => 'Test holiday', |
3154 |
description => 'Test holiday' |
3155 |
); |
3156 |
$issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from ); |
3157 |
$accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); |
3158 |
is( $accountline->amount, '6.000000', "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays" ); |
3159 |
$accountline->delete(); |
3160 |
AddRenewal( $patron->id, $item->id, $library->id, $dt_to_renew, $dt_to ); |
3161 |
$accountline = Koha::Account::Lines->find({ itemnumber => $item->id }); |
3162 |
is( $accountline->amount, '5.000000', "Daily rental charge calulated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays, for renewal" ); |
3163 |
$accountline->delete(); |
3164 |
$issue->delete(); |
3165 |
|
3166 |
}; |