Bug 34529: Offline circulation should be able to accept userid as well as cardnumber

Like everywhere else in Koha, offline circulation should be able to use userid as well as cardnumber to look up the patron for a transaction ( checkouts and fine payments ).

Test Plan:
1) Apply this patch
2) Restart all the things!
3) Download the test.koc file attached to this bug
4) Verify you have an item with the barcode 39999000001396
   create it if needed
5) Set a patron's username to "hacevedo"
6) Upload and import the test.koc file into offline circ
7) Verify the item was checked out and the payment was made

Signed-off-by: Philip Orr <philip.orr@lmscloud.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Kyle Hall 2023-08-14 10:55:09 -04:00 committed by Tomas Cohen Arazi
parent dcbd3f8387
commit 14f7660b2e
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 10 additions and 2 deletions

View file

@ -4242,6 +4242,7 @@ sub ProcessOfflineIssue {
my $operation = shift;
my $patron = Koha::Patrons->find( { cardnumber => $operation->{cardnumber} } );
$patron ||= Koha::Patrons->find( { userid => $operation->{cardnumber} } );
if ( $patron ) {
my $item = Koha::Items->find({ barcode => $operation->{barcode} });
@ -4275,7 +4276,8 @@ sub ProcessOfflineIssue {
sub ProcessOfflinePayment {
my $operation = shift;
my $patron = Koha::Patrons->find({ cardnumber => $operation->{cardnumber} });
my $patron = Koha::Patrons->find( { cardnumber => $operation->{cardnumber} } );
$patron ||= Koha::Patrons->find( { userid => $operation->{cardnumber} } );
$patron->account->pay(
{

View file

@ -48,7 +48,13 @@ for (@$operations) {
$_->{'bibliotitle'} = $biblio->title;
$_->{'biblionumber'} = $biblio->biblionumber;
}
my $patron = $_->{cardnumber} ? Koha::Patrons->find( { cardnumber => $_->{cardnumber} } ) : undef;
my $patron =
$_->{cardnumber}
? Koha::Patrons->find( { cardnumber => $_->{cardnumber} } )
|| Koha::Patrons->find( { userid => $_->{cardnumber} } )
: undef;
if ($patron) {
$_->{'borrowernumber'} = $patron->borrowernumber;
$_->{'borrower'} = ($patron->firstname ? $patron->firstname:'').' '.$patron->surname;