Bugzilla – Attachment 20147 Details for
Bug 10694
Allow arbitrary backdating of returns
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10694 - Allow arbitrary backdating of returns
Bug-10694---Allow-arbitrary-backdating-of-returns.patch (text/plain), 12.76 KB, created by
Kyle M Hall
on 2013-08-07 15:19:10 UTC
(
hide
)
Description:
Bug 10694 - Allow arbitrary backdating of returns
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2013-08-07 15:19:10 UTC
Size:
12.76 KB
patch
obsolete
>From 5bc6699e98f21aa94035699df68684c306e75270 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 7 Aug 2013 11:03:17 -0400 >Subject: [PATCH] Bug 10694 - Allow arbitrary backdating of returns > >Sometimes libraries need to backdate returns further back in time than >Koha's dropbox mode will allow. The returns backdating will check in an >item as if it had been returned on the specified date, and will reduce >any fine accordingly. > >Test Plan: >1) Apply the patch for bug 8769 >2) Apply this patch >3) Check out an item, and backdate the due date by 1 month or so > * This issue needs to generate a fine >4) Run fines.pl to generate the fine >5) Browse to returns.pl >6) Specify a return date of the day after the specified due date >7) Check the borrowers issue history, you should see the backdated > return date, rather than today's date >8) Check the fine, it should be reduced to a fine for a single day > overdue, rather than the previous larger fine. >--- > C4/Circulation.pm | 36 +++++++++++++------ > circ/returns.pl | 26 ++++++++++++++- > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 12 ++++++ > .../en/modules/admin/preferences/circulation.pref | 6 +++ > .../intranet-tmpl/prog/en/modules/circ/returns.tt | 33 ++++++++++++++++++ > 6 files changed, 101 insertions(+), 13 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index be62078..450ae86 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1781,7 +1781,7 @@ sub AddReturn { > # case of a return of document (deal with issues and holdingbranch) > my $today = DateTime->now( time_zone => C4::Context->tz() ); > if ($doreturn) { >- my $datedue = $issue->{date_due}; >+ my $datedue = $issue->{date_due}; > $borrower or warn "AddReturn without current borrower"; > my $circControlBranch; > if ($dropbox) { >@@ -1790,31 +1790,43 @@ sub AddReturn { > # FIXME: check issuedate > returndate, factoring in holidays > #$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );; > $circControlBranch = _GetCircControlBranch($item,$borrower); >- $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0; >+ $issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0; > } > > if ($borrowernumber) { >- if( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'}){ >- # we only need to calculate and change the fines if we want to do that on return >- # Should be on for hourly loans >+ if ( ( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'} ) || $return_date ) { >+ # we only need to calculate and change the fines if we want to do that on return >+ # Should be on for hourly loans > my $control = C4::Context->preference('CircControl'); > my $control_branchcode = > ( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch} > : ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} > : $issue->{branchcode}; > >+ my $date_returned = >+ $return_date ? dt_from_string($return_date) : $today; >+ > my ( $amount, $type, $unitcounttotal ) = > C4::Overdues::CalcFine( $item, $borrower->{categorycode}, >- $control_branchcode, $datedue, $today ); >+ $control_branchcode, $datedue, $date_returned ); > > $type ||= q{}; > >- if ( $amount > 0 >- && C4::Context->preference('finesMode') eq 'production' ) >- { >- C4::Overdues::UpdateFine( $issue->{itemnumber}, >- $issue->{borrowernumber}, >- $amount, $type, output_pref($datedue) ); >+ if ( C4::Context->preference('finesMode') eq 'production' ) { >+ if ( $amount > 0 ) { >+ C4::Overdues::UpdateFine( $issue->{itemnumber}, >+ $issue->{borrowernumber}, >+ $amount, $type, output_pref($datedue) ); >+ } >+ elsif ($return_date) { >+ >+ # Backdated returns may have fines that shouldn't exist, >+ # so in this case, we need to drop those fines to 0 >+ >+ C4::Overdues::UpdateFine( $issue->{itemnumber}, >+ $issue->{borrowernumber}, >+ 0, $type, output_pref($datedue) ); >+ } > } > } > >diff --git a/circ/returns.pl b/circ/returns.pl >index 9472797..86bb476 100755 >--- a/circ/returns.pl >+++ b/circ/returns.pl >@@ -180,6 +180,30 @@ my $calendar = Koha::Calendar->new( branchcode => $userenv_branch ); > #dropbox: get last open day (today - 1) > my $today = DateTime->now( time_zone => C4::Context->tz()); > my $dropboxdate = $calendar->addDate($today, -1); >+ >+my $return_date_override = $query->param('return_date_override'); >+my $return_date_override_remember = >+ $query->param('return_date_override_remember'); >+if ($return_date_override) { >+ if ( C4::Context->preference('SpecifyReturnDate') ) { >+ if ( $return_date_override =~ C4::Dates->regexp('syspref') ) { >+ >+ # Save the original format if we are remembering for this series >+ $template->param( >+ return_date_override => $return_date_override, >+ return_date_override_remember => 1 >+ ) if ($return_date_override_remember); >+ >+ my $dt = dt_from_string($return_date_override); >+ $return_date_override = >+ DateTime::Format::MySQL->format_datetime($dt); >+ } >+ } >+ else { >+ $return_date_override = q{}; >+ } >+} >+ > if ($dotransfer){ > # An item has been returned to a branch other than the homebranch, and the librarian has chosen to initiate a transfer > my $transferitem = $query->param('transferitem'); >@@ -216,7 +240,7 @@ if ($barcode) { > # save the return > # > ( $returned, $messages, $issueinformation, $borrower ) = >- AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode); # do the return >+ AddReturn( $barcode, $userenv_branch, $exemptfine, $dropboxmode, $return_date_override ); > my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn'); > $homeorholdingbranchreturn ||= 'homebranch'; > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index c8caee7..c45fbef 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -430,3 +430,4 @@ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) V > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('CalculateFinesOnReturn','1','Switch to control if overdue fines are calculated on return or not', '', 'YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('AcqWarnOnDuplicateInvoice','0','Warn librarians when they try to create a duplicate invoice', '', 'YesNo'); > INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('AllowTooManyOverride', '1', 'If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts', '', 'YesNo'); >+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('SpecifyReturnDate',1,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 74aeb3e..2fe6b9d 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7067,6 +7067,18 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.13.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do(q{ >+ INSERT INTO systempreferences >+ (variable,value,explanation,options,type) >+ VALUES >+ ('SpecifyReturnDate',1,'Define whether to display \"Specify Return Date\" form in Circulation','','YesNo') >+ }); >+ print "Upgrade to $DBversion done (Bug 10694 - Allow arbitrary backdating of returns)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >index 026b7fa..cf6724a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref >@@ -58,6 +58,12 @@ Circulation: > no: "Don't allow" > - staff to specify a due date for a checkout. > - >+ - pref: SpecifyReturnDate >+ choices: >+ yes: Allow >+ no: "Don't allow" >+ - staff to specify a return date for a check in. >+ - > - Set the default start date for the Holds to pull list to > - pref: HoldsToPullStartDate > class: integer >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >index 98d2ae9..a6dcc96 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >@@ -1,9 +1,14 @@ > [% USE KohaDates %] > [% USE KohaBranchName %] >+[% USE Koha %] > > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Circulation › Check in [% title |html %]</title> > [% INCLUDE 'doc-head-close.inc' %] >+ >+[% INCLUDE 'calendar.inc' %] >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery-ui-timepicker-addon.js"></script> >+ > <script type="text/javascript"> > //<![CDATA[ > function Dopop(link) { >@@ -11,6 +16,11 @@ function Dopop(link) { > $("#barcode").focus(); > } > $(document).ready(function () { >+ $("#return_date_override").datetimepicker({ >+ onClose: function(dateText, inst) { $("#barcode").focus(); }, >+ hour: 23, >+ minute: 59 >+ }); > $("#exemptcheck").change(function () { > if (this.checked == true) { > $("#barcode").addClass("alert"); >@@ -25,9 +35,15 @@ $(document).ready(function () { > if (this.checked == true) { > $("#barcode").addClass("alert"); > $("#dropboxmode").show(); >+ >+ $("#return_date_override_fields :input").attr("disabled", true); >+ $("#return_date_override").datetimepicker("disable"); > } else { > $("#barcode").removeClass("alert"); > $("#dropboxmode").hide(); >+ >+ $("#return_date_override_fields :input").attr("disabled", false); >+ $("#return_date_override").datetimepicker("enable"); > } > $("#barcode").focus(); > }); >@@ -383,6 +399,23 @@ $(document).ready(function () { > <input name="barcode" id="barcode" size="14" class="focus"/> > [% END %] > <input type="submit" class="submit" value="Submit" /> >+ >+ [% IF Koha.Preference('SpecifyReturnDate') %] >+ <div class="date-select" id="return_date_override_fields"> >+ <div class="hint">Specify return date [% INCLUDE 'date-format.inc' %]: </div> >+ >+ <input type="text" size="13" id="return_date_override" name="return_date_override" value="[% return_date_override %]" readonly="readonly" /> >+ >+ <label for="return_date_override_remember"> Remember for next check in:</label> >+ [% IF ( return_date_override_remember ) %] >+ <input type="checkbox" id="return_date_override_remember" onclick="this.form.barcode.focus();" name="return_date_override_remember" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" id="return_date_override_remember" onclick="this.form.barcode.focus();" name="return_date_override_remember" /> >+ [% END %] >+ >+ <input type="button" class="action" id="cleardate" value="Clear" name="cleardate" onclick="this.checked = false; this.form.return_date_override.value = ''; this.form.return_date_override_remember.checked = false; this.form.barcode.focus(); return false;" /> >+ </div> >+ [% END %] > [% FOREACH inputloo IN inputloop %] > <input type="hidden" name="ri-[% inputloo.counter %]" value="[% inputloo.barcode %]" /> > <input type="hidden" name="dd-[% inputloo.counter %]" value="[% inputloo.duedate %]" /> >-- >1.7.2.5
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 10694
:
20146
|
20147
|
21094
|
21095
|
21096
|
22122
|
22123
|
23672
|
23673
|
23697
|
25658
|
25659
|
25660
|
25661
|
26162
|
26163
|
26707
|
26708
|
27461
|
27475