Lines 35-41
BEGIN {
Link Here
|
35 |
} |
35 |
} |
36 |
|
36 |
|
37 |
can_ok( 'C4::Accounts', |
37 |
can_ok( 'C4::Accounts', |
38 |
qw( recordpayment |
38 |
qw( |
39 |
makepayment |
39 |
makepayment |
40 |
getnextacctno |
40 |
getnextacctno |
41 |
chargelostitem |
41 |
chargelostitem |
Lines 138-144
for my $data (@test_data) {
Link Here
|
138 |
|
138 |
|
139 |
$dbh->do(q|DELETE FROM accountlines|); |
139 |
$dbh->do(q|DELETE FROM accountlines|); |
140 |
|
140 |
|
141 |
subtest "recordpayment() tests" => sub { |
141 |
subtest "Koha::Account::pay tests" => sub { |
142 |
|
142 |
|
143 |
plan tests => 10; |
143 |
plan tests => 10; |
144 |
|
144 |
|
Lines 155-160
subtest "recordpayment() tests" => sub {
Link Here
|
155 |
$borrower->branchcode( $branchcode ); |
155 |
$borrower->branchcode( $branchcode ); |
156 |
$borrower->store; |
156 |
$borrower->store; |
157 |
|
157 |
|
|
|
158 |
my $account = Koha::Account->new({ patron_id => $borrower->id }); |
159 |
|
158 |
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 100 })->store(); |
160 |
my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 100 })->store(); |
159 |
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 200 })->store(); |
161 |
my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 200 })->store(); |
160 |
$line1->_result->discard_changes; |
162 |
$line1->_result->discard_changes; |
Lines 165-171
subtest "recordpayment() tests" => sub {
Link Here
|
165 |
my $count = $sth->fetchrow_array; |
167 |
my $count = $sth->fetchrow_array; |
166 |
is($count, 2, 'There is 2 lines as expected'); |
168 |
is($count, 2, 'There is 2 lines as expected'); |
167 |
|
169 |
|
168 |
# Testing recordpayment ------------------------- |
|
|
169 |
# There is $100 in the account |
170 |
# There is $100 in the account |
170 |
$sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?"); |
171 |
$sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?"); |
171 |
my $amountoutstanding = $dbh->selectcol_arrayref($sth, {}, $borrower->borrowernumber); |
172 |
my $amountoutstanding = $dbh->selectcol_arrayref($sth, {}, $borrower->borrowernumber); |
Lines 178-186
subtest "recordpayment() tests" => sub {
Link Here
|
178 |
# We make a $20 payment |
179 |
# We make a $20 payment |
179 |
my $borrowernumber = $borrower->borrowernumber; |
180 |
my $borrowernumber = $borrower->borrowernumber; |
180 |
my $data = '20.00'; |
181 |
my $data = '20.00'; |
181 |
my $sys_paytype; |
|
|
182 |
my $payment_note = '$20.00 payment note'; |
182 |
my $payment_note = '$20.00 payment note'; |
183 |
recordpayment($borrowernumber, $data, $sys_paytype, $payment_note); |
183 |
$account->pay( { amount => $data, note => $payment_note } ); |
|
|
184 |
|
184 |
# There is now $280 in the account |
185 |
# There is now $280 in the account |
185 |
$sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?"); |
186 |
$sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?"); |
186 |
$amountoutstanding = $dbh->selectcol_arrayref($sth, {}, $borrower->borrowernumber); |
187 |
$amountoutstanding = $dbh->selectcol_arrayref($sth, {}, $borrower->borrowernumber); |
Lines 189-194
subtest "recordpayment() tests" => sub {
Link Here
|
189 |
$amountleft += $line; |
190 |
$amountleft += $line; |
190 |
} |
191 |
} |
191 |
is($amountleft, 280, 'The account has $280 as expected' ); |
192 |
is($amountleft, 280, 'The account has $280 as expected' ); |
|
|
193 |
|
192 |
# Is the payment note well registered |
194 |
# Is the payment note well registered |
193 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
195 |
$sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1"); |
194 |
$sth->execute($borrower->borrowernumber); |
196 |
$sth->execute($borrower->borrowernumber); |
Lines 198-204
subtest "recordpayment() tests" => sub {
Link Here
|
198 |
# We make a -$30 payment (a NEGATIVE payment) |
200 |
# We make a -$30 payment (a NEGATIVE payment) |
199 |
$data = '-30.00'; |
201 |
$data = '-30.00'; |
200 |
$payment_note = '-$30.00 payment note'; |
202 |
$payment_note = '-$30.00 payment note'; |
201 |
recordpayment($borrowernumber, $data, $sys_paytype, $payment_note); |
203 |
$account->pay( { amount => $data, note => $payment_note } ); |
|
|
204 |
|
202 |
# There is now $310 in the account |
205 |
# There is now $310 in the account |
203 |
$sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?"); |
206 |
$sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?"); |
204 |
$amountoutstanding = $dbh->selectcol_arrayref($sth, {}, $borrower->borrowernumber); |
207 |
$amountoutstanding = $dbh->selectcol_arrayref($sth, {}, $borrower->borrowernumber); |
Lines 216-222
subtest "recordpayment() tests" => sub {
Link Here
|
216 |
#We make a $150 payment ( > 1stLine ) |
219 |
#We make a $150 payment ( > 1stLine ) |
217 |
$data = '150.00'; |
220 |
$data = '150.00'; |
218 |
$payment_note = '$150.00 payment note'; |
221 |
$payment_note = '$150.00 payment note'; |
219 |
recordpayment($borrowernumber, $data, $sys_paytype, $payment_note); |
222 |
$account->pay( { amount => $data, note => $payment_note } ); |
|
|
223 |
|
220 |
# There is now $160 in the account |
224 |
# There is now $160 in the account |
221 |
$sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?"); |
225 |
$sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?"); |
222 |
$amountoutstanding = $dbh->selectcol_arrayref($sth, {}, $borrower->borrowernumber); |
226 |
$amountoutstanding = $dbh->selectcol_arrayref($sth, {}, $borrower->borrowernumber); |
Lines 234-240
subtest "recordpayment() tests" => sub {
Link Here
|
234 |
#We make a $200 payment ( > amountleft ) |
238 |
#We make a $200 payment ( > amountleft ) |
235 |
$data = '200.00'; |
239 |
$data = '200.00'; |
236 |
$payment_note = '$200.00 payment note'; |
240 |
$payment_note = '$200.00 payment note'; |
237 |
recordpayment($borrowernumber, $data, $sys_paytype, $payment_note); |
241 |
$account->pay( { amount => $data, note => $payment_note } ); |
|
|
242 |
|
238 |
# There is now -$40 in the account |
243 |
# There is now -$40 in the account |
239 |
$sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?"); |
244 |
$sth = $dbh->prepare("SELECT amountoutstanding FROM accountlines WHERE borrowernumber=?"); |
240 |
$amountoutstanding = $dbh->selectcol_arrayref($sth, {}, $borrower->borrowernumber); |
245 |
$amountoutstanding = $dbh->selectcol_arrayref($sth, {}, $borrower->borrowernumber); |
241 |
- |
|
|