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

(-)a/Koha/Cash/Register.pm (-18 / +20 lines)
Lines 448-462 sub add_cashup { Link Here
448
                    # Surplus: more cash found than expected (credits are negative amounts)
448
                    # Surplus: more cash found than expected (credits are negative amounts)
449
                    my $surplus = Koha::Account::Line->new(
449
                    my $surplus = Koha::Account::Line->new(
450
                        {
450
                        {
451
                            date             => $reconciliation_date,
451
                            date              => $reconciliation_date,
452
                            amount           => -abs($difference),      # Credits are negative
452
                            amount            => -abs($difference),      # Credits are negative
453
                            credit_type_code => 'CASHUP_SURPLUS',
453
                            amountoutstanding => 0,
454
                            manager_id       => $manager_id,
454
                            credit_type_code  => 'CASHUP_SURPLUS',
455
                            interface        => 'intranet',
455
                            manager_id        => $manager_id,
456
                            branchcode       => $self->branch,
456
                            interface         => 'intranet',
457
                            register_id      => $self->id,
457
                            branchcode        => $self->branch,
458
                            payment_type     => 'CASH',
458
                            register_id       => $self->id,
459
                            note             => $reconciliation_note
459
                            payment_type      => 'CASH',
460
                            note              => $reconciliation_note
460
                        }
461
                        }
461
                    )->store();
462
                    )->store();
462
463
Lines 474-488 sub add_cashup { Link Here
474
                    # Deficit: less cash found than expected
475
                    # Deficit: less cash found than expected
475
                    my $deficit = Koha::Account::Line->new(
476
                    my $deficit = Koha::Account::Line->new(
476
                        {
477
                        {
477
                            date            => $reconciliation_date,
478
                            date              => $reconciliation_date,
478
                            amount          => abs($difference),
479
                            amount            => abs($difference),
479
                            debit_type_code => 'CASHUP_DEFICIT',
480
                            amountoutstanding => 0,
480
                            manager_id      => $manager_id,
481
                            debit_type_code   => 'CASHUP_DEFICIT',
481
                            interface       => 'intranet',
482
                            manager_id        => $manager_id,
482
                            branchcode      => $self->branch,
483
                            interface         => 'intranet',
483
                            register_id     => $self->id,
484
                            branchcode        => $self->branch,
484
                            payment_type    => 'CASH',
485
                            register_id       => $self->id,
485
                            note            => $reconciliation_note
486
                            payment_type      => 'CASH',
487
                            note              => $reconciliation_note
486
                        }
488
                        }
487
                    )->store();
489
                    )->store();
488
                    my $account_offset = Koha::Account::Offset->new(
490
                    my $account_offset = Koha::Account::Offset->new(
(-)a/t/db_dependent/Koha/Cash/Register.t (-7 / +8 lines)
Lines 423-429 subtest 'cashup_reconciliation' => sub { Link Here
423
    };
423
    };
424
424
425
    subtest 'surplus_cashup' => sub {
425
    subtest 'surplus_cashup' => sub {
426
        plan tests => 9;
426
        plan tests => 10;
427
427
428
        $schema->storage->txn_begin;
428
        $schema->storage->txn_begin;
429
429
Lines 472-479 subtest 'cashup_reconciliation' => sub { Link Here
472
            sprintf( '%.0f', $surplus_line->amount ), sprintf( '%.0f', -$surplus ),
472
            sprintf( '%.0f', $surplus_line->amount ), sprintf( '%.0f', -$surplus ),
473
            'Surplus amount is correct (negative for credit)'
473
            'Surplus amount is correct (negative for credit)'
474
        );
474
        );
475
        is( $surplus_line->branchcode,   $register2->branch, 'Surplus branchcode matches register branch' );
475
        is( $surplus_line->branchcode,   $register2->branch,          'Surplus branchcode matches register branch' );
476
        is( $surplus_line->payment_type, 'CASH',             'Surplus payment_type is set to CASH' );
476
        is( $surplus_line->payment_type, 'CASH',                      'Surplus payment_type is set to CASH' );
477
        is( sprintf( '%.0f', $surplus_line->amountoutstanding ), '0', 'Surplus amountoutstanding is set to 0' );
477
478
478
        # Note should be undef for surplus without user note
479
        # Note should be undef for surplus without user note
479
        is( $surplus_line->note, undef, 'No note for surplus without user reconciliation note' );
480
        is( $surplus_line->note, undef, 'No note for surplus without user reconciliation note' );
Lines 522-528 subtest 'cashup_reconciliation' => sub { Link Here
522
    };
523
    };
523
524
524
    subtest 'deficit_cashup' => sub {
525
    subtest 'deficit_cashup' => sub {
525
        plan tests => 9;
526
        plan tests => 10;
526
527
527
        $schema->storage->txn_begin;
528
        $schema->storage->txn_begin;
528
529
Lines 571-578 subtest 'cashup_reconciliation' => sub { Link Here
571
            sprintf( '%.0f', $deficit_line->amount ), sprintf( '%.0f', $deficit ),
572
            sprintf( '%.0f', $deficit_line->amount ), sprintf( '%.0f', $deficit ),
572
            'Deficit amount is correct (positive for debit)'
573
            'Deficit amount is correct (positive for debit)'
573
        );
574
        );
574
        is( $deficit_line->branchcode,   $register3->branch, 'Deficit branchcode matches register branch' );
575
        is( $deficit_line->branchcode,   $register3->branch,          'Deficit branchcode matches register branch' );
575
        is( $deficit_line->payment_type, 'CASH',             'Deficit payment_type is set to CASH' );
576
        is( $deficit_line->payment_type, 'CASH',                      'Deficit payment_type is set to CASH' );
577
        is( sprintf( '%.0f', $deficit_line->amountoutstanding ), '0', 'Deficit amountoutstanding is set to 0' );
576
578
577
        # Note should be undef for deficit without user note
579
        # Note should be undef for deficit without user note
578
        is( $deficit_line->note, undef, 'No note for deficit without user reconciliation note' );
580
        is( $deficit_line->note, undef, 'No note for deficit without user reconciliation note' );
579
- 

Return to bug 40445