Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fixes #14149993] make a transfer at checkin: lost, notlost, &c. Othe…

…r fixes:

- fix undef Perl warning in mapping in fines.pl
- fix overdue from datedue calculation, was using object instead of ISO date
  from issues
- finally finished work on refund owed for backdate checkin resulting
  in downward adjustment of fine
- converted Yes|No option to Continue prompt: Remove from patron's Lost Items
- retested and fixed some lost prompts +notissued/issued, +hold/nohold, &c.
  • Loading branch information...
commit 09804e69cc989413f6bb3e1bd84b34210f7d7bf7 1 parent 9f98f96
@hgq hgq authored
View
61 C4/Circulation.pm
@@ -1545,7 +1545,7 @@ sub AddReturn {
$$issue{returndate} = $returndate;
$datedue = C4::Dates->new($$issue{date_due},'iso');
my $rd = $returndate; $rd =~ s/\D//g;
- my $dd = $datedue ; $dd =~ s/\D//g;
+ my $dd = $$issue{date_due}; $dd =~ s/\D//g;
if ($$issue{overdue} && ($rd <= $dd)) {
$$issue{overdue} = 0;
$dropbox = 1;
@@ -1844,8 +1844,6 @@ C<$flags> : hashref containing flags indicating checkin options. Can be one of:
Returns nothing.
-*** NOTE *** TODO: handle refund owed for payment+backdate checkin
-
=cut
sub _chargeToAccount
@@ -1961,6 +1959,7 @@ sub _FixAccountOverdues {
}
elsif (!$$issue{overdue}) { # wow: backdate checkin where it's no longer overdue
my $msg = 'adjusted to no longer overdue';
+ $msg .= ", returned $checkindate" if $$flags{atreturn};
$dbh->do("UPDATE accountlines
SET description = CONCAT(description, ', $msg'),
amountoutstanding = 0,
@@ -1968,7 +1967,6 @@ sub _FixAccountOverdues {
WHERE borrowernumber = $$issue{borrowernumber}
AND accountno = $$row{accountno}
");
- $msg .= ", returned $checkindate" if $$flags{atreturn};
_rcrFine($issue,$row,0);
_logFine($$issue{borrowernumber},$msg,1);
return;
@@ -2001,6 +1999,12 @@ sub _FixAccountOverdues {
## lower both the amount and the amountoutstanding by diff cmp to new amount
my $diff = $$row{amount} - $amount;
my $newout = $$row{amountoutstanding} - $diff;
+ my $tryRCR = 0;
+ my $amountoutstanding = $newout;
+ if ($amountoutstanding <0) {
+ $tryRCR = 1;
+ $amountoutstanding = 0;
+ }
if ($$row{description} =~ /max overdue/i) {
$$row{description} =~ s/\, max overdue//i;
}
@@ -2014,12 +2018,19 @@ sub _FixAccountOverdues {
WHERE borrowernumber = ?
AND accountno = ?",undef,
$amount,
- $newout,
+ $amountoutstanding,
$desc,
$$issue{borrowernumber},
$$row{accountno}
);
- _rcrFine($issue,$row,$newout);
+ ##general case _rcrFine($issue,$row,$newout) doesn't apply
+ RCR: {
+ last RCR unless $tryRCR;
+ my $paid = $$row{amount}-$$row{amountoutstanding};
+ my $owed = -1*($paid-$amount) if ($paid > $amount);
+ last RCR unless $owed;
+ _rcrFine($issue,$row,$owed,1);
+ }
}
else { # new amount is greater than previous
C4::Overdues::UpdateFine(
@@ -2205,7 +2216,7 @@ sub _getnextaccountno
# RCR refund owed (not yet issued) for prior payment on overdue charges
sub _rcrFine
{
- my($iss,$acc,$newoutstanding) = @_;
+ my($iss,$acc,$newoutstanding,$amountIsOwed) = @_;
return if $$acc{description} !~ /paid at no\.\d+/;
## the paid amount is amount-amountoutstanding
@@ -2215,9 +2226,12 @@ sub _rcrFine
## amountoutstanding $4.00 $2.00
## new overdue $3.50 $4.00
## refund owed $0 $1.00 if paid>newamountoutstanding
- my $paid = $$acc{amount} - $$acc{amountoutstanding};
- my $owed = -1*($paid - $newoutstanding);
- return unless ($paid > $newoutstanding);
+ my $paid = my $owed = 0;
+ if (!$amountIsOwed) {
+ $paid = $$acc{amount} - $$acc{amountoutstanding};
+ $owed = -1*($paid - $newoutstanding);
+ return unless ($paid > $newoutstanding);
+ }
my $dbh = C4::Context->dbh;
## already have an RCR accountline
@@ -2232,22 +2246,27 @@ sub _rcrFine
if (my $dat = $sth->fetchrow_hashref()) {
##... doing this would never happen, since you can't checkin
## item twice for same due date
- if ($$dat{amount} != $owed) {
- ## update previous RCR amount owed to patron
+ my $setamount = 0;
+ if ($amountIsOwed) {
+ $setamount = $$dat{amount}+$newoutstanding;
+ }
+ elsif ($$dat{amount} != $owed) {
+ $setamount = $$dat{amount}+$owed;
+ }
+ if ($setamount) {
$dbh->do("UPDATE accountlines
- SET amount = ?
- WHERE accountno = ?
- AND borrowernumber = ?",undef,
- $owed, $$dat{accountno}, $$iss{borrowernumber}
- );
- return;
+ SET amount = ?, amountoutstanding = ?
+ WHERE accountno = ?
+ AND borrowernumber = ?",undef,
+ $setamount,$setamount,$$dat{accountno},$$iss{borrowernumber});
} # else the refund amount is unchanged
return;
}
## else typical case: insert new RCR for refund owed
## avoid circular dependency by doing this here instead of in Accounts.pm
- my($nextnum) = _getnextaccountno($$iss{borrowernumber});
+ my($nextnum) = _getnextaccountno($$iss{borrowernumber});
+ my $setamount = $amountIsOwed? $newoutstanding : $owed;
$dbh->do("INSERT INTO accountlines (
date,
accountno,
@@ -2262,8 +2281,8 @@ sub _rcrFine
$$iss{borrowernumber},
$$iss{itemnumber},
"Refund owed at no.$$acc{accountno} for payment on overdue charges",
- $owed,
- $owed
+ $setamount,
+ $setamount
);
return;
}
View
14 C4/Items.pm
@@ -639,27 +639,29 @@ to another.
=cut
sub ModItemTransfer {
- my ( $itemnumber, $frombranch, $tobranch ) = @_;
+ my ( $itemnumber, $frombranch, $tobranch, $currbranch ) = @_;
my $dbh = C4::Context->dbh;
if(!$frombranch && !$tobranch) {
$dbh->do('DELETE FROM branchtransfers WHERE itemnumber=?',undef,$itemnumber);
return;
}
+ my $datearrived = ($currbranch ~~ $tobranch)? 'NOW()' : 'NULL';
my $sth = $dbh->prepare('SELECT 1 FROM branchtransfers WHERE itemnumber = ?');
$sth->execute($itemnumber);
if ($sth->fetchrow_array) {
- $sth = $dbh->prepare('UPDATE branchtransfers
+ $sth = $dbh->prepare("UPDATE branchtransfers
SET frombranch = ?,
tobranch = ?,
- datesent = NOW()
- WHERE itemnumber = ?');
+ datesent = NOW(),
+ datearrived = $datearrived
+ WHERE itemnumber = ?");
$sth->execute($frombranch,$tobranch,$itemnumber);
}
else {
$sth = $dbh->prepare(
- "INSERT INTO branchtransfers (itemnumber, frombranch, datesent, tobranch)
- VALUES (?, ?, NOW(), ?)");
+ "INSERT INTO branchtransfers (itemnumber, frombranch, datesent, tobranch, datearrived)
+ VALUES (?, ?, NOW(),?,$datearrived)");
$sth->execute($itemnumber, $frombranch, $tobranch);
}
ModItem({ holdingbranch => $tobranch }, undef, $itemnumber);
View
4 circ/returns.pl
@@ -235,7 +235,7 @@ =head1 returns.pl
# 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');
my $tobranch = $query->param('tobranch');
- C4::Items::ModItemTransfer($transferitem, $userenv_branch, $tobranch);
+ C4::Items::ModItemTransfer($transferitem, $userenv_branch, $tobranch, $userenv_branch);
}
elsif ($query->param('cancelTransfer')) {
C4::Items::ModItemTransfer($query->param('itemnumber'));
@@ -521,7 +521,7 @@ =head1 returns.pl
# $err{reserve} = 1;
foreach(keys %{$$messages{$code}}) { $template->param("res_$_"=>$$messages{$code}{$_}) }
$template->param(
- currBranch => C4::Context->userenv->{branch},
+ currBranch => $userenv_branch,
pickbranchname => $$branches{$$messages{$code}{branchcode}}{branchname},
);
}
View
80 koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tmpl
@@ -60,22 +60,6 @@ function HaltReturns() {
$('#barcode').attr("disabled", true);
$('#barcode_submit').attr("disabled", true);
}
-
-function ContinueReturns() {
- $('#barcode').focus();
- if (document.transferf) {
- document.transferf.lost_item_id.value = '<TMPL_VAR NAME="lost_item_id">';
- document.transferf.lostbarcode.value = '<TMPL_VAR NAME="itembarcode">';
- document.transferf.lostborrowernumber.value = '<TMPL_VAR NAME="lostborrowernumber">';
- document.transferf.unlinkFromAccount.value = 1;
- $('#errmsg').hide('slow');
- return false;
- }
- else {
- document.simplelostf.submit();
- return;
- }
-}
</script>
<!-- TMPL_INCLUDE NAME="calendar.inc" -->
@@ -116,9 +100,9 @@ function ContinueReturns() {
<script type="text/javascript">$(document).ready(function() {HaltReturns();});</script>
<p class="problem"><font style="color:red"><h3>Item was lost, now found.</h3></font></p>
<TMPL_IF NAME="lostborrowernumber">
- Remove from <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=<TMPL_VAR NAME="lostborrowernumber">"><TMPL_VAR NAME="lostbor_firstname">
+ Linked as lost to <a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=<TMPL_VAR NAME="lostborrowernumber">"><TMPL_VAR NAME="lostbor_firstname">
<TMPL_VAR NAME="lostbor_surname"></a>'s
- (<TMPL_VAR NAME="lostbor_cardnumber">) lost items?<br>
+ (<TMPL_VAR NAME="lostbor_cardnumber">) account<br>
<form action="returns.pl" method="post" name="lostf">
<TMPL_LOOP NAME="inputloop">
<input type="hidden" name="od-<!-- TMPL_VAR NAME="counter" -->" value="<!-- TMPL_VAR NAME="overdue" -->" />
@@ -131,7 +115,7 @@ function ContinueReturns() {
<input type=hidden name="lost_item_id" value="<TMPL_VAR NAME="lost_item_id">">
<input type=hidden name="itemnumber" value="<TMPL_VAR NAME="itemnumber">">
<input type=hidden name="borrowernumber" value="<TMPL_VAR NAME="borrowernumber">">
- <input type="button" value="Yes" onclick="
+ <input type="button" value="Remove from patron's Lost Items" onclick="
if(document.foundf) {
document.foundf.lost_item_id.value = '<TMPL_VAR NAME="lost_item_id">';
document.foundf.lostbarcode.value = '<TMPL_VAR NAME="itembarcode">';
@@ -141,10 +125,14 @@ function ContinueReturns() {
return false;
}
else if (document.transferf || document.alreadytransf || document.holdtransf) {
- document.transferf.lost_item_id.value = '<TMPL_VAR NAME="lost_item_id">';
- document.transferf.lostbarcode.value = '<TMPL_VAR NAME="itembarcode">';
- document.transferf.lostborrowernumber.value = '<TMPL_VAR NAME="lostborrowernumber">';
- document.transferf.unlinkFromAccount.value = 1;
+ var f;
+ if (document.transferf) { f = document.transferf }
+ else if (document.alreadytransf) { f = document.alreadytransf }
+ else { f = document.holdtransf }
+ f.lost_item_id.value = '<TMPL_VAR NAME="lost_item_id">';
+ f.lostbarcode.value = '<TMPL_VAR NAME="itembarcode">';
+ f.lostborrowernumber.value = '<TMPL_VAR NAME="lostborrowernumber">';
+ f.unlinkFromAccount.value = 1;
$('#errmsg').hide('slow');
return false;
}
@@ -152,18 +140,6 @@ function ContinueReturns() {
document.lostf.submit();
}
" />
- <input type=button value="No" onclick="
- if(document.foundf) {
- $('#errmsg').hide('slow');
- }
- else if (document.transferf || document.alreadytransf || document.holdtransf) {
- $('#errmsg').hide('slow');
- }
- else {
- document.lostf.unlinkFromAccount.value=0;
- document.lostf.submit();
- }
- " />
<TMPL_IF NAME="UseReceiptTemplates_ClaimsReturnedFound">
<input type="submit" value="Print Receipt" class="print" onclick="Dopop('/cgi-bin/koha/tools/receipt_generation.pl?action=claims_returned_found&amp;barcode=<!-- TMPL_VAR Name="itembarcode" -->');" />
</TMPL_IF>
@@ -176,7 +152,16 @@ function ContinueReturns() {
<input type="hidden" name="dd-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="duedate" -->" />
<input type="hidden" name="bn-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="borrowernumber" -->" />
</TMPL_LOOP>
- <p><button id="continue_button" onclick="ContinueReturns();">Continue</button></p>
+ <p><input type=button value="Continue" onclick="
+ if (document.transferf || document.holdtransf || document.foundf || document.transwaitf) {
+ $('#errmsg').hide('slow');
+ return false;
+ }
+ else {
+ //submit, show mainform
+ this.form.submit();
+ }
+ "></p>
</form>
</TMPL_IF><!-- lostborrowernumber -->
</TMPL_IF><!-- waslost -->
@@ -258,6 +243,10 @@ function ContinueReturns() {
<input type=hidden name="queue_currPage" value="<TMPL_VAR NAME="queue_currPage">">
<input type=hidden name="queue_limit" value="<TMPL_VAR NAME="queue_limit">">
<input type=hidden name="queue_orderby" value="<TMPL_VAR NAME="queue_orderby">">
+ <input type=hidden name="lost_item_id" value="">
+ <input type=hidden name="lostbarcode" value="">
+ <input type=hidden name="lostborrowernumber" value="">
+ <input type=hidden name="unlinkFromAccount" value="1">
<TMPL_LOOP NAME="inputloop">
<input type="hidden" name="od-<!-- TMPL_VAR NAME="counter" -->" value="<!-- TMPL_VAR NAME="overdue" -->" />
<input type="hidden" name="ri-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="barcode" -->" />
@@ -373,7 +362,7 @@ function ContinueReturns() {
<h3>Hold found marked as <span class=error>
<TMPL_IF EXPR="res_found eq 'W'">Waiting
<TMPL_ELSIF EXPR="res_found eq 'T'">In Transit
- <TMPL_ELSE>ERROR
+ <TMPL_ELSE>ERROR: Uncaught exception
</TMPL_IF></span>:</h3>
<h4><a href="/cgi-bin/koha/detail.pl?biblionumber=<TMPL_VAR NAME="biblionumber">"><TMPL_VAR NAME="title"></a><br>
at <TMPL_VAR NAME="pickbranchname"> for</h4>
@@ -384,11 +373,14 @@ function ContinueReturns() {
<TMPL_VAR NAME="borcity"> <TMPL_VAR NAME="borzip"></li>
</ul><br>
<form method=post action="returns.pl" name="transwaitf">
+ <input type=hidden name="dotransfer" value="1">
<input type=hidden name="requeue" value="0">
<input type=hidden name="reservenumber" value="<TMPL_VAR NAME="reservenumber">">
<input type=hidden name="biblionumber" value="<TMPL_VAR NAME="biblionumber">">
+ <input type=hidden name="transferitem" value="<TMPL_VAR NAME="itemnumber">">
<input type=hidden name="itemnumber" value="<TMPL_VAR NAME="itemnumber">">
<input type=hidden name="resbarcode" value="<TMPL_VAR NAME="barcode">">
+ <input type=hidden name="tobranch" value="<TMPL_VAR NAME="destbranch">">
<input type=hidden name="diffBranch" value="<TMPL_VAR NAME="destbranch">">
<input type=hidden name="pickbranch" value="<TMPL_VAR NAME="destbranch">">
<input type=hidden name="exemptfine" value="<TMPL_VAR NAME="exemptfine">">
@@ -401,7 +393,8 @@ function ContinueReturns() {
<!-- /TMPL_LOOP -->
<input type=button value="Confirm and transfer" class="approve" onclick="this.form.submit();">
<input type=button value="Ignore, Requeue hold and Keep Here" class="deny" onclick="
- document.transwaitf.requeue.value = 1;
+ document.transwaitf.requeue.value = 1;
+ document.transwaitf.dotransfer.value = 0;
this.form.submit();
">
</form>
@@ -478,15 +471,19 @@ function ContinueReturns() {
<input type=hidden name="lostborrowernumber" value="">
<input type=hidden name="unlinkFromAccount" value="0">
<input type=hidden name="cancelTransfer" value="0">
+ <input type=hidden name="dotransfer" value="1">
+ <input type=hidden name="tobranch" value="<TMPL_VAR NAME="homebranch">">
+ <input type=hidden name="transferitem" value="<TMPL_VAR NAME="itemnumber">">
<input type=hidden name="itemnumber" value="<TMPL_VAR NAME="itemnumber">">
<!-- TMPL_LOOP Name="inputloop" -->
- <input type="hidden" name="od-<!-- TMPL_VAR NAME="counter" -->" value="<!-- TMPL_VAR NAME="overdue" -->" />
+ <input type="hidden" name="od-<!-- TMPL_VAR NAME="counter" -->" value="<!-- TMPL_VAR NAME="overdue" -->" />
<input type="hidden" name="ri-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="barcode" -->" />
<input type="hidden" name="dd-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="duedate" -->" />
<input type="hidden" name="bn-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="borrowernumber" -->" />
<!-- /TMPL_LOOP -->
<input type=submit value="Confirm transfer" class="approve">
<input type=button value="Keep here" class="deny" onclick="
+ document.transferf.dotransfer.value =0;
document.transferf.cancelTransfer.value=1;
this.form.submit();"
/>
@@ -594,10 +591,10 @@ function ContinueReturns() {
<h4><strong>Hold at</strong> <!-- TMPL_VAR Name="destbranchname" --></h4>
<!-- /TMPL_IF -->
<!-- TMPL_IF name="transfertodo" -->
- <!-- TMPL_IF name="HoldButtonConfirm" -->
<input type=hidden name="dotransfer" value="1">
<input type=hidden name="transferitem" value="<TMPL_VAR NAME="itemnumber">">
<input type=hidden name="tobranch" value="<TMPL_VAR NAME="destbranch">">
+ <!-- TMPL_IF name="HoldButtonConfirm" -->
<input type="submit" class="approve" value="Confirm hold and <TMPL_IF NAME="reroute">reroute </TMPL_IF>Transfer" />
<!-- /TMPL_IF -->
<!-- TMPL_IF name="HoldButtonPrintConfirm" -->
@@ -629,6 +626,7 @@ function ContinueReturns() {
<TMPL_IF NAME="queue_branchlimit">parent.parent.GB_hide();
</TMPL_IF>
// don't autoset reserve to Waiting, leave alone
+ document.foundf.dotransfer = 0;
document.foundf.reservenumber.value = 0;
document.foundf.resbarcode.value = '';
document.foundf.cancelTransfer.value= 1;
@@ -636,7 +634,7 @@ function ContinueReturns() {
" />
<!-- /TMPL_IF -->
<!-- TMPL_LOOP Name="inputloop" -->
- <input type="hidden" name="od-<!-- TMPL_VAR NAME="counter" -->" value="<!-- TMPL_VAR NAME="overdue" -->" />
+ <input type="hidden" name="od-<!-- TMPL_VAR NAME="counter" -->" value="<!-- TMPL_VAR NAME="overdue" -->" />
<input type="hidden" name="ri-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="barcode" -->" />
<input type="hidden" name="dd-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="duedate" -->" />
<input type="hidden" name="bn-<!-- TMPL_VAR Name="counter" -->" value="<!-- TMPL_VAR Name="borrowernumber" -->" />
View
4 misc/cronjobs/fines.pl
@@ -165,8 +165,8 @@ INIT
if( $amount > 0 ) ;
}
my @cells = ();
- push @cells, map {$borrower->{$_}} @borrower_fields;
- push @cells, map {$data->[$i]->{$_}} @item_fields;
+ push @cells, map {$borrower->{$_} // ''} @borrower_fields;
+ push @cells, map {$data->[$i]->{$_} // ''} @item_fields;
push @cells, $type, $daycounttotal, $amount;
print FILE join($delim, @cells), "\n";
}
Please sign in to comment.
Something went wrong with that request. Please try again.