View | Details | Raw Unified | Return to bug 28844
Collapse All | Expand All

(-)a/Koha/Acquisition/Order.pm (+19 lines)
Lines 283-288 sub subscription { Link Here
283
    return Koha::Subscription->_new_from_dbic( $subscription_rs );
283
    return Koha::Subscription->_new_from_dbic( $subscription_rs );
284
}
284
}
285
285
286
=head3 suggestion
287
288
    my $suggestion = $order->suggestion
289
290
Returns the I<Koha::Suggestion> object for the suggestion associated
291
to the order.
292
293
It returns B<undef> if no linked suggestion is found.
294
295
=cut
296
297
sub suggestion {
298
    my ( $self )  = @_;
299
    my $rs = $self->_result->suggestion;
300
    return unless $rs;
301
    return Koha::Suggestion->_new_from_dbic( $rs );
302
}
303
286
=head3 current_item_level_holds
304
=head3 current_item_level_holds
287
305
288
    my $holds = $order->current_item_level_holds;
306
    my $holds = $order->current_item_level_holds;
Lines 628-633 sub to_api_mapping { Link Here
628
        sort2                         => 'statistics_2',
646
        sort2                         => 'statistics_2',
629
        sort2_authcat                 => 'statistics_2_authcat',
647
        sort2_authcat                 => 'statistics_2_authcat',
630
        subscriptionid                => 'subscription_id',
648
        subscriptionid                => 'subscription_id',
649
        suggestionid                  => 'suggestion_id',
631
        suppliers_reference_number    => undef,                    # EDIFACT related
650
        suppliers_reference_number    => undef,                    # EDIFACT related
632
        suppliers_reference_qualifier => undef,                    # EDIFACT related
651
        suppliers_reference_qualifier => undef,                    # EDIFACT related
633
        suppliers_report              => undef,                    # EDIFACT related
652
        suppliers_report              => undef,                    # EDIFACT related
(-)a/acqui/addorder.pl (+1 lines)
Lines 259-264 my $orderinfo = { Link Here
259
    sort2                => scalar $input->param('sort2'),
259
    sort2                => scalar $input->param('sort2'),
260
    subscriptionid       => scalar $input->param('subscriptionid'),
260
    subscriptionid       => scalar $input->param('subscriptionid'),
261
    estimated_delivery_date => scalar $input->param('estimated_delivery_date'),
261
    estimated_delivery_date => scalar $input->param('estimated_delivery_date'),
262
    suggestionid         => scalar $input->param('suggestionid'),
262
};
263
};
263
264
264
$orderinfo->{uncertainprice} ||= 0;
265
$orderinfo->{uncertainprice} ||= 0;
(-)a/acqui/basket.pl (-6 lines)
Lines 27-33 use CGI qw ( -utf8 ); Link Here
27
use C4::Acquisition qw( GetBasket CanUserManageBasket GetBasketAsCSV NewBasket NewBasketgroup ModBasket ReopenBasket ModBasketUsers GetBasketgroup GetBasketgroups GetBasketUsers GetOrders GetOrder get_rounded_price );
27
use C4::Acquisition qw( GetBasket CanUserManageBasket GetBasketAsCSV NewBasket NewBasketgroup ModBasket ReopenBasket ModBasketUsers GetBasketgroup GetBasketgroups GetBasketUsers GetOrders GetOrder get_rounded_price );
28
use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget );
28
use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget );
29
use C4::Contract qw( GetContract );
29
use C4::Contract qw( GetContract );
30
use C4::Suggestions qw( GetSuggestion GetSuggestionInfoFromBiblionumber GetSuggestionInfo );
31
use Koha::Biblios;
30
use Koha::Biblios;
32
use Koha::Acquisition::Baskets;
31
use Koha::Acquisition::Baskets;
33
use Koha::Acquisition::Booksellers;
32
use Koha::Acquisition::Booksellers;
Lines 496-506 sub get_order_infos { Link Here
496
        $line{order_object}         = $order;
495
        $line{order_object}         = $order;
497
    }
