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

(-)a/Koha/Acquisition/Order.pm (-9 / +27 lines)
Lines 146-160 sub cancel { Link Here
146
    }
146
    }
147
147
148
    # If ordered from a suggestion, revert the suggestion status to ACCEPTED
148
    # If ordered from a suggestion, revert the suggestion status to ACCEPTED
149
    my $suggestion = Koha::Suggestions->find({ biblionumber => $self->biblionumber, status => "ORDERED" });
149
    my $suggestions = $self->suggestions;
150
    if ( $suggestion and $suggestion->id ) {
150
    while ( my $suggestion = $suggestions->next ){
151
        ModSuggestion(
151
        if ( $suggestion && $suggestion->STATUS eq "ORDERED" ) {
152
            {
152
            ModSuggestion(
153
                suggestionid => $suggestion->id,
153
                {
154
                biblionumber => $self->biblionumber,
154
                    suggestionid => $suggestion->id,
155
                STATUS       => 'ACCEPTED',
155
                    biblionumber => $self->biblionumber,
156
            }
156
                    STATUS       => 'ACCEPTED',
157
        );
157
                }
158
            );
159
        }
158
    }
160
    }
159
161
160
    my $biblio = $self->biblio;
162
    my $biblio = $self->biblio;
Lines 297-302 sub subscription { Link Here
297
    return Koha::Subscription->_new_from_dbic( $subscription_rs );
299
    return Koha::Subscription->_new_from_dbic( $subscription_rs );
298
}
300
}
299
301
302
=head3 suggestions
303
304
    my $suggestions = $order->suggestions
305
306
Returns the I<Koha::Suggestions> object for the suggestions associated
307
to the order.
308
309
=cut
310
311
sub suggestions {
312
    my ( $self )  = @_;
313
    my $rs = $self->_result->suggestions;
314
    return unless $rs;
315
    return Koha::Suggestions->_new_from_dbic( $rs );
316
}
317
300
=head3 current_item_level_holds
318
=head3 current_item_level_holds
301
319
302
    my $holds = $order->current_item_level_holds;
320
    my $holds = $order->current_item_level_holds;
