|
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 |
}; |