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 369-374 if ( $op eq 'cud-order' ) { Link Here
369
        $order->populate_with_prices_for_ordering();
369
        $order->populate_with_prices_for_ordering();
370
        $order->store;
370
        $order->store;
371
371
372
        # change suggestion status if applicable
373
        if ( my $suggestionid = $input->param('suggestionid') ) {
374
            ModSuggestion(
375
                {
376
                    suggestionid => $suggestionid,
377
                    biblionumber => $orderinfo->{biblionumber},
378
                    ordernumber => $order->ordernumber,
379
                    STATUS       => 'ORDERED',
380
                }
381
            );
382
        }
383
372
        # Log the order creation
384
        # Log the order creation
373
        if ( C4::Context->preference("AcquisitionLog") ) {
385
        if ( C4::Context->preference("AcquisitionLog") ) {
374
            my $infos = {};
386
            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 610-619 Link Here
610
                                                                [%- IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear | html -%]
610
                                                                [%- IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear | html -%]
611
                                                                [%- ELSIF ( books_loo.copyrightdate ) %] [% books_loo.copyrightdate | html %][% END -%]
611
                                                                [%- ELSIF ( books_loo.copyrightdate ) %] [% books_loo.copyrightdate | html %][% END -%]
612
                                                                [%- IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement | html %][% END -%]
612
                                                                [%- IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement | html %][% END -%]
613
                                                                [%- IF ( books_loo.suggestionid ) %]
613
                                                                [% SET suggestions = books_loo.order_object.suggestions %]
614
                                                                [% FOREACH suggestion IN suggestions %]
614
                                                                    <br/>
615
                                                                    <br/>
615
                                                                    Suggested by: [% books_loo.surnamesuggestedby | html %][% IF ( books_loo.firstnamesuggestedby ) %], [% books_loo.firstnamesuggestedby | html %] [% END %]
616
                                                                    [% SET suggester = suggestion.suggester %]
616
                                                                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% books_loo.suggestionid | uri %]&amp;op=show">suggestion #[% books_loo.suggestionid | html %]</a>)
617
                                                                    Suggested by: [% suggester.surname | html %][% IF suggester.firstname %] %], [% suggester.firstname | html %] [% END %]
618
                                                                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&amp;op=show">suggestion #[% suggestion.suggestionid | html %]</a>)
617
                                                                [% END %]
619
                                                                [% END %]
618
                                                            </p>
620
                                                            </p>
619
                                                            [% IF ( books_loo.order_internalnote ) %]
621
                                                            [% IF ( books_loo.order_internalnote ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-17 / +23 lines)
Lines 554-560 Link Here
554
        $(document).ready(function(){
554
        $(document).ready(function(){
555
            // keep a copy for re-rendering
555
            // keep a copy for re-rendering
556
            var $funds_tree = $('#bookfund').html();
556
            var $funds_tree = $('#bookfund').html();
557
            var base_query = { "order_id": {"in": [[% multiple_orders | html %]]}};
557
            var base_query = { "me.order_id": {"in": [[% multiple_orders | html %]]}};
558
            var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1";
558
            var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1";
559
            var options = {
559
            var options = {
560
                "ajax": {
560
                "ajax": {
Lines 562-571 Link Here
562
                },
562
                },
563
                "embed": [
563
                "embed": [
564
                    "basket",
564
                    "basket",
565
                    "biblio.suggestions.suggester",
565
                    "biblio",
566
                    "fund.budget",
566
                    "fund.budget",
567
                    "items+strings",
567
                    "items+strings",
568
                    "creator"
568
                    "creator",
569
                    "suggestions.suggester",
569
                ],
570
                ],
570
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
571
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
571
                "columns": [
572
                "columns": [
Lines 695-708 Link Here
695
                params['ordernumber'] = row.order_id;
696
                params['ordernumber'] = row.order_id;
696
                params['booksellerid'] = row.basket.vendor_id;
697
                params['booksellerid'] = row.basket.vendor_id;
697
698
698
                if(row.biblio.suggestions.length && row.biblio.suggestions[0].reason) {
699
                if(row.suggestions && row.suggestions[0].reason) {
699
                    params["suggestionid"] = row.biblio.suggestions[0].suggestion_id;
700
701
                    params["suggestionid"] = row.suggestions[0].suggestion_id;
700
                    const options = Array.from(document.querySelectorAll('#reason option'));
702
                    const options = Array.from(document.querySelectorAll('#reason option'));
701
                    if (options.some(option => option.value === row.biblio.suggestions[0].reason)) {
703
                    if (options.some(option => option.value === row.suggestions[0].reason)) {
702
                        params['reason'] =  row.biblio.suggestions[0].reason;
704
                        params['reason'] =  row.suggestions[0].reason;
703
                    } else {
705
                    } else {
704
                        params['reason'] = 'other';
706
                        params['reason'] = 'other';
705
                        params['other_reason'] = row.biblio.suggestions[0].reason;
707
                        params['other_reason'] = row.suggestions[0].reason;
706
                    }
708
                    }
707
                }
709
                }
708
                params['datereceived'] = row.date_received;
710
                params['datereceived'] = row.date_received;
Lines 840-853 Link Here
840
                    $("#other_reason").show();
842
                    $("#other_reason").show();
841
                    $(this).hide();
843
                    $(this).hide();
842
                } else {
844
                } else {
843
                    row.biblio.suggestions[0].reason = val;
845
                    row.suggestions[0].reason = val;
844
                }
846
                }
845
            });
847
            });
846
848
847
            $("#order_edit").on("change", "#select-other_reason", function() {
849
            $("#order_edit").on("change", "#select-other_reason", function() {
848
                var val = $(this).val();
850
                var val = $(this).val();
849
                var row = $("#order_edit").data('row');
851
                var row = $("#order_edit").data('row');
850
                row.biblio.suggestions[0].reason = val;
852
                row.suggestions[0].reason = val;
851
            });
853
            });
852
854
853
            $("#order_edit").on("click", "#other_reason a", function() {
855
            $("#order_edit").on("click", "#other_reason a", function() {
Lines 1135-1165 Link Here
1135
                        o.parent().hide();
1137
                        o.parent().hide();
1136
                    }
1138
                    }
1137
                });
1139
                });
1138
                if(row.biblio.suggestions.length) {
1140
                if(row.suggestions) {
1139
                    $("#suggestion_fieldset").show();
1141
                    $("#suggestion_fieldset").show();
1140
                    if(row.biblio.suggestions[0].suggester) {
1142
                    if(row.suggestions[0].suggester) {
1141
                        $("#biblio_suggestion_suggester").parent().show();
1143
                        $("#biblio_suggestion_suggester").parent().show();
1142
                        $("#biblio_suggestion_suggester")
1144
                        $("#biblio_suggestion_suggester")
1143
                            .html(
1145
                            .html(
1144
                                [row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname]
1146
                                [row.suggestions[0].suggester.surname, row.suggestions[0].suggester.firstname]
1145
                                    .filter(function(name){
1147
                                    .filter(function(name){
1146
                                        return name
1148
                                        return name
1147
                                    })
1149
                                    })
1148
                                    .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>)'
1150
                                    .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>)'
1149
                            );
1151
                            );
1150
                    } else {
1152
                    } else {
1151
                        $("#biblio_suggestion_suggester").parent().hide();
1153
                        $("#biblio_suggestion_suggester").parent().hide();
1152
                    }
1154
                    }
1153
                    if(row.biblio.suggestions[0].reason) {
1155
                    if(row.suggestions[0].reason) {
1154
                        $("#suggestion_reason").show();
1156
                        $("#suggestion_reason").show();
1157
<<<<<<< HEAD
1155
                        const options = Array.from(document.querySelectorAll('#reason option'));
1158
                        const options = Array.from(document.querySelectorAll('#reason option'));
1156
                        if (options.some(option => option.value === row.biblio.suggestions[0].reason)) {
1159
                        if (options.some(option => option.value === row.biblio.suggestions[0].reason)) {
1160
=======
1161
                        if($("#reason option[value='"+row.suggestions[0].reason+"']").length) {
1162
>>>>>>> Bug 35717: Add link between suggestions and orders
1157
                             $("#other_reason a").click();
1163
                             $("#other_reason a").click();
1158
                            $("#reason").val(row.biblio.suggestions[0].reason);
1164
                            $("#reason").val(row.suggestions[0].reason);
1159
                            $("#select-other_reason").val(null);
1165
                            $("#select-other_reason").val(null);
1160
                        } else {
1166
                        } else {
1161
                            $("#reason").val("other").change();
1167
                            $("#reason").val("other").change();
1162
                            $("#select-other_reason").val(row.biblio.suggestions[0].reason);
1168
                            $("#select-other_reason").val(row.suggestions[0].reason);
1163
                        }
1169
                        }
1164
1170
1165
                    } else {
1171
                    } else {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt (-25 / +27 lines)
Lines 245-254 Link Here
245
                    [%- ELSIF ( order.copyrightdate   > 0) -%] [% order.copyrightdate | html %]
245
                    [%- ELSIF ( order.copyrightdate   > 0) -%] [% order.copyrightdate | html %]
246
                    [% END %]
246
                    [% END %]
247
                [% END %]
247
                [% END %]
248
                [% IF ( order.suggestionid ) %]
248
249
                    <br/>
249
                [% SET suggestions = order.order_object.suggestions %]
250
                    Suggested by: [% order.surnamesuggestedby | html %][% IF ( order.firstnamesuggestedby ) %], [% order.firstnamesuggestedby | html %] [% END %]
250
                [% FOREACH suggestion IN suggestions %]
251
                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% order.suggestionid | uri %]&amp;op=show">suggestion #[% order.suggestionid | html %]</a>)
251
                    [% SET suggester = suggestion.suggester %]
252
                        <br/>
253
                        Suggested by: [% suggester.surname | html %][% IF suggester.firstname %] %], [% suggester.firstname | html %] [% END %]
254
                        (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&amp;op=show">suggestion #[% suggestion.suggestionid | html %]</a>)
252
                [% END %]
255
                [% END %]
253
                <br />
256
                <br />
254
                [% IF ( order.order_internalnote ) %]
257
                [% IF ( order.order_internalnote ) %]
Lines 407-416 Link Here
407
                    "biblio.active_orders+count",
410
                    "biblio.active_orders+count",
408
                    "biblio.holds+count",
411
                    "biblio.holds+count",
409
                    "biblio.items+count",
412
                    "biblio.items+count",
410
                    "biblio.suggestions.suggester",
411
                    "fund",
413
                    "fund",
412
                    "current_item_level_holds+count",
414
                    "current_item_level_holds+count",
413
                    "items"
415
                    "items",
416
                    "suggestions.suggester"
414
                ],
417
                ],
415
                "stateSave": true, // remember state on page reload
418
                "stateSave": true, // remember state on page reload
416
                "drawCallback": function (settings) {
419
                "drawCallback": function (settings) {
Lines 481-507 Link Here
481
                                        result += escape_str(row.biblio.copyright_date);
484
                                        result += escape_str(row.biblio.copyright_date);
482
                                    }
485
                                    }
483
                                }
486
                                }