(-)a/acqui/addorder.pl (+12 lines)
Lines 356-361 if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { Link Here
356
    $order->populate_with_prices_for_ordering();
356
    $order->populate_with_prices_for_ordering();
357
    $order->store;
357
    $order->store;
358
358
359
    # change suggestion status if applicable
360
    if ( my $suggestionid = $input->param('suggestionid') ) {
361
        ModSuggestion(
362
            {
363
                suggestionid => $suggestionid,
364
                biblionumber => $orderinfo->{biblionumber},
365
                ordernumber => $order->ordernumber,
366
                STATUS       => 'ORDERED',
367
            }
368
        );
369
    }
370
359
    # Log the order creation
371
    # Log the order creation
360
    if (C4::Context->preference("AcquisitionLog")) {
372
    if (C4::Context->preference("AcquisitionLog")) {
361
        my $infos = {};
373
        my $infos = {};
(-)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 503-513 sub get_order_infos { Link Here
503
502
504
    }
503
    }
505
504
506
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
507
    $line{suggestionid}         = $$suggestion{suggestionid};
508
    $line{surnamesuggestedby}   = $$suggestion{surnamesuggestedby};
509
    $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby};
510
511
    $line{estimated_delivery_date} = $order->{estimated_delivery_date};
505
    $line{estimated_delivery_date} = $order->{estimated_delivery_date};
512
506
513
    foreach my $key (qw(transferred_from transferred_to)) {
507
    foreach my $key (qw(transferred_from transferred_to)) {
(-)a/acqui/orderreceive.pl (-1 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 );
(-)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 (+3 lines)
Lines 264-267 properties: Link Here
264
      - object
264
      - object
265
      - "null"
265
      - "null"
266
    description: Patron that created the order
266
    description: Patron that created the order
267
  suggestions:
268
    type:
269
      - array
267
additionalProperties: false
270
additionalProperties: false
(-)a/api/v1/swagger/definitions/suggestion.yaml (+6 lines)
Lines 136-141 properties: Link Here
136
      - "null"
136
      - "null"
137
    description: foreign key linking the suggestion to the biblio table after the
137
    description: foreign key linking the suggestion to the biblio table after the
138
      suggestion has been ordered
138
      suggestion has been ordered
139
  order_id:
140
    type:
141
      - integer
142
      - "null"
143
    description: foreign key linking the suggestion to the aqorders table after the
144
      suggestion has been ordered
139
  reason:
145
  reason:
140
    type:
146
    type:
141
      - string
147
      - string
(-)a/api/v1/swagger/paths/acquisitions_orders.yaml (-2 / +4 lines)
Lines 57-63 Link Here
57
            - biblio.active_orders+count
57
            - biblio.active_orders+count
58
            - biblio.holds+count
58
            - biblio.holds+count
59
            - biblio.items+count
59
            - biblio.items+count
60
            - biblio.suggestions.suggester
61
            - creator
60
            - creator
62
            - fund
61
            - fund
63
            - fund.budget
62
            - fund.budget
Lines 66-71 Link Here
66
            - items
65
            - items
67
            - items+strings
66
            - items+strings
68
            - subscription
67
            - subscription
68
            - suggestions
69
            - suggestions.suggester
69
        collectionFormat: csv
70
        collectionFormat: csv
70
    responses:
71
    responses:
71
      "200":
72
      "200":
Lines 177-188 Link Here
177
            - biblio.active_orders+count
178
            - biblio.active_orders+count
178
            - biblio.holds+count
179
            - biblio.holds+count
179
            - biblio.items+count
180
            - biblio.items+count
180
            - biblio.suggestions.suggester
181
            - fund
181
            - fund
182
            - current_item_level_holds+count
182
            - current_item_level_holds+count
183
            - invoice
183
            - invoice
184
            - items
184
            - items
185
            - subscription
185
            - subscription
186
            - suggestion
187
            - suggestion.suggester
186
        collectionFormat: csv
188
        collectionFormat: csv
187
    produces:
189
    produces:
188
      - application/json
190
      - application/json
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-3 / +5 lines)
Lines 582-591 Link Here
582
                                                                [%- IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear | html -%]
582
                                                                [%- IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear | html -%]
583
                                                                [%- ELSIF ( books_loo.copyrightdate ) %] [% books_loo.copyrightdate | html %][% END -%]
583
                                                                [%- ELSIF ( books_loo.copyrightdate ) %] [% books_loo.copyrightdate | html %][% END -%]
584
                                                                [%- IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement | html %][% END -%]
584
                                                                [%- IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement | html %][% END -%]
585
                                                                [%- IF ( books_loo.suggestionid ) %]
585
                                                                [% SET suggestions = books_loo.order_object.suggestions %]
586
                                                                [% FOREACH suggestion IN suggestions %]
586
                                                                    <br/>
587
                                                                    <br/>
587
                                                                    Suggested by: [% books_loo.surnamesuggestedby | html %][% IF ( books_loo.firstnamesuggestedby ) %], [% books_loo.firstnamesuggestedby | html %] [% END %]
588
                                                                    [% SET suggester = suggestion.suggester %]
588
                                                                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% books_loo.suggestionid | uri %]&amp;op=show">suggestion #[% books_loo.suggestionid | html %]</a>)
589
                                                                    Suggested by: [% suggester.surname | html %][% IF suggester.firstname %] %], [% suggester.firstname | html %] [% END %]
590
                                                                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&amp;op=show">suggestion #[% suggestion.suggestionid | html %]</a>)
589
                                                                [% END %]
591
                                                                [% END %]
590
                                                            </p>
592
                                                            </p>
591
                                                            [% IF ( books_loo.order_internalnote ) %]
