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

(-)a/Koha/Account.pm (-1 / +3 lines)
Lines 519-525 sub lines { Link Here
519
519
520
$account->reconcile_balance();
520
$account->reconcile_balance();
521
521
522
Find outstanding credits and use them to pay outstanding debits
522
Find outstanding credits and use them to pay outstanding debits.
523
Currently, this implicitly uses the 'First In First Out' rule for
524
applying credits against debits.
523
525
524
=cut
526
=cut
525
527
(-)a/Koha/Account/Line.pm (+8 lines)
Lines 241-244 sub _type { Link Here
241
    return 'Accountline';
241
    return 'Accountline';
242
}
242
}
243
243
244
=head3 object_class (internal)
245
246
=cut
247
248
sub object_class {
249
    return 'Koha::Account::Line';
250
}
251
244
1;
252
1;
(-)a/Koha/Schema/Result/Accountline.pm (-1 / +7 lines)
Lines 238-244 __PACKAGE__->belongs_to( Link Here
238
238
239
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-05-16 17:00:24
239
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-05-16 17:00:24
240
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pygYYKxFDRLX97PyeUeLvg
240
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pygYYKxFDRLX97PyeUeLvg
241
#
241
242
243
sub koha_objects_class {
244
    'Koha::Account::Lines';
245
}
246
sub koha_object_class {
247
    'Koha::Account::Line';
248
}
242
249
243
# You can replace this text with custom content, and it will be preserved on regeneration
244
1;
250
1;
(-)a/t/db_dependent/Koha/Account.t (-4 / +5 lines)
Lines 269-275 subtest 'reconcile_balance' => sub { Link Here
269
        $schema->storage->txn_rollback;
269
        $schema->storage->txn_rollback;
270
    };
270
    };
271
271
272
    subtest 'same debit than credit' => sub {
272
    subtest 'same debit as credit' => sub {
273
273
274
        plan tests => 6;
274
        plan tests => 6;
275
275
Lines 309-315 subtest 'reconcile_balance' => sub { Link Here
309
309
310
    subtest 'more debit than credit' => sub {
310
    subtest 'more debit than credit' => sub {
311
311
312
        plan tests => 6;
312
        plan tests => 7;
313
313
314
        $schema->storage->txn_begin;
314
        $schema->storage->txn_begin;
315
315
Lines 327-333 subtest 'reconcile_balance' => sub { Link Here
327
        Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2 })->store;
327
        Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2 })->store;
328
        Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3 })->store;
328
        Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3 })->store;
329
        Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 4, amountoutstanding => 4 })->store;
329
        Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 4, amountoutstanding => 4 })->store;
330
        Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 5, amountoutstanding => 5 })->store;
330
        my $line5 = Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 5, amountoutstanding => 5 })->store;
331
331
332
        # Paid Off
332
        # Paid Off
333
        Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0 })->store;
333
        Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 0 })->store;
Lines 343-348 subtest 'reconcile_balance' => sub { Link Here
343
        is( $account->outstanding_debits->total_outstanding, 5, 'Outstanding debits sum 5' );
343
        is( $account->outstanding_debits->total_outstanding, 5, 'Outstanding debits sum 5' );
344
        is( $account->outstanding_credits->total_outstanding, 0, 'Outstanding credits sum 0' );
344
        is( $account->outstanding_credits->total_outstanding, 0, 'Outstanding credits sum 0' );
345
345
346
        is( $line5->get_from_storage->amountoutstanding, '5.000000', 'First In First Out method of payment selection used');
347
346
        $schema->storage->txn_rollback;
348
        $schema->storage->txn_rollback;
347
    };
349
    };
348
};
350
};
349
- 

Return to bug 21896