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 152-170
subtest "recordpayment() tests" => sub {
Link Here
|
152 |
$borrower->branchcode( $branchcode ); |
155 |
$borrower->branchcode( $branchcode ); |
153 |
$borrower->store; |
156 |
$borrower->store; |
154 |
|
157 |
|
155 |
my $sth = $dbh->prepare( |
158 |
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 100 })->store(); |
156 |
"INSERT INTO accountlines ( |
159 |
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 200 })->store(); |
157 |
borrowernumber, |
160 |
$line1->_result->discard_changes; |
158 |
amountoutstanding ) |
161 |
$line2->_result->discard_changes; |
159 |
VALUES ( ?, ? )" |
|
|
160 |
); |
161 |
$sth->execute($borrower->borrowernumber, '100'); |
162 |
$sth->execute($borrower->borrowernumber, '200'); |
163 |
|
162 |
|
164 |
$sth = $dbh->prepare("SELECT count(*) FROM accountlines"); |
163 |
$sth = $dbh->prepare("SELECT count(*) FROM accountlines"); |
165 |
$sth->execute; |
164 |
$sth->execute; |
166 |
my $count = $sth->fetchrow_array; |
165 |
my $count = $sth->fetchrow_array; |
167 |
is ($count, 2, 'There is 2 lines as expected'); |
166 |
is($count, 2, 'There is 2 lines as expected'); |
168 |
|
167 |
|
169 |
# Testing recordpayment ------------------------- |
168 |
# Testing recordpayment ------------------------- |
170 |
# There is $100 in the account |
169 |
# There is $100 in the account |
Lines 174-180
subtest "recordpayment() tests" => sub {
Link Here
|
174 |
for my $line ( @$amountoutstanding ) { |
173 |
for my $line ( @$amountoutstanding ) { |
175 |
$amountleft += $line; |
174 |
$amountleft += $line; |
176 |
} |
175 |
} |
177 |
ok($amountleft == 300, 'The account has 300$ as expected' ); |
176 |
is($amountleft, 300, 'The account has 300$ as expected' ); |
178 |
|
177 |
|
179 |
# We make a $20 payment |
178 |
# We make a $20 payment |
180 |
my $borrowernumber = $borrower->borrowernumber; |
179 |
my $borrowernumber = $borrower->borrowernumber; |
Lines 189-195
subtest "recordpayment() tests" => sub {
Link Here
|
189 |
for my $line ( @$amountoutstanding ) { |
188 |
for my $line ( @$amountoutstanding ) { |
190 |
$amountleft += $line; |
189 |
$amountleft += $line; |
191 |
} |
190 |
} |
192 |
ok($amountleft == 280, 'The account has $280 as expected' ); |
191 |
is($amountleft, 280, 'The account has $280 as expected' ); |
193 |
# Is the payment note well registered |
192 |
# Is the payment note well registered |
194 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
193 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
195 |
$sth->execute($borrower->borrowernumber); |
194 |
$sth->execute($borrower->borrowernumber); |
Lines 207-213
subtest "recordpayment() tests" => sub {
Link Here
|
207 |
for my $line ( @$amountoutstanding ) { |
206 |
for my $line ( @$amountoutstanding ) { |
208 |
$amountleft += $line; |
207 |
$amountleft += $line; |
209 |
} |
208 |
} |
210 |
ok($amountleft == 310, 'The account has $310 as expected' ); |
209 |
is($amountleft, 310, 'The account has $310 as expected' ); |
211 |
# Is the payment note well registered |
210 |
# Is the payment note well registered |
212 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
211 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
213 |
$sth->execute($borrower->borrowernumber); |
212 |
$sth->execute($borrower->borrowernumber); |
Lines 225-231
subtest "recordpayment() tests" => sub {
Link Here
|
225 |
for my $line ( @$amountoutstanding ) { |
224 |
for my $line ( @$amountoutstanding ) { |
226 |
$amountleft += $line; |
225 |
$amountleft += $line; |
227 |
} |
226 |
} |
228 |
ok($amountleft == 160, 'The account has $160 as expected' ); |
227 |
is($amountleft, 160, 'The account has $160 as expected' ); |
229 |
# Is the payment note well registered |
228 |
# Is the payment note well registered |
230 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
229 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
231 |
$sth->execute($borrower->borrowernumber); |
230 |
$sth->execute($borrower->borrowernumber); |
Lines 243-249
subtest "recordpayment() tests" => sub {
Link Here
|
243 |
for my $line ( @$amountoutstanding ) { |
242 |
for my $line ( @$amountoutstanding ) { |
244 |
$amountleft += $line; |
243 |
$amountleft += $line; |
245 |
} |
244 |
} |
246 |
ok($amountleft == -40, 'The account has -$40 as expected, (credit situation)' ); |
245 |
is($amountleft, -40, 'The account has -$40 as expected, (credit situation)' ); |
247 |
# Is the payment note well registered |
246 |
# Is the payment note well registered |
248 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
247 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
249 |
$sth->execute($borrower->borrowernumber); |
248 |
$sth->execute($borrower->borrowernumber); |
250 |
- |
|
|