Bug 38184: [24.05] Show due date on OpacTrustedCheckout modal

This fixes checkout fields being made available to the public API.

Note: This depends on the fix at Bug 39313, so make sure you apply that
first.

To test:

1. Enabled OpacTrustedCheckout system preference
2. Search for an item and get the barcode
3. Go to the OPAC
4. Click the Self-checkout button at the top
5. Enter the barcode and submit
6. Notice that the due date does not show in the modal, even though the
   due date was correctly set

7. Apply the patch and restart services

8. Go to the staff interface and check in your barcode
9. Repeat steps 3-5
10. Confirm the due date does show correctly in the modal

11. Confirm tests pass t/db_dependent/Koha/Checkout.t

Sponsored-by: Reserve Bank of New Zealand
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
This commit is contained in:
Aleisha Amohia 2025-03-13 23:34:23 +00:00 committed by Jesse Maseto
parent 92ed47e182
commit 2f8637325c
No known key found for this signature in database
GPG Key ID: 4D16BFCF78FFFDEC
2 changed files with 65 additions and 0 deletions

View File

@ -222,6 +222,21 @@ sub to_api_mapping {
};
}
=head3 public_read_list
This method returns the list of publicly readable database fields for both API and UI output purposes
=cut
sub public_read_list {
return [
'checkin_library', 'issue_id', 'borrowernumber',
'itemnumber', 'date_due', 'branchcode',
'returndate', 'lastreneweddate', 'issuedate',
'notedate', 'noteseen'
];
}
=head3 claim_returned
my $return_claim = $checkout->claim_returned();

View File

@ -77,3 +77,53 @@ subtest 'renewals() tests' => sub {
$schema->storage->txn_rollback;
};
subtest 'public_read_list() tests' => sub {
$schema->storage->txn_begin;
my @all_attrs = Koha::Checkouts->columns();
my $public_attrs =
{ map { $_ => 1 } @{ Koha::Checkout->public_read_list() } };
my $mapping = Koha::Checkout->to_api_mapping;
plan tests => scalar @all_attrs * 2;
# Create a sample checkout
my $checkout = $builder->build_object( { class => 'Koha::Checkouts' } );
my $unprivileged_representation = $checkout->to_api( { public => 1 } );
my $privileged_representation = $checkout->to_api;
foreach my $attr (@all_attrs) {
my $mapped = exists $mapping->{$attr} ? $mapping->{$attr} : $attr;
if ( defined($mapped) ) {
ok(
exists $privileged_representation->{$mapped},
"Attribute '$attr' is present when privileged"
);
if ( exists $public_attrs->{$attr} ) {
ok(
exists $unprivileged_representation->{$mapped},
"Attribute '$attr' is present when public"
);
} else {
ok(
!exists $unprivileged_representation->{$mapped},
"Attribute '$attr' is not present when public"
);
}
} else {
ok(
!exists $privileged_representation->{$attr},
"Unmapped attribute '$attr' is not present when privileged"
);
ok(
!exists $unprivileged_representation->{$attr},
"Unmapped attribute '$attr' is not present when public"
);
}
}
$schema->storage->txn_rollback;
};