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

(-)a/t/db_dependent/Koha/Cash/Register/Action.t (-2 / +64 lines)
Lines 81-87 subtest 'register' => sub { Link Here
81
};
81
};
82
82
83
subtest 'cashup_summary' => sub {
83
subtest 'cashup_summary' => sub {
84
    plan tests => 8;
84
    plan tests => 14;
85
85
86
    $schema->storage->txn_begin;
86
    $schema->storage->txn_begin;
87
87
Lines 281-286 subtest 'cashup_summary' => sub { Link Here
281
    is_deeply( $summary->{outgoing}, $expected_outgoing,
281
    is_deeply( $summary->{outgoing}, $expected_outgoing,
282
        "outgoing arrayref is correct" );
282
        "outgoing arrayref is correct" );
283
283
284
    # Backdate cashup1 so we can add a new cashup to check 'previous'
285
    $cashup1->timestamp(\'NOW() - INTERVAL 2 MINUTE')->store();
286
    $cashup1->discard_changes;
287
288
    # Transaction 4
289
    my $debt4 = $builder->build_object(
290
        {
291
            class => 'Koha::Account::Lines',
292
            value => {
293
                register_id       => undef,
294
                amount            => '2.75',
295
                amountoutstanding => '0.00',
296
                credit_type_code  => undef,
297
                debit_type_code   => 'OVERDUE',
298
                date              => \'NOW() - INTERVAL 1 MINUTE'
299
            },
300
        }
301
    );
302
    my $income3 = $builder->build_object(
303
        {
304
            class => 'Koha::Account::Lines',
305
            value => {
306
                register_id       => $register->id,
307
                amount            => '-2.75',
308
                amountoutstanding => '0.00',
309
                credit_type_code  => 'PAYMENT',
310
                debit_type_code   => undef,
311
                date              => \'NOW() - INTERVAL 1 MINUTE'
312
            },
313
        }
314
    );
315
    $builder->build_object(
316
        {
317
            class => 'Koha::Account::Offsets',
318
            value => {
319
                credit_id => $income3->accountlines_id,
320
                debit_id  => $debt4->accountlines_id,
321
                amount    => '2.75',
322
                type      => 'Payment'
323
            },
324
        }
325
    );
326
327
    my $cashup2 =
328
      $register->add_cashup( { manager_id => $manager->id, amount => '2.75' } );
329
330
    $summary = $cashup2->cashup_summary;
331
332
    is( $summary->{from_date}, $cashup1->timestamp,
333
        "from_date returns the timestamp of the previous cashup action" );
334
    is( $summary->{to_date}, $cashup2->timestamp,
335
        "to_date equals cashup timestamp" );
336
    is( ref( $summary->{income_transactions} ),
337
        'Koha::Account::Lines',
338
        "income_transactions contains Koha::Account::Lines" );
339
    is( $summary->{income_transactions}->count,
340
        1, "income_transactions contains 2 transactions" );
341
    is( ref( $summary->{outgoing_transactions} ),
342
        'Koha::Account::Lines',
343
        "outgoing_transactions contains Koha::Account::Lines" );
344
    is( $summary->{outgoing_transactions}->count,
345
        0, "outgoing_transactions contains 1 transaction" );
346
284
    $schema->storage->txn_rollback;
347
    $schema->storage->txn_rollback;
285
};
348
};
286
349
287
- 

Return to bug 26172