Lines 24-29
use Test::Warn;
Link Here
|
24 |
|
24 |
|
25 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
26 |
|
26 |
|
|
|
27 |
use Koha::Account::Lines; |
28 |
use Koha::Account::Line; |
29 |
|
27 |
BEGIN { |
30 |
BEGIN { |
28 |
use_ok('C4::Accounts'); |
31 |
use_ok('C4::Accounts'); |
29 |
use_ok('Koha::Object'); |
32 |
use_ok('Koha::Object'); |
Lines 150-168
subtest "recordpayment() tests" => sub {
Link Here
|
150 |
$borrower->branchcode( $branchcode ); |
153 |
$borrower->branchcode( $branchcode ); |
151 |
$borrower->store; |
154 |
$borrower->store; |
152 |
|
155 |
|
153 |
my $sth = $dbh->prepare( |
156 |
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 100 })->store(); |
154 |
"INSERT INTO accountlines ( |
157 |
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 200 })->store(); |
155 |
borrowernumber, |
158 |
$line1->_result->discard_changes; |
156 |
amountoutstanding ) |
159 |
$line2->_result->discard_changes; |
157 |
VALUES ( ?, ? )" |
|
|
158 |
); |
159 |
$sth->execute($borrower->borrowernumber, '100'); |
160 |
$sth->execute($borrower->borrowernumber, '200'); |
161 |
|
160 |
|
162 |
$sth = $dbh->prepare("SELECT count(*) FROM accountlines"); |
161 |
$sth = $dbh->prepare("SELECT count(*) FROM accountlines"); |
163 |
$sth->execute; |
162 |
$sth->execute; |
164 |
my $count = $sth->fetchrow_array; |
163 |
my $count = $sth->fetchrow_array; |
165 |
is ($count, 2, 'There is 2 lines as expected'); |
164 |
is($count, 2, 'There is 2 lines as expected'); |
166 |
|
165 |
|
167 |
# Testing recordpayment ------------------------- |
166 |
# Testing recordpayment ------------------------- |
168 |
# There is $100 in the account |
167 |
# There is $100 in the account |
Lines 172-178
subtest "recordpayment() tests" => sub {
Link Here
|
172 |
for my $line ( @$amountoutstanding ) { |
171 |
for my $line ( @$amountoutstanding ) { |
173 |
$amountleft += $line; |
172 |
$amountleft += $line; |
174 |
} |
173 |
} |
175 |
ok($amountleft == 300, 'The account has 300$ as expected' ); |
174 |
is($amountleft, 300, 'The account has 300$ as expected' ); |
176 |
|
175 |
|
177 |
# We make a $20 payment |
176 |
# We make a $20 payment |
178 |
my $borrowernumber = $borrower->borrowernumber; |
177 |
my $borrowernumber = $borrower->borrowernumber; |
Lines 187-193
subtest "recordpayment() tests" => sub {
Link Here
|
187 |
for my $line ( @$amountoutstanding ) { |
186 |
for my $line ( @$amountoutstanding ) { |
188 |
$amountleft += $line; |
187 |
$amountleft += $line; |
189 |
} |
188 |
} |
190 |
ok($amountleft == 280, 'The account has $280 as expected' ); |
189 |
is($amountleft, 280, 'The account has $280 as expected' ); |
191 |
# Is the payment note well registered |
190 |
# Is the payment note well registered |
192 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
191 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
193 |
$sth->execute($borrower->borrowernumber); |
192 |
$sth->execute($borrower->borrowernumber); |
Lines 205-211
subtest "recordpayment() tests" => sub {
Link Here
|
205 |
for my $line ( @$amountoutstanding ) { |
204 |
for my $line ( @$amountoutstanding ) { |
206 |
$amountleft += $line; |
205 |
$amountleft += $line; |
207 |
} |
206 |
} |
208 |
ok($amountleft == 310, 'The account has $310 as expected' ); |
207 |
is($amountleft, 310, 'The account has $310 as expected' ); |
209 |
# Is the payment note well registered |
208 |
# Is the payment note well registered |
210 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
209 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
211 |
$sth->execute($borrower->borrowernumber); |
210 |
$sth->execute($borrower->borrowernumber); |
Lines 223-229
subtest "recordpayment() tests" => sub {
Link Here
|
223 |
for my $line ( @$amountoutstanding ) { |
222 |
for my $line ( @$amountoutstanding ) { |
224 |
$amountleft += $line; |
223 |
$amountleft += $line; |
225 |
} |
224 |
} |
226 |
ok($amountleft == 160, 'The account has $160 as expected' ); |
225 |
is($amountleft, 160, 'The account has $160 as expected' ); |
227 |
# Is the payment note well registered |
226 |
# Is the payment note well registered |
228 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
227 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
229 |
$sth->execute($borrower->borrowernumber); |
228 |
$sth->execute($borrower->borrowernumber); |
Lines 241-247
subtest "recordpayment() tests" => sub {
Link Here
|
241 |
for my $line ( @$amountoutstanding ) { |
240 |
for my $line ( @$amountoutstanding ) { |
242 |
$amountleft += $line; |
241 |
$amountleft += $line; |
243 |
} |
242 |
} |
244 |
ok($amountleft == -40, 'The account has -$40 as expected, (credit situation)' ); |
243 |
is($amountleft, -40, 'The account has -$40 as expected, (credit situation)' ); |
245 |
# Is the payment note well registered |
244 |
# Is the payment note well registered |
246 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
245 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
247 |
$sth->execute($borrower->borrowernumber); |
246 |
$sth->execute($borrower->borrowernumber); |
248 |
- |
|
|