496
    }
498
497
499
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
500
    $line{suggestionid}         = $$suggestion{suggestionid};
501
    $line{surnamesuggestedby}   = $$suggestion{surnamesuggestedby};
502
    $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby};
503
504
    $line{estimated_delivery_date} = $order->{estimated_delivery_date};
498
    $line{estimated_delivery_date} = $order->{estimated_delivery_date};
505
499
506
    foreach my $key (qw(transferred_from transferred_to)) {
500
    foreach my $key (qw(transferred_from transferred_to)) {
(-)a/acqui/orderreceive.pl (-6 lines)
Lines 68-74 use C4::Output qw( output_html_with_http_headers ); Link Here
68
use C4::Budgets qw( GetBudget GetBudgetPeriods GetBudgetPeriod GetBudgetHierarchy CanUserUseBudget );
68
use C4::Budgets qw( GetBudget GetBudgetPeriods GetBudgetPeriod GetBudgetHierarchy CanUserUseBudget );
69
use C4::Members;
69
use C4::Members;
70
use C4::Biblio qw( GetMarcStructure );
70
use C4::Biblio qw( GetMarcStructure );
71
use C4::Suggestions qw( GetSuggestion GetSuggestionInfoFromBiblionumber GetSuggestionInfo );
72
71
73
use Koha::Acquisition::Booksellers;
72
use Koha::Acquisition::Booksellers;
74
use Koha::Acquisition::Currencies qw( get_active );
73
use Koha::Acquisition::Currencies qw( get_active );
Lines 164-174 $template->param( Link Here
164
    gst_values            => \@gst_values,
163
    gst_values            => \@gst_values,
165
);
164
);
166
165
167
my $suggestion = GetSuggestionInfoFromBiblionumber($order->biblionumber);
168
if ( $suggestion ) {
169
    $template->param( suggestion => $suggestion );
170
}
171
172
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
166
my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
173
my %budget_loops;
167
my %budget_loops;
174
my $budgets = GetBudgetHierarchy( undef, undef, undef, 1 );
168
my $budgets = GetBudgetHierarchy( undef, undef, undef, 1 );
(-)a/acqui/parcel.pl (-5 / +1 lines)
Lines 61-67 use C4::Acquisition qw( CancelReceipt GetInvoice GetInvoiceDetails get_rounded_p Link Here
61
use C4::Budgets qw( GetBudget GetBudgetByOrderNumber GetBudgetName );
61
use C4::Budgets qw( GetBudget GetBudgetByOrderNumber GetBudgetName );
62
use CGI qw ( -utf8 );
62
use CGI qw ( -utf8 );
63
use C4::Output qw( output_html_with_http_headers );
63
use C4::Output qw( output_html_with_http_headers );
64
use C4::Suggestions qw( GetSuggestion GetSuggestionInfoFromBiblionumber GetSuggestionInfo );
65
64
66
use Koha::Acquisition::Baskets;
65
use Koha::Acquisition::Baskets;
67
use Koha::Acquisition::Bookseller;
66
use Koha::Acquisition::Bookseller;
Lines 149-158 for my $order ( @orders ) { Link Here
149
    $total_tax_excluded += get_rounded_price($line{unitprice_tax_excluded}) * $line{quantity};
148
    $total_tax_excluded += get_rounded_price($line{unitprice_tax_excluded}) * $line{quantity};
150
    $total_tax_included += get_rounded_price($line{unitprice_tax_included}) * $line{quantity};
149
    $total_tax_included += get_rounded_price($line{unitprice_tax_included}) * $line{quantity};
151
150
152
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
151
    $line{order_object} = $order_object;
153
    $line{suggestionid}         = $suggestion->{suggestionid};
154
    $line{surnamesuggestedby}   = $suggestion->{surnamesuggestedby};
155
    $line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
156
152
157
    if ( $line{parent_ordernumber} != $line{ordernumber} ) {
153
    if ( $line{parent_ordernumber} != $line{ordernumber} ) {
158
        if ( grep { $_->{ordernumber} == $line{parent_ordernumber} }
154
        if ( grep { $_->{ordernumber} == $line{parent_ordernumber} }
(-)a/api/v1/swagger/definitions/order.yaml (+9 lines)
Lines 204-209 properties: Link Here
204
      - integer
204
      - integer
205
      - "null"
205
      - "null"
206
    description: Subscription ID linking the order to a subscription
206
    description: Subscription ID linking the order to a subscription
207
  suggestion_id:
208
    type:
209
      - integer
210
      - "null"
211
    description: Suggestion ID linking the order to a suggestion
207
  parent_order_id:
212
  parent_order_id:
208
    type:
213
    type:
209
      - integer
214
      - integer
Lines 259-262 properties: Link Here
259
    type:
264
    type:
260
      - object
265
      - object
261
      - "null"
266
      - "null"
267
  suggestion:
268
    type:
269
      - object
270
      - "null"
262
additionalProperties: false
271
additionalProperties: false
(-)a/api/v1/swagger/paths/acquisitions_orders.yaml (-2 / +4 lines)
Lines 58-70 Link Here
58
            - biblio.active_orders+count
58
            - biblio.active_orders+count
59
            - biblio.holds+count
59
            - biblio.holds+count
60
            - biblio.items+count
60
            - biblio.items+count
61
            - biblio.suggestions.suggester
62
            - fund
61
            - fund
63
            - current_item_level_holds+count
62
            - current_item_level_holds+count
64
            - invoice
63
            - invoice
65
            - items
64
            - items
66
            - items+strings
65
            - items+strings
67
            - subscription
66
            - subscription
67
            - suggestion
68
            - suggestion.suggester
68
        collectionFormat: csv
69
        collectionFormat: csv
69
    responses:
70
    responses:
70
      "200":
71
      "200":
Lines 175-186 Link Here
175
            - biblio.active_orders+count
176
            - biblio.active_orders+count
176
            - biblio.holds+count
177
            - biblio.holds+count
177
            - biblio.items+count
178
            - biblio.items+count
178
            - biblio.suggestions.suggester
179
            - fund
179
            - fund
180
            - current_item_level_holds+count
180
            - current_item_level_holds+count
181
            - invoice
181
            - invoice
182
            - items
182
            - items
183
            - subscription
183
            - subscription
184
            - suggestion
185
            - suggestion.suggester
184
        collectionFormat: csv
186
        collectionFormat: csv
185
    produces:
187
    produces:
186
      - application/json
188
      - application/json
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-3 / +5 lines)
Lines 566-575 Link Here
566
                                                                [%- IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear | html -%]
566
                                                                [%- IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear | html -%]
567
                                                                [%- ELSIF ( books_loo.copyrightdate ) %] [% books_loo.copyrightdate | html %][% END -%]
567
                                                                [%- ELSIF ( books_loo.copyrightdate ) %] [% books_loo.copyrightdate | html %][% END -%]
568
                                                                [%- IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement | html %][% END -%]
568
                                                                [%- IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement | html %][% END -%]
569
                                                                [%- IF ( books_loo.suggestionid ) %]
569
                                                                [% SET suggestion = books_loo.order_object.suggestion %]
570
                                                                [% IF suggestion %]
570
                                                                    <br/>
571
                                                                    <br/>
571
                                                                    Suggested by: [% books_loo.surnamesuggestedby | html %][% IF ( books_loo.firstnamesuggestedby ) %], [% books_loo.firstnamesuggestedby | html %] [% END %]
572
                                                                    [% SET suggester = suggestion.suggester %]
572
                                                                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% books_loo.suggestionid | uri %]&amp;op=show">suggestion #[% books_loo.suggestionid | html %]</a>)
573
                                                                    Suggested by: [% suggester.surname | html %][% IF suggester.firstname %] %], [% suggester.firstname | html %] [% END %]
574
                                                                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&amp;op=show">suggestion #[% suggestion.suggestionid | html %]</a>)
573
                                                                [% END %]
575
                                                                [% END %]
574
                                                            </p>
576
                                                            </p>
575
                                                            [% IF ( books_loo.order_internalnote ) %]
577
                                                            [% IF ( books_loo.order_internalnote ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-1 / +3 lines)
Lines 67-79 Link Here
67
    </ol>
67
    </ol>
68
	</fieldset>
68
	</fieldset>
69
69
70
    [% SET suggestion = order.suggestion %]
70
    [% IF suggestion %]
71
    [% IF suggestion %]
71
        <fieldset class="rows">
72
        <fieldset class="rows">
72
        <legend>Suggestion</legend>
73
        <legend>Suggestion</legend>
73
        <ol>
74
        <ol>
74
          <li>
75
          <li>
75
            <span class="label">Suggested by: </span>
76
            <span class="label">Suggested by: </span>
76
            [% suggestion.surnamesuggestedby | html %][% IF suggestion.firstnamesuggestedby %], [% suggestion.firstnamesuggestedby | html %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&amp;op=show">suggestion #[% suggestion.suggestionid | html %]</a>)
77
            [% SET suggester = suggestion.suggester %]
78
            [% suggester.surname | html %][% IF suggester.firstname %], [% suggester.firstname | html %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&amp;op=show">suggestion #[% suggestion.suggestionid | html %]</a>)
77
            [% IF suggestion.reason %]
79
            [% IF suggestion.reason %]
78
                <li>
80
                <li>
79
                    <span class="label">Reason:</span>
81
                    <span class="label">Reason:</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-24 / +24 lines)
Lines 235-244 Link Here
235
                    [%- ELSIF ( order.copyrightdate   > 0) -%] [% order.copyrightdate | html %]
235
                    [%- ELSIF ( order.copyrightdate   > 0) -%] [% order.copyrightdate | html %]
236
                    [% END %]
236
                    [% END %]
237
                [% END %]
237
                [% END %]
238
                [% IF ( order.suggestionid ) %]
238
239
                [% SET suggestion = order.order_object.suggestion %]
240
                [% IF suggestion %]
241
                [% SET suggester = suggestion.suggester %]
239
                    <br/>
242
                    <br/>
240
                    Suggested by: [% order.surnamesuggestedby | html %][% IF ( order.firstnamesuggestedby ) %], [% order.firstnamesuggestedby | html %] [% END %]
243
                    Suggested by: [% suggester.surname | html %][% IF suggester.firstname %] %], [% suggester.firstname | html %] [% END %]
241
                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% order.suggestionid | uri %]&amp;op=show">suggestion #[% order.suggestionid | html %]</a>)
244
                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&amp;op=show">suggestion #[% suggestion.suggestionid | html %]</a>)
242
                [% END %]
245
                [% END %]
243
                <br />
246
                <br />
244
                [% IF ( order.order_internalnote ) %]
247
                [% IF ( order.order_internalnote ) %]
Lines 383-392 Link Here
383
                    "biblio.active_orders+count",
386
                    "biblio.active_orders+count",
384
                    "biblio.holds+count",
387
                    "biblio.holds+count",
385
                    "biblio.items+count",
388
                    "biblio.items+count",
386
                    "biblio.suggestions.suggester",
387
                    "fund",
389
                    "fund",
388
                    "current_item_level_holds+count",
390
                    "current_item_level_holds+count",
389
                    "items"
391
                    "items",
392
                    "suggestion.suggester"
390
                ],
393
                ],
391
                "stateSave": true, // remember state on page reload
394
                "stateSave": true, // remember state on page reload
392
                "drawCallback": function (settings) {
395
                "drawCallback": function (settings) {
Lines 457-482 Link Here
457
                                        result += escape_str(row.biblio.copyright_date);
460
                                        result += escape_str(row.biblio.copyright_date);
458
                                    }
461
                                    }
459
                                }
462
                                }
