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

(-)a/t/db_dependent/Circulation.t (-11 / +18 lines)
Lines 2053-2059 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2053
        my $lost_fee_line = $lost_fee_lines->next;
2053
        my $lost_fee_line = $lost_fee_lines->next;
2054
        is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' );
2054
        is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' );
2055
        is( $lost_fee_line->amountoutstanding + 0,
2055
        is( $lost_fee_line->amountoutstanding + 0,
2056
            $replacement_amount, 'The right L amountountstanding is generated' );
2056
            $replacement_amount, 'The right L amountoutstanding is generated' );
2057
2057
2058
        my $account = $patron->account;
2058
        my $account = $patron->account;
2059
        my $debts   = $account->outstanding_debits;
2059
        my $debts   = $account->outstanding_debits;
Lines 2148-2154 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2148
2148
2149
    subtest 'Test without payment or write off' => sub {
2149
    subtest 'Test without payment or write off' => sub {
2150
2150
2151
        plan tests => 10;
2151
        plan tests => 12;
2152
2152
2153
        my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
2153
        my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
2154
        my $barcode = 'KD123456791';
2154
        my $barcode = 'KD123456791';
Lines 2187-2193 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2187
            $replacement_amount, 'The right L amountountstanding is generated' );
2187
            $replacement_amount, 'The right L amountountstanding is generated' );
2188
2188
2189
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item_id, $patron->id );
2189
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item_id, $patron->id );
2190
        is( $credit_return_id, undef, 'No CR account line added' );
2190
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2191
2192
        is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' );
2193
        is( $credit_return->amount + 0, -99.00, 'The account line of type CR has an amount of -99' );
2194
        is( $credit_return->amountoutstanding + 0, 0, 'The account line of type CR has an amountoutstanding of 0' );
2191
2195
2192
        $lost_fee_line->discard_changes;
2196
        $lost_fee_line->discard_changes;
2193
        is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
2197
        is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
Lines 2263-2288 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2263
            'Payment and write off applied'
2267
            'Payment and write off applied'
2264
        );
2268
        );
2265
2269
2270
        # Store the amountoutstanding value
2271
        $lost_fee_line->discard_changes;
2272
        my $outstanding = $lost_fee_line->amountoutstanding;
2273
2266
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item_id, $patron->id );
2274
        my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item_id, $patron->id );
2267
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2275
        my $credit_return = Koha::Account::Lines->find($credit_return_id);
2268
2276
2269
        is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PF - payment (CR)' );
2277
        is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PF - payment (CR)' );
2270
2278
2279
        $lost_fee_line->discard_changes;
2280
        is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
2281
        is( $lost_fee_line->accounttype,
2282
            'LR', 'Lost fee now has account type of LR ( Lost Returned )' );
2283
2271
        is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' );
2284
        is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' );
2272
        is( $credit_return->amount + 0,
2285
        is( $credit_return->amount + 0,
2273
            $payment_amount * -1,
2286
            ($payment_amount + $outstanding ) * -1,
2274
            'The account line of type CR has an amount equal to the payment'
2287
            'The account line of type CR has an amount equal to the payment + outstanding'
2275
        );
2288
        );
2276
        is( $credit_return->amountoutstanding + 0,
2289
        is( $credit_return->amountoutstanding + 0,
2277
            $payment_amount * -1,
2290
            $payment_amount * -1,
2278
            'The account line of type CR has an amountoutstanding equal to the payment'
2291
            'The account line of type CR has an amountoutstanding equal to the payment'
2279
        );
2292
        );
2280
2293
2281
        $lost_fee_line->discard_changes;
2282
        is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
2283
        is( $lost_fee_line->accounttype,
2284
            'LR', 'Lost fee now has account type of LR ( Lost Returned )' );
2285
2286
        is( $account->balance,
2294
        is( $account->balance,
2287
            $processfee_amount - $payment_amount,
2295
            $processfee_amount - $payment_amount,
2288
            'The patron balance is the difference between the PF and the credit'
2296
            'The patron balance is the difference between the PF and the credit'
2289
- 

Return to bug 21759