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

(-)a/C4/Circulation.pm (-8 / +8 lines)
Lines 3243-3249 sub CanBookBeRenewed { Link Here
3243
        my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
3243
        my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
3244
        my $restricted               = $patron->is_debarred;
3244
        my $restricted               = $patron->is_debarred;
3245
        my $hasoverdues              = $patron->has_overdues;
3245
        my $hasoverdues              = $patron->has_overdues;
3246
        my $balance                  = $patron->account->balance;
3246
        my $account                  = $patron->account;
3247
        my $balance                  = $account->balance;
3248
        my $non_issues_charges       = $account->non_issues_charges;
3247
3249
3248
        if ( $restricted and $restrictionblockrenewing ) {
3250
        if ( $restricted and $restrictionblockrenewing ) {
3249
            return ( 0, 'restriction' );
3251
            return ( 0, 'restriction' );
Lines 3251-3257 sub CanBookBeRenewed { Link Here
3251
            || ( $issue->is_overdue and $overduesblockrenewing eq 'blockitem' ) )
3253
            || ( $issue->is_overdue and $overduesblockrenewing eq 'blockitem' ) )
3252
        {
3254
        {
3253
            return ( 0, 'overdue' );
3255
            return ( 0, 'overdue' );
3254
        } elsif ( $finesblockrenewing && $balance > $finesblockrenewing ) {
3256
        } elsif ( $finesblockrenewing && $non_issues_charges > $finesblockrenewing ) {
3255
            return ( 0, 'too_much_owing' );
3257
            return ( 0, 'too_much_owing' );
3256
        }
3258
        }
3257
3259
Lines 4988-4999 sub _CanBookBeAutoRenewed { Link Here
4988
    }
4990
    }
4989
4991
4990
    if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
4992
    if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
4991
        my $fine_no_renewals = C4::Context->preference("FineNoRenewals");
4993
        my $fine_no_renewals   = C4::Context->preference("FineNoRenewals");
4992
        my $amountoutstanding =
4994
        my $account            = $patron->account;
4993
            C4::Context->preference("OPACFineNoRenewalsIncludeCredits")
4995
        my $non_issues_charges = $account->non_issues_charges;
4994
            ? $patron->account->balance
4996
        if ( $non_issues_charges and $non_issues_charges > $fine_no_renewals ) {
4995
            : $patron->account->outstanding_debits->total_outstanding;
4996
        if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
4997
            return "auto_too_much_owing";
4997
            return "auto_too_much_owing";
4998
        }
4998
        }
4999
    }
4999
    }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (-15 / +33 lines)
Lines 36-42 Link Here
36
[% SET aside = Koha.Preference('CircSidebar') ? 'circ-nav' : '' %]
36
[% SET aside = Koha.Preference('CircSidebar') ? 'circ-nav' : '' %]
37
[% WRAPPER 'main-container.inc' aside=aside %]
37
[% WRAPPER 'main-container.inc' aside=aside %]
38
    [% IF error %]
38
    [% IF error %]
39
        <div class="alert alert-warning">
39
        <div class="dialog alert alert-warning">
40
            <h1>Cannot renew:</h1>
40
            <h1>Cannot renew:</h1>
41
41
42
            [% IF error == "no_item" %]
42
            [% IF error == "no_item" %]
Lines 128-153 Link Here
128
                [% END %]
128
                [% END %]
129
            [% ELSIF error == "auto_renew" or error == "auto_too_much_owing" %]
129
            [% ELSIF error == "auto_renew" or error == "auto_too_much_owing" %]
130
                <p>[% INCLUDE 'biblio-title.inc' biblio=item.biblio link = 1 %] ( [% item.barcode | html %] ) has been scheduled for automatic renewal. </p>
130
                <p>[% INCLUDE 'biblio-title.inc' biblio=item.biblio link = 1 %] ( [% item.barcode | html %] ) has been scheduled for automatic renewal. </p>
131
                [% SET override_limit = error == "auto_renew" ? "AUTO_RENEW" : "TOO_MUCH" %]
131
                [% IF error == "auto_too_much_owing" %]
132
132
                    [% IF balance %]
133
                [% IF Koha.Preference('AllowRenewalLimitOverride') %]
133
                        <ul>
134
                    <form method="post" action="/cgi-bin/koha/circ/renew.pl">
134
                            <li>The patron has a debt of [% balance | $Price %] and renewals are restricted at [% Koha.Preference('FineNoRenewals') | $Price %].</li>
135
                        [% INCLUDE 'csrf-token.inc' %]
135
                        </ul>
136
                        <input type="hidden" name="barcode" value="[% item.barcode | html %]" />
136
                    [% END %]
137
                        <input type="hidden" name="override_limit" value="[% override_limit | html %]" />
