@@ -, +, @@ --- C4/Circulation.pm | 22 +++--- Koha/Charges/Fees.pm | 12 ++-- Koha/Schema/Result/Itemtype.pm | 4 +- admin/itemtypes.pl | 6 +- installer/data/mysql/kohastructure.sql | 2 +- .../prog/en/modules/admin/itemtypes.tt | 6 +- .../prog/en/modules/catalogue/moredetail.tt | 2 +- t/db_dependent/Circulation.t | 71 +++++++++++++++++-- t/db_dependent/Koha/Charges/Fees.t | 14 ++-- 9 files changed, 98 insertions(+), 41 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -994,7 +994,7 @@ sub CanBookBeIssued { if ( $rentalConfirmation ){ my ($rentalCharge) = GetIssuingCharges( $item->{'itemnumber'}, $patron->borrowernumber ); my $itemtype = Koha::ItemTypes->find( $item->{itype} ); # GetItem sets effective itemtype - $rentalCharge += $itemtype->calc_rental_charge_daily( { from => dt_from_string(), to => $duedate } ); + $rentalCharge += $fees->accumulate_rentalcharge(); if ( $rentalCharge > 0 ){ $needsconfirmation{RENTALCHARGE} = $rentalCharge; } @@ -1454,7 +1454,7 @@ sub AddIssue { ); ModDateLastSeen( $item->{'itemnumber'} ); - # If it costs to borrow this book, charge it to the patron's account. + # If it costs to borrow this book, charge it to the patron's account. my ( $charge ) = GetIssuingCharges( $item->{'itemnumber'}, $borrower->{'borrowernumber'} ); if ( $charge > 0 ) { my $description = "Rental"; @@ -1464,10 +1464,10 @@ sub AddIssue { my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype ); if ( $itemtype ) { - my $daily_charge = $fees->rental_charge_daily(); - if ( $daily_charge > 0 ) { - AddIssuingCharge( $issue, $daily_charge, 'Daily rental' ) if $daily_charge > 0; - $charge += $daily_charge; + my $accumulate_charge = $fees->accumulate_rentalcharge(); + if ( $accumulate_charge > 0 ) { + AddIssuingCharge( $issue, $accumulate_charge, 'Daily rental' ) if $accumulate_charge > 0; + $charge += $accumulate_charge; $item->{charge} = $charge; } } @@ -2937,15 +2937,15 @@ sub AddRenewal { AddIssuingCharge($issue, $charge, $description); } - # Charge a new daily rental fee, if applicable + # Charge a new accumulate rental fee, if applicable my $itemtype = Koha::ItemTypes->find( $item_object->effective_itemtype ); if ( $itemtype ) { - my $daily_charge = $fees->rental_charge_daily(); - if ( $daily_charge > 0 ) { + my $accumulate_charge = $fees->accumulate_rentalcharge(); + if ( $accumulate_charge > 0 ) { my $type_desc = "Renewal of Daily Rental Item " . $biblio->title . " $item->{'barcode'}"; - AddIssuingCharge( $issue, $daily_charge, $type_desc ) + AddIssuingCharge( $issue, $accumulate_charge, $type_desc ) } - $charge += $daily_charge; + $charge += $accumulate_charge; } # Send a renewal slip according to checkout alert preferencei --- a/Koha/Charges/Fees.pm +++ a/Koha/Charges/Fees.pm @@ -75,22 +75,22 @@ sub new { return bless( $params, $class ); } -=head3 rental_charge_daily +=head3 accumulate_rentalcharge - my $fee = $self->rental_charge_daily(); + my $fee = $self->accumulate_rentalcharge(); This method calculates the daily rental fee for a given itemtype for a given period of time passed in as a pair of DateTime objects. =cut -sub rental_charge_daily { +sub accumulate_rentalcharge { my ( $self, $params ) = @_; my $itemtype = Koha::ItemTypes->find( $self->item->effective_itemtype ); - my $rental_charge_daily = $itemtype->rental_charge_daily; + my $rentalcharge_daily = $itemtype->rentalcharge_daily; - return undef unless $rental_charge_daily && $rental_charge_daily > 0; + return undef unless $rentalcharge_daily && $rentalcharge_daily > 0; my $duration; if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) { @@ -102,7 +102,7 @@ sub rental_charge_daily { } my $days = $duration->in_units('days'); - my $charge = $rental_charge_daily * $days; + my $charge = $rentalcharge_daily * $days; return $charge; } --- a/Koha/Schema/Result/Itemtype.pm +++ a/Koha/Schema/Result/Itemtype.pm @@ -41,7 +41,7 @@ __PACKAGE__->table("itemtypes"); is_nullable: 1 size: [28,6] -=head2 rental_charge_daily +=head2 rentalcharge_daily data_type: 'decimal' is_nullable: 1 @@ -115,7 +115,7 @@ __PACKAGE__->add_columns( { data_type => "longtext", is_nullable => 1 }, "rentalcharge", { data_type => "decimal", is_nullable => 1, size => [28, 6] }, - "rental_charge_daily", + "rentalcharge_daily", { data_type => "decimal", is_nullable => 1, size => [28, 6] }, "defaultreplacecost", { data_type => "decimal", is_nullable => 1, size => [28, 6] }, --- a/admin/itemtypes.pl +++ a/admin/itemtypes.pl @@ -72,7 +72,7 @@ if ( $op eq 'add_form' ) { my $itemtype = Koha::ItemTypes->find($itemtype_code); my $description = $input->param('description'); my $rentalcharge = $input->param('rentalcharge'); - my $rental_charge_daily = $input->param('rental_charge_daily'); + my $rentalcharge_daily = $input->param('rentalcharge_daily'); my $defaultreplacecost = $input->param('defaultreplacecost'); my $processfee = $input->param('processfee'); my $image = $input->param('image') || q||; @@ -93,7 +93,7 @@ if ( $op eq 'add_form' ) { if ( $itemtype and $is_a_modif ) { # it's a modification $itemtype->description($description); $itemtype->rentalcharge($rentalcharge); - $itemtype->rental_charge_daily($rental_charge_daily); + $itemtype->rentalcharge_daily($rentalcharge_daily); $itemtype->defaultreplacecost($defaultreplacecost); $itemtype->processfee($processfee); $itemtype->notforloan($notforloan); @@ -118,7 +118,7 @@ if ( $op eq 'add_form' ) { itemtype => $itemtype_code, description => $description, rentalcharge => $rentalcharge, - rental_charge_daily => $rental_charge_daily, + rentalcharge_daily => $rentalcharge_daily, defaultreplacecost => $defaultreplacecost, processfee => $processfee, notforloan => $notforloan, --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -988,7 +988,7 @@ CREATE TABLE `itemtypes` ( -- defines the item types itemtype varchar(10) NOT NULL default '', -- unique key, a code associated with the item type description LONGTEXT, -- a plain text explanation of the item type rentalcharge decimal(28,6) default NULL, -- the amount charged when this item is checked out/issued - rental_charge_daily decimal(28,6) default NULL, -- the amount charged for each day between checkout date and due date + rentalcharge_daily decimal(28,6) default NULL, -- the amount charged for each increment (day/hour) between checkout date and due date defaultreplacecost decimal(28,6) default NULL, -- default replacement cost processfee decimal(28,6) default NULL, -- default text be recorded in the column note when the processing fee is applied notforloan smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -234,8 +234,8 @@ Item types administration This fee is charged once per checkout/renewal per item