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