Lines 1781-1787
sub AddReturn {
Link Here
|
1781 |
# case of a return of document (deal with issues and holdingbranch) |
1781 |
# case of a return of document (deal with issues and holdingbranch) |
1782 |
my $today = DateTime->now( time_zone => C4::Context->tz() ); |
1782 |
my $today = DateTime->now( time_zone => C4::Context->tz() ); |
1783 |
if ($doreturn) { |
1783 |
if ($doreturn) { |
1784 |
my $datedue = $issue->{date_due}; |
1784 |
my $datedue = $issue->{date_due}; |
1785 |
$borrower or warn "AddReturn without current borrower"; |
1785 |
$borrower or warn "AddReturn without current borrower"; |
1786 |
my $circControlBranch; |
1786 |
my $circControlBranch; |
1787 |
if ($dropbox) { |
1787 |
if ($dropbox) { |
Lines 1790-1820
sub AddReturn {
Link Here
|
1790 |
# FIXME: check issuedate > returndate, factoring in holidays |
1790 |
# FIXME: check issuedate > returndate, factoring in holidays |
1791 |
#$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );; |
1791 |
#$circControlBranch = _GetCircControlBranch($item,$borrower) unless ( $item->{'issuedate'} eq C4::Dates->today('iso') );; |
1792 |
$circControlBranch = _GetCircControlBranch($item,$borrower); |
1792 |
$circControlBranch = _GetCircControlBranch($item,$borrower); |
1793 |
$issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0; |
1793 |
$issue->{'overdue'} = DateTime->compare($issue->{'date_due'}, $today ) == -1 ? 1 : 0; |
1794 |
} |
1794 |
} |
1795 |
|
1795 |
|
1796 |
if ($borrowernumber) { |
1796 |
if ($borrowernumber) { |
1797 |
if( C4::Context->preference('CalculateFinesOnReturn') && $issue->{'overdue'}){ |
1797 |
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 |
1798 |
# we only need to calculate and change the fines if we want to do that on return |
1799 |
# Should be on for hourly loans |
1799 |
# Should be on for hourly loans |
1800 |
my $control = C4::Context->preference('CircControl'); |
1800 |
my $control = C4::Context->preference('CircControl'); |
1801 |
my $control_branchcode = |
1801 |
my $control_branchcode = |
1802 |
( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch} |
1802 |
( $control eq 'ItemHomeLibrary' ) ? $item->{homebranch} |
1803 |
: ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} |
1803 |
: ( $control eq 'PatronLibrary' ) ? $borrower->{branchcode} |
1804 |
: $issue->{branchcode}; |
1804 |
: $issue->{branchcode}; |
1805 |
|
1805 |
|
|
|
1806 |
my $date_returned = |
1807 |
$return_date ? dt_from_string($return_date) : $today; |
1808 |
|
1806 |
my ( $amount, $type, $unitcounttotal ) = |
1809 |
my ( $amount, $type, $unitcounttotal ) = |
1807 |
C4::Overdues::CalcFine( $item, $borrower->{categorycode}, |
1810 |
C4::Overdues::CalcFine( $item, $borrower->{categorycode}, |
1808 |
$control_branchcode, $datedue, $today ); |
1811 |
$control_branchcode, $datedue, $date_returned ); |
1809 |
|
1812 |
|
1810 |
$type ||= q{}; |
1813 |
$type ||= q{}; |
1811 |
|
1814 |
|
1812 |
if ( $amount > 0 |
1815 |
if ( C4::Context->preference('finesMode') eq 'production' ) { |
1813 |
&& C4::Context->preference('finesMode') eq 'production' ) |
1816 |
if ( $amount > 0 ) { |
1814 |
{ |
1817 |
C4::Overdues::UpdateFine( $issue->{itemnumber}, |
1815 |
C4::Overdues::UpdateFine( $issue->{itemnumber}, |
1818 |
$issue->{borrowernumber}, |
1816 |
$issue->{borrowernumber}, |
1819 |
$amount, $type, output_pref($datedue) ); |
1817 |
$amount, $type, output_pref($datedue) ); |
1820 |
} |
|
|
1821 |
elsif ($return_date) { |
1822 |
|
1823 |
# Backdated returns may have fines that shouldn't exist, |
1824 |
# so in this case, we need to drop those fines to 0 |
1825 |
|
1826 |
C4::Overdues::UpdateFine( $issue->{itemnumber}, |
1827 |
$issue->{borrowernumber}, |
1828 |
0, $type, output_pref($datedue) ); |
1829 |
} |
1818 |
} |
1830 |
} |
1819 |
} |
1831 |
} |
1820 |
|
1832 |
|