View | Details | Raw Unified | Return to bug 15896
Collapse All | Expand All

(-)a/t/db_dependent/Accounts.t (-4 / +12 lines)
Lines 56-68 $schema->storage->txn_begin; Link Here
56
my $dbh = C4::Context->dbh;
56
my $dbh = C4::Context->dbh;
57
57
58
my $builder = t::lib::TestBuilder->new;
58
my $builder = t::lib::TestBuilder->new;
59
my $library = $builder->build({ source => 'Branch' });
59
my $library  = $builder->build( { source => 'Branch' } );
60
60
61
$dbh->do(q|DELETE FROM accountlines|);
61
$dbh->do(q|DELETE FROM accountlines|);
62
$dbh->do(q|DELETE FROM issues|);
62
$dbh->do(q|DELETE FROM issues|);
63
$dbh->do(q|DELETE FROM borrowers|);
63
$dbh->do(q|DELETE FROM borrowers|);
64
64
65
my $branchcode = $library->{branchcode};
65
my $branchcode  = $library->{branchcode};
66
my $borrower_number;
66
my $borrower_number;
67
67
68
my $context = new Test::MockModule('C4::Context');
68
my $context = new Test::MockModule('C4::Context');
Lines 138-144 $dbh->do(q|DELETE FROM accountlines|); Link Here
138
138
139
subtest "Koha::Account::pay tests" => sub {
139
subtest "Koha::Account::pay tests" => sub {
140
140
141
    plan tests => 10;
141
    plan tests => 12;
142
142
143
    # Create a borrower
143
    # Create a borrower
144
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
144
    my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
Lines 225-230 subtest "Koha::Account::pay tests" => sub { Link Here
225
        $amountleft += $line;
225
        $amountleft += $line;
226
    }
226
    }
227
    is($amountleft, 160, 'The account has $160 as expected' );
227
    is($amountleft, 160, 'The account has $160 as expected' );
228
228
    # Is the payment note well registered
229
    # Is the payment note well registered
229
    $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");
230
    $sth->execute($borrower->borrowernumber);
231
    $sth->execute($borrower->borrowernumber);
Lines 244-254 subtest "Koha::Account::pay tests" => sub { Link Here
244
        $amountleft += $line;
245
        $amountleft += $line;
245
    }
246
    }
246
    is($amountleft, -40, 'The account has -$40 as expected, (credit situation)' );
247
    is($amountleft, -40, 'The account has -$40 as expected, (credit situation)' );
248
247
    # Is the payment note well registered
249
    # Is the payment note well registered
248
    $sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1");
250
    $sth = $dbh->prepare("SELECT note FROM accountlines WHERE borrowernumber=? ORDER BY accountlines_id DESC LIMIT 1");
249
    $sth->execute($borrower->borrowernumber);
251
    $sth->execute($borrower->borrowernumber);
250
    $note = $sth->fetchrow_array;
252
    $note = $sth->fetchrow_array;
251
    is($note,'$200.00 payment note', '$200.00 payment note is registered');
253
    is($note,'$200.00 payment note', '$200.00 payment note is registered');
254
255
    my $line3 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amountoutstanding => 42 })->store();
256
    my $payment_id = $account->pay( { accountlines_id => $line3->id, amount => 42 } );
257
    my $payment = Koha::Account::Lines->find( $payment_id );
258
    is( $payment->amount(), '-42.000000', "Payment paid the specified fine" );
259
    $line3 = Koha::Account::Lines->find( $line3->id );
260
    is( $line3->amountoutstanding, '0.000000', "Specified fine is paid" );
252
};
261
};
253
262
254
subtest "makepayment() tests" => sub {
263
subtest "makepayment() tests" => sub {
255
- 

Return to bug 15896