Bug 40866: Remove original Bug 9762 implementation remnants (Part 1)
This patch removes the duplicate logging code from the original
Bug 9762 implementation that was not properly removed when the
Alternative implementation was merged.
The original implementation added separate logaction() calls in
CanBookBeIssued and circulation.pl that created additional log
entries with a different JSON format. This caused double logging
when the Alternative implementation (which logs via AddIssue) was
merged on top.
Changes in this patch:
C4/Circulation.pm:
- Removed @message_log array and all pushes to it
- Removed the separate logaction() call at the end of CanBookBeIssued
- Removed 5th return value (@message_log) from CanBookBeIssued
- Removed all if ($issueconfirmed) blocks that were populating @message_log
circ/circulation.pl:
- Removed the problematic line that added OVERRIDDEN to every confirmed
checkout: $needsconfirmation->{'OVERRIDDEN'} = $issueconfirmed
This addresses the double logging issue where circulation overrides
were being logged twice with different formats.
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 2fea44ff25)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
2feabfa5dc
commit
da4ef4bb7f
|
|
@ -825,15 +825,11 @@ sub CanBookBeIssued {
|
||||||
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) );
|
my $circ_library = Koha::Libraries->find( _GetCircControlBranch( $item_object, $patron ) );
|
||||||
|
|
||||||
my $now = dt_from_string();
|
my $now = dt_from_string();
|
||||||
my @message_log;
|
|
||||||
|
|
||||||
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
|
$duedate ||= CalcDateDue( $now, $effective_itemtype, $circ_library->branchcode, $patron );
|
||||||
|
|
||||||
if ( DateTime->compare( $duedate, $now ) == -1 ) { # duedate cannot be before now
|
if ( DateTime->compare( $duedate, $now ) == -1 ) { # duedate cannot be before now
|
||||||
$needsconfirmation{INVALID_DATE} = $duedate;
|
$needsconfirmation{INVALID_DATE} = $duedate;
|
||||||
if ($issueconfirmed) {
|
|
||||||
push( @message_log, "sticky due date is invalid or due date in the past" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $fees = Koha::Charges::Fees->new(
|
my $fees = Koha::Charges::Fees->new(
|
||||||
|
|
@ -879,9 +875,6 @@ sub CanBookBeIssued {
|
||||||
}
|
}
|
||||||
if ( $patron->is_debarred ) {
|
if ( $patron->is_debarred ) {
|
||||||
$issuingimpossible{DEBARRED} = 1;
|
$issuingimpossible{DEBARRED} = 1;
|
||||||
if ($issueconfirmed) {
|
|
||||||
push( @message_log, "borrower is restricted" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $patron->is_expired ) {
|
if ( $patron->is_expired ) {
|
||||||
|
|
@ -954,16 +947,10 @@ sub CanBookBeIssued {
|
||||||
} else {
|
} else {
|
||||||
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) {
|
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) {
|
||||||
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
|
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
|
||||||
if ($issueconfirmed) {
|
|
||||||
push( @message_log, "borrower had amend" );
|
|
||||||
}
|
|
||||||
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
|
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) {
|
||||||
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
|
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
|
||||||
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) {
|
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) {
|
||||||
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
|
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge};
|
||||||
if ($issueconfirmed) {
|
|
||||||
push( @message_log, "borrower had amend" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1044,9 +1031,6 @@ sub CanBookBeIssued {
|
||||||
$needsconfirmation{issued_surname} = $patron->surname;
|
$needsconfirmation{issued_surname} = $patron->surname;
|
||||||
$needsconfirmation{issued_cardnumber} = $patron->cardnumber;
|
$needsconfirmation{issued_cardnumber} = $patron->cardnumber;
|
||||||
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
|
$needsconfirmation{issued_borrowernumber} = $patron->borrowernumber;
|
||||||
if ($issueconfirmed) {
|
|
||||||
push( @message_log, "item is checked out for someone else" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1074,9 +1058,6 @@ sub CanBookBeIssued {
|
||||||
$needsconfirmation{current_loan_count} = $toomany->{count};
|
$needsconfirmation{current_loan_count} = $toomany->{count};
|
||||||
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed};
|
$needsconfirmation{max_loans_allowed} = $toomany->{max_allowed};
|
||||||
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
|
$needsconfirmation{circulation_rule_TOO_MANY} = $toomany->{circulation_rule};
|
||||||
if ($issueconfirmed) {
|
|
||||||
push( @message_log, "too many checkout" );
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$issuingimpossible{TOO_MANY} = $toomany->{reason};
|
$issuingimpossible{TOO_MANY} = $toomany->{reason};
|
||||||
$issuingimpossible{current_loan_count} = $toomany->{count};
|
$issuingimpossible{current_loan_count} = $toomany->{count};
|
||||||
|
|
@ -1109,9 +1090,6 @@ sub CanBookBeIssued {
|
||||||
} else {
|
} else {
|
||||||
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
|
$needsconfirmation{NOT_FOR_LOAN_FORCING} = 1;
|
||||||
$needsconfirmation{item_notforloan} = $item_object->notforloan;
|
$needsconfirmation{item_notforloan} = $item_object->notforloan;
|
||||||
if ($issueconfirmed) {
|
|
||||||
push( @message_log, "item not for loan" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
@ -1157,9 +1135,6 @@ sub CanBookBeIssued {
|
||||||
my $code = $av->count ? $av->next->lib : '';
|
my $code = $av->count ? $av->next->lib : '';
|
||||||
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
|
$needsconfirmation{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'confirm' );
|
||||||
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
|
$alerts{ITEM_LOST} = $code if ( C4::Context->preference("IssueLostItem") eq 'alert' );
|
||||||
if ($issueconfirmed) {
|
|
||||||
push( @message_log, "item lost" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ( C4::Context->preference("IndependentBranches") ) {
|
if ( C4::Context->preference("IndependentBranches") ) {
|
||||||
my $userenv = C4::Context->userenv;
|
my $userenv = C4::Context->userenv;
|
||||||
|
|
@ -1260,13 +1235,6 @@ sub CanBookBeIssued {
|
||||||
$needsconfirmation{'resbranchcode'} = $res->{branchcode};
|
$needsconfirmation{'resbranchcode'} = $res->{branchcode};
|
||||||
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
|
$needsconfirmation{'reswaitingdate'} = $res->{'waitingdate'};
|
||||||
$needsconfirmation{'reserve_id'} = $res->{reserve_id};
|
$needsconfirmation{'reserve_id'} = $res->{reserve_id};
|
||||||
|
|
||||||
if ($issueconfirmed) {
|
|
||||||
push(
|
|
||||||
@message_log,
|
|
||||||
"item is on reserve and waiting, but has been reserved by some other patron"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} elsif ( $restype eq "Reserved" ) {
|
} elsif ( $restype eq "Reserved" ) {
|
||||||
|
|
||||||
# The item is on reserve for someone else.
|
# The item is on reserve for someone else.
|
||||||
|
|
@ -1278,10 +1246,6 @@ sub CanBookBeIssued {
|
||||||
$needsconfirmation{'resbranchcode'} = $res->{branchcode};
|
$needsconfirmation{'resbranchcode'} = $res->{branchcode};
|
||||||
$needsconfirmation{'resreservedate'} = $res->{reservedate};
|
$needsconfirmation{'resreservedate'} = $res->{reservedate};
|
||||||
$needsconfirmation{'reserve_id'} = $res->{reserve_id};
|
$needsconfirmation{'reserve_id'} = $res->{reserve_id};
|
||||||
|
|
||||||
if ($issueconfirmed) {
|
|
||||||
push( @message_log, "item is on reserve for someone else" );
|
|
||||||
}
|
|
||||||
} elsif ( $restype eq "Transferred" ) {
|
} elsif ( $restype eq "Transferred" ) {
|
||||||
|
|
||||||
# The item is determined hold being transferred for someone else.
|
# The item is determined hold being transferred for someone else.
|
||||||
|
|
@ -1293,10 +1257,6 @@ sub CanBookBeIssued {
|
||||||
$needsconfirmation{'resbranchcode'} = $res->{branchcode};
|
$needsconfirmation{'resbranchcode'} = $res->{branchcode};
|
||||||
$needsconfirmation{'resreservedate'} = $res->{reservedate};
|
$needsconfirmation{'resreservedate'} = $res->{reservedate};
|
||||||
$needsconfirmation{'reserve_id'} = $res->{reserve_id};
|
$needsconfirmation{'reserve_id'} = $res->{reserve_id};
|
||||||
|
|
||||||
if ($issueconfirmed) {
|
|
||||||
push( @message_log, "item is determined hold being transferred for someone else" );
|
|
||||||
}
|
|
||||||
} elsif ( $restype eq "Processing" ) {
|
} elsif ( $restype eq "Processing" ) {
|
||||||
|
|
||||||
# The item is determined hold being processed for someone else.
|
# The item is determined hold being processed for someone else.
|
||||||
|
|
@ -1308,10 +1268,6 @@ sub CanBookBeIssued {
|
||||||
$needsconfirmation{'resbranchcode'} = $res->{branchcode};
|
$needsconfirmation{'resbranchcode'} = $res->{branchcode};
|
||||||
$needsconfirmation{'resreservedate'} = $res->{reservedate};
|
$needsconfirmation{'resreservedate'} = $res->{reservedate};
|
||||||
$needsconfirmation{'reserve_id'} = $res->{reserve_id};
|
$needsconfirmation{'reserve_id'} = $res->{reserve_id};
|
||||||
|
|
||||||
if ($issueconfirmed) {
|
|
||||||
push( @message_log, "item is determined hold being processed for someone else" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1355,9 +1311,6 @@ sub CanBookBeIssued {
|
||||||
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) {
|
if ( $restriction_age && $patron->dateofbirth && $restriction_age > $patron->get_age() ) {
|
||||||
if ( C4::Context->preference('AgeRestrictionOverride') ) {
|
if ( C4::Context->preference('AgeRestrictionOverride') ) {
|
||||||
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
|
$needsconfirmation{AGE_RESTRICTION} = "$agerestriction";
|
||||||
if ($issueconfirmed) {
|
|
||||||
push( @message_log, "age restriction" );
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
|
$issuingimpossible{AGE_RESTRICTION} = "$agerestriction";
|
||||||
}
|
}
|
||||||
|
|
@ -1416,34 +1369,7 @@ sub CanBookBeIssued {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $borrower = $patron;
|
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages );
|
||||||
my $user = C4::Context->userenv->{number};
|
|
||||||
my $branchcode = C4::Context->userenv->{branch};
|
|
||||||
|
|
||||||
# action, cardnumber, barcode, date, heure, user, branche
|
|
||||||
if ($issueconfirmed) {
|
|
||||||
|
|
||||||
my $infos = (
|
|
||||||
{
|
|
||||||
message => \@message_log,
|
|
||||||
borrowernumber => $borrower->borrowernumber,
|
|
||||||
barcode => $barcode,
|
|
||||||
manager_id => $user,
|
|
||||||
branchcode => $branchcode,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
my $json_infos = JSON->new->utf8->pretty->encode($infos);
|
|
||||||
$json_infos =~ s/"/'/g;
|
|
||||||
|
|
||||||
logaction(
|
|
||||||
"CIRCULATION", "ISSUE",
|
|
||||||
$borrower->{'borrowernumber'},
|
|
||||||
$json_infos,
|
|
||||||
) if C4::Context->preference("IssueLog");
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( \%issuingimpossible, \%needsconfirmation, \%alerts, \%messages, \@message_log );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 CanBookBeReturned
|
=head2 CanBookBeReturned
|
||||||
|
|
|
||||||
|
|
@ -544,8 +544,7 @@ if ( @$barcodes && $op eq 'cud-checkout' ) {
|
||||||
if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) {
|
if ( my $booked = $needsconfirmation->{BOOKED_EARLY} // $alerts->{BOOKED} ) {
|
||||||
$datedue = $booked->end_date;
|
$datedue = $booked->end_date;
|
||||||
}
|
}
|
||||||
$needsconfirmation->{'DEBT'} = $needsconfirmationDEBT if ($debt_confirmed);
|
$needsconfirmation->{'DEBT'} = $needsconfirmationDEBT if ($debt_confirmed);
|
||||||
$needsconfirmation->{'OVERRIDDEN'} = $issueconfirmed if ($issueconfirmed);
|
|
||||||
my $issue = AddIssue(
|
my $issue = AddIssue(
|
||||||
$patron, $barcode, $datedue,
|
$patron, $barcode, $datedue,
|
||||||
$cancelreserve,
|
$cancelreserve,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue