Browse Source

Bug 28730: Add option to format AH field (due date) in SIP checkout response

This patch adds a new option to sip accounts:
format_due_date

If set to 1 the AH field in checkouts will follow the dateFormat system preference and format as due dates (ignoring time portion if 23:59:59 or 11:59:59)

To test:
 1 - checkout an item via SIP:
perl misc/sip_cli_emulator.pl -a localhost -p 6001 -su term1 -sp term1 -l CPL -t CR --item 3999900000001 --patron enda -m checkout
 2 - Note the AH field is like "YYYYMMDD    HHMMSS"
 3 - Apply patch
 4 - repeat SIP checkout - nothing has changed
 5 - edit SIPConfig.xml and add format_due_date="1" to 'term1' account:
    <login id="term1"  password="term1" delimiter="|" error-detect="enabled" institution="CPL" encoding="ascii"     checked_in_ok="1" format_due_date="1"/>
 6 - restart all
 7 - repeat the SIP checkout
 8 - AH field now matches dateFormat system preference
 9 - Change your dateFormat preference
10 - repeat the SIP checkout
11 - AH matches new format

Note: If you cannot renew and don't get an AH just check the item back in:
perl misc/sip_cli_emulator.pl -a localhost -p 6001 -su term1 -sp term1 -l CPL -t CR --item 3999900000001 --patron enda -m checkin

Signed-off-by: Winfred Thompkins <Winfred.thompkins@cedarhilltx.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.11/bug30761
Nick Clemens 1 year ago
committed by Jonathan Druart
parent
commit
5be090b556
  1. 9
      C4/SIP/Sip/MsgType.pm
  2. 11
      t/db_dependent/SIP/Message.t

9
C4/SIP/Sip/MsgType.pm

@ -22,6 +22,7 @@ use Koha::Patrons;
use Koha::Patron::Attributes;
use Koha::Plugins;
use Koha::Items;
use Koha::DateUtils qw( output_pref );
use UNIVERSAL::can;
@ -564,7 +565,13 @@ sub handle_checkout {
$resp .= add_field( FID_ITEM_ID, $item_id, $server );
$resp .= add_field( FID_TITLE_ID, $item->title_id, $server );
if ( $item->due_date ) {
$resp .= add_field( FID_DUE_DATE, timestamp( $item->due_date ), $server );
my $due_date;
if( $account->{format_due_date} ){
$due_date = output_pref({ str => $item->due_date, as_due_date => 1 });
} else {
$due_date = timestamp( $item->due_date );
}
$resp .= add_field( FID_DUE_DATE, $due_date, $server );
} else {
$resp .= add_field( FID_DUE_DATE, q{}, $server );
}

11
t/db_dependent/SIP/Message.t

@ -71,7 +71,7 @@ subtest 'Testing Patron Info Request V2' => sub {
subtest 'Checkout V2' => sub {
my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
plan tests => 3;
plan tests => 5;
$C4::SIP::Sip::protocol_version = 2;
test_checkout_v2();
$schema->storage->txn_rollback;
@ -614,6 +614,15 @@ sub test_checkout_v2 {
$msg->handle_checkout( $server );
$respcode = substr( $response, 0, 2 );
is( Koha::Checkouts->search({ itemnumber => $item_object->id })->count, 1, "Item was checked out (prevcheckout_block_checkout disabled)");
$msg->handle_checkout( $server );
ok( $response =~ m/AH\d{8} \d{6}/, "Found AH field as timestamp in response");
$server->{account}->{format_due_date} = 1;
t::lib::Mocks::mock_preference( 'dateFormat', 'sql' );
undef $response;
$msg->handle_checkout( $server );
ok( $response =~ m/AH\d{4}-\d{2}-\d{2}/, "Found AH field as SQL date in response");
}
sub test_checkin_v2 {

Loading…
Cancel
Save