Bugzilla – Attachment 151004 Details for
Bug 28844
Suggestion from existing title can alert patron in error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28844: Add link between suggestions and orders
Bug-28844-Add-link-between-suggestions-and-orders.patch (text/plain), 17.88 KB, created by
Jonathan Druart
on 2023-05-10 13:25:30 UTC
(
hide
)
Description:
Bug 28844: Add link between suggestions and orders
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-05-10 13:25:30 UTC
Size:
17.88 KB
patch
obsolete
>From b212995f7568db0bdcd354a00401597202fc4e67 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 10 May 2023 15:18:15 +0200 >Subject: [PATCH] Bug 28844: Add link between suggestions and orders > >--- > Koha/Acquisition/Order.pm | 19 ++++++++ > acqui/addorder.pl | 1 + > acqui/basket.pl | 6 --- > acqui/orderreceive.pl | 6 --- > acqui/parcel.pl | 6 +-- > api/v1/swagger/definitions/order.yaml | 9 ++++ > api/v1/swagger/paths/acquisitions_orders.yaml | 6 ++- > .../prog/en/modules/acqui/basket.tt | 8 ++-- > .../prog/en/modules/acqui/orderreceive.tt | 4 +- > .../prog/en/modules/acqui/parcel.tt | 48 +++++++++---------- > t/db_dependent/Koha/Acquisition/Order.t | 31 +++++++++++- > 11 files changed, 96 insertions(+), 48 deletions(-) > >diff --git a/Koha/Acquisition/Order.pm b/Koha/Acquisition/Order.pm >index a365f3163ab..2bdc0d0b84d 100644 >--- a/Koha/Acquisition/Order.pm >+++ b/Koha/Acquisition/Order.pm >@@ -283,6 +283,24 @@ sub subscription { > return Koha::Subscription->_new_from_dbic( $subscription_rs ); > } > >+=head3 suggestion >+ >+ my $suggestion = $order->suggestion >+ >+Returns the I<Koha::Suggestion> object for the suggestion associated >+to the order. >+ >+It returns B<undef> if no linked suggestion is found. >+ >+=cut >+ >+sub suggestion { >+ my ( $self ) = @_; >+ my $rs = $self->_result->suggestion; >+ return unless $rs; >+ return Koha::Suggestion->_new_from_dbic( $rs ); >+} >+ > =head3 current_item_level_holds > > my $holds = $order->current_item_level_holds; >@@ -628,6 +646,7 @@ sub to_api_mapping { > sort2 => 'statistics_2', > sort2_authcat => 'statistics_2_authcat', > subscriptionid => 'subscription_id', >+ suggestionid => 'suggestion_id', > suppliers_reference_number => undef, # EDIFACT related > suppliers_reference_qualifier => undef, # EDIFACT related > suppliers_report => undef, # EDIFACT related >diff --git a/acqui/addorder.pl b/acqui/addorder.pl >index 25fd4b3109d..2b40192faeb 100755 >--- a/acqui/addorder.pl >+++ b/acqui/addorder.pl >@@ -259,6 +259,7 @@ my $orderinfo = { > sort2 => scalar $input->param('sort2'), > subscriptionid => scalar $input->param('subscriptionid'), > estimated_delivery_date => scalar $input->param('estimated_delivery_date'), >+ suggestionid => scalar $input->param('suggestionid'), > }; > > $orderinfo->{uncertainprice} ||= 0; >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 80c633cf56a..899b7d4cf28 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -27,7 +27,6 @@ use CGI qw ( -utf8 ); > use C4::Acquisition qw( GetBasket CanUserManageBasket GetBasketAsCSV NewBasket NewBasketgroup ModBasket ReopenBasket ModBasketUsers GetBasketgroup GetBasketgroups GetBasketUsers GetOrders GetOrder get_rounded_price ); > use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget ); > use C4::Contract qw( GetContract ); >-use C4::Suggestions qw( GetSuggestion GetSuggestionInfoFromBiblionumber GetSuggestionInfo ); > use Koha::Biblios; > use Koha::Acquisition::Baskets; > use Koha::Acquisition::Booksellers; >@@ -496,11 +495,6 @@ sub get_order_infos { > $line{order_object} = $order; > } > >- my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); >- $line{suggestionid} = $$suggestion{suggestionid}; >- $line{surnamesuggestedby} = $$suggestion{surnamesuggestedby}; >- $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby}; >- > $line{estimated_delivery_date} = $order->{estimated_delivery_date}; > > foreach my $key (qw(transferred_from transferred_to)) { >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index 17c7280ea37..c49ff5482b9 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -68,7 +68,6 @@ use C4::Output qw( output_html_with_http_headers ); > use C4::Budgets qw( GetBudget GetBudgetPeriods GetBudgetPeriod GetBudgetHierarchy CanUserUseBudget ); > use C4::Members; > use C4::Biblio qw( GetMarcStructure ); >-use C4::Suggestions qw( GetSuggestion GetSuggestionInfoFromBiblionumber GetSuggestionInfo ); > > use Koha::Acquisition::Booksellers; > use Koha::Acquisition::Currencies qw( get_active ); >@@ -164,11 +163,6 @@ $template->param( > gst_values => \@gst_values, > ); > >-my $suggestion = GetSuggestionInfoFromBiblionumber($order->biblionumber); >-if ( $suggestion ) { >- $template->param( suggestion => $suggestion ); >-} >- > my $patron = Koha::Patrons->find( $loggedinuser )->unblessed; > my %budget_loops; > my $budgets = GetBudgetHierarchy( undef, undef, undef, 1 ); >diff --git a/acqui/parcel.pl b/acqui/parcel.pl >index 06172690f68..ed3ca1a8fee 100755 >--- a/acqui/parcel.pl >+++ b/acqui/parcel.pl >@@ -61,7 +61,6 @@ use C4::Acquisition qw( CancelReceipt GetInvoice GetInvoiceDetails get_rounded_p > use C4::Budgets qw( GetBudget GetBudgetByOrderNumber GetBudgetName ); > use CGI qw ( -utf8 ); > use C4::Output qw( output_html_with_http_headers ); >-use C4::Suggestions qw( GetSuggestion GetSuggestionInfoFromBiblionumber GetSuggestionInfo ); > > use Koha::Acquisition::Baskets; > use Koha::Acquisition::Bookseller; >@@ -149,10 +148,7 @@ for my $order ( @orders ) { > $total_tax_excluded += get_rounded_price($line{unitprice_tax_excluded}) * $line{quantity}; > $total_tax_included += get_rounded_price($line{unitprice_tax_included}) * $line{quantity}; > >- my $suggestion = GetSuggestionInfoFromBiblionumber($line{biblionumber}); >- $line{suggestionid} = $suggestion->{suggestionid}; >- $line{surnamesuggestedby} = $suggestion->{surnamesuggestedby}; >- $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby}; >+ $line{order_object} = $order_object; > > if ( $line{parent_ordernumber} != $line{ordernumber} ) { > if ( grep { $_->{ordernumber} == $line{parent_ordernumber} } >diff --git a/api/v1/swagger/definitions/order.yaml b/api/v1/swagger/definitions/order.yaml >index 2b53ad12dd8..c91caa529e8 100644 >--- a/api/v1/swagger/definitions/order.yaml >+++ b/api/v1/swagger/definitions/order.yaml >@@ -204,6 +204,11 @@ properties: > - integer > - "null" > description: Subscription ID linking the order to a subscription >+ suggestion_id: >+ type: >+ - integer >+ - "null" >+ description: Suggestion ID linking the order to a suggestion > parent_order_id: > type: > - integer >@@ -259,4 +264,8 @@ properties: > type: > - object > - "null" >+ suggestion: >+ type: >+ - object >+ - "null" > additionalProperties: false >diff --git a/api/v1/swagger/paths/acquisitions_orders.yaml b/api/v1/swagger/paths/acquisitions_orders.yaml >index 3f3d5e4a935..27339ef3de7 100644 >--- a/api/v1/swagger/paths/acquisitions_orders.yaml >+++ b/api/v1/swagger/paths/acquisitions_orders.yaml >@@ -58,13 +58,14 @@ > - biblio.active_orders+count > - biblio.holds+count > - biblio.items+count >- - biblio.suggestions.suggester > - fund > - current_item_level_holds+count > - invoice > - items > - items+strings > - subscription >+ - suggestion >+ - suggestion.suggester > collectionFormat: csv > responses: > "200": >@@ -175,12 +176,13 @@ > - biblio.active_orders+count > - biblio.holds+count > - biblio.items+count >- - biblio.suggestions.suggester > - fund > - current_item_level_holds+count > - invoice > - items > - subscription >+ - suggestion >+ - suggestion.suggester > collectionFormat: csv > produces: > - application/json >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >index e7d4cbfaa03..17713c1c1ea 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >@@ -566,10 +566,12 @@ > [%- IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear | html -%] > [%- ELSIF ( books_loo.copyrightdate ) %] [% books_loo.copyrightdate | html %][% END -%] > [%- IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement | html %][% END -%] >- [%- IF ( books_loo.suggestionid ) %] >+ [% SET suggestion = books_loo.order_object.suggestion %] >+ [% IF suggestion %] > <br/> >- Suggested by: [% books_loo.surnamesuggestedby | html %][% IF ( books_loo.firstnamesuggestedby ) %], [% books_loo.firstnamesuggestedby | html %] [% END %] >- (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% books_loo.suggestionid | uri %]&op=show">suggestion #[% books_loo.suggestionid | html %]</a>) >+ [% SET suggester = suggestion.suggester %] >+ Suggested by: [% suggester.surname | html %][% IF suggester.firstname %] %], [% suggester.firstname | html %] [% END %] >+ (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&op=show">suggestion #[% suggestion.suggestionid | html %]</a>) > [% END %] > </p> > [% IF ( books_loo.order_internalnote ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >index 05dd6915205..f2aa80de62b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -67,13 +67,15 @@ > </ol> > </fieldset> > >+ [% SET suggestion = order.suggestion %] > [% IF suggestion %] > <fieldset class="rows"> > <legend>Suggestion</legend> > <ol> > <li> > <span class="label">Suggested by: </span> >- [% suggestion.surnamesuggestedby | html %][% IF suggestion.firstnamesuggestedby %], [% suggestion.firstnamesuggestedby | html %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&op=show">suggestion #[% suggestion.suggestionid | html %]</a>) >+ [% SET suggester = suggestion.suggester %] >+ [% suggester.surname | html %][% IF suggester.firstname %], [% suggester.firstname | html %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&op=show">suggestion #[% suggestion.suggestionid | html %]</a>) > [% IF suggestion.reason %] > <li> > <span class="label">Reason:</span> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >index 5ec656850f8..e4eb4be5393 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >@@ -235,10 +235,13 @@ > [%- ELSIF ( order.copyrightdate > 0) -%] [% order.copyrightdate | html %] > [% END %] > [% END %] >- [% IF ( order.suggestionid ) %] >+ >+ [% SET suggestion = order.order_object.suggestion %] >+ [% IF suggestion %] >+ [% SET suggester = suggestion.suggester %] > <br/> >- Suggested by: [% order.surnamesuggestedby | html %][% IF ( order.firstnamesuggestedby ) %], [% order.firstnamesuggestedby | html %] [% END %] >- (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% order.suggestionid | uri %]&op=show">suggestion #[% order.suggestionid | html %]</a>) >+ Suggested by: [% suggester.surname | html %][% IF suggester.firstname %] %], [% suggester.firstname | html %] [% END %] >+ (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&op=show">suggestion #[% suggestion.suggestionid | html %]</a>) > [% END %] > <br /> > [% IF ( order.order_internalnote ) %] >@@ -383,10 +386,10 @@ > "biblio.active_orders+count", > "biblio.holds+count", > "biblio.items+count", >- "biblio.suggestions.suggester", > "fund", > "current_item_level_holds+count", >- "items" >+ "items", >+ "suggestion.suggester" > ], > "stateSave": true, // remember state on page reload > "drawCallback": function (settings) { >@@ -457,26 +460,23 @@ > result += escape_str(row.biblio.copyright_date); > } > } >- var suggestions = row.biblio.suggestions; >- if ( suggestions != null && suggestions.length > 0 ) { >- var suggestion = suggestions[0]; >- if ( suggestion.suggester != null ) { >- var suggester = suggestion.suggester; >- var suggested_by = []; >- if ( suggester.surname != null ) { >- suggested_by.push(escape_str(suggester.surname)); >- } >- if ( suggester.firstname != null ) { >- suggested_by.push(escape_str(suggester.firstname)); >- } >- >- result += "<br/>" + _("Suggested by: ") + >- '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=' >- + encodeURIComponent(suggestion.suggestionid) >- + '&op=show">' >- + suggested_by.join(", ") >- + " (#" + escape_str(suggestions[0].suggestionid) + ")</a>"; // FIXME: could be changed if we allow matching multiple suggestions >+ let suggestion = row.suggestion; >+ if ( suggestion.suggester != null ) { >+ var suggester = suggestion.suggester; >+ var suggested_by = []; >+ if ( suggester.surname != null ) { >+ suggested_by.push(escape_str(suggester.surname)); >+ } >+ if ( suggester.firstname != null ) { >+ suggested_by.push(escape_str(suggester.firstname)); > } >+ >+ result += "<br/>" + _("Suggested by: ") + >+ '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=' >+ + encodeURIComponent(suggestion.suggestion_id) >+ + '&op=show">' >+ + suggested_by.join(", ") >+ + " (#" + escape_str(suggestion.suggestionid) + ")</a>"; > } > result += '</p>'; > } >diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t >index 784acd11cbf..12a18252bfb 100755 >--- a/t/db_dependent/Koha/Acquisition/Order.t >+++ b/t/db_dependent/Koha/Acquisition/Order.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 12; >+use Test::More tests => 13; > use Test::Exception; > > use t::lib::TestBuilder; >@@ -210,6 +210,35 @@ subtest 'subscription' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'suggestion' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ my $o = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ value => { suggestionid => undef }, # not linked to a suggestion >+ } >+ ); >+ >+ my $order = Koha::Acquisition::Orders->find( $o->ordernumber ); >+ is( $order->suggestion, undef, >+ '->suggestion should return undef if not created from a suggestion'); >+ >+ $o = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Orders', >+ # Will be linked to a suggestion by TestBuilder >+ } >+ ); >+ >+ $order = Koha::Acquisition::Orders->find( $o->ordernumber ); >+ is( ref( $order->suggestion ), 'Koha::Suggestion', >+ '->suggestion should return a Koha::Suggestion object if created from a suggestion'); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'duplicate_to | add_item' => sub { > plan tests => 3; > >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28844
:
151001
|
151002
|
151003
|
151004
|
151005
|
151006
|
151007
|
153157
|
153158
|
153159
|
153160
|
153161
|
153162
|
153163
|
153174
|
153175
|
153176
|
158982
|
158983
|
158984
|
158985
|
158986
|
158987
|
158988
|
158989
|
158990
|
159759
|
159760
|
159761
|
159762
|
159763
|
159764
|
159765
|
159766
|
159767
|
159768