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