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

(-)a/Koha/Account.pm (-2 lines)
Lines 346-352 sub add_credit { Link Here
346
                    manager_id        => $user_id,
346
                    manager_id        => $user_id,
347
                    branchcode        => $library_id,
347
                    branchcode        => $library_id,
348
                    itemnumber        => $item_id,
348
                    itemnumber        => $item_id,
349
                    lastincrement     => undef,
350
                }
349
                }
351
            )->store();
350
            )->store();
352
351
Lines 472-478 sub add_debit { Link Here
472
                    itemnumber        => $item_id,
471
                    itemnumber        => $item_id,
473
                    issue_id          => $issue_id,
472
                    issue_id          => $issue_id,
474
                    branchcode        => $library_id,
473
                    branchcode        => $library_id,
475
                    ( $type eq 'fine' ? ( lastincrement => $amount ) : ()),
476
                }
474
                }
477
            )->store();
475
            )->store();
478
476
(-)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 (-4 / +4 lines)
Lines 228-238 for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { Link Here
228
228
229
            my $desc        = "staticfine";
229
            my $desc        = "staticfine";
230
            my $query       = "INSERT INTO accountlines
230
            my $query       = "INSERT INTO accountlines
231
                        (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,lastincrement)
231
                        (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding)
232
                                VALUES (?,?,now(),?,?,'F',?,?)";
232
                                VALUES (?,?,now(),?,?,'F',?)";
233
            my $sth2 = $dbh->prepare($query);
233
            my $sth2 = $dbh->prepare($query);
234
            $bigdebug and warn "query: $query\nw/ args: $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount\n";
234
            $bigdebug and warn "query: $query\nw/ args: $borrowernumber, $itemnumber, $amount, $desc, $amount\n";
235
            $sth2->execute( $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount );
235
            $sth2->execute( $borrowernumber, $itemnumber, $amount, $desc, $amount );
236
236
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 849-855 my ( $reused_itemnumber_1, $reused_itemnumber_2 ); Link Here
849
849
850
    my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next();
850
    my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next();
851
    is( $line->accounttype, 'FU', 'Account line type is FU' );
851
    is( $line->accounttype, 'FU', 'Account line type is FU' );
852
    is( $line->lastincrement, '15.000000', 'Account line last increment is 15.00' );
853
    is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' );
852
    is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' );
854
    is( $line->amount, '15.000000', 'Account line amount is 15.00' );
853
    is( $line->amount, '15.000000', 'Account line amount is 15.00' );
855
    is( $line->issue_id, $issue->id, 'Account line issue id matches' );
854
    is( $line->issue_id, $issue->id, 'Account line issue id matches' );
Lines 2377-2383 subtest '_FixOverduesOnReturn' => sub { Link Here
2377
            itemnumber     => $item->itemnumber,
2376
            itemnumber     => $item->itemnumber,
2378
            amount => 99.00,
2377
            amount => 99.00,
2379
            amountoutstanding => 99.00,
2378
            amountoutstanding => 99.00,
2380
            lastincrement => 9.00,
2381
        }
2379
        }
2382
    )->store();
2380
    )->store();
2383
2381
(-)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