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

(-)a/t/db_dependent/Koha/Account/Offsets.t (-11 / +10 lines)
Lines 38-44 subtest 'total() tests' => sub { Link Here
38
    my $line = $builder->build_object(
38
    my $line = $builder->build_object(
39
        {
39
        {
40
            class => 'Koha::Account::Lines',
40
            class => 'Koha::Account::Lines',
41
            value => { debit_type_code => undef }
41
            value => { debit_type_code => 'OVERDUE', credit_type_code => undef }
42
        }
42
        }
43
    );
43
    );
44
44
Lines 49-74 subtest 'total() tests' => sub { Link Here
49
    my $amount_5 = 500;
49
    my $amount_5 = 500;
50
50
51
    my $offset_1 = Koha::Account::Offset->new(
51
    my $offset_1 = Koha::Account::Offset->new(
52
        { type => 'OVERDUE', amount => $amount_1, credit_id => $line->id } )->store;
52
        { type => 'OVERDUE_INCREASE', amount => $amount_1, debit_id => $line->id } )->store;
53
    my $offset_2 = Koha::Account::Offset->new(
53
    my $offset_2 = Koha::Account::Offset->new(
54
        { type => 'OVERDUE', amount => $amount_2, credit_id => $line->id } )->store;
54
        { type => 'OVERDUE_INCREASE', amount => $amount_2, debit_id => $line->id } )->store;
55
    my $offset_3 = Koha::Account::Offset->new(
55
    my $offset_3 = Koha::Account::Offset->new(
56
        { type => 'Payment', amount => $amount_3, credit_id => $line->id } )->store;
56
        { type => 'OVERDUE_DECREASE', amount => $amount_3, debit_id => $line->id } )->store;
57
    my $offset_4 = Koha::Account::Offset->new(
57
    my $offset_4 = Koha::Account::Offset->new(
58
        { type => 'Payment', amount => $amount_4, credit_id => $line->id } )->store;
58
        { type => 'OVERDUE_DECREASE', amount => $amount_4, debit_id => $line->id } )->store;
59
    my $offset_5 = Koha::Account::Offset->new(
59
    my $offset_5 = Koha::Account::Offset->new(
60
        { type => 'OVERDUE', amount => $amount_5, credit_id => $line->id } )->store;
60
        { type => 'OVERDUE_INCREASE', amount => $amount_5, debit_id => $line->id } )->store;
61
61
62
    my $debits = Koha::Account::Offsets->search( { type => 'OVERDUE', credit_id => $line->id } );
62
    my $debits = Koha::Account::Offsets->search( { type => 'OVERDUE_INCREASE', debit_id => $line->id } );
63
    is( $debits->total, $amount_1 + $amount_2 + $amount_5 );
63
    is( $debits->total, $amount_1 + $amount_2 + $amount_5 );
64
64
65
    my $credits = Koha::Account::Offsets->search( { type => 'Payment', credit_id => $line->id } );
65
    my $credits = Koha::Account::Offsets->search( { type => 'OVERDUE_DECREASE', debit_id => $line->id } );
66
    is( $credits->total, $amount_3 + $amount_4 );
66
    is( $credits->total, $amount_3 + $amount_4 );
67
67
68
    my $all = Koha::Account::Offsets->search( { credit_id => $line->id } );
68
    my $all = Koha::Account::Offsets->search( { debit_id => $line->id } );
69
    is( $all->total, $amount_1 + $amount_2 + $amount_3 + $amount_4 + $amount_5 );
69
    is( $all->total, $amount_1 + $amount_2 + $amount_3 + $amount_4 + $amount_5 );
70
70
71
    my $none = Koha::Account::Offsets->search( { credit_id => $line->id + 1 } );
71
    my $none = Koha::Account::Offsets->search( { debit_id => $line->id + 1 } );
72
    is( $none->total, 0, 'No offsets, returns 0' );
72
    is( $none->total, 0, 'No offsets, returns 0' );
73
73
74
    $schema->storage->txn_rollback;
74
    $schema->storage->txn_rollback;
75
- 

Return to bug 22435