137
                    [% IF Koha.Preference('AllowFineOverrideRenewing') %]
138
                        <input type="hidden" name="op" value="cud-renew" />
138
                        <form method="post" action="/cgi-bin/koha/circ/renew.pl">
139
                        <button type="submit" class="btn btn-default approve"><i class="fa fa-check"></i> Override limit and renew</button>
139
                            [% INCLUDE 'csrf-token.inc' %]
140
                    </form>
140
                            <input type="hidden" name="barcode" value="[% item.barcode | html %]" />
141
                            <input type="hidden" name="override_debt" value="1" />
142
                            <input type="hidden" name="op" value="cud-renew" />
143
                            <button type="submit" class="btn btn-default approve"><i class="fa fa-check"></i> Override and renew</button>
144
                        </form>
145
                    [% END %]
146
                [% ELSE %]
147
                    [% SET override_limit = "AUTO_RENEW" %]
148
                    [% IF Koha.Preference('AllowRenewalLimitOverride') %]
149
                        <form method="post" action="/cgi-bin/koha/circ/renew.pl">
150
                            [% INCLUDE 'csrf-token.inc' %]
151
                            <input type="hidden" name="barcode" value="[% item.barcode | html %]" />
152
                            <input type="hidden" name="override_limit" value="[% override_limit | html %]" />
153
                            <input type="hidden" name="op" value="cud-renew" />
154
                            <button type="submit" class="btn btn-default approve"><i class="fa fa-check"></i> Override limit and renew</button>
155
                        </form>
156
                    [% END %]
141
                [% END %]
157
                [% END %]
142
            [% ELSIF error == "too_much_owing" %]
158
            [% ELSIF error == "too_much_owing" %]
143
                <li>The patron has a debt of [% balance | $Price %].</li>
159
                <ul>
160
                    <li>The patron has a debt of [% balance | $Price %] and renewals are restricted at [% Koha.Preference('FineNoRenewals') | $Price %].</li>
161
                </ul>
144
                [% IF Koha.Preference('AllowFineOverrideRenewing') %]
162
                [% IF Koha.Preference('AllowFineOverrideRenewing') %]
145
                    <form method="post" action="/cgi-bin/koha/circ/renew.pl">
163
                    <form method="post" action="/cgi-bin/koha/circ/renew.pl">
146
                        [% INCLUDE 'csrf-token.inc' %]
164
                        [% INCLUDE 'csrf-token.inc' %]
147
                        <input type="hidden" name="barcode" value="[% item.barcode | html %]" />
165
                        <input type="hidden" name="barcode" value="[% item.barcode | html %]" />
148
                        <input type="hidden" name="override_debt" value="1" />
166
                        <input type="hidden" name="override_debt" value="1" />
149
                        <input type="hidden" name="op" value="cud-renew" />
167
                        <input type="hidden" name="op" value="cud-renew" />
150
                        <button type="submit" class="approve"><i class="fa fa-check"></i>Renew checkout(s)</button>
168
                        <button type="submit" class="btn btn-default approve"><i class="fa fa-check"></i> Override and renew</button>
151
                    </form>
169
                    </form>
152
                [% END %]
170
                [% END %]
153
            [% ELSIF error == "on_reserve" %]
171
            [% ELSIF error == "on_reserve" %]
Lines 189-195 Link Here
189
    [% END %]
207
    [% END %]
190
208
191
    [% IF date_due %]
209
    [% IF date_due %]
192
        <div class="alert alert-info">
210
        <div class="dialog message alert alert-info">
193
            <h1>Item renewed:</h1>
211
            <h1>Item renewed:</h1>
194
            <p>
212
            <p>
195
                [% INCLUDE 'biblio-title.inc' biblio=item.biblio link = 1 %] (
213
                [% INCLUDE 'biblio-title.inc' biblio=item.biblio link = 1 %] (
Lines 219-225 Link Here
219
                        <input value="1" name="unseen" id="unseen" type="checkbox" />
237
                        <input value="1" name="unseen" id="unseen" type="checkbox" />
220
                    </div>
238
                    </div>
221
                [% ELSE %]
239
                [% ELSE %]
222
                    <input name="barcode" size="14" class="barcode focus" type="text" placeholder="Enter item barcode" />
240
                    <input name="barcode" id="barcode" size="14" class="barcode focus" type="text" placeholder="Enter item barcode" />
223
                [% END %]
241
                [% END %]
224
                <input type="hidden" name="op" value="cud-renew" />
242
                <input type="hidden" name="op" value="cud-renew" />
225
                <div id="show-circ-settings">
243
                <div id="show-circ-settings">
(-)a/t/cypress/integration/Circulation/FineNoRenewals_spec.ts (-32 / +25 lines)
Lines 13-24 describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => { Link Here
13
                patron = objects.patron;
13
                patron = objects.patron;
14
                checkout = objects.checkout;
14
                checkout = objects.checkout;
15
15
16
                // Set FineNoRenewals to 5
16
                // Disable auto_renew on the checkout to get too_much_owing error instead of auto_too_much_owing
17
                cy.task("query", {
17
                cy.task("query", {
18
                    sql: "UPDATE systempreferences SET value = ? WHERE variable = ?",
18
                    sql: "UPDATE issues SET auto_renew = 0 WHERE issue_id = ?",
19
                    values: ["5", "FineNoRenewals"],
19
                    values: [checkout.checkout_id],
20
                });
20
                });
21
21
22
                // Set FineNoRenewals to 5
23
                cy.set_syspref("FineNoRenewals", "5");
24
22
                // Add a fine of 10 to the patron (exceeds limit)
25
                // Add a fine of 10 to the patron (exceeds limit)
23
                fine_amount = 10;
26
                fine_amount = 10;
24
                cy.task("query", {
27
                cy.task("query", {
Lines 27-33 describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => { Link Here
27
                    values: [
30
                    values: [
28
                        patron.patron_id,
31
                        patron.patron_id,
29
                        fine_amount,
32
                        fine_amount,
30
                        objects.item.item_id,
33
                        objects.items[0].item_id,
31
                    ],
34
                    ],
32
                });
35
                });
33
36
Lines 40-62 describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => { Link Here
40
            cy.task("deleteSampleObjects", [this.testObjects]);
43
            cy.task("deleteSampleObjects", [this.testObjects]);
41
44
42
            // Reset system preferences
45
            // Reset system preferences
43
            cy.task("query", {
46
            cy.set_syspref("FineNoRenewals", "100");
44
                sql: "UPDATE systempreferences SET value = '100' WHERE variable = 'FineNoRenewals'",
47
            cy.set_syspref("AllowFineOverrideRenewing", "0");
45
            });
46
            cy.task("query", {
47
                sql: "UPDATE systempreferences SET value = '0' WHERE variable = 'AllowFineOverrideRenewing'",
48
            });
49
        });
48
        });
50
49
51
        it("should block renewal when patron has fines over FineNoRenewals limit", function () {
50
        it("should block renewal when patron has fines over FineNoRenewals limit", function () {
52
            const barcode = this.testObjects.item.barcode;
51
            const barcode = this.testObjects.items[0].external_id;
53
52
54
            // Visit renewal page
53
            // Visit renewal page
55
            cy.visit("/cgi-bin/koha/circ/renew.pl");
54
            cy.visit("/cgi-bin/koha/circ/renew.pl");
56
55
57
            // Enter barcode
56
            // Enter barcode
58
            cy.get("#barcode").type(barcode);
57
            cy.get("#barcode").type(barcode);
59
            cy.get("form").submit();
58
            cy.get("#barcode").closest("form").submit();
60
59
61
            // Should see error message about patron debt
60
            // Should see error message about patron debt
62
            cy.get(".dialog.alert").should("be.visible");
61
            cy.get(".dialog.alert").should("be.visible");
Lines 68-88 describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => { Link Here
68
67
69
        it("should show override button when AllowFineOverrideRenewing is enabled", function () {
68
        it("should show override button when AllowFineOverrideRenewing is enabled", function () {
70
            // Enable AllowFineOverrideRenewing
69
            // Enable AllowFineOverrideRenewing
71
            cy.task("query", {
70
            cy.set_syspref("AllowFineOverrideRenewing", "1");
72
                sql: "UPDATE systempreferences SET value = '1' WHERE variable = 'AllowFineOverrideRenewing'",
73
            });
74
71
75
            const barcode = this.testObjects.item.barcode;
72
            const barcode = this.testObjects.items[0].external_id;
76
73
77
            // Visit renewal page
74
            // Visit renewal page
78
            cy.visit("/cgi-bin/koha/circ/renew.pl");
75
            cy.visit("/cgi-bin/koha/circ/renew.pl");
79
76
80
            // Enter barcode
77
            // Enter barcode
81
            cy.get("#barcode").type(barcode);
78
            cy.get("#barcode").type(barcode);
82
            cy.get("form").submit();
79
            cy.get("#barcode").closest("form").submit();
83
80
84
            // Should see error message about patron debt
81
            // Should see error message about patron debt
85
            cy.get(".dialog.alert").should("be.visible");
82
            cy.get(".dialog.alert").should("be.visible");
83
86
            cy.get(".dialog.alert li").should(
84
            cy.get(".dialog.alert li").should(
87
                "contain",
85
                "contain",
88
                `The patron has a debt of`
86
                `The patron has a debt of`
Lines 94-117 describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => { Link Here
94
            );
92
            );
95
            cy.get('.dialog.alert form button[type="submit"].approve').should(
93
            cy.get('.dialog.alert form button[type="submit"].approve').should(
96
                "contain",
94
                "contain",
97
                "Renew checkout(s)"
95
                "Override and renew"
98
            );
96
            );
99
        });
97
        });
100
98
101
        it("should NOT show override button when AllowFineOverrideRenewing is disabled", function () {
99
        it("should NOT show override button when AllowFineOverrideRenewing is disabled", function () {
102
            // Ensure AllowFineOverrideRenewing is disabled
100
            // Ensure AllowFineOverrideRenewing is disabled
103
            cy.task("query", {
101
            cy.set_syspref("AllowFineOverrideRenewing", "0");
104
                sql: "UPDATE systempreferences SET value = '0' WHERE variable = 'AllowFineOverrideRenewing'",
105
            });
106
102
107
            const barcode = this.testObjects.item.barcode;
103
            const barcode = this.testObjects.items[0].external_id;
108
104
109
            // Visit renewal page
105
            // Visit renewal page
110
            cy.visit("/cgi-bin/koha/circ/renew.pl");
106
            cy.visit("/cgi-bin/koha/circ/renew.pl");
111
107
112
            // Enter barcode
108
            // Enter barcode
113
            cy.get("#barcode").type(barcode);
109
            cy.get("#barcode").type(barcode);
114
            cy.get("form").submit();
110
            cy.get("#barcode").closest("form").submit();
115
111
116
            // Should see error message about patron debt
112
            // Should see error message about patron debt
117
            cy.get(".dialog.alert").should("be.visible");
113
            cy.get(".dialog.alert").should("be.visible");
Lines 128-145 describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => { Link Here
128
124
129
        it("should allow renewal after override when AllowFineOverrideRenewing is enabled", function () {
125
        it("should allow renewal after override when AllowFineOverrideRenewing is enabled", function () {
130
            // Enable AllowFineOverrideRenewing
126
            // Enable AllowFineOverrideRenewing
131
            cy.task("query", {
127
            cy.set_syspref("AllowFineOverrideRenewing", "1");
132
                sql: "UPDATE systempreferences SET value = '1' WHERE variable = 'AllowFineOverrideRenewing'",
133
            });
134
128
135
            const barcode = this.testObjects.item.barcode;
129
            const barcode = this.testObjects.items[0].external_id;
136
130
137
            // Visit renewal page
131
            // Visit renewal page
138
            cy.visit("/cgi-bin/koha/circ/renew.pl");
132
            cy.visit("/cgi-bin/koha/circ/renew.pl");
139
133
140
            // Enter barcode
134
            // Enter barcode
141
            cy.get("#barcode").type(barcode);
135
            cy.get("#barcode").type(barcode);
142
            cy.get("form").submit();
136
            cy.get("#barcode").closest("form").submit();
143
137
144
            // Click override button
138
            // Click override button
145
            cy.get('.dialog.alert form button[type="submit"].approve').click();
139
            cy.get('.dialog.alert form button[type="submit"].approve').click();
Lines 160-176 describe("Circulation - FineNoRenewals and AllowFineOverrideRenewing", () => { Link Here
160
            cy.task("query", {
154
            cy.task("query", {
161
                sql: `INSERT INTO accountlines (borrowernumber, amountoutstanding, debit_type_code, status, interface, itemnumber)
155
                sql: `INSERT INTO accountlines (borrowernumber, amountoutstanding, debit_type_code, status, interface, itemnumber)
162
                      VALUES (?, 3.00, 'OVERDUE', 'UNRETURNED', 'test', ?)`,
156
                      VALUES (?, 3.00, 'OVERDUE', 'UNRETURNED', 'test', ?)`,
163
                values: [patron.patron_id, this.testObjects.item.item_id],
157
                values: [patron.patron_id, this.testObjects.items[0].item_id],
164
            });
158
            });
165
159
166
            const barcode = this.testObjects.item.barcode;
160
            const barcode = this.testObjects.items[0].external_id;
167
161
168
            // Visit renewal page
162
            // Visit renewal page
169
            cy.visit("/cgi-bin/koha/circ/renew.pl");
163
            cy.visit("/cgi-bin/koha/circ/renew.pl");
170
164
171
            // Enter barcode
165
            // Enter barcode
172
            cy.get("#barcode").type(barcode);
166
            cy.get("#barcode").type(barcode);
173
            cy.get("form").submit();
167
            cy.get("#barcode").closest("form").submit();
174
168
175
            // Should see success message (no error about fines)
169
            // Should see success message (no error about fines)
176
            cy.get(".dialog.message").should("be.visible");
170
            cy.get(".dialog.message").should("be.visible");
177
- 

Return to bug 23415