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

(-)a/Koha/Account/Line.pm (-1 / +1 lines)
Lines 190-196 sub apply { Link Here
190
            Koha::Account::Offset->new(
190
            Koha::Account::Offset->new(
191
                {   credit_id => $self->id,
191
                {   credit_id => $self->id,
192
                    debit_id  => $debit->id,
192
                    debit_id  => $debit->id,
193
                    amount    => $amount_to_cancel,
193
                    amount    => $amount_to_cancel * -1,
194
                    type      => $offset_type,
194
                    type      => $offset_type,
195
                }
195
                }
196
            )->store();
196
            )->store();
(-)a/t/db_dependent/Koha/Account/Lines.t (-3 / +2 lines)
Lines 202-208 subtest 'apply() tests' => sub { Link Here
202
    my $offsets = Koha::Account::Offsets->search( { credit_id => $credit->id, debit_id => $debit_1->id } );
202
    my $offsets = Koha::Account::Offsets->search( { credit_id => $credit->id, debit_id => $debit_1->id } );
203
    is( $offsets->count, 1, 'Only one offset is generated' );
203
    is( $offsets->count, 1, 'Only one offset is generated' );
204
    my $THE_offset = $offsets->next;
204
    my $THE_offset = $offsets->next;
205
    is( $THE_offset->amount * 1, 10, 'Amount was calculated correctly (less than the available credit)' );
205
    is( $THE_offset->amount * 1, -10, 'Amount was calculated correctly (less than the available credit)' );
206
    is( $THE_offset->type, 'Manual Credit', 'Passed type stored correctly' );
206
    is( $THE_offset->type, 'Manual Credit', 'Passed type stored correctly' );
207
207
208
    $debits = Koha::Account::Lines->search({ accountlines_id => $debit_2->id });
208
    $debits = Koha::Account::Lines->search({ accountlines_id => $debit_2->id });
Lines 216-222 subtest 'apply() tests' => sub { Link Here
216
    $offsets = Koha::Account::Offsets->search( { credit_id => $credit->id, debit_id => $debit_2->id } );
216
    $offsets = Koha::Account::Offsets->search( { credit_id => $credit->id, debit_id => $debit_2->id } );
217
    is( $offsets->count, 1, 'Only one offset is generated' );
217
    is( $offsets->count, 1, 'Only one offset is generated' );
218
    $THE_offset = $offsets->next;
218
    $THE_offset = $offsets->next;
219
    is( $THE_offset->amount * 1, 90, 'Amount was calculated correctly (less than the available credit)' );
219
    is( $THE_offset->amount * 1, -90, 'Amount was calculated correctly (less than the available credit)' );
220
    is( $THE_offset->type, 'Credit Applied', 'Defaults to \'Credit Applied\' offset type' );
220
    is( $THE_offset->type, 'Credit Applied', 'Defaults to \'Credit Applied\' offset type' );
221
221
222
    $debits = Koha::Account::Lines->search({ accountlines_id => $debit_1->id });
222
    $debits = Koha::Account::Lines->search({ accountlines_id => $debit_1->id });
223
- 

Return to bug 21607