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

(-)a/Koha/Cash/Register.pm (-7 / +8 lines)
Lines 291-302 sub start_cashup { Link Here
291
291
292
    my $expected_amount = $self->outstanding_accountlines->total( { payment_type => [ 'CASH', 'SIP00' ] } ) * -1;
292
    my $expected_amount = $self->outstanding_accountlines->total( { payment_type => [ 'CASH', 'SIP00' ] } ) * -1;
293
293
294
    # Prevent starting a cashup when there are no cash transactions
294
    # Prevent starting a cashup when there are no transactions at all
295
    unless ( $expected_amount != 0 ) {
295
    my $total_transactions = $self->outstanding_accountlines->total() * -1;
296
    unless ( $total_transactions != 0 ) {
296
        Koha::Exceptions::Object::BadValue->throw(
297
        Koha::Exceptions::Object::BadValue->throw(
297
            error => "Cannot start cashup with zero cash transactions",
298
            error => "Cannot start cashup with no transactions",
298
            type  => 'amount',
299
            type  => 'amount',
299
            value => $expected_amount
300
            value => $total_transactions
300
        );
301
        );
301
    }
302
    }
302
303
Lines 345-354 sub add_cashup { Link Here
345
    }
346
    }
346
    my $manager_id = $params->{manager_id};
347
    my $manager_id = $params->{manager_id};
347
348
348
    # Validate amount is a non-zero number
349
    # Validate amount is a valid number
349
    my $amount = $params->{amount};
350
    my $amount = $params->{amount};
350
    unless ( looks_like_number($amount) && $amount != 0 ) {
351
    unless ( looks_like_number($amount) ) {
351
        Koha::Exceptions::Account::AmountNotPositive->throw( error => 'Cashup amount must be a non-zero number' );
352
        Koha::Exceptions::Account::AmountNotPositive->throw( error => 'Cashup amount must be a valid number' );
352
    }
353
    }
353
354
354
    # Sanitize reconciliation note - treat empty/whitespace-only as undef
355
    # Sanitize reconciliation note - treat empty/whitespace-only as undef
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt (-4 / +4 lines)
Lines 57-63 Link Here
57
        [% END %]
57
        [% END %]
58
58
59
        [% IF ( error_cashup_no_transactions ) %]
59
        [% IF ( error_cashup_no_transactions ) %]
60
            <div id="error_message" class="alert alert-info"> Cannot start cashup - there are no cash transactions in this register since the last cashup. </div>
60
            <div id="error_message" class="alert alert-info"> Cannot start cashup - there are no transactions in this register since the last cashup. </div>
61
        [% END %]
61
        [% END %]
62
62
63
        [% IF ( error_no_cashup_start ) %]
63
        [% IF ( error_no_cashup_start ) %]
Lines 77-83 Link Here
77
        [% END %]
77
        [% END %]
78
78
79
        [% IF ( error_cashup_amount_invalid ) %]
79
        [% IF ( error_cashup_amount_invalid ) %]
80
            <div id="error_message" class="alert alert-warning"> The cashup amount must be a positive number greater than zero. </div>
80
            <div id="error_message" class="alert alert-warning"> The cashup amount must be a valid number. </div>
81
        [% END %]
81
        [% END %]
82
82
83
        [% IF ( error_reconciliation_note_required ) %]
83
        [% IF ( error_reconciliation_note_required ) %]
Lines 109-120 Link Here
109
        [% END %]
109
        [% END %]
110
110
111
        [% SET total_bankable = accountlines.total( payment_type => [ 'CASH', 'SIP00' ]) * -1 %]
111
        [% SET total_bankable = accountlines.total( payment_type => [ 'CASH', 'SIP00' ]) * -1 %]
112
        [% SET total_transactions = accountlines.total() * -1 %]
112
        [% IF ( CAN_user_cash_management_cashup ) %]
113
        [% IF ( CAN_user_cash_management_cashup ) %]
113
            <div id="toolbar" class="btn-toolbar">
114
            <div id="toolbar" class="btn-toolbar">
114
                [% IF cashup_in_progress %]
115
                [% IF cashup_in_progress %]
115
                    <button id="pos_complete_cashup" type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#confirmCashupModal"> <i class="fa-solid fa-check"></i> Complete cashup </button>
116
                    <button id="pos_complete_cashup" type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#confirmCashupModal"> <i class="fa-solid fa-check"></i> Complete cashup </button>
116
                [% ELSE %]
117
                [% ELSE %]
117
                    <button type="button" class="btn btn-default" data-bs-toggle="modal" data-bs-target="#triggerCashupModal" [% IF total_bankable == 0 %]disabled title="No bankable transactions"[% END %]>
118
                    <button type="button" class="btn btn-default" data-bs-toggle="modal" data-bs-target="#triggerCashupModal" [% IF total_transactions == 0 %]disabled title="No transactions"[% END %]>
118
                        <i class="fa fa-money-bill-alt"></i> Record cashup
119
                        <i class="fa fa-money-bill-alt"></i> Record cashup
119
                    </button>
120
                    </button>
120
                [% END %]
121
                [% END %]
121
- 

Return to bug 40445