593
                                                            [% IF ( books_loo.order_internalnote ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-18 / +20 lines)
Lines 553-559 Link Here
553
        $(document).ready(function(){
553
        $(document).ready(function(){
554
            // keep a copy for re-rendering
554
            // keep a copy for re-rendering
555
            var $funds_tree = $('#bookfund').html();
555
            var $funds_tree = $('#bookfund').html();
556
            var base_query = { "order_id": {"in": [[% multiple_orders | html %]]}};
556
            var base_query = { "me.order_id": {"in": [[% multiple_orders | html %]]}};
557
            var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1";
557
            var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1";
558
            var options = {
558
            var options = {
559
                "ajax": {
559
                "ajax": {
Lines 561-570 Link Here
561
                },
561
                },
562
                "embed": [
562
                "embed": [
563
                    "basket",
563
                    "basket",
564
                    "biblio.suggestions.suggester",
564
                    "biblio",
565
                    "fund.budget",
565
                    "fund.budget",
566
                    "items+strings",
566
                    "items+strings",
567
                    "creator"
567
                    "creator",
568
                    "suggestions.suggester",
568
                ],
569
                ],
569
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
570
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
570
                "columns": [
571
                "columns": [
Lines 693-705 Link Here
693
                params['ordernumber'] = row.order_id;
694
                params['ordernumber'] = row.order_id;
694
                params['booksellerid'] = row.basket.vendor_id;
695
                params['booksellerid'] = row.basket.vendor_id;
695
696
696
                if(row.biblio.suggestions.length && row.biblio.suggestions[0].reason) {
697
                if(row.suggestions && row.suggestions[0].reason) {
697
                    params["suggestionid"] = row.biblio.suggestions[0].suggestion_id;
698
698
                    if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) {
699
                    params["suggestionid"] = row.suggestions[0].suggestion_id;
699
                        params['reason'] =  row.biblio.suggestions[0].reason;
700
                    if($("#reason option[value='"+row.suggestions[0].reason+"']").length) {
701
                        params['reason'] =  row.suggestions[0].reason;
700
                    } else {
702
                    } else {
701
                        params['reason'] = 'other';
703
                        params['reason'] = 'other';
702
                        params['other_reason'] = row.biblio.suggestions[0].reason;
704
                        params['other_reason'] = row.suggestions[0].reason;
703
                    }
705
                    }
704
                }
706
                }
705
                params['datereceived'] = row.date_received;
707
                params['datereceived'] = row.date_received;
Lines 837-850 Link Here
837
                    $("#other_reason").show();
839
                    $("#other_reason").show();
838
                    $(this).hide();
840
                    $(this).hide();
839
                } else {
841
                } else {
840
                    row.biblio.suggestions[0].reason = val;
842
                    row.suggestions[0].reason = val;
841
                }
843
                }
842
            });
844
            });
843
845
844
            $("#order_edit").on("change", "#select-other_reason", function() {
846
            $("#order_edit").on("change", "#select-other_reason", function() {
845
                var val = $(this).val();
847
                var val = $(this).val();
846
                var row = $("#order_edit").data('row');
848
                var row = $("#order_edit").data('row');
847
                row.biblio.suggestions[0].reason = val;
849
                row.suggestions[0].reason = val;
848
            });
850
            });
849
851
850
            $("#order_edit").on("click", "#other_reason a", function() {
852
            $("#order_edit").on("click", "#other_reason a", function() {
Lines 1132-1161 Link Here
1132
                        o.parent().hide();
1134
                        o.parent().hide();
1133
                    }
1135
                    }
1134
                });
1136
                });
