From d06dd4d8aa57316528548d834faef9d4744bcc96 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 4 Nov 2025 18:01:40 +0000 Subject: [PATCH] Bug 41182: Allow choosing format of date passed to SUSHI These patches add a new dateformat field to erm_usage_data_providers to allow for choosing the format sent to sushi The formats supported are: yyyy-mm yyyy-mm-dd yyyy-mm is the current assumption and remains the default To test: 0 - Apply patches, updatedatabase, yarn build, restart all 1 - Enable ERMModule 2 - Add a new Data providers 3 - Click 'Add manually' and add a provider without setting the 'Date format' field 4 - Confirm the provider is saved with dateformat 'YYYY-MM' 5 - Edit and set the provider date format to 'YYYY-MM-DD' 6 - Confirm it saves correctly 7 - Edit and set to 'YYYY-MM' and confirm saved 8 - Edit and clear the field, it remains as 'YYYY-MM' 9 - Edit and save as 'YYYY-MM-DD' 10 - Edit and clear the field and save 11 - Confirm it remains 'YYYY-MM-DD' 12 - Run unit tests --- Koha/ERM/EUsage/UsageDataProvider.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Koha/ERM/EUsage/UsageDataProvider.pm b/Koha/ERM/EUsage/UsageDataProvider.pm index 97ccac6cbb4..89603623c30 100644 --- a/Koha/ERM/EUsage/UsageDataProvider.pm +++ b/Koha/ERM/EUsage/UsageDataProvider.pm @@ -396,14 +396,15 @@ sub _build_url_query { $self->erm_usage_data_provider_id; } - my $url = $self->_validate_url( $self->service_url, 'harvest' ); + my $url = $self->_validate_url( $self->service_url, 'harvest' ); + my $date_format_length = $self->dateformat && $self->dateformat eq "yyyy-mm-dd" ? 10 : 7; $url .= lc $self->{report_type}; $url .= '?customer_id=' . $self->customer_id; $url .= '&requestor_id=' . $self->requestor_id if $self->requestor_id; $url .= '&api_key=' . $self->api_key if $self->api_key; - $url .= '&begin_date=' . substr $self->{begin_date}, 0, 7 if $self->{begin_date}; - $url .= '&end_date=' . substr $self->{end_date}, 0, 7 if $self->{end_date}; + $url .= '&begin_date=' . substr $self->{begin_date}, 0, $date_format_length if $self->{begin_date}; + $url .= '&end_date=' . substr $self->{end_date}, 0, $date_format_length if $self->{end_date}; $url .= '&platform=' . $self->service_platform if $self->service_platform; return $url; -- 2.39.5