@@ -, +, @@ field in item information response --- C4/SIP/Sip/MsgType.pm | 23 +++++++++++++---------- t/db_dependent/SIP/Message.t | 14 +++++++++++++- 2 files changed, 26 insertions(+), 11 deletions(-) --- a/C4/SIP/Sip/MsgType.pm +++ a/C4/SIP/Sip/MsgType.pm @@ -574,12 +574,10 @@ 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 ) { - 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 ); - } + my $due_date = + $account->{format_due_date} + ? output_pref( { str => $item->due_date, as_due_date => 1 } ) + : timestamp( $item->due_date ); $resp .= add_field( FID_DUE_DATE, $due_date, $server ); } else { $resp .= add_field( FID_DUE_DATE, q{}, $server ); @@ -1203,10 +1201,11 @@ sub handle_fee_paid { sub handle_item_information { my ( $self, $server ) = @_; - my $ils = $server->{ils}; + my $account = $server->{account}; + my $ils = $server->{ils}; + my $fields = $self->{fields}; + my $resp = ITEM_INFO_RESP; my $trans_date; - my $fields = $self->{fields}; - my $resp = ITEM_INFO_RESP; my $item; my $i; @@ -1266,7 +1265,11 @@ sub handle_item_information { $resp .= add_field( FID_HOLD_QUEUE_LEN, $i, $server ); } if ( $item->due_date ) { - $resp .= add_field( FID_DUE_DATE, timestamp( $item->due_date ), $server ); + my $due_date = + $account->{format_due_date} + ? output_pref( { str => $item->due_date, as_due_date => 1 } ) + : timestamp( $item->due_date ); + $resp .= add_field( FID_DUE_DATE, $due_date, $server ); } if ( ( $i = $item->recall_date ) != 0 ) { $resp .= add_field( FID_RECALL_DATE, timestamp($i), $server ); --- a/t/db_dependent/SIP/Message.t +++ a/t/db_dependent/SIP/Message.t @@ -296,7 +296,7 @@ subtest "Test build_custom_field_string" => sub { }; subtest "Test cr_item_field" => sub { - plan tests => 2; + plan tests => 3; my $builder = t::lib::TestBuilder->new(); my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; @@ -368,6 +368,18 @@ subtest "Test cr_item_field" => sub { my $itype = $item_object->itype; ok( $response =~ m/CR$itype/, "Found correct CR field in response"); + + $server->{account}->{format_due_date} = 1; + t::lib::Mocks::mock_preference( 'dateFormat', 'sql' ); + my $issue = Koha::Checkout->new({ branchcode => $branchcode, borrowernumber => $patron1->{borrowernumber}, itemnumber => $item_object->itemnumber, date_due => "1999-01-01 12:59:00" })->store; + $siprequest = ITEM_INFORMATION . 'YYYYMMDDZZZZHHMMSS' . + FID_INST_ID . $branchcode . '|'. + FID_ITEM_ID . $item_object->barcode . '|' . + FID_TERMINAL_PWD . 'ignored' . '|'; + undef $response; + $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); + $msg->handle_item_information( $server ); + ok( $response =~ m/AH1999-01-01 12:59/, "Found correct CR field in response"); }; subtest 'Patron info summary > 5 should not crash server' => sub { --