@@ -, +, @@
---
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(-)
--- a/Koha/Acquisition/Order.pm
+++ a/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 object for the suggestion associated
+to the order.
+
+It returns B 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
--- a/acqui/addorder.pl
+++ a/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;
--- a/acqui/basket.pl
+++ a/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)) {
--- a/acqui/orderreceive.pl
+++ a/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 );
--- a/acqui/parcel.pl
+++ a/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} }
--- a/api/v1/swagger/definitions/order.yaml
+++ a/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
--- a/api/v1/swagger/paths/acquisitions_orders.yaml
+++ a/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
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
+++ a/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 %]
- Suggested by: [% books_loo.surnamesuggestedby | html %][% IF ( books_loo.firstnamesuggestedby ) %], [% books_loo.firstnamesuggestedby | html %] [% END %]
- (suggestion #[% books_loo.suggestionid | html %])
+ [% SET suggester = suggestion.suggester %]
+ Suggested by: [% suggester.surname | html %][% IF suggester.firstname %] %], [% suggester.firstname | html %] [% END %]
+ (suggestion #[% suggestion.suggestionid | html %])
[% END %]
[% IF ( books_loo.order_internalnote ) %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt
@@ -67,13 +67,15 @@
+ [% SET suggestion = order.suggestion %]
[% IF suggestion %]