Lines 1768-1781
sub AddIssue {
Link Here
|
1768 |
# and SwitchOnSiteCheckouts is enabled this converts it to a regular checkout |
1768 |
# and SwitchOnSiteCheckouts is enabled this converts it to a regular checkout |
1769 |
$issue = Koha::Checkouts->find( { itemnumber => $item_object->itemnumber } ); |
1769 |
$issue = Koha::Checkouts->find( { itemnumber => $item_object->itemnumber } ); |
1770 |
|
1770 |
|
1771 |
#if this checkout is a booking mark it as completed |
1771 |
# If this checkout relates to a booking, handle booking status appropriately |
1772 |
if ( |
1772 |
if ( my $booking = $item_object->find_booking( { checkout_date => $issuedate, due_date => $datedue } ) ) { |
1773 |
my $booking = $item_object->find_booking( |
1773 |
if ( $booking->patron_id == $patron->borrowernumber ) { |
1774 |
{ checkout_date => $issuedate, due_date => $datedue, patron_id => $patron->borrowernumber } |
1774 |
|
1775 |
) |
1775 |
# Patron's own booking - mark as completed |
1776 |
) |
1776 |
$booking->status('completed')->store; |
1777 |
{ |
1777 |
} else { |
1778 |
$booking->status('completed')->store; |
1778 |
|
|
|
1779 |
# Another patron's booking - only cancel if checkout period overlaps with actual booking period |
1780 |
my $booking_start = dt_from_string( $booking->start_date ); |
1781 |
my $booking_end = dt_from_string( $booking->end_date ); |
1782 |
|
1783 |
# Check if checkout period overlaps with actual booking period (not just lead/trail) |
1784 |
if ( ( $issuedate >= $booking_start && $issuedate <= $booking_end ) |
1785 |
|| ( $datedue >= $booking_start && $datedue <= $booking_end ) |
1786 |
|| ( $issuedate <= $booking_start && $datedue >= $booking_end ) ) |
1787 |
{ |
1788 |
# Checkout overlaps with actual booking period - cancel the booking |
1789 |
$booking->status('cancelled')->store; |
1790 |
} |
1791 |
|
1792 |
# If only in lead/trail period, do nothing - librarian has made informed decision |
1793 |
} |
1779 |
} |
1794 |
} |
1780 |
|
1795 |
|
1781 |
if ($issue) { |
1796 |
if ($issue) { |
1782 |
- |
|
|