1135
                if(row.biblio.suggestions.length) {
1137
                if(row.suggestions) {
1136
                    $("#suggestion_fieldset").show();
1138
                    $("#suggestion_fieldset").show();
1137
                    if(row.biblio.suggestions[0].suggester) {
1139
                    if(row.suggestions[0].suggester) {
1138
                        $("#biblio_suggestion_suggester").parent().show();
1140
                        $("#biblio_suggestion_suggester").parent().show();
1139
                        $("#biblio_suggestion_suggester")
1141
                        $("#biblio_suggestion_suggester")
1140
                            .html(
1142
                            .html(
1141
                                [row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname]
1143
                                [row.suggestions[0].suggester.surname, row.suggestions[0].suggester.firstname]
1142
                                    .filter(function(name){
1144
                                    .filter(function(name){
1143
                                        return name
1145
                                        return name
1144
                                    })
1146
                                    })
1145
                                    .join(', ')+' (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='+row.biblio.suggestions[0].suggestion_id+'&op=show">'+SUGGESTION.format(row.biblio.suggestions[0].suggestion_id)+'</a>)'
1147
                                    .join(', ')+' (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='+row.suggestions[0].suggestion_id+'&op=show">'+SUGGESTION.format(row.suggestions[0].suggestion_id)+'</a>)'
1146
                            );
1148
                            );
1147
                    } else {
1149
                    } else {
1148
                        $("#biblio_suggestion_suggester").parent().hide();
1150
                        $("#biblio_suggestion_suggester").parent().hide();
1149
                    }
1151
                    }
1150
                    if(row.biblio.suggestions[0].reason) {
1152
                    if(row.suggestions[0].reason) {
1151
                        $("#suggestion_reason").show();
1153
                        $("#suggestion_reason").show();
1152
                        if($("#reason option[value='"+row.biblio.suggestions[0].reason+"']").length) {
1154
                        if($("#reason option[value='"+row.suggestions[0].reason+"']").length) {
1153
                             $("#other_reason a").click();
1155
                             $("#other_reason a").click();
1154
                            $("#reason").val(row.biblio.suggestions[0].reason);
1156
                            $("#reason").val(row.suggestions[0].reason);
1155
                            $("#select-other_reason").val(null);
1157
                            $("#select-other_reason").val(null);
1156
                        } else {
1158
                        } else {
1157
                            $("#reason").val("other").change();
1159
                            $("#reason").val("other").change();
1158
                            $("#select-other_reason").val(row.biblio.suggestions[0].reason);
1160
                            $("#select-other_reason").val(row.suggestions[0].reason);
1159
                        }
1161
                        }
1160
1162
1161
                    } else {
1163
                    } else {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-25 / +27 lines)
Lines 244-253 Link Here
244
                    [%- ELSIF ( order.copyrightdate   > 0) -%] [% order.copyrightdate | html %]
244
                    [%- ELSIF ( order.copyrightdate   > 0) -%] [% order.copyrightdate | html %]
245
                    [% END %]
245
                    [% END %]
246
                [% END %]
246
                [% END %]
247
                [% IF ( order.suggestionid ) %]
247
248
                    <br/>
248
                [% SET suggestions = order.order_object.suggestions %]
249
                    Suggested by: [% order.surnamesuggestedby | html %][% IF ( order.firstnamesuggestedby ) %], [% order.firstnamesuggestedby | html %] [% END %]
249
                [% FOREACH suggestion IN suggestions %]
250
                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% order.suggestionid | uri %]&amp;op=show">suggestion #[% order.suggestionid | html %]</a>)
250
                    [% SET suggester = suggestion.suggester %]
251
                        <br/>
252
                        Suggested by: [% suggester.surname | html %][% IF suggester.firstname %] %], [% suggester.firstname | html %] [% END %]
253
                        (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&amp;op=show">suggestion #[% suggestion.suggestionid | html %]</a>)
251
                [% END %]
254
                [% END %]
252
                <br />
255
                <br />
253
                [% IF ( order.order_internalnote ) %]
256
                [% IF ( order.order_internalnote ) %]
Lines 394-403 Link Here
394
                    "biblio.active_orders+count",
397
                    "biblio.active_orders+count",
395
                    "biblio.holds+count",
398
                    "biblio.holds+count",
396
                    "biblio.items+count",
399
                    "biblio.items+count",
397
                    "biblio.suggestions.suggester",
398
                    "fund",
400
                    "fund",
399
                    "current_item_level_holds+count",
401
                    "current_item_level_holds+count",
400
                    "items"
402
                    "items",
403
                    "suggestions.suggester"
401
                ],
404
                ],
402
                "stateSave": true, // remember state on page reload
405
                "stateSave": true, // remember state on page reload
403
                "drawCallback": function (settings) {
406
                "drawCallback": function (settings) {
Lines 468-494 Link Here
468
                                        result += escape_str(row.biblio.copyright_date);
471
                                        result += escape_str(row.biblio.copyright_date);
469
                                    }
472
                                    }
470
                                }
473
                                }
471
                                var suggestions = row.biblio.suggestions;
474
                                let suggestions = row.suggestions;