484
                                var suggestions = row.biblio.suggestions;
487
                                let suggestions = row.suggestions;
485
                                if ( suggestions != null && suggestions.length > 0 ) {
488
                                suggestions.forEach( (suggestion) => {
486
                                    var suggestion = suggestions[0];
489
                                if ( suggestion && suggestion.suggested_by != null ) {
487
                                    if ( suggestion.suggester != null ) {
490
                                    var suggester = suggestion.suggester;
488
                                        var suggester = suggestion.suggester;
491
                                    var suggested_by = [];
489
                                        var suggested_by = [];
492
                                    if ( suggester.surname != null ) {
490
                                        if ( suggester.surname != null ) {
493
                                        suggested_by.push(escape_str(suggester.surname));
491
                                            suggested_by.push(escape_str(suggester.surname));
494
                                    }
492
                                        }
495
                                    if ( suggester.firstname != null ) {
493
                                        if ( suggester.firstname != null ) {
496
                                        suggested_by.push(escape_str(suggester.firstname));
494
                                            suggested_by.push(escape_str(suggester.firstname));
495
                                        }
496
497
                                            result += "<br/>" + _("Suggested by: ") +
498
                                                        '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='
499
                                                            + encodeURIComponent(suggestion.suggestionid)
500
                                                            + '&amp;op=show">'
501
                                                            + suggested_by.join(", ")
502
                                                            + " (#" + escape_str(suggestions[0].suggestionid) + ")</a>"; // FIXME: could be changed if we allow matching multiple suggestions
503
                                    }
497
                                    }
498
499
                                    result += "<br/>" + _("Suggested by: ") +
500
                                                '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='
501
                                                    + encodeURIComponent(suggestion.suggestion_id)
502
                                                    + '&amp;op=show">'
503
                                                    + suggested_by.join(", ")
504
                                                    + " (#" + escape_str(suggestion.suggestion_id) + ")</a>";
504
                                }
505
                                }
506
                                } );
505
                                result += '</p>';
507
                                result += '</p>';
506
                            }
508
                            }
507
509
(-)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