#
# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Data::Dumper;
-use Test::More tests => 25;
+use Test::More tests => 24;
use t::lib::Mocks;
use t::lib::TestBuilder;
ok( defined($type), 'first result' );
is( $type->itemtype, 'type1', 'itemtype/code' );
is( $type->description, 'description', 'description' );
-is( $type->rentalcharge, '0.000000', 'rentalcharge' );
+is( $type->rentalcharge+0, 0, 'rentalcharge' );
is( $type->imageurl, 'imageurl', 'imageurl' );
is( $type->summary, 'summary', 'summary' );
is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' );
ok( defined($type), 'second result' );
is( $type->itemtype, 'type2', 'itemtype/code' );
is( $type->description, 'description', 'description' );
-is( $type->rentalcharge, '0.000000', 'rentalcharge' );
+is( $type->rentalcharge+0, 0, 'rentalcharge' );
is( $type->imageurl, 'imageurl', 'imageurl' );
is( $type->summary, 'summary', 'summary' );
is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' );
is ( $item_type->can_be_deleted, 1, 'The item type that was being used by the removed item and biblioitem can now be deleted' );
-subtest 'Koha::ItemType::calc_rental_charge_daily tests' => sub {
- plan tests => 4;
-
- my $library = Koha::Libraries->search()->next();
- my $module = new Test::MockModule('C4::Context');
- $module->mock('userenv', sub { { branch => $library->id } });
-
- my $itemtype = Koha::ItemType->new(
- {
- itemtype => 'type4',
- description => 'description',
- rental_charge_daily => 1.00,
- rentalcharge => '0.00',
- processfee => '0.00',
- defaultreplacecost => '0.00',
- }
- )->store;
-
- is( $itemtype->rental_charge_daily, 1.00, 'Daily rental charge stored and retreived correctly' );
-
- my $dt_from = dt_from_string();
- my $dt_to = dt_from_string()->add( days => 6 );
-
- t::lib::Mocks::mock_preference('finesCalendar', 'ignoreCalendar');
- my $charge = $itemtype->calc_rental_charge_daily( { from => $dt_from, to => $dt_to } );
- is( $charge, 6.00, "Daily rental charge calculated correctly with finesCalendar = ignoreCalendar" );
-
- t::lib::Mocks::mock_preference('finesCalendar', 'noFinesWhenClosed');
- $charge = $itemtype->calc_rental_charge_daily( { from => $dt_from, to => $dt_to } );
- is( $charge, 6.00, "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed" );
-
- my $calendar = C4::Calendar->new( branchcode => $library->id );
- $calendar->insert_week_day_holiday(
- weekday => 3,
- title => 'Test holiday',
- description => 'Test holiday'
- );
- $charge = $itemtype->calc_rental_charge_daily( { from => $dt_from, to => $dt_to } );
- is( $charge, 5.00, "Daily rental charge calculated correctly with finesCalendar = noFinesWhenClosed and closed Wednesdays" );
-
-};
-
$schema->txn_rollback;