Lines 1636-1642
sub GetBranchItemRule {
Link Here
|
1636 |
=head2 AddReturn |
1636 |
=head2 AddReturn |
1637 |
|
1637 |
|
1638 |
($doreturn, $messages, $iteminformation, $borrower) = |
1638 |
($doreturn, $messages, $iteminformation, $borrower) = |
1639 |
&AddReturn($barcode, $branch, $exemptfine, $dropbox); |
1639 |
&AddReturn($barcode, $branch, $exemptfine, $dropbox, $returndate); |
1640 |
|
1640 |
|
1641 |
Returns a book. |
1641 |
Returns a book. |
1642 |
|
1642 |
|
Lines 1655-1660
overdue charges are applied and C<$dropbox> is true, the last charge
Link Here
|
1655 |
will be removed. This assumes that the fines accrual script has run |
1655 |
will be removed. This assumes that the fines accrual script has run |
1656 |
for _today_. |
1656 |
for _today_. |
1657 |
|
1657 |
|
|
|
1658 |
=item C<$return_date> allows the default return date to be overridden |
1659 |
by the given return date. |
1660 |
|
1658 |
=back |
1661 |
=back |
1659 |
|
1662 |
|
1660 |
C<&AddReturn> returns a list of four items: |
1663 |
C<&AddReturn> returns a list of four items: |
Lines 1708-1714
patron who last borrowed the book.
Link Here
|
1708 |
=cut |
1711 |
=cut |
1709 |
|
1712 |
|
1710 |
sub AddReturn { |
1713 |
sub AddReturn { |
1711 |
my ( $barcode, $branch, $exemptfine, $dropbox ) = @_; |
1714 |
my ( $barcode, $branch, $exemptfine, $dropbox, $return_date ) = @_; |
1712 |
|
1715 |
|
1713 |
if ($branch and not GetBranchDetail($branch)) { |
1716 |
if ($branch and not GetBranchDetail($branch)) { |
1714 |
warn "AddReturn error: branch '$branch' not found. Reverting to " . C4::Context->userenv->{'branch'}; |
1717 |
warn "AddReturn error: branch '$branch' not found. Reverting to " . C4::Context->userenv->{'branch'}; |
Lines 1781-1787
sub AddReturn {
Link Here
|
1781 |
# case of a return of document (deal with issues and holdingbranch) |
1784 |
# case of a return of document (deal with issues and holdingbranch) |
1782 |
my $today = DateTime->now( time_zone => C4::Context->tz() ); |
1785 |
my $today = DateTime->now( time_zone => C4::Context->tz() ); |
1783 |
if ($doreturn) { |
1786 |
if ($doreturn) { |
1784 |
my $datedue = $issue->{date_due}; |
1787 |
my $datedue = $issue->{date_due}; |
1785 |
$borrower or warn "AddReturn without current borrower"; |
1788 |
$borrower or warn "AddReturn without current borrower"; |
1786 |
my $circControlBranch; |
1789 |
my $circControlBranch; |
1787 |
if ($dropbox) { |
1790 |
if ($dropbox) { |
Lines 1790-1825
sub AddReturn {
Link Here
|
1790 |
# FIXME: check issuedate > returndate, factoring in holidays |
1793 |
# FIXME: check issuedate > returndate, factoring in holidays |
1791 |
#$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );; |
1794 |
#$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );; |
1792 |
$circControlBranch = _GetCircControlBranch($item,$borrower); |
1795 |
$circControlBranch = _GetCircControlBranch($item,$borrower); |
1793 |
$issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0; |
1796 |
$issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0; |
1794 |
} |
1797 |
} |
1795 |
|
1798 |
|
1796 |
if ($borrowernumber) { |
1799 |
if ($borrowernumber) { |
1797 |
if( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'}){ |
1800 |
if ( ( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'} ) || $return_date ) { |
1798 |
# we only need to calculate and change the fines if we want to do that on return |
1801 |
# we only need to calculate and change the fines if we want to do that on return |
1799 |
# Should be on for hourly loans |
1802 |
# Should be on for hourly loans |
1800 |
my $control = C4::Context->preference('CircControl'); |
1803 |
my $control = C4::Context->preference('CircControl'); |
1801 |
my $control_branchcode = |
1804 |
my $control_branchcode = |
1802 |
( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch} |
1805 |
( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch} |
1803 |
: ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} |
1806 |
: ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} |
1804 |
: $issue->{branchcode}; |
1807 |
: $issue->{branchcode}; |
1805 |
|
1808 |
|
|
|
1809 |
my $date_returned = |
1810 |
$return_date ? dt_from_string($return_date) : $today; |
1811 |
|
1806 |
my ( $amount, $type, $unitcounttotal ) = |
1812 |
my ( $amount, $type, $unitcounttotal ) = |
1807 |
C4::Overdues::CalcFine( $item, $borrower->{categorycode}, |
1813 |
C4::Overdues::CalcFine( $item, $borrower->{categorycode}, |
1808 |
$control_branchcode, $datedue, $today ); |
1814 |
$control_branchcode, $datedue, $date_returned ); |
1809 |
|
1815 |
|
1810 |
$type ||= q{}; |
1816 |
$type ||= q{}; |
1811 |
|
1817 |
|
1812 |
if ( $amount > 0 |
1818 |
if ( C4::Context->preference('finesMode') eq 'production' ) { |
1813 |
&& C4::Context->preference('finesMode') eq 'production' ) |
1819 |
if ( $amount > 0 ) { |
1814 |
{ |
1820 |
C4::Overdues::UpdateFine( $issue->{itemnumber}, |
1815 |
C4::Overdues::UpdateFine( $issue->{itemnumber}, |
1821 |
$issue->{borrowernumber}, |
1816 |
$issue->{borrowernumber}, |
1822 |
$amount, $type, output_pref($datedue) ); |
1817 |
$amount, $type, output_pref($datedue) ); |
1823 |
} |
|
|
1824 |
elsif ($return_date) { |
1825 |
|
1826 |
# Backdated returns may have fines that shouldn't exist, |
1827 |
# so in this case, we need to drop those fines to 0 |
1828 |
|
1829 |
C4::Overdues::UpdateFine( $issue->{itemnumber}, |
1830 |
$issue->{borrowernumber}, |
1831 |
0, $type, output_pref($datedue) ); |
1832 |
} |
1818 |
} |
1833 |
} |
1819 |
} |
1834 |
} |
1820 |
|
1835 |
|
1821 |
MarkIssueReturned( $borrowernumber, $item->{'itemnumber'}, |
1836 |
MarkIssueReturned( $borrowernumber, $item->{'itemnumber'}, |
1822 |
$circControlBranch, '', $borrower->{'privacy'} ); |
1837 |
$circControlBranch, $return_date, $borrower->{'privacy'} ); |
1823 |
|
1838 |
|
1824 |
# FIXME is the "= 1" right? This could be the borrower hash. |
1839 |
# FIXME is the "= 1" right? This could be the borrower hash. |
1825 |
$messages->{'WasReturned'} = 1; |
1840 |
$messages->{'WasReturned'} = 1; |