460
                                var suggestions = row.biblio.suggestions;
463
                                let suggestion = row.suggestion;
461
                                if ( suggestions != null && suggestions.length > 0 ) {
464
                                if ( suggestion.suggester != null ) {
462
                                    var suggestion = suggestions[0];
465
                                    var suggester = suggestion.suggester;
463
                                    if ( suggestion.suggester != null ) {
466
                                    var suggested_by = [];
464
                                        var suggester = suggestion.suggester;
467
                                    if ( suggester.surname != null ) {
465
                                        var suggested_by = [];
468
                                        suggested_by.push(escape_str(suggester.surname));
466
                                        if ( suggester.surname != null ) {
469
                                    }
467
                                            suggested_by.push(escape_str(suggester.surname));
470
                                    if ( suggester.firstname != null ) {
468
                                        }
471
                                        suggested_by.push(escape_str(suggester.firstname));
469
                                        if ( suggester.firstname != null ) {
470
                                            suggested_by.push(escape_str(suggester.firstname));
471
                                        }
472
473
                                            result += "<br/>" + _("Suggested by: ") +
474
                                                        '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='
475
                                                            + encodeURIComponent(suggestion.suggestionid)
476
                                                            + '&amp;op=show">'
477
                                                            + suggested_by.join(", ")
478
                                                            + " (#" + escape_str(suggestions[0].suggestionid) + ")</a>"; // FIXME: could be changed if we allow matching multiple suggestions
479
                                    }
472
                                    }
473
474
                                    result += "<br/>" + _("Suggested by: ") +
475
                                                '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='
476
                                                    + encodeURIComponent(suggestion.suggestion_id)
477
                                                    + '&amp;op=show">'
478
                                                    + suggested_by.join(", ")
479
                                                    + " (#" + escape_str(suggestion.suggestionid) + ")</a>";
480
                                }
480
                                }
