diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index 7a1651a2fc..6de5f33067 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/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 ); } diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t index 0fbfd81a89..bc13c3bf25 100755 --- a/t/db_dependent/SIP/Message.t +++ b/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 {