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

(-)a/C4/SIP/ILS/Transaction/Checkout.pm (-2 / +3 lines)
Lines 146-157 sub do_checkout { Link Here
146
    } else {
146
    } else {
147
        # can issue
147
        # can issue
148
        my $recall_id;
148
        my $recall_id;
149
        foreach (keys %{$messages}) {
149
        foreach ( keys %{$messages} ) {
150
            if ( $_ eq "RECALLED" ) {
150
            if ( $_ eq "RECALLED" ) {
151
                $recall_id = $messages->{RECALLED};
151
                $recall_id = $messages->{RECALLED};
152
            }
152
            }
153
        }
153
        }
154
        my $issue = AddIssue( $patron->unblessed, $barcode, $overridden_duedate, 0, undef, undef, { recall_id => $recall_id } );
154
        my $issue =
155
            AddIssue( $patron->unblessed, $barcode, $overridden_duedate, 0, undef, undef, { recall_id => $recall_id } );
155
        $self->{due} = $self->duedatefromissue($issue, $itemnumber);
156
        $self->{due} = $self->duedatefromissue($issue, $itemnumber);
156
    }
157
    }
157
158
(-)a/t/db_dependent/SIP/Transaction.t (-25 / +29 lines)
Lines 1049-1055 subtest do_checkout_with_recalls => sub { Link Here
1049
    plan tests => 7;
1049
    plan tests => 7;
1050
1050
1051
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
1051
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
1052
    my $patron = $builder->build_object(
1052
    my $patron  = $builder->build_object(
1053
        {
1053
        {
1054
            class => 'Koha::Patrons',
1054
            class => 'Koha::Patrons',
1055
            value => {
1055
            value => {
Lines 1066-1073 subtest do_checkout_with_recalls => sub { Link Here
1066
        }
1066
        }
1067
    );
1067
    );
1068
1068
1069
    t::lib::Mocks::mock_userenv(
1069
    t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode, flags => 1 } );
1070
        { branchcode => $library->branchcode, flags => 1 } );
1071
1070
1072
    my $item = $builder->build_sample_item(
1071
    my $item = $builder->build_sample_item(
1073
        {
1072
        {
Lines 1075-1088 subtest do_checkout_with_recalls => sub { Link Here
1075
        }
1074
        }
1076
    );
1075
    );
1077
1076
1078
    t::lib::Mocks::mock_preference('UseRecalls',1);
1077
    t::lib::Mocks::mock_preference( 'UseRecalls', 1 );
1079
    Koha::CirculationRules->set_rule({
1078
    Koha::CirculationRules->set_rule(
1080
        branchcode => undef,
1079
        {
1081
        categorycode => undef,
1080
            branchcode   => undef,
1082
        itemtype => undef,
1081
            categorycode => undef,
1083
        rule_name => 'recalls_allowed',
1082
            itemtype     => undef,
1084
        rule_value => '10',
1083
            rule_name    => 'recalls_allowed',
1085
    });
1084
            rule_value   => '10',
1085
        }
1086
    );
1086
1087
1087
    my $recall1 = Koha::Recall->new(
1088
    my $recall1 = Koha::Recall->new(
1088
        {
1089
        {
Lines 1096-1124 subtest do_checkout_with_recalls => sub { Link Here
1096
        }
1097
        }
1097
    )->store;
1098
    )->store;
1098
1099
1099
    my $sip_patron  = C4::SIP::ILS::Patron->new( $patron->cardnumber );
1100
    my $sip_patron     = C4::SIP::ILS::Patron->new( $patron->cardnumber );
1100
    my $sip_item    = C4::SIP::ILS::Item->new( $item->barcode );
1101
    my $sip_item       = C4::SIP::ILS::Item->new( $item->barcode );
1101
    my $co_transaction = C4::SIP::ILS::Transaction::Checkout->new();
1102
    my $co_transaction = C4::SIP::ILS::Transaction::Checkout->new();
1102
    is( $co_transaction->patron($sip_patron),
1103
    is(
1103
        $sip_patron, "Patron assigned to transaction" );
1104
        $co_transaction->patron($sip_patron),
1104
    is( $co_transaction->item($sip_item),
1105
        $sip_patron, "Patron assigned to transaction"
1105
        $sip_item, "Item assigned to transaction" );
1106
    );
1107
    is(
1108
        $co_transaction->item($sip_item),
1109
        $sip_item, "Item assigned to transaction"
1110
    );
1106
1111
1107
    # Test recalls made by another patron
1112
    # Test recalls made by another patron
1108
1113
1109
    $recall1->set_waiting({ item => $item });
1114
    $recall1->set_waiting( { item => $item } );
1110
    $co_transaction->do_checkout();
1115
    $co_transaction->do_checkout();
1111
    is( $patron->checkouts->count, 0, 'Checkout was not done due to waiting recall');
1116
    is( $patron->checkouts->count, 0, 'Checkout was not done due to waiting recall' );
1112
1117
1113
    $recall1->revert_waiting;
1118
    $recall1->revert_waiting;
1114
    $recall1->start_transfer({ item => $item });
1119
    $recall1->start_transfer( { item => $item } );
1115
    $co_transaction->do_checkout();
1120
    $co_transaction->do_checkout();
1116
    is( $patron->checkouts->count, 0, 'Checkout was not done due to recall in transit');
1121
    is( $patron->checkouts->count, 0, 'Checkout was not done due to recall in transit' );
1117
1122
1118
    $recall1->revert_transfer;
1123
    $recall1->revert_transfer;
1119
    $recall1->update({ item_id => undef, item_level => 0 });
1124
    $recall1->update( { item_id => undef, item_level => 0 } );
1120
    $co_transaction->do_checkout();
1125
    $co_transaction->do_checkout();
1121
    is( $patron->checkouts->count, 0, 'Checkout was not done due to a biblio-level recall that this item could fill');
1126
    is( $patron->checkouts->count, 0, 'Checkout was not done due to a biblio-level recall that this item could fill' );
1122
1127
1123
    $recall1->set_cancelled;
1128
    $recall1->set_cancelled;
1124
1129
Lines 1136-1142 subtest do_checkout_with_recalls => sub { Link Here
1136
1141
1137
    # Test recalls made by SIP patron
1142
    # Test recalls made by SIP patron
1138
1143
1139
    $recall2->set_waiting({ item => $item });
1144
    $recall2->set_waiting( { item => $item } );
1140
    $co_transaction->do_checkout();
1145
    $co_transaction->do_checkout();
1141
    is( $patron->checkouts->count, 1, 'Checkout was done because recalled item was allocated to them' );
1146
    is( $patron->checkouts->count, 1, 'Checkout was done because recalled item was allocated to them' );
1142
    $recall2 = Koha::Recalls->find( $recall2->id );
1147
    $recall2 = Koha::Recalls->find( $recall2->id );
1143
- 

Return to bug 34016