481
                                result += '</p>';
481
                                result += '</p>';
482
                            }
482
                            }
(-)a/t/db_dependent/Koha/Acquisition/Order.t (-2 / +30 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 12;
22
use Test::More tests => 13;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use t::lib::TestBuilder;
25
use t::lib::TestBuilder;
Lines 210-215 subtest 'subscription' => sub { Link Here
210
    $schema->storage->txn_rollback;
210
    $schema->storage->txn_rollback;
211
};
211
};
212
212
213
subtest 'suggestion' => sub {
214
    plan tests => 2;
215
216
    $schema->storage->txn_begin;
217
    my $o = $builder->build_object(
218
        {
219
            class => 'Koha::Acquisition::Orders',
220
            value => { suggestionid => undef }, # not linked to a suggestion
221
        }
222
    );
223
224
    my $order = Koha::Acquisition::Orders->find( $o->ordernumber );
225
    is( $order->suggestion, undef,
226
        '->suggestion should return undef if not created from a suggestion');
227
228
    $o = $builder->build_object(
229
        {
230
            class => 'Koha::Acquisition::Orders',
231
            # Will be linked to a suggestion by TestBuilder
232
        }
233
    );
234
235
    $order = Koha::Acquisition::Orders->find( $o->ordernumber );
236
    is( ref( $order->suggestion ), 'Koha::Suggestion',
237
        '->suggestion should return a Koha::Suggestion object if created from a suggestion');
238
239
    $schema->storage->txn_rollback;
240
};
241
213
subtest 'duplicate_to | add_item' => sub {
242
subtest 'duplicate_to | add_item' => sub {
214
    plan tests => 3;
243
    plan tests => 3;
215
244
216
- 

Return to bug 28844