472
                                if ( suggestions != null && suggestions.length > 0 ) {
475
                                suggestions.forEach( (suggestion) => {
473
                                    var suggestion = suggestions[0];
476
                                if ( suggestion && suggestion.suggested_by != null ) {
474
                                    if ( suggestion.suggester != null ) {
477
                                    var suggester = suggestion.suggester;
475
                                        var suggester = suggestion.suggester;
478
                                    var suggested_by = [];
476
                                        var suggested_by = [];
479
                                    if ( suggester.surname != null ) {
477
                                        if ( suggester.surname != null ) {
480
                                        suggested_by.push(escape_str(suggester.surname));
478
                                            suggested_by.push(escape_str(suggester.surname));
481
                                    }
479
                                        }
482
                                    if ( suggester.firstname != null ) {
480
                                        if ( suggester.firstname != null ) {
483
                                        suggested_by.push(escape_str(suggester.firstname));
481
                                            suggested_by.push(escape_str(suggester.firstname));
482
                                        }
483
484
                                            result += "<br/>" + _("Suggested by: ") +
485
                                                        '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='
486
                                                            + encodeURIComponent(suggestion.suggestionid)
487
                                                            + '&amp;op=show">'
488
                                                            + suggested_by.join(", ")
489
                                                            + " (#" + escape_str(suggestions[0].suggestionid) + ")</a>"; // FIXME: could be changed if we allow matching multiple suggestions
490
                                    }
484
                                    }
485
486
                                    result += "<br/>" + _("Suggested by: ") +
487
                                                '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='
488
                                                    + encodeURIComponent(suggestion.suggestion_id)
489
                                                    + '&amp;op=show">'
490
                                                    + suggested_by.join(", ")
491
                                                    + " (#" + escape_str(suggestion.suggestion_id) + ")</a>";
491
                                }
492
                                }
493
                                } );
492
                                result += '</p>';
494
                                result += '</p>';
493
                            }
495
                            }
494
496
(-)a/t/db_dependent/Koha/Acquisition/Order.t (-14 / +51 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 13;
22
use Test::More tests => 14;
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 'suggestions' => sub {
214
    plan tests => 4;
215
216
    $schema->storage->txn_begin;
217
    my $o = $builder->build_object(
218
        {
219
            class => 'Koha::Acquisition::Orders',
220
        }
221
    );
222
223
    my $order = Koha::Acquisition::Orders->find( $o->ordernumber );
224
    is( ref( $order->suggestions ), 'Koha::Suggestions',
225
        '->suggestions should return a Koha::Suggestions object');
226
    is( $order->suggestions->count, 0,
227
        '->suggestions should return empty set if no linked suggestion');
228
229
    $o = $builder->build_object(
230
        {
231
            class => 'Koha::Acquisition::Orders',
232
        }
233
    );
234
    $o = $builder->build_object(
235
        {
236
            class => 'Koha::Suggestions',
237
            value => { ordernumber => $o->id }
238
        }
239
    );
240
241
    $order = Koha::Acquisition::Orders->find( $o->ordernumber );
242
    is( ref( $order->suggestions ), 'Koha::Suggestions',
243
        '->suggestions should return a Koha::Suggestions object');
244
    is( $order->suggestions->count, 1,
245
        '->suggestions should return linked suggestions');
246
247
    $schema->storage->txn_rollback;
248
};
249
213
subtest 'duplicate_to | add_item' => sub {
250
subtest 'duplicate_to | add_item' => sub {
214
    plan tests => 3;
251
    plan tests => 3;
215
252
Lines 903-908 subtest 'cancel() tests' => sub { Link Here
903
    $item      = $builder->build_sample_item;
940
    $item      = $builder->build_sample_item;
904
    $biblio_id = $item->biblionumber;
941
    $biblio_id = $item->biblionumber;
905
942
943
    $order = $builder->build_object(
944
        {
945
            class => 'Koha::Acquisition::Orders',
946
            value => {
947
                orderstatus             => 'new',
948
                biblionumber            => $biblio_id,
949
                datecancellationprinted => undef,
950
                cancellationreason      => undef,
951
            }
952
        }
953
    );
954
906
    # Add the suggestion
955
    # Add the suggestion
907
    my $suggestion = $builder->build_object(
956
    my $suggestion = $builder->build_object(
908
        {
957
        {
Lines 912-929 subtest 'cancel() tests' => sub { Link Here
912
                suggesteddate => dt_from_string,
961
                suggesteddate => dt_from_string,
913
                STATUS => 'ORDERED',
962
                STATUS => 'ORDERED',
914
                archived => 0,
963
                archived => 0,
915
            }
964
                ordernumber => $order->id,
916
        }
917
    );
918
919
    $order = $builder->build_object(
920
        {
921
            class => 'Koha::Acquisition::Orders',
922
            value => {
923
                orderstatus             => 'new',
924
                biblionumber            => $biblio_id,
925
                datecancellationprinted => undef,
926
                cancellationreason      => undef,
927
            }
965
            }
928
        }
966
        }
929
    );
967
    );
930
- 

Return to bug 35717