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

(-)a/C4/Circulation.pm (-9 / +13 lines)
Lines 2953-2967 sub AddRenewal { Link Here
2953
    }
2953
    }
2954
2954
2955
    # Log the renewal
2955
    # Log the renewal
2956
    UpdateStats({branch => $branch,
2956
    UpdateStats(
2957
                type => 'renew',
2957
        {
2958
                amount => $charge,
2958
            branch => C4::Context->userenv ? C4::Context->userenv->{branch} : $branch,
2959
                itemnumber => $itemnumber,
2959
            type           => 'renew',
2960
                itemtype => $item->{itype},
2960
            amount         => $charge,
2961
                borrowernumber => $borrowernumber,
2961
            itemnumber     => $itemnumber,
2962
                ccode => $item->{'ccode'}}
2962
            itemtype       => $item->{itype},
2963
                );
2963
            borrowernumber => $borrowernumber,
2964
	return $datedue;
2964
            ccode          => $item->{'ccode'}
2965
        }
2966
    );
2967
2968
    return $datedue;
2965
}
2969
}
2966
2970
2967
sub GetRenewCount {
2971
sub GetRenewCount {
(-)a/t/db_dependent/Circulation/issue.t (-6 / +21 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 32;
20
use Test::More tests => 33;
21
use DateTime::Duration;
21
use DateTime::Duration;
22
22
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 67-72 $dbh->do(q|DELETE FROM branches|); Link Here
67
$dbh->do(q|DELETE FROM categories|);
67
$dbh->do(q|DELETE FROM categories|);
68
$dbh->do(q|DELETE FROM accountlines|);
68
$dbh->do(q|DELETE FROM accountlines|);
69
$dbh->do(q|DELETE FROM issuingrules|);
69
$dbh->do(q|DELETE FROM issuingrules|);
70
$dbh->do(q|DELETE FROM reserves|);
71
$dbh->do(q|DELETE FROM old_reserves|);
72
$dbh->do(q|DELETE FROM statistics|);
70
73
71
# Generate sample datas
74
# Generate sample datas
72
my $itemtype = $builder->build(
75
my $itemtype = $builder->build(
Lines 76-81 my $itemtype = $builder->build( Link Here
76
)->{itemtype};
79
)->{itemtype};
77
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode};
80
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode};
78
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode};
81
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode};
82
my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode};
79
my $categorycode = $builder->build({
83
my $categorycode = $builder->build({
80
        source => 'Category',
84
        source => 'Category',
81
        value => { enrolmentfee => undef }
85
        value => { enrolmentfee => undef }
Lines 159-164 my @USERENV = ( Link Here
159
    $branchcode_1, 'email@example.org'
163
    $branchcode_1, 'email@example.org'
160
);
164
);
161
165
166
my @USERENV_DIFFERENT_LIBRARY = (
167
    $borrower_id1, 'test', 'MASTERTEST', 'firstname', $branchcode_3,
168
    $branchcode_3, 'email@example.org'
169
);
170
162
171
163
C4::Context->_new_userenv('DUMMY_SESSION_ID');
172
C4::Context->_new_userenv('DUMMY_SESSION_ID');
164
C4::Context->set_userenv(@USERENV);
173
C4::Context->set_userenv(@USERENV);
Lines 206-221 $sth->execute; Link Here
206
$countaccount = $sth -> fetchrow_array;
215
$countaccount = $sth -> fetchrow_array;
207
is ($countaccount,1,"1 accountline has been added");
216
is ($countaccount,1,"1 accountline has been added");
208
217
209
#Test AddRenewal
218
# Test AddRenewal
210
my $datedue3 =
219
211
  AddRenewal( $borrower_id1, $item_id1, $branchcode_1,
220
# Let's renew this one at a different library for statistical purposes to test Bug 17781
212
    $datedue1, $daysago10 );
221
C4::Context->set_userenv(@USERENV_DIFFERENT_LIBRARY);
222
my $datedue3 = AddRenewal( $borrower_id1, $item_id1, $branchcode_1, $datedue1, $daysago10 );
223
C4::Context->set_userenv(@USERENV);
224
213
like(
225
like(
214
    $datedue3,
226
    $datedue3,
215
    qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
227
    qr/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,
216
    "AddRenewal returns a date"
228
    "AddRenewal returns a date"
217
);
229
);
218
230
231
my $stat = $dbh->selectrow_hashref("SELECT * FROM statistics WHERE type = 'renew' AND borrowernumber = ? AND itemnumber = ? AND branch = ?", undef, $borrower_id1, $item_id1, $branchcode_3 );
232
ok( $stat, "Bug 17781 - 'Improper branchcode set during renewal' still fixed" );
233
234
219
#Test GetBiblioIssues
235
#Test GetBiblioIssues
220
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" );
236
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" );
221
237
222
- 

Return to bug 17781