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

(-)a/Koha/Account.pm (-2 lines)
Lines 363-369 sub add_credit { Link Here
363
                    manager_id        => $user_id,
363
                    manager_id        => $user_id,
364
                    branchcode        => $library_id,
364
                    branchcode        => $library_id,
365
                    itemnumber        => $item_id,
365
                    itemnumber        => $item_id,
366
                    lastincrement     => undef,
367
                }
366
                }
368
            )->store();
367
            )->store();
369
368
Lines 495-501 sub add_debit { Link Here
495
                    itemnumber        => $item_id,
494
                    itemnumber        => $item_id,
496
                    issue_id          => $issue_id,
495
                    issue_id          => $issue_id,
497
                    branchcode        => $library_id,
496
                    branchcode        => $library_id,
498
                    ( $type eq 'fine' ? ( lastincrement => $amount ) : ()),
499
                }
497
                }
500
            )->store();
498
            )->store();
501
499
(-)a/Koha/Account/Line.pm (-2 / +1 lines)
Lines 297-304 sub adjust { Link Here
297
                {
297
                {
298
                    date              => \'NOW()',
298
                    date              => \'NOW()',
299
                    amount            => $amount,
299
                    amount            => $amount,
300
                    amountoutstanding => $new_outstanding,
300
                    amountoutstanding => $new_outstanding
301
                    ( $update_type eq 'fine_update' ? ( lastincrement => $difference ) : ()),
302
                }
301
                }
303
            )->store();
302
            )->store();
304
303
(-)a/misc/cronjobs/staticfines.pl (-2 / +2 lines)
Lines 229-238 for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { Link Here
229
            my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
229
            my $nextaccntno = C4::Accounts::getnextacctno($borrowernumber);
230
            my $desc        = "staticfine";
230
            my $desc        = "staticfine";
231
            my $query       = "INSERT INTO accountlines
231
            my $query       = "INSERT INTO accountlines
232
                        (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,lastincrement,accountno)
232
                        (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,accountno)
233
                                VALUES (?,?,now(),?,?,'F',?,?,?)";
233
                                VALUES (?,?,now(),?,?,'F',?,?,?)";
234
            my $sth2 = $dbh->prepare($query);
234
            my $sth2 = $dbh->prepare($query);
235
            $bigdebug and warn "query: $query\nw/ args: $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount, $nextaccntno\n";
235
            $bigdebug and warn "query: $query\nw/ args: $borrowernumber, $itemnumber, $amount, $desc, $amount, $nextaccntno\n";
236
            $sth2->execute( $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount, $nextaccntno );
236
            $sth2->execute( $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount, $nextaccntno );
237
237
238
        }
238
        }
(-)a/t/db_dependent/Circulation.t (-3 / +1 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
use utf8;
19
use utf8;
20
20
21
use Test::More tests => 126;
21
use Test::More tests => 125;
22
use Test::MockModule;
22
use Test::MockModule;
23
23
24
use Data::Dumper;
24
use Data::Dumper;
Lines 827-833 my ( $reused_itemnumber_1, $reused_itemnumber_2 ); Link Here
827
827
828
    my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next();
828
    my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next();
829
    is( $line->accounttype, 'FU', 'Account line type is FU' );
829
    is( $line->accounttype, 'FU', 'Account line type is FU' );
830
    is( $line->lastincrement, '15.000000', 'Account line last increment is 15.00' );
831
    is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' );
830
    is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' );
832
    is( $line->amount, '15.000000', 'Account line amount is 15.00' );
831
    is( $line->amount, '15.000000', 'Account line amount is 15.00' );
833
    is( $line->issue_id, $issue->id, 'Account line issue id matches' );
832
    is( $line->issue_id, $issue->id, 'Account line issue id matches' );
Lines 2356-2362 subtest '_FixOverduesOnReturn' => sub { Link Here
2356
            itemnumber     => $item->itemnumber,
2355
            itemnumber     => $item->itemnumber,
2357
            amount => 99.00,
2356
            amount => 99.00,
2358
            amountoutstanding => 99.00,
2357
            amountoutstanding => 99.00,
2359
            lastincrement => 9.00,
2360
        }
2358
        }
2361
    )->store();
2359
    )->store();
2362
2360
(-)a/t/db_dependent/Koha/Account/Lines.t (-6 / +1 lines)
Lines 303-309 subtest 'Keep account info when a patron is deleted' => sub { Link Here
303
303
304
subtest 'adjust() tests' => sub {
304
subtest 'adjust() tests' => sub {
305
305
306
    plan tests => 33;
306
    plan tests => 29;
307
307
308
    $schema->storage->txn_begin;
308
    $schema->storage->txn_begin;
309
309
Lines 347-353 subtest 'adjust() tests' => sub { Link Here
347
    is( $debit_2->amount * 1, 150, 'Fine amount was updated in full' );
347
    is( $debit_2->amount * 1, 150, 'Fine amount was updated in full' );
348
    is( $debit_2->amountoutstanding * 1, 150, 'Fine amountoutstanding was update in full' );
348
    is( $debit_2->amountoutstanding * 1, 150, 'Fine amountoutstanding was update in full' );
349
    isnt( $debit_2->date, undef, 'Date has been set' );
349
    isnt( $debit_2->date, undef, 'Date has been set' );
350
    is( $debit_2->lastincrement * 1, 50, 'lastincrement is the to the right value' );
351
350
352
    my $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } );
351
    my $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } );
353
    is( $offsets->count, 1, 'An offset is generated for the increment' );
352
    is( $offsets->count, 1, 'An offset is generated for the increment' );
Lines 373-379 subtest 'adjust() tests' => sub { Link Here
373
372
374
    is( $debit_2->amount * 1, 160, 'Fine amount was updated in full' );
373
    is( $debit_2->amount * 1, 160, 'Fine amount was updated in full' );
375
    is( $debit_2->amountoutstanding * 1, 120, 'Fine amountoutstanding was updated by difference' );
374
    is( $debit_2->amountoutstanding * 1, 120, 'Fine amountoutstanding was updated by difference' );
376
    is( $debit_2->lastincrement * 1, 10, 'lastincrement is the to the right value' );
377
375
378
    $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } );
376
    $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } );
379
    is( $offsets->count, 3, 'An offset is generated for the increment' );
377
    is( $offsets->count, 3, 'An offset is generated for the increment' );
Lines 388-394 subtest 'adjust() tests' => sub { Link Here
388
386
389
    is( $debit_2->amount * 1, 50, 'Fine amount was updated in full' );
387
    is( $debit_2->amount * 1, 50, 'Fine amount was updated in full' );
390
    is( $debit_2->amountoutstanding * 1, 10, 'Fine amountoutstanding was updated by difference' );
388
    is( $debit_2->amountoutstanding * 1, 10, 'Fine amountoutstanding was updated by difference' );
391
    is( $debit_2->lastincrement * 1, -110, 'lastincrement is the to the right value' );
392
389
393
    $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } );
390
    $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } );
394
    is( $offsets->count, 4, 'An offset is generated for the decrement' );
391
    is( $offsets->count, 4, 'An offset is generated for the decrement' );
Lines 400-406 subtest 'adjust() tests' => sub { Link Here
400
    $debit_2->adjust( { amount => 30, type => 'fine_update' } )->discard_changes;
397
    $debit_2->adjust( { amount => 30, type => 'fine_update' } )->discard_changes;
401
    is( $debit_2->amount * 1, 30, 'Fine amount was updated in full' );
398
    is( $debit_2->amount * 1, 30, 'Fine amount was updated in full' );
402
    is( $debit_2->amountoutstanding * 1, 0, 'Fine amountoutstanding was zeroed (payment was 40)' );
399
    is( $debit_2->amountoutstanding * 1, 0, 'Fine amountoutstanding was zeroed (payment was 40)' );
403
    is( $debit_2->lastincrement * 1, -20, 'lastincrement is the to the right value' );
404
400
405
    $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } );
401
    $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } );
406
    is( $offsets->count, 5, 'An offset is generated for the decrement' );
402
    is( $offsets->count, 5, 'An offset is generated for the decrement' );
407
- 

Return to bug 22516