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

(-)a/Koha/REST/V1/CashRegisters/Cashups.pm (+16 lines)
Lines 63-70 sub get { Link Here
63
    my $c = shift->openapi->valid_input or return;
63
    my $c = shift->openapi->valid_input or return;
64
64
65
    return try {
65
    return try {
66
67
        # Try to find as a completed cashup first
66
        my $cashup = Koha::Cash::Register::Cashups->find( $c->param('cashup_id') );
68
        my $cashup = Koha::Cash::Register::Cashups->find( $c->param('cashup_id') );
67
69
70
        # If not found, try as a CASHUP_START action (for preview)
71
        unless ($cashup) {
72
            require Koha::Cash::Register::Actions;
73
            my $action = Koha::Cash::Register::Actions->find( $c->param('cashup_id') );
74
75
            # Only allow CASHUP_START actions for preview
76
            if ( $action && $action->code eq 'CASHUP_START' ) {
77
78
                # Wrap as Cashup object for summary generation
79
                require Koha::Cash::Register::Cashup;
80
                $cashup = Koha::Cash::Register::Cashup->_new_from_dbic( $action->_result );
81
            }
82
        }
83
68
        return $c->render_resource_not_found("Cashup")
84
        return $c->render_resource_not_found("Cashup")
69
            unless $cashup;
85
            unless $cashup;
70
86
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt (-1 / +5 lines)
Lines 96-102 Link Here
96
        [% IF cashup_in_progress %]
96
        [% IF cashup_in_progress %]
97
            <div class="alert alert-warning">
97
            <div class="alert alert-warning">
98
                <i class="fa-solid fa-info-circle"></i>
98
                <i class="fa-solid fa-info-circle"></i>
99
                Cashup in progress - started [% cashup_in_progress.timestamp | $KohaDates with_hours => 1 %]. You can continue to make transactions while counting cash.
99
                [% SET progress_timestamp = cashup_in_progress.timestamp | $KohaDates(with_hours => 1) %]
100
                [% tx("Cashup in progress - started {timestamp}. You can continue to make transactions while counting cash.", { timestamp = progress_timestamp }) | html %]
101
                (<a data-bs-toggle="modal" data-cashup="[% cashup_in_progress.id | html %]" data-register="[% register.description | html %]" data-in-progress="true" href="#cashupSummaryModal" class="button"
102
                    >[% t("Preview cashup summary") | html %]</a
103
                >)
100
            </div>
104
            </div>
101
        [% END %]
105
        [% END %]
102
106
(-)a/koha-tmpl/intranet-tmpl/prog/js/cashup_modal.js (-7 / +46 lines)
Lines 3-9 $(document).ready(function () { Link Here
3
        var button = $(e.relatedTarget);
3
        var button = $(e.relatedTarget);
4
        var cashup = button.data("cashup");
4
        var cashup = button.data("cashup");
5
        var description = button.data("register");
5
        var description = button.data("register");
6
        var inProgress = button.data("in-progress") || false;
6
        var summary_modal = $(this);
7
        var summary_modal = $(this);
8
9
        // Update title based on whether this is a preview
10
        if (inProgress) {
11
            summary_modal
12
                .find("#cashupSummaryLabel")
13
                .text(__("Cashup summary preview"));
14
        } else {
15
            summary_modal
16
                .find("#cashupSummaryLabel")
17
                .text(__("Cashup summary"));
18
        }
19
7
        summary_modal.find("#register_description").text(description);
20
        summary_modal.find("#register_description").text(description);
8
        $.ajax({
21
        $.ajax({
9
            url: "/api/v1/cashups/" + cashup,
22
            url: "/api/v1/cashups/" + cashup,
Lines 17-22 $(document).ready(function () { Link Here
17
                let to_date = $datetime(data.summary.to_date);
30
                let to_date = $datetime(data.summary.to_date);
18
                summary_modal.find("#to_date").text(to_date);
31
                summary_modal.find("#to_date").text(to_date);
19
32
33
                // Add preview notice if this is an in-progress cashup
34
                if (inProgress) {
35
                    var previewNotice = summary_modal.find(".preview-notice");
36
                    if (previewNotice.length === 0) {
37
                        summary_modal
38
                            .find(".modal-body > ul")
39
                            .before(
40
                                '<div class="alert alert-info preview-notice">' +
41
                                    '<i class="fa-solid fa-info-circle"></i> ' +
42
                                    "<strong>" +
43
                                    __("Preview:") +
44
                                    "</strong> " +
45
                                    __(
46
                                        "This summary shows the expected cashup amounts. A reconciliation record may be added when you complete the cashup."
47
                                    ) +
48
                                    "</div>"
49
                            );
50
                    }
51
                } else {
52
                    summary_modal.find(".preview-notice").remove();
53
                }
54
20
                // Check for reconciliation (surplus or deficit) from dedicated fields
55
                // Check for reconciliation (surplus or deficit) from dedicated fields
21
                var surplus = data.summary.surplus_total;
56
                var surplus = data.summary.surplus_total;
22
                var deficit = data.summary.deficit_total;
57
                var deficit = data.summary.deficit_total;
Lines 71-77 $(document).ready(function () { Link Here
71
106
72
                // 1. Total (sum of all transactions)
107
                // 1. Total (sum of all transactions)
73
                tfoot.append(
108
                tfoot.append(
74
                    "<tr class='total-row'><td><strong>Total</strong></td><td><strong>" +
109
                    "<tr class='total-row'><td><strong>" +
110
                        __("Total") +
111
                        "</strong></td><td><strong>" +
75
                        data.summary.total.format_price() +
112
                        data.summary.total.format_price() +
76
                        "</strong></td></tr>"
113
                        "</strong></td></tr>"
77
                );
114
                );
Lines 94-100 $(document).ready(function () { Link Here
94
                }
131
                }
95
                if (cashCollected !== null) {
132
                if (cashCollected !== null) {
96
                    tfoot.append(
133
                    tfoot.append(
97
                        "<tr><td><strong>Cash collected</strong></td><td><strong>" +
134
                        "<tr><td><strong>" +
135
                            __("Cash collected") +
136
                            "</strong></td><td><strong>" +
98
                            cashCollected.format_price() +
137
                            cashCollected.format_price() +
99
                            "</strong></td></tr>"
138
                            "</strong></td></tr>"
100
                    );
139
                    );
Lines 109-116 $(document).ready(function () { Link Here
109
                    ) {
148
                    ) {
110
                        tfoot.append(
149
                        tfoot.append(
111
                            "<tr><td><strong>" +
150
                            "<tr><td><strong>" +
112
                                escape_str(type.payment_type) +
151
                                __x("{payment_type} collected", {
113
                                " collected" +
152
                                    payment_type: escape_str(type.payment_type),
153
                                }) +
114
                                "</strong></td><td><strong>" +
154
                                "</strong></td><td><strong>" +
115
                                type.total.format_price() +
155
                                type.total.format_price() +
116
                                "</strong></td></tr>"
156
                                "</strong></td></tr>"
Lines 133-146 $(document).ready(function () { Link Here
133
                    if (surplus) {
173
                    if (surplus) {
134
                        reconciliationClass =
174
                        reconciliationClass =
135
                            "reconciliation-result text-warning";
175
                            "reconciliation-result text-warning";
136
                        reconciliationLabel = "Cashup surplus";
176
                        reconciliationLabel = __("Cashup surplus");
137
                        reconciliationAmount =
177
                        reconciliationAmount =
138
                            "+" + Math.abs(surplus).format_price();
178
                            "+" + Math.abs(surplus).format_price();
139
                        reconciliationNote = data.summary.surplus_note;
179
                        reconciliationNote = data.summary.surplus_note;
140
                    } else if (deficit) {
180
                    } else if (deficit) {
141
                        reconciliationClass =
181
                        reconciliationClass =
142
                            "reconciliation-result text-danger";
182
                            "reconciliation-result text-danger";
143
                        reconciliationLabel = "Cashup deficit";
183
                        reconciliationLabel = __("Cashup deficit");
144
                        reconciliationAmount =
184
                        reconciliationAmount =
145
                            "-" + Math.abs(deficit).format_price();
185
                            "-" + Math.abs(deficit).format_price();
146
                        reconciliationNote = data.summary.deficit_note;
186
                        reconciliationNote = data.summary.deficit_note;
147
- 

Return to bug 40445