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 519-529 sub get_order_infos { Link Here
519
        $line{deleted_biblio} = Koha::Old::Biblios->find( $order->{deleted_biblionumber} );
518
        $line{deleted_biblio} = Koha::Old::Biblios->find( $order->{deleted_biblionumber} );
520
    }
519
    }
521
520
522
    my $suggestion   = GetSuggestionInfoFromBiblionumber($line{biblionumber});
523
    $line{suggestionid}         = $$suggestion{suggestionid};
524
    $line{surnamesuggestedby}   = $$suggestion{surnamesuggestedby};
525
    $line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby};
526
527
    $line{estimated_delivery_date} = $order->{estimated_delivery_date};
521
    $line{estimated_delivery_date} = $order->{estimated_delivery_date};
528
522
529
    foreach my $key (qw(transferred_from transferred_to)) {
523
    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.uncancelled_orders+count
57
            - biblio.uncancelled_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 184-195 Link Here
184
            - biblio.uncancelled_orders+count
185
            - biblio.uncancelled_orders+count
185
            - biblio.holds+count
186
            - biblio.holds+count
186
            - biblio.items+count
187
            - biblio.items+count
187
            - biblio.suggestions.suggester
188
            - fund
188
            - fund
189
            - current_item_level_holds+count
189
            - current_item_level_holds+count
190
            - invoice
190
            - invoice
191
            - items
191
            - items
192
            - subscription
192
            - subscription
193
            - suggestion
194
            - suggestion.suggester
193
        collectionFormat: csv
195
        collectionFormat: csv
194
    produces:
196
    produces:
195
      - application/json
197
      - application/json
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt (-3 / +5 lines)
Lines 613-622 Link Here
613
                                                                [%- IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear | html -%]
613
                                                                [%- IF ( books_loo.publicationyear ) %], [% books_loo.publicationyear | html -%]
614
                                                                [%- ELSIF ( books_loo.copyrightdate ) %] [% books_loo.copyrightdate | html %][% END -%]
614
                                                                [%- ELSIF ( books_loo.copyrightdate ) %] [% books_loo.copyrightdate | html %][% END -%]
615
                                                                [%- IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement | html %][% END -%]
615
                                                                [%- IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement | html %][% END -%]
616
                                                                [%- IF ( books_loo.suggestionid ) %]
616
                                                                [% SET suggestions = books_loo.order_object.suggestions %]
617
                                                                [% FOREACH suggestion IN suggestions %]
617
                                                                    <br/>
618
                                                                    <br/>
618
                                                                    Suggested by: [% books_loo.surnamesuggestedby | html %][% IF ( books_loo.firstnamesuggestedby ) %], [% books_loo.firstnamesuggestedby | html %] [% END %]
619
                                                                    [% SET suggester = suggestion.suggester %]
619
                                                                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% books_loo.suggestionid | uri %]&amp;op=show">suggestion #[% books_loo.suggestionid | html %]</a>)
620
                                                                    Suggested by: [% suggester.surname | html %][% IF suggester.firstname %] %], [% suggester.firstname | html %] [% END %]
621
                                                                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestion.suggestionid | uri %]&amp;op=show">suggestion #[% suggestion.suggestionid | html %]</a>)
620
                                                                [% END %]
622
                                                                [% END %]
621
                                                            </p>
623
                                                            </p>
622
                                                            [% IF ( books_loo.order_internalnote ) %]
624
                                                            [% IF ( books_loo.order_internalnote ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-18 / +20 lines)
Lines 555-561 Link Here
555
        $(document).ready(function(){
555
        $(document).ready(function(){
556
            // keep a copy for re-rendering
556
            // keep a copy for re-rendering
557
            var $funds_tree = $('#bookfund').html();
557
            var $funds_tree = $('#bookfund').html();
558
            var base_query = { "order_id": {"-in": [[% multiple_orders | html %]]}};
558
            var base_query = { "me.order_id": {"in": [[% multiple_orders | html %]]}};
559
            var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1";
559
            var pending_orders_url = "/api/v1/acquisitions/orders?only_active=1";
560
            var options = {
560
            var options = {
561
                "ajax": {
561
                "ajax": {
Lines 563-572 Link Here
563
                },
563
                },
564
                "embed": [
564
                "embed": [
565
                    "basket",
565
                    "basket",
566
                    "biblio.suggestions.suggester",
566
                    "biblio",
567
                    "fund.budget",
567
                    "fund.budget",
568
                    "items+strings",
568
                    "items+strings",
569
                    "creator"
569
                    "creator",
570
                    "suggestions.suggester",
570
                ],
571
                ],
571
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
572
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
572
                "columns": [
573
                "columns": [
Lines 696-709 Link Here
696
                params['ordernumber'] = row.order_id;
697
                params['ordernumber'] = row.order_id;
697
                params['booksellerid'] = row.basket.vendor_id;
698
                params['booksellerid'] = row.basket.vendor_id;
698
699
699
                if(row.biblio.suggestions.length && row.biblio.suggestions[0].reason) {
700
                if(row.suggestions && row.suggestions[0].reason) {
700
                    params["suggestionid"] = row.biblio.suggestions[0].suggestion_id;
701
702
                    params["suggestionid"] = row.suggestions[0].suggestion_id;
701
                    const options = Array.from(document.querySelectorAll('#reason option'));
703
                    const options = Array.from(document.querySelectorAll('#reason option'));
702
                    if (options.some(option => option.value === row.biblio.suggestions[0].reason)) {
704
                    if (options.some(option => option.value === row.suggestions[0].reason)) {
703
                        params['reason'] =  row.biblio.suggestions[0].reason;
705
                        params['reason'] =  row.suggestions[0].reason;
704
                    } else {
706
                    } else {
705
                        params['reason'] = 'other';
707
                        params['reason'] = 'other';
706
                        params['other_reason'] = row.biblio.suggestions[0].reason;
708
                        params['other_reason'] = row.suggestions[0].reason;
707
                    }
709
                    }
708
                }
710
                }
709
                params['datereceived'] = row.date_received;
711
                params['datereceived'] = row.date_received;
Lines 841-854 Link Here
841
                    $("#other_reason").show();
843
                    $("#other_reason").show();
842
                    $(this).hide();
844
                    $(this).hide();
843
                } else {
845
                } else {
844
                    row.biblio.suggestions[0].reason = val;
846
                    row.suggestions[0].reason = val;
845
                }
847
                }
846
            });
848
            });
847
849
848
            $("#order_edit").on("change", "#select-other_reason", function() {
850
            $("#order_edit").on("change", "#select-other_reason", function() {
849
                var val = $(this).val();
851
                var val = $(this).val();
850
                var row = $("#order_edit").data('row');
852
                var row = $("#order_edit").data('row');
851
                row.biblio.suggestions[0].reason = val;
853
                row.suggestions[0].reason = val;
852
            });
854
            });
853
855
854
            $("#order_edit").on("click", "#other_reason a", function() {
856
            $("#order_edit").on("click", "#other_reason a", function() {
Lines 1136-1166 Link Here
1136
                        o.parent().hide();
1138
                        o.parent().hide();
1137
                    }
1139
                    }
1138
                });
1140
                });
1139
                if(row.biblio.suggestions.length) {
1141
                if(row.suggestions) {
1140
                    $("#suggestion_fieldset").show();
1142
                    $("#suggestion_fieldset").show();
1141
                    if(row.biblio.suggestions[0].suggester) {
1143
                    if(row.suggestions[0].suggester) {
1142
                        $("#biblio_suggestion_suggester").parent().show();
1144
                        $("#biblio_suggestion_suggester").parent().show();
1143
                        $("#biblio_suggestion_suggester")
1145
                        $("#biblio_suggestion_suggester")
1144
                            .html(
1146
                            .html(
1145
                                [row.biblio.suggestions[0].suggester.surname, row.biblio.suggestions[0].suggester.firstname]
1147
                                [row.suggestions[0].suggester.surname, row.suggestions[0].suggester.firstname]
1146
                                    .filter(function(name){
1148
                                    .filter(function(name){
1147
                                        return name
1149
                                        return name
1148
                                    })
1150
                                    })
1149
                                    .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>)'
1151
                                    .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>)'
1150
                            );
1152
                            );
1151
                    } else {
1153
                    } else {
1152
                        $("#biblio_suggestion_suggester").parent().hide();
1154
                        $("#biblio_suggestion_suggester").parent().hide();
1153
                    }
1155
                    }
1154
                    if(row.biblio.suggestions[0].reason) {
1156
                    if(row.suggestions[0].reason) {
1155
                        $("#suggestion_reason").show();
1157
                        $("#suggestion_reason").show();
1156
                        const options = Array.from(document.querySelectorAll('#reason option'));
1158
                        const options = Array.from(document.querySelectorAll('#reason option'));
1157
                        if (options.some(option => option.value === row.biblio.suggestions[0].reason)) {
1159
                        if (options.some(option => option.value === row.suggestions[0].reason)) {
1158
                             $("#other_reason a").click();
1160
                             $("#other_reason a").click();
1159
                            $("#reason").val(row.biblio.suggestions[0].reason);
1161
                            $("#reason").val(row.suggestions[0].reason);
1160
                            $("#select-other_reason").val(null);
1162
                            $("#select-other_reason").val(null);
1161
                        } else {
1163
                        } else {
1162
                            $("#reason").val("other").change();
1164
                            $("#reason").val("other").change();
1163
                            $("#select-other_reason").val(row.biblio.suggestions[0].reason);
1165
                            $("#select-other_reason").val(row.suggestions[0].reason);
1164
                        }
1166
                        }
1165
1167
1166
                    } else {
1168
                    } 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.uncancelled_orders+count",
410
                    "biblio.uncancelled_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
                "columns": [
419
                "columns": [
Lines 471-497 Link Here
471
                                        result += escape_str(row.biblio.copyright_date);
474
                                        result += escape_str(row.biblio.copyright_date);
472
                                    }
475
                                    }
473
                                }
476
                                }
474
                                var suggestions = row.biblio.suggestions;
477
                                let suggestions = row.suggestions;
475
                                if ( suggestions != null && suggestions.length > 0 ) {
478
                                suggestions.forEach( (suggestion) => {
476
                                    var suggestion = suggestions[0];
479
                                if ( suggestion && suggestion.suggested_by != null ) {
477
                                    if ( suggestion.suggester != null ) {
480
                                    var suggester = suggestion.suggester;
478
                                        var suggester = suggestion.suggester;
481
                                    var suggested_by = [];
479
                                        var suggested_by = [];
482
                                    if ( suggester.surname != null ) {
480
                                        if ( suggester.surname != null ) {
483
                                        suggested_by.push(escape_str(suggester.surname));
481
                                            suggested_by.push(escape_str(suggester.surname));
484
                                    }
482
                                        }
485
                                    if ( suggester.firstname != null ) {
483
                                        if ( suggester.firstname != null ) {
486
                                        suggested_by.push(escape_str(suggester.firstname));
484
                                            suggested_by.push(escape_str(suggester.firstname));
485
                                        }
486
487
                                            result += "<br/>" + _("Suggested by: ") +
488
                                                        '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='
489
                                                            + encodeURIComponent(suggestion.suggestionid)
490
                                                            + '&amp;op=show">'
491
                                                            + suggested_by.join(", ")
492
                                                            + " (#" + escape_str(suggestions[0].suggestionid) + ")</a>"; // FIXME: could be changed if we allow matching multiple suggestions
493
                                    }
487
                                    }
488
489
                                    result += "<br/>" + _("Suggested by: ") +
490
                                                '<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid='
491
                                                    + encodeURIComponent(suggestion.suggestion_id)
492
                                                    + '&amp;op=show">'
493
                                                    + suggested_by.join(", ")
494
                                                    + " (#" + escape_str(suggestion.suggestion_id) + ")</a>";
494
                                }
495
                                }
496
                                } );
495
                                result += '</p>';
497
                                result += '</p>';
496
                            }
498
                            }
497
499
(-)a/t/db_dependent/Koha/Acquisition/Order.t (-15 / +60 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() tests' => 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(
225
        ref( $order->suggestions ), 'Koha::Suggestions',
226
        '->suggestions should return a Koha::Suggestions object'
227
    );
228
    is(
229
        $order->suggestions->count, 0,
230
        '->suggestions should return empty set if no linked suggestion'
231
    );
232
233
    $o = $builder->build_object(
234
        {
235
            class => 'Koha::Acquisition::Orders',
236
        }
237
    );
238
    $o = $builder->build_object(
239
        {
240
            class => 'Koha::Suggestions',
241
            value => { ordernumber => $o->id }
242
        }
243
    );
244
245
    $order = Koha::Acquisition::Orders->find( $o->ordernumber );
246
    is(
247
        ref( $order->suggestions ), 'Koha::Suggestions',
248
        '->suggestions should return a Koha::Suggestions object'
249
    );
250
    is(
251
        $order->suggestions->count, 1,
252
        '->suggestions should return linked suggestions'
253
    );
254
255
    $schema->storage->txn_rollback;
256
};
257
213
subtest 'duplicate_to | add_item' => sub {
258
subtest 'duplicate_to | add_item' => sub {
214
    plan tests => 3;
259
    plan tests => 3;
215
260
Lines 915-933 subtest 'cancel() tests' => sub { Link Here
915
    $item      = $builder->build_sample_item;
960
    $item      = $builder->build_sample_item;
916
    $biblio_id = $item->biblionumber;
961
    $biblio_id = $item->biblionumber;
917
962
918
    # Add the suggestion
919
    my $suggestion = $builder->build_object(
920
        {
921
            class => 'Koha::Suggestions',
922
            value => {
923
                biblionumber => $biblio_id,
924
                suggesteddate => dt_from_string,
925
                STATUS => 'ORDERED',
926
                archived => 0,
927
            }
928
        }
929
    );
930
931
    $order = $builder->build_object(
963
    $order = $builder->build_object(
932
        {
964
        {
933
            class => 'Koha::Acquisition::Orders',
965
            class => 'Koha::Acquisition::Orders',
Lines 940-945 subtest 'cancel() tests' => sub { Link Here
940
        }
972
        }
941
    );
973
    );
942
974
975
    # Add the suggestion
976
    my $suggestion = $builder->build_object(
977
        {
978
            class => 'Koha::Suggestions',
979
            value => {
980
                biblionumber  => $biblio_id,
981
                suggesteddate => dt_from_string,
982
                STATUS        => 'ORDERED',
983
                archived      => 0,
984
                ordernumber   => $order->id,
985
            }
986
        }
987
    );
988
943
    $order->cancel({ reason => $reason })
989
    $order->cancel({ reason => $reason })
944
          ->discard_changes;
990
          ->discard_changes;
945
991
946
- 

Return to bug 35717