Bug 31552: SIP2 option format_due_date not honored for AH field in item information response

Bug 28730 added the ability to format due dates based on Koha's date format, but missed formatting the due date field in the item information response.

Test Plan:
1) Apply this patch
2) prove t/db_dependent/SIP/Message.t

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 93e418c0b3)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Kyle Hall 2022-09-12 13:52:23 -04:00 committed by Lucas Gass
parent cb0967ae7d
commit 0c7b340508
2 changed files with 26 additions and 11 deletions

View file

@ -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 );

View file

@ -231,7 +231,7 @@ subtest "Test build_additional_item_fields_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};
@ -303,6 +303,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 {