Bugzilla – Attachment 86319 Details for
Bug 20912
Rental fees based on time period
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20912: (follow-up) Add hourly support
Bug-20912-follow-up-Add-hourly-support.patch (text/plain), 11.95 KB, created by
Martin Renvoize (ashimema)
on 2019-03-07 17:21:52 UTC
(
hide
)
Description:
Bug 20912: (follow-up) Add hourly support
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-03-07 17:21:52 UTC
Size:
11.95 KB
patch
obsolete
>From 06b484ee397e19c96e8e4bba8fb67afbc31cba15 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 30 Jan 2019 20:34:13 +0000 >Subject: [PATCH] Bug 20912: (follow-up) Add hourly support > >It seemed strange to only add support for Daily loans in the feature >when Koha also support loan periods in hours. This patch adds parallel >functionaliy for hourly loan periods. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Charges/Fees.pm | 42 ++++++++++++++----- > Koha/ItemType.pm | 2 +- > Koha/Schema/Result/Itemtype.pm | 12 +++++- > admin/itemtypes.pl | 5 ++- > .../data/mysql/atomicupdate/bug_20912.perl | 4 ++ > installer/data/mysql/kohastructure.sql | 3 +- > .../prog/en/modules/admin/itemtypes.tt | 14 ++++++- > .../prog/en/modules/catalogue/moredetail.tt | 1 + > 8 files changed, 66 insertions(+), 17 deletions(-) > >diff --git a/Koha/Charges/Fees.pm b/Koha/Charges/Fees.pm >index 0d948338b3..03cce2f9e7 100644 >--- a/Koha/Charges/Fees.pm >+++ b/Koha/Charges/Fees.pm >@@ -22,6 +22,7 @@ use Modern::Perl; > use Carp qw( confess ); > > use Koha::Calendar; >+use Koha::IssuingRules; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Exceptions; > >@@ -85,25 +86,44 @@ sub new { > =cut > > sub accumulate_rentalcharge { >- my ( $self, $params ) = @_; >+ my ( $self ) = @_; > > my $itemtype = Koha::ItemTypes->find( $self->item->effective_itemtype ); >- my $rentalcharge_daily = $itemtype->rentalcharge_daily; >- >- return undef unless $rentalcharge_daily && $rentalcharge_daily > 0; >+ my $issuing_rule = Koha::IssuingRules->get_effective_issuing_rule( >+ { >+ categorycode => $self->patron->categorycode, >+ itemtype => $itemtype->id, >+ branchcode => $self->library->id >+ } >+ ); >+ my $units = $issuing_rule->lengthunit; >+ my $rentalcharge_increment = ( $units eq 'days' ) ? $itemtype->rentalcharge_daily : $itemtype->rentalcharge_hourly; >+ >+ return 0 unless $rentalcharge_increment && $rentalcharge_increment > 0; > > my $duration; >- if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) { >- my $calendar = Koha::Calendar->new( branchcode => $self->library->id ); >- $duration = $calendar->days_between( $self->from_date, $self->to_date ); >+ my $calendar = Koha::Calendar->new( branchcode => $self->library->id ); >+ >+ if ( $units eq 'hours' ) { >+ if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) { >+ $duration = >+ $calendar->hours_between( $self->from_date, $self->to_date ); >+ } >+ else { >+ $duration = $self->to_date->delta_ms($self->from_date); >+ } > } > else { >- $duration = $self->to_date->delta_days($self->from_date); >+ if ( C4::Context->preference('finesCalendar') eq 'noFinesWhenClosed' ) { >+ $duration = >+ $calendar->days_between( $self->from_date, $self->to_date ); >+ } >+ else { >+ $duration = $self->to_date->delta_days( $self->from_date ); >+ } > } >- my $days = $duration->in_units('days'); >- >- my $charge = $rentalcharge_daily * $days; > >+ my $charge = $rentalcharge_increment * $duration->in_units($units); > return $charge; > } > >diff --git a/Koha/ItemType.pm b/Koha/ItemType.pm >index 31578f05d0..63c113c83d 100644 >--- a/Koha/ItemType.pm >+++ b/Koha/ItemType.pm >@@ -33,7 +33,7 @@ Koha::ItemType - Koha Item type Object class > > =head1 API > >-=head2 Class Methods >+=head2 Class methods > > =cut > >diff --git a/Koha/Schema/Result/Itemtype.pm b/Koha/Schema/Result/Itemtype.pm >index 6f022e986f..b2c4774e57 100644 >--- a/Koha/Schema/Result/Itemtype.pm >+++ b/Koha/Schema/Result/Itemtype.pm >@@ -47,6 +47,12 @@ __PACKAGE__->table("itemtypes"); > is_nullable: 1 > size: [28,6] > >+=head2 rentalcharge_hourly >+ >+ data_type: 'decimal' >+ is_nullable: 1 >+ size: [28,6] >+ > =head2 defaultreplacecost > > data_type: 'decimal' >@@ -117,6 +123,8 @@ __PACKAGE__->add_columns( > { data_type => "decimal", is_nullable => 1, size => [28, 6] }, > "rentalcharge_daily", > { data_type => "decimal", is_nullable => 1, size => [28, 6] }, >+ "rentalcharge_hourly", >+ { data_type => "decimal", is_nullable => 1, size => [28, 6] }, > "defaultreplacecost", > { data_type => "decimal", is_nullable => 1, size => [28, 6] }, > "processfee", >@@ -234,8 +242,8 @@ __PACKAGE__->has_many( > ); > > >-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-10-25 12:41:04 >-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Iyb9JKB8gdyZPtZloHVxSQ >+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-01-31 11:59:27 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:gYBgGWpeUyFuyzfBNIEKCQ > > # Use the ItemtypeLocalization view to create the join on localization > our $LANGUAGE; >diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl >index 3381e21ec3..441bd0514a 100755 >--- a/admin/itemtypes.pl >+++ b/admin/itemtypes.pl >@@ -73,6 +73,7 @@ if ( $op eq 'add_form' ) { > my $description = $input->param('description'); > my $rentalcharge = $input->param('rentalcharge'); > my $rentalcharge_daily = $input->param('rentalcharge_daily'); >+ my $rentalcharge_hourly = $input->param('rentalcharge_hourly'); > my $defaultreplacecost = $input->param('defaultreplacecost'); > my $processfee = $input->param('processfee'); > my $image = $input->param('image') || q||; >@@ -94,6 +95,7 @@ if ( $op eq 'add_form' ) { > $itemtype->description($description); > $itemtype->rentalcharge($rentalcharge); > $itemtype->rentalcharge_daily($rentalcharge_daily); >+ $itemtype->rentalcharge_hourly($rentalcharge_hourly); > $itemtype->defaultreplacecost($defaultreplacecost); > $itemtype->processfee($processfee); > $itemtype->notforloan($notforloan); >@@ -118,7 +120,8 @@ if ( $op eq 'add_form' ) { > itemtype => $itemtype_code, > description => $description, > rentalcharge => $rentalcharge, >- rentalcharge_daily => $rentalcharge_daily, >+ rentalcharge_daily => $rentalcharge_daily, >+ rentalcharge_hourly => $rentalcharge_hourly, > defaultreplacecost => $defaultreplacecost, > processfee => $processfee, > notforloan => $notforloan, >diff --git a/installer/data/mysql/atomicupdate/bug_20912.perl b/installer/data/mysql/atomicupdate/bug_20912.perl >index 6e5f9ed212..c75eed9eb0 100644 >--- a/installer/data/mysql/atomicupdate/bug_20912.perl >+++ b/installer/data/mysql/atomicupdate/bug_20912.perl >@@ -5,6 +5,10 @@ if ( CheckVersion($DBversion) ) { > $dbh->do("ALTER TABLE `itemtypes` ADD COLUMN `rentalcharge_daily` decimal(28,6) default NULL AFTER `rentalcharge`"); > } > >+ if ( !column_exists( 'itemtypes', 'rentalcharge_hourly' ) ) { >+ $dbh->do("ALTER TABLE `itemtypes` ADD COLUMN `rentalcharge_hourly` decimal(28,6) default NULL AFTER `rentalcharge_daily`"); >+ } >+ > if ( column_exists( 'itemtypes', 'rental_charge_daily' ) ) { > $dbh->do("UPDATE `itemtypes` SET `rentalcharge_daily` = `rental_charge_daily`"); > $dbh->do("ALTER TABLE `itemtypes` DROP COLUMN `rental_charge_daily`"); >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 8fad803739..d20bc7eaee 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -951,7 +951,8 @@ 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 >- rentalcharge_daily decimal(28,6) default NULL, -- the amount charged for each increment (day/hour) between checkout date and due date >+ rentalcharge_daily decimal(28,6) default NULL, -- the amount charged for each day between checkout date and due date >+ rentalcharge_hourly decimal(28,6) default NULL, -- the amount charged for each 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 >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >index 0f48e11a86..465010b207 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >@@ -236,7 +236,12 @@ Item types administration > <li> > <label for="rentalcharge_daily">Daily rental charge: </label> > <input type="text" id="rentalcharge_daily" name="rentalcharge_daily" size="10" value="[% itemtype.rentalcharge_daily | $Price %]" /> >- <span class="hint">This fee is charged a checkout/renewal time for each day between the checkout/renewal date and due date.</span> >+ <span class="hint">This fee is charged at checkout/renewal time for each day between the checkout/renewal date and due date for loans specified in days.</span> >+ </li> >+ <li> >+ <label for="rentalcharge_hourly">Hourly rental charge: </label> >+ <input type="text" id="rentalcharge_hourly" name="rentalcharge_hourly" size="10" value="[% itemtype.rentalcharge_hourly | $Price %]" /> >+ <span class="hint">This fee is charged at checkout/renewal time for each hour between the checkout/renewal date and due date for loans specifie in hours.</span> > </li> > <li> > <label for="defaultreplacecost">Default replacement cost: </label> >@@ -337,6 +342,7 @@ Item types administration > <th>Hide in OPAC</th> > <th>Rental charge</th> > <th>Daily rental charge</th> >+ <th>Hourly rental charge</th> > <th>Default replacement cost</th> > <th>Processing fee (when lost)</th> > <th>Checkin message</th> >@@ -383,6 +389,12 @@ Item types administration > [% itemtype.rentalcharge_daily | $Price %] > [% END %] > </td> >+ <td> >+ [% UNLESS ( itemtype.notforloan ) %] >+ [% itemtype.rentalcharge_hourly | $Price %] >+ [% END %] >+ </td> >+ > <td>[% itemtype.defaultreplacecost | $Price %]</td> > <td>[% itemtype.processfee | $Price %]</td> > <td>[% itemtype.checkinmsg | html_line_break | $raw %]</td> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >index afe6f0a2f1..78c3498925 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >@@ -36,6 +36,7 @@ > [% END %] > [% IF ( rentalcharge ) %]<li><span class="label">Rental charge:</span>[% rentalcharge | $Price %] </li>[% END %] > [% IF ( rentalcharge_daily ) %]<li><span class="label">Daily rental charge:</span>[% rentalcharge_daily | $Price %] </li>[% END %] >+ [% IF ( rentalcharge_hourly ) %]<li><span class="label">Hourly rental charge:</span>[% rentalcharge_hourly | $Price %] </li>[% END %] > <li><span class="label">ISBN:</span> [% isbn | html %] </li> > <li><span class="label">Publisher:</span>[% place | html %] [% publishercode | html %] [% publicationyear | html %] </li> > [% IF ( volumeddesc ) %]<li><span class="label">Volume:</span> [% volumeddesc | html %]</li>[% END %] >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20912
:
76065
|
76066
|
76067
|
76068
|
76069
|
77302
|
77303
|
77304
|
81141
|
81142
|
81143
|
81450
|
81771
|
81772
|
81773
|
81774
|
81775
|
81778
|
82195
|
82196
|
84412
|
84413
|
84414
|
84415
|
84416
|
84417
|
84418
|
84419
|
84420
|
84570
|
84571
|
84572
|
84573
|
84574
|
84575
|
84576
|
84577
|
84578
|
84579
|
84580
|
84581
|
84582
|
84583
|
84584
|
84585
|
84610
|
84611
|
84612
|
84613
|
84614
|
84615
|
84616
|
84617
|
84618
|
84619
|
84620
|
84621
|
84622
|
84623
|
84624
|
84625
|
84707
|
84708
|
84709
|
84710
|
84711
|
84712
|
84713
|
84714
|
84715
|
84716
|
84717
|
84718
|
84719
|
84720
|
84721
|
84722
|
84723
|
84724
|
85291
|
85292
|
85293
|
85294
|
85295
|
85296
|
85297
|
85298
|
85299
|
85300
|
85301
|
85302
|
85303
|
85304
|
85305
|
85306
|
85307
|
85308
|
85316
|
85543
|
85544
|
85545
|
85546
|
85547
|
85548
|
85549
|
85550
|
85551
|
85552
|
85553
|
85554
|
85555
|
85556
|
85557
|
85558
|
85559
|
85560
|
85561
|
85628
|
85631
|
86140
|
86141
|
86142
|
86143
|
86144
|
86145
|
86146
|
86147
|
86148
|
86149
|
86151
|
86152
|
86153
|
86154
|
86155
|
86156
|
86157
|
86158
|
86159
|
86160
|
86244
|
86245
|
86246
|
86247
|
86248
|
86249
|
86250
|
86251
|
86252
|
86253
|
86254
|
86255
|
86256
|
86257
|
86258
|
86259
|
86260
|
86261
|
86262
|
86263
|
86264
|
86282
|
86283
|
86284
|
86285
|
86286
|
86287
|
86288
|
86289
|
86290
|
86291
|
86292
|
86293
|
86294
|
86295
|
86296
|
86297
|
86298
|
86299
|
86300
|
86301
|
86302
|
86306
|
86307
|
86308
|
86309
|
86310
|
86311
|
86312
|
86313
|
86314
|
86315
|
86316
|
86317
|
86318
| 86319 |
86320
|
86321
|
86322
|
86323
|
86324
|
86325
|
86326
|
86327
|
87363
|
87413
|
87703