Lines 30-36
use C4::Items;
Link Here
|
30 |
use C4::Members; |
30 |
use C4::Members; |
31 |
use C4::Dates; |
31 |
use C4::Dates; |
32 |
use C4::Dates qw(format_date); |
32 |
use C4::Dates qw(format_date); |
33 |
use C4::Accounts; |
33 |
use Koha::Accounts; |
34 |
use C4::ItemCirculationAlertPreference; |
34 |
use C4::ItemCirculationAlertPreference; |
35 |
use C4::Message; |
35 |
use C4::Message; |
36 |
use C4::Debug; |
36 |
use C4::Debug; |
Lines 48-53
use Data::Dumper;
Link Here
|
48 |
use Koha::DateUtils; |
48 |
use Koha::DateUtils; |
49 |
use Koha::Calendar; |
49 |
use Koha::Calendar; |
50 |
use Koha::Borrower::Debarments; |
50 |
use Koha::Borrower::Debarments; |
|
|
51 |
use Koha::Database; |
51 |
use Carp; |
52 |
use Carp; |
52 |
use Date::Calc qw( |
53 |
use Date::Calc qw( |
53 |
Today |
54 |
Today |
Lines 1273-1279
sub AddIssue {
Link Here
|
1273 |
## If item was lost, it has now been found, reverse any list item charges if neccessary. |
1274 |
## If item was lost, it has now been found, reverse any list item charges if neccessary. |
1274 |
if ( $item->{'itemlost'} ) { |
1275 |
if ( $item->{'itemlost'} ) { |
1275 |
if ( C4::Context->preference('RefundLostItemFeeOnReturn' ) ) { |
1276 |
if ( C4::Context->preference('RefundLostItemFeeOnReturn' ) ) { |
1276 |
_FixAccountForLostAndReturned( $item->{'itemnumber'}, undef, $item->{'barcode'} ); |
1277 |
_FixAccountForLostAndReturned( $item->{'itemnumber'} ); |
1277 |
} |
1278 |
} |
1278 |
} |
1279 |
} |
1279 |
|
1280 |
|
Lines 1814-1834
sub AddReturn {
Link Here
|
1814 |
|
1815 |
|
1815 |
$type ||= q{}; |
1816 |
$type ||= q{}; |
1816 |
|
1817 |
|
1817 |
if ( C4::Context->preference('finesMode') eq 'production' ) { |
1818 |
if ( $amount > 0 |
1818 |
if ( $amount > 0 ) { |
1819 |
&& C4::Context->preference('finesMode') eq 'production' ) |
1819 |
C4::Overdues::UpdateFine( $issue->{itemnumber}, |
1820 |
{ |
1820 |
$issue->{borrowernumber}, |
1821 |
C4::Overdues::UpdateFine( |
1821 |
$amount, $type, output_pref($datedue) ); |
1822 |
{ |
1822 |
} |
1823 |
itemnumber => $issue->{itemnumber}, |
1823 |
elsif ($return_date) { |
1824 |
borrowernumber => $issue->{borrowernumber}, |
1824 |
|
1825 |
amount => $amount, |
1825 |
# Backdated returns may have fines that shouldn't exist, |
1826 |
due => output_pref($datedue), |
1826 |
# so in this case, we need to drop those fines to 0 |
1827 |
issue_id => $issue->{issue_id} |
1827 |
|
1828 |
} |
1828 |
C4::Overdues::UpdateFine( $issue->{itemnumber}, |
1829 |
); |
1829 |
$issue->{borrowernumber}, |
1830 |
} |
1830 |
0, $type, output_pref($datedue) ); |
1831 |
elsif ($return_date) { |
1831 |
} |
1832 |
|
|
|
1833 |
# Backdated returns may have fines that shouldn't exist, |
1834 |
# so in this case, we need to drop those fines to 0 |
1835 |
C4::Overdues::UpdateFine( |
1836 |
{ |
1837 |
itemnumber => $issue->{itemnumber}, |
1838 |
borrowernumber => $issue->{borrowernumber}, |
1839 |
amount => 0, |
1840 |
due => output_pref($datedue), |
1841 |
issue_id => $issue->{issue_id} |
1842 |
} |
1843 |
); |
1832 |
} |
1844 |
} |
1833 |
} |
1845 |
} |
1834 |
|
1846 |
|
Lines 1878-1892
sub AddReturn {
Link Here
|
1878 |
$messages->{'WasLost'} = 1; |
1890 |
$messages->{'WasLost'} = 1; |
1879 |
|
1891 |
|
1880 |
if ( C4::Context->preference('RefundLostItemFeeOnReturn' ) ) { |
1892 |
if ( C4::Context->preference('RefundLostItemFeeOnReturn' ) ) { |
1881 |
_FixAccountForLostAndReturned($item->{'itemnumber'}, $borrowernumber, $barcode); # can tolerate undef $borrowernumber |
1893 |
_FixAccountForLostAndReturned( $item->{'itemnumber'} ); |
1882 |
$messages->{'LostItemFeeRefunded'} = 1; |
1894 |
$messages->{'LostItemFeeRefunded'} = 1; |
1883 |
} |
1895 |
} |
1884 |
} |
1896 |
} |
1885 |
|
1897 |
|
1886 |
# fix up the overdues in accounts... |
1898 |
# fix up the overdues in accounts... |
1887 |
if ($borrowernumber) { |
1899 |
if ($borrowernumber) { |
1888 |
my $fix = _FixOverduesOnReturn($borrowernumber, $item->{itemnumber}, $exemptfine, $dropbox); |
1900 |
_FixOverduesOnReturn( |
1889 |
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $item->{itemnumber}...) failed!"; # zero is OK, check defined |
1901 |
{ |
|
|
1902 |
exempt_fine => $exemptfine, |
1903 |
dropbox => $dropbox, |
1904 |
issue => $issue, |
1905 |
} |
1906 |
); |
1890 |
|
1907 |
|
1891 |
if ( $issue->{overdue} && $issue->{date_due} ) { |
1908 |
if ( $issue->{overdue} && $issue->{date_due} ) { |
1892 |
# fix fine days |
1909 |
# fix fine days |
Lines 2121-2259
Internal function, called only by AddReturn
Link Here
|
2121 |
=cut |
2138 |
=cut |
2122 |
|
2139 |
|
2123 |
sub _FixOverduesOnReturn { |
2140 |
sub _FixOverduesOnReturn { |
2124 |
my ($borrowernumber, $item); |
2141 |
my ( $params ) = @_; |
2125 |
unless ($borrowernumber = shift) { |
2142 |
|
2126 |
warn "_FixOverduesOnReturn() not supplied valid borrowernumber"; |
2143 |
my $exemptfine = $params->{exempt_fine}; |
2127 |
return; |
2144 |
my $dropbox = $params->{dropbox}; |
2128 |
} |
2145 |
my $issue = $params->{issue}; |
2129 |
unless ($item = shift) { |
2146 |
|
2130 |
warn "_FixOverduesOnReturn() not supplied valid itemnumber"; |
|
|
2131 |
return; |
2132 |
} |
2133 |
my ($exemptfine, $dropbox) = @_; |
2134 |
my $dbh = C4::Context->dbh; |
2147 |
my $dbh = C4::Context->dbh; |
2135 |
|
2148 |
|
2136 |
# check for overdue fine |
2149 |
my $schema = Koha::Database->new()->schema; |
2137 |
my $sth = $dbh->prepare( |
2150 |
my $fine = |
2138 |
"SELECT * FROM accountlines WHERE (borrowernumber = ?) AND (itemnumber = ?) AND (accounttype='FU' OR accounttype='O')" |
2151 |
$schema->resultset('AccountDebit') |
2139 |
); |
2152 |
->single( { issue_id => $issue->{issue_id}, type => Koha::Accounts::DebitTypes::Fine() } ); |
2140 |
$sth->execute( $borrowernumber, $item ); |
|
|
2141 |
|
2153 |
|
2142 |
# alter fine to show that the book has been returned |
2154 |
return unless ( $fine ); |
2143 |
my $data = $sth->fetchrow_hashref; |
2155 |
|
2144 |
return 0 unless $data; # no warning, there's just nothing to fix |
2156 |
$fine->accruing(0); |
2145 |
|
2157 |
|
2146 |
my $uquery; |
|
|
2147 |
my @bind = ($data->{'accountlines_id'}); |
2148 |
if ($exemptfine) { |
2158 |
if ($exemptfine) { |
2149 |
$uquery = "update accountlines set accounttype='FFOR', amountoutstanding=0"; |
2159 |
AddCredit( |
2150 |
if (C4::Context->preference("FinesLog")) { |
2160 |
{ |
2151 |
&logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item"); |
2161 |
borrower => $fine->borrowernumber(), |
2152 |
} |
2162 |
amount => $fine->amount_original(), |
2153 |
} elsif ($dropbox && $data->{lastincrement}) { |
2163 |
debit_id => $fine->debit_id(), |
2154 |
my $outstanding = $data->{amountoutstanding} - $data->{lastincrement} ; |
2164 |
type => Koha::Accounts::CreditTypes::Forgiven(), |
2155 |
my $amt = $data->{amount} - $data->{lastincrement} ; |
2165 |
} |
|
|
2166 |
); |
2156 |
if (C4::Context->preference("FinesLog")) { |
2167 |
if (C4::Context->preference("FinesLog")) { |
2157 |
&logaction("FINES", 'MODIFY',$borrowernumber,"Dropbox adjustment $amt, item $item"); |
2168 |
&logaction( |
2158 |
} |
2169 |
"FINES", 'MODIFY', |
2159 |
$uquery = "update accountlines set accounttype='F' "; |
2170 |
$issue->{borrowernumber}, |
2160 |
if($outstanding >= 0 && $amt >=0) { |
2171 |
"Overdue forgiven: item " . $issue->{itemnumber} |
2161 |
$uquery .= ", amount = ? , amountoutstanding=? "; |
2172 |
); |
2162 |
unshift @bind, ($amt, $outstanding) ; |
|
|
2163 |
} |
2173 |
} |
2164 |
} else { |
2174 |
} elsif ($dropbox && $fine->amount_last_increment() != $fine->amount_original() ) { |
2165 |
$uquery = "update accountlines set accounttype='F' "; |
2175 |
if ( C4::Context->preference("FinesLog") ) { |
|
|
2176 |
&logaction( "FINES", 'MODIFY', $issue->{borrowernumber}, |
2177 |
"Dropbox adjustment " |
2178 |
. $fine->amount_last_increment() |
2179 |
. ", item " . $issue->{itemnumber} ); |
2180 |
} |
2181 |
$fine->amount_original( |
2182 |
$fine->amount_original() - $fine->amount_last_increment() ); |
2183 |
$fine->amount_outstanding( |
2184 |
$fine->amount_outstanding - $fine->amount_last_increment() ); |
2185 |
$schema->resultset('AccountOffset')->create( |
2186 |
{ |
2187 |
debit_id => $fine->debit_id(), |
2188 |
type => Koha::Accounts::OffsetTypes::Dropbox(), |
2189 |
amount => $fine->amount_last_increment() * -1, |
2190 |
} |
2191 |
); |
2166 |
} |
2192 |
} |
2167 |
$uquery .= " where (accountlines_id = ?)"; |
2193 |
|
2168 |
my $usth = $dbh->prepare($uquery); |
2194 |
return $fine->update(); |
2169 |
return $usth->execute(@bind); |
|
|
2170 |
} |
2195 |
} |
2171 |
|
2196 |
|
2172 |
=head2 _FixAccountForLostAndReturned |
2197 |
=head2 _FixAccountForLostAndReturned |
2173 |
|
2198 |
|
2174 |
&_FixAccountForLostAndReturned($itemnumber, [$borrowernumber, $barcode]); |
2199 |
&_FixAccountForLostAndReturned($itemnumber); |
2175 |
|
2200 |
|
2176 |
Calculates the charge for a book lost and returned. |
2201 |
Refunds a lost item fee in necessary |
2177 |
|
|
|
2178 |
Internal function, not exported, called only by AddReturn. |
2179 |
|
2180 |
FIXME: This function reflects how inscrutable fines logic is. Fix both. |
2181 |
FIXME: Give a positive return value on success. It might be the $borrowernumber who received credit, or the amount forgiven. |
2182 |
|
2202 |
|
2183 |
=cut |
2203 |
=cut |
2184 |
|
2204 |
|
2185 |
sub _FixAccountForLostAndReturned { |
2205 |
sub _FixAccountForLostAndReturned { |
2186 |
my $itemnumber = shift or return; |
2206 |
my ( $itemnumber ) = @_; |
2187 |
my $borrowernumber = @_ ? shift : undef; |
2207 |
|
2188 |
my $item_id = @_ ? shift : $itemnumber; # Send the barcode if you want that logged in the description |
2208 |
my $schema = Koha::Database->new()->schema; |
2189 |
my $dbh = C4::Context->dbh; |
2209 |
|
2190 |
# check for charge made for lost book |
2210 |
# Find the last issue for this item |
2191 |
my $sth = $dbh->prepare("SELECT * FROM accountlines WHERE itemnumber = ? AND accounttype IN ('L', 'Rep', 'W') ORDER BY date DESC, accountno DESC"); |
2211 |
my $issue = |
2192 |
$sth->execute($itemnumber); |
2212 |
$schema->resultset('Issue')->single( { itemnumber => $itemnumber } ); |
2193 |
my $data = $sth->fetchrow_hashref; |
2213 |
$issue ||= |
2194 |
$data or return; # bail if there is nothing to do |
2214 |
$schema->resultset('OldIssue')->single( { itemnumber => $itemnumber } ); |
2195 |
$data->{accounttype} eq 'W' and return; # Written off |
2215 |
|
2196 |
|
2216 |
return unless $issue; |
2197 |
# writeoff this amount |
2217 |
|
2198 |
my $offset; |
2218 |
# Find a lost fee for this issue |
2199 |
my $amount = $data->{'amount'}; |
2219 |
my $debit = $schema->resultset('AccountDebit')->single( |
2200 |
my $acctno = $data->{'accountno'}; |
2220 |
{ |
2201 |
my $amountleft; # Starts off undef/zero. |
2221 |
issue_id => $issue->issue_id(), |
2202 |
if ($data->{'amountoutstanding'} == $amount) { |
2222 |
type => Koha::Accounts::DebitTypes::Lost() |
2203 |
$offset = $data->{'amount'}; |
2223 |
} |
2204 |
$amountleft = 0; # Hey, it's zero here, too. |
2224 |
); |
2205 |
} else { |
2225 |
|
2206 |
$offset = $amount - $data->{'amountoutstanding'}; # Um, isn't this the same as ZERO? We just tested those two things are == |
2226 |
return unless $debit; |
2207 |
$amountleft = $data->{'amountoutstanding'} - $amount; # Um, isn't this the same as ZERO? We just tested those two things are == |
2227 |
|
2208 |
} |
2228 |
# Check for an existing found credit for this debit, if there is one, the fee has already been refunded and we do nothing |
2209 |
my $usth = $dbh->prepare("UPDATE accountlines SET accounttype = 'LR',amountoutstanding='0' |
2229 |
my @credits = $debit->account_offsets->search_related('credit', { 'credit.type' => Koha::Accounts::CreditTypes::Found() }); |
2210 |
WHERE (accountlines_id = ?)"); |
2230 |
|
2211 |
$usth->execute($data->{'accountlines_id'}); # We might be adjusting an account for some OTHER borrowernumber now. Not the one we passed in. |
2231 |
return if @credits; |
2212 |
#check if any credit is left if so writeoff other accounts |
2232 |
|
2213 |
my $nextaccntno = getnextacctno($data->{'borrowernumber'}); |
2233 |
# Ok, so we know we have an unrefunded lost item fee, let's refund it |
2214 |
$amountleft *= -1 if ($amountleft < 0); |
2234 |
CreditLostItem( |
2215 |
if ($amountleft > 0) { |
2235 |
{ |
2216 |
my $msth = $dbh->prepare("SELECT * FROM accountlines WHERE (borrowernumber = ?) |
2236 |
borrower => $issue->borrower(), |
2217 |
AND (amountoutstanding >0) ORDER BY date"); # might want to order by amountoustanding ASC (pay smallest first) |
2237 |
debit => $debit |
2218 |
$msth->execute($data->{'borrowernumber'}); |
2238 |
} |
2219 |
# offset transactions |
2239 |
); |
2220 |
my $newamtos; |
2240 |
|
2221 |
my $accdata; |
|
|
2222 |
while (($accdata=$msth->fetchrow_hashref) and ($amountleft>0)){ |
2223 |
if ($accdata->{'amountoutstanding'} < $amountleft) { |
2224 |
$newamtos = 0; |
2225 |
$amountleft -= $accdata->{'amountoutstanding'}; |
2226 |
} else { |
2227 |
$newamtos = $accdata->{'amountoutstanding'} - $amountleft; |
2228 |
$amountleft = 0; |
2229 |
} |
2230 |
my $thisacct = $accdata->{'accountlines_id'}; |
2231 |
# FIXME: move prepares outside while loop! |
2232 |
my $usth = $dbh->prepare("UPDATE accountlines SET amountoutstanding= ? |
2233 |
WHERE (accountlines_id = ?)"); |
2234 |
$usth->execute($newamtos,$thisacct); |
2235 |
$usth = $dbh->prepare("INSERT INTO accountoffsets |
2236 |
(borrowernumber, accountno, offsetaccount, offsetamount) |
2237 |
VALUES |
2238 |
(?,?,?,?)"); |
2239 |
$usth->execute($data->{'borrowernumber'},$accdata->{'accountno'},$nextaccntno,$newamtos); |
2240 |
} |
2241 |
} |
2242 |
$amountleft *= -1 if ($amountleft > 0); |
2243 |
my $desc = "Item Returned " . $item_id; |
2244 |
$usth = $dbh->prepare("INSERT INTO accountlines |
2245 |
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding) |
2246 |
VALUES (?,?,now(),?,?,'CR',?)"); |
2247 |
$usth->execute($data->{'borrowernumber'},$nextaccntno,0-$amount,$desc,$amountleft); |
2248 |
if ($borrowernumber) { |
2249 |
# FIXME: same as query above. use 1 sth for both |
2250 |
$usth = $dbh->prepare("INSERT INTO accountoffsets |
2251 |
(borrowernumber, accountno, offsetaccount, offsetamount) |
2252 |
VALUES (?,?,?,?)"); |
2253 |
$usth->execute($borrowernumber, $data->{'accountno'}, $nextaccntno, $offset); |
2254 |
} |
2255 |
ModItem({ paidfor => '' }, undef, $itemnumber); |
2241 |
ModItem({ paidfor => '' }, undef, $itemnumber); |
2256 |
return; |
|
|
2257 |
} |
2242 |
} |
2258 |
|
2243 |
|
2259 |
=head2 _GetCircControlBranch |
2244 |
=head2 _GetCircControlBranch |
Lines 2697-2715
sub AddRenewal {
Link Here
|
2697 |
# Charge a new rental fee, if applicable? |
2682 |
# Charge a new rental fee, if applicable? |
2698 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2683 |
my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber ); |
2699 |
if ( $charge > 0 ) { |
2684 |
if ( $charge > 0 ) { |
2700 |
my $accountno = getnextacctno( $borrowernumber ); |
|
|
2701 |
my $item = GetBiblioFromItemNumber($itemnumber); |
2685 |
my $item = GetBiblioFromItemNumber($itemnumber); |
2702 |
my $manager_id = 0; |
2686 |
|
2703 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
2687 |
my $borrower = |
2704 |
$sth = $dbh->prepare( |
2688 |
Koha::Database->new()->schema->resultset('Borrower') |
2705 |
"INSERT INTO accountlines |
2689 |
->find($borrowernumber); |
2706 |
(date, borrowernumber, accountno, amount, manager_id, |
2690 |
|
2707 |
description,accounttype, amountoutstanding, itemnumber) |
2691 |
AddDebit( |
2708 |
VALUES (now(),?,?,?,?,?,?,?,?)" |
2692 |
{ |
|
|
2693 |
borrower => $borrower, |
2694 |
itemnumber => $itemnumber, |
2695 |
amount => $charge, |
2696 |
type => Koha::Accounts::DebitTypes::Rental(), |
2697 |
description => |
2698 |
"Renewal of Rental Item $item->{'title'} $item->{'barcode'}" |
2699 |
} |
2709 |
); |
2700 |
); |
2710 |
$sth->execute( $borrowernumber, $accountno, $charge, $manager_id, |
|
|
2711 |
"Renewal of Rental Item $item->{'title'} $item->{'barcode'}", |
2712 |
'Rent', $charge, $itemnumber ); |
2713 |
} |
2701 |
} |
2714 |
|
2702 |
|
2715 |
# Send a renewal slip according to checkout alert preferencei |
2703 |
# Send a renewal slip according to checkout alert preferencei |
Lines 2928-2952
sub _get_discount_from_rule {
Link Here
|
2928 |
|
2916 |
|
2929 |
=head2 AddIssuingCharge |
2917 |
=head2 AddIssuingCharge |
2930 |
|
2918 |
|
2931 |
&AddIssuingCharge( $itemno, $borrowernumber, $charge ) |
2919 |
&AddIssuingCharge( $itemnumber, $borrowernumber, $amount ) |
2932 |
|
2920 |
|
2933 |
=cut |
2921 |
=cut |
2934 |
|
2922 |
|
2935 |
sub AddIssuingCharge { |
2923 |
sub AddIssuingCharge { |
2936 |
my ( $itemnumber, $borrowernumber, $charge ) = @_; |
2924 |
my ( $itemnumber, $borrowernumber, $amount ) = @_; |
2937 |
my $dbh = C4::Context->dbh; |
2925 |
|
2938 |
my $nextaccntno = getnextacctno( $borrowernumber ); |
2926 |
return AddDebit( |
2939 |
my $manager_id = 0; |
2927 |
{ |
2940 |
$manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; |
2928 |
borrower => Koha::Database->new()->schema->resultset('Borrower')->find($borrowernumber), |
2941 |
my $query =" |
2929 |
itemnumber => $itemnumber, |
2942 |
INSERT INTO accountlines |
2930 |
amount => $amount, |
2943 |
(borrowernumber, itemnumber, accountno, |
2931 |
type => Koha::Accounts::DebitTypes::Rental(), |
2944 |
date, amount, description, accounttype, |
2932 |
} |
2945 |
amountoutstanding, manager_id) |
2933 |
); |
2946 |
VALUES (?, ?, ?,now(), ?, 'Rental', 'Rent',?,?) |
|
|
2947 |
"; |
2948 |
my $sth = $dbh->prepare($query); |
2949 |
$sth->execute( $borrowernumber, $itemnumber, $nextaccntno, $charge, $charge, $manager_id ); |
2950 |
} |
2934 |
} |
2951 |
|
2935 |
|
2952 |
=head2 GetTransfers |
2936 |
=head2 GetTransfers |
Lines 3465-3494
sub ReturnLostItem{
Link Here
|
3465 |
sub LostItem{ |
3449 |
sub LostItem{ |
3466 |
my ($itemnumber, $mark_returned) = @_; |
3450 |
my ($itemnumber, $mark_returned) = @_; |
3467 |
|
3451 |
|
3468 |
my $dbh = C4::Context->dbh(); |
3452 |
my $schema = Koha::Database->new()->schema; |
3469 |
my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title |
|
|
3470 |
FROM issues |
3471 |
JOIN items USING (itemnumber) |
3472 |
JOIN biblio USING (biblionumber) |
3473 |
WHERE issues.itemnumber=?"); |
3474 |
$sth->execute($itemnumber); |
3475 |
my $issues=$sth->fetchrow_hashref(); |
3476 |
|
3453 |
|
3477 |
# If a borrower lost the item, add a replacement cost to the their record |
3454 |
my $issue = |
3478 |
if ( my $borrowernumber = $issues->{borrowernumber} ){ |
3455 |
$schema->resultset('Issue')->single( { itemnumber => $itemnumber } ); |
3479 |
my $borrower = C4::Members::GetMemberDetails( $borrowernumber ); |
3456 |
|
|
|
3457 |
my ( $borrower, $item ); |
3458 |
|
3459 |
if ( $issue ) { |
3460 |
$borrower = $issue->borrower(); |
3461 |
$item = $issue->item(); |
3462 |
} |
3480 |
|
3463 |
|
|
|
3464 |
# If a borrower lost the item, add a replacement cost to the their record |
3465 |
if ( $borrower ){ |
3481 |
if (C4::Context->preference('WhenLostForgiveFine')){ |
3466 |
if (C4::Context->preference('WhenLostForgiveFine')){ |
3482 |
my $fix = _FixOverduesOnReturn($borrowernumber, $itemnumber, 1, 0); # 1, 0 = exemptfine, no-dropbox |
3467 |
_FixOverduesOnReturn( |
3483 |
defined($fix) or warn "_FixOverduesOnReturn($borrowernumber, $itemnumber...) failed!"; # zero is OK, check defined |
3468 |
{ |
|
|
3469 |
exempt_fine => 1, |
3470 |
dropbox => 0, |
3471 |
issue => $issue, |
3472 |
} |
3473 |
); |
3484 |
} |
3474 |
} |
3485 |
if (C4::Context->preference('WhenLostChargeReplacementFee')){ |
3475 |
if ( C4::Context->preference('WhenLostChargeReplacementFee') ) { |
3486 |
C4::Accounts::chargelostitem($borrowernumber, $itemnumber, $issues->{'replacementprice'}, "Lost Item $issues->{'title'} $issues->{'barcode'}"); |
3476 |
DebitLostItem( { borrower => $borrower, issue => $issue } ); |
3487 |
#FIXME : Should probably have a way to distinguish this from an item that really was returned. |
|
|
3488 |
#warn " $issues->{'borrowernumber'} / $itemnumber "; |
3489 |
} |
3477 |
} |
3490 |
|
3478 |
|
3491 |
MarkIssueReturned($borrowernumber,$itemnumber,undef,undef,$borrower->{'privacy'}) if $mark_returned; |
3479 |
MarkIssueReturned( $borrower->borrowernumber(), $item->itemnumber(), undef, undef, $borrower->privacy() ) if $mark_returned; |
3492 |
} |
3480 |
} |
3493 |
} |
3481 |
} |
3494 |
|
3482 |
|