Bug 34920: Ensure 'description' property is an empty string if 'lib' is null

Test plan:
1. Enable ERM module
2. Confirm that you can open the ERM module in the staff interface.
3. Go to the authorized values, select 'ERM_AGREEMENT_CLOSURE_REASON' and edit the 'Cancelled' authorized value by removing the description. Making this change with any of the ERM authorized values will result in an error.
4. Go back to the ERM module and notice that there is an error. 'Something went wrong: Error: Expected string - got null.'
5. Apply patch. Run yarn js:build. Repeat test plan
6. Create a new agreement. Pick status 'Closed'.
7. Open 'Closure reason'. Confirm there is an entry for 'Expired' and an empty entry below that.

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Pedro Amorim 2024-02-29 15:26:54 +00:00 committed by Katrin Fischer
parent 7a20ef5d1c
commit c81a4bb213
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 20 additions and 0 deletions

View File

@ -132,6 +132,26 @@ sub is_integer_only {
return $self->_result->category->is_integer_only;
}
=head3 to_api
my $json = $av->to_api;
Overloaded method that returns a JSON representation of the Koha::AuthorisedValue object,
suitable for API output.
=cut
sub to_api {
my ( $self, $params ) = @_;
my $response = $self->SUPER::to_api($params);
my $overrides = {};
$overrides->{description} = $self->lib // q{};
return { %$response, %$overrides };
}
=head2 Internal methods
=head3 _check_is_integer_only