|
Lines 210-218
subtest 'add_credit() tests' => sub {
Link Here
|
| 210 |
|
210 |
|
| 211 |
my $credit = { amount => 100 }; |
211 |
my $credit = { amount => 100 }; |
| 212 |
|
212 |
|
| 213 |
$t->post_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/credits" => json => $credit) |
213 |
my $ret = $t->post_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/credits" => json => $credit) |
| 214 |
->status_is(200) |
214 |
->status_is(201)->tx->res->json; |
| 215 |
->json_has('/account_line_id'); |
215 |
|
|
|
216 |
is_deeply( $ret, Koha::Account::Lines->find( $ret->{account_line_id} )->to_api, 'Line returned correctly' ); |
| 216 |
|
217 |
|
| 217 |
my $outstanding_credits = $account->outstanding_credits; |
218 |
my $outstanding_credits = $account->outstanding_credits; |
| 218 |
is( $outstanding_credits->count, 1 ); |
219 |
is( $outstanding_credits->count, 1 ); |
|
Lines 244-252
subtest 'add_credit() tests' => sub {
Link Here
|
| 244 |
is( $account->outstanding_debits->total_outstanding, 25 ); |
245 |
is( $account->outstanding_debits->total_outstanding, 25 ); |
| 245 |
$credit->{library_id} = $library->id; |
246 |
$credit->{library_id} = $library->id; |
| 246 |
|
247 |
|
| 247 |
$t->post_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/credits" => json => $credit) |
248 |
$ret = $t->post_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/credits" => json => $credit) |
| 248 |
->status_is(200) |
249 |
->status_is(201) |
| 249 |
->json_has('/account_line_id'); |
250 |
->tx->res->json; |
|
|
251 |
|
| 252 |
is_deeply( $ret, Koha::Account::Lines->find( $ret->{account_line_id} )->to_api, 'Line returned correctly' ); |
| 250 |
|
253 |
|
| 251 |
my $account_line_id = $t->tx->res->json->{account_line_id}; |
254 |
my $account_line_id = $t->tx->res->json->{account_line_id}; |
| 252 |
is( Koha::Account::Lines->find($account_line_id)->branchcode, |
255 |
is( Koha::Account::Lines->find($account_line_id)->branchcode, |
|
Lines 272-280
subtest 'add_credit() tests' => sub {
Link Here
|
| 272 |
account_lines_ids => [ $debit_1->id, $debit_2->id, $debit_3->id ] |
275 |
account_lines_ids => [ $debit_1->id, $debit_2->id, $debit_3->id ] |
| 273 |
}; |
276 |
}; |
| 274 |
|
277 |
|
| 275 |
$t->post_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/credits" => json => $credit) |
278 |
$ret = $t->post_ok("//$userid:$password@/api/v1/patrons/$patron_id/account/credits" => json => $credit) |
| 276 |
->status_is(200) |
279 |
->status_is(201) |
| 277 |
->json_has('/account_line_id'); |
280 |
->tx->res->json; |
|
|
281 |
|
| 282 |
is_deeply( $ret, Koha::Account::Lines->find( $ret->{account_line_id} )->to_api, 'Line returned correctly' ); |
| 278 |
|
283 |
|
| 279 |
my $outstanding_debits = $account->outstanding_debits; |
284 |
my $outstanding_debits = $account->outstanding_debits; |
| 280 |
is( $outstanding_debits->total_outstanding, 65 ); |
285 |
is( $outstanding_debits->total_outstanding, 65 ); |
| 281 |
- |
|
|