Koha Solutions knowledge base: run log of a live check Article https://kohasolutions.com/knowledge-base/koha-checkout-refused Check scripts/kb/live/koha-checkout-refused.mjs (SHA-256 23716a26be30a4ed7b489aedeacd55f8ba9c5b8c92569a9a5febd01c67513d23) Ran 2026-11-05T15:12:07Z (UTC), 57 s Koha 26.05.02 (Koha::version 26.05.02.002, database version 26.0600002) Source https://git.koha-community.org/Koha-community/Koha/src/commit/d3fc229bc5eaea25dfe88f86149386408fe5d32d System Debian GNU/Linux 13 (trixie) Result PASS: all 26 claims held Each claim is something the article says. "seen" is what the check read back when it is not just a yes/no. Changes the check made to the test server were undone afterwards, as its header describes. == Claims == ok test record with KBVERIFYR1 (BK), KBVERIFYR2 (not for loan) and KBVERIFYR3 (item type not for loan) seen: 2578 ok sysprefs.sql: AllowTooManyOverride '1' and ConsiderOnSiteCheckoutsAsNormalCheckouts '1' on a new Koha seen: ('AllowTooManyOverride','1'), ('ConsiderOnSiteCheckoutsAsNormalCheckouts','1'), ok sysprefs.sql: CircControl 'ItemHomeLibrary', AllowFineOverride '0', AllowNotForLoanOverride '0' ok rule maxissueqty 0, AllowTooManyOverride Allow → "Please confirm checkout" with "Too many checked out. 0 checked out, only 0 are allowed." seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Check in | Renew | Search catalog | Home | Circulation | Checkouts | Reset Test (KBRESET1) | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Check out | Please confirm checkout | Too many checked out. 0 checked out, only 0 are allowed. | Maximum checkouts calculated from the circulation rule for | Item type: Books | Patron category: Patron | Library: Centerville | This patron can't check out this item per library circulation policy. | Remember for the session for this patron | Yes, check out (Y) | No, don't check out (N) | Checking out to Reset Test (KBRESET1) | Check out | Messages | Add a new message | Checkouts | Holds | Bookings | Claims | Restrictions | Patron lists | Patron has nothing checked out. | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:11 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions ok …plus "This patron can't check out this item per library circulation policy." ok …a line naming the rule used: "Maximum checkouts calculated from the circulation rule for …" seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Check in | Renew | Search catalog | Home | Circulation | Checkouts | Reset Test (KBRESET1) | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Check out | Please confirm checkout | Too many checked out. 0 checked out, only 0 are allowed. | Maximum checkouts calculated from the circulation rule for | Item type: Books | Patron category: Patron | Library: Centerville | This patron can't check out this item per library circulation policy. | Remember for the session for this patron | Yes, check out (Y) | No, don't check out (N) | Checking out to Reset Test (KBRESET1) | Check out | Messages | Add a new message | Checkouts | Holds | Bookings | Claims | Restrictions | Patron lists | Patron has nothing checked out. | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:11 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions ok …and nothing is lent until staff confirm ok AllowTooManyOverride Don't allow → refused, and the message loses its numbers: "Too many checked out. checked out, only are allowed." seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Check in | Renew | Search catalog | Home | Circulation | Checkouts | Reset Test (KBRESET1) | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Check out | Too many checked out. checked out, only are allowed. | Maximum checkouts calculated from the circulation rule for | Item type: All item types | Patron category: All patron categories | Library: All libraries | Checking out to Reset Test (KBRESET1) | Check out | Messages | Add a new message | Checkouts | Holds | Bookings | Claims | Restrictions | Patron lists | Patron has nothing checked out. | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:11 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions ok no maxissueqty rule anywhere → CanBookBeIssued says NO_RULE_DEFINED (rolled back afterwards) seen: NO_RULE_DEFINED| ok …which the checkout screen shows as "No circulation rule is defined for this patron and itemtype combination." ok live maxissueqty rules are all still there after the rollback ok an item type marked not for loan → "Item type not for loan." seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Check in | Renew | Search catalog | Home | Circulation | Checkouts | Reset Test (KBRESET1) | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Check out | Item type not for loan. | Checking out to Reset Test (KBRESET1) | Check out | Messages | Add a new message | Checkouts | Holds | Bookings | Claims | Restrictions | Patron lists | Patron has nothing checked out. | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:11 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions ok a copy with a not-for-loan status → "Item not for loan(Not for loan)." (no space before the bracket) seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Check in | Renew | Search catalog | Home | Circulation | Checkouts | Reset Test (KBRESET1) | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Check out | Item not for loan(Not for loan). | Checking out to Reset Test (KBRESET1) | Check out | Messages | Add a new message | Checkouts | Holds | Bookings | Claims | Restrictions | Patron lists | Patron has nothing checked out. | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:11 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions ok AllowNotForLoanOverride Allow → it asks instead ("Please confirm checkout") seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Check in | Renew | Search catalog | Home | Circulation | Checkouts | Reset Test (KBRESET1) | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Check out | Please confirm checkout | Item is normally not for loan(Not for loan). Check out anyway? | Remember for the session for this patron | Yes, check out (Y) | No, don't check out (N) | Checking out to Reset Test (KBRESET1) | Check out | Messages | Add a new message | Checkouts | Holds | Bookings | Claims | Restrictions | Patron lists | Patron has nothing checked out. | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:11 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions ok expired card → "Patron's card has expired." on the checkout screen, with a Renew link seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Check in | Renew | Search catalog | Home | Circulation | Checkouts | Reset Test (KBRESET1) | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Check out | Checking out to Reset Test (KBRESET1) | Cannot check out! | Attention | Expiration: Patron's card has expired. Patron's card expired on 11/03/2026 Renew or Edit details | Override restriction temporarily | Messages | Add a new message | Checkouts | Holds | Bookings | Claims | Restrictions | Patron lists | Patron has nothing checked out. | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:12 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions ok …and the checkout box is gone ("Cannot check out!") seen: barcode box: false ok after "Override restriction temporarily", scanning a book → "Patron's card is expired" seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Check in | Renew | Search catalog | Home | Circulation | Checkouts | Reset Test (KBRESET1) | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Check out | Patron's card is expired | Restriction overridden temporarily. | Checking out to Reset Test (KBRESET1) | Check out | Checked out: Kbverify refused test (KBVERIFYR1). Due on 11/10/2026 | Attention | Expiration: Patron's card has expired. Patron's card expired on 11/03/2026 Renew or Edit details | Messages | Add a new message | Checkouts | 1 | Holds | Bookings | Claims | Restrictions | Patron lists | Show checkouts | Always show checkouts automatically | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:12 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions | on loan: 1 ok owing 10.00 with noissuescharge 10: no block (only GREATER than the limit blocks) ok owing 10.00 with noissuescharge 5 → "Cannot check out!" and "Charges: Patron has outstanding charges of 10.00.", no checkout box seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Check in | Renew | Search catalog | Home | Circulation | Checkouts | Reset Test (KBRESET1) | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Check out | Checking out to Reset Test (KBRESET1) | Cannot check out! | Attention | Charges: Patron has outstanding charges of 10.00. Make payment Pay all charges | Override restriction temporarily | Messages | Add a new message | Checkouts | Holds | Bookings | Claims | Restrictions | Patron lists | Patron has nothing checked out. | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:12 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions ok …and NOT "Checkouts are BLOCKED because fine balance is OVER THE LIMIT." (26.05 never prints it for the patron's own charges) ok …because blocked-fines.inc tests NoIssuesCharge.limit / .overlimit, and patron_messages.inc passes it a plain amount (NoIssuesCharge = chargesamount) ok AllowFineOverride Allow → "The patron has a debt of …" and a confirm box seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Check in | Renew | Search catalog | Home | Circulation | Checkouts | Reset Test (KBRESET1) | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Check out | Please confirm checkout | The patron has a debt of 10.00. | Remember for the session for this patron | Yes, check out (Y) | No, don't check out (N) | Checking out to Reset Test (KBRESET1) | Check out | Attention | Charges: Patron has outstanding charges of 10.00. Make payment Pay all charges | Messages | Add a new message | Checkouts | Holds | Bookings | Claims | Restrictions | Patron lists | Patron has nothing checked out. | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:12 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions ok an indefinite restriction → "Account restricted since …" / "Indefinite restriction", no checkout box seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Check in | Renew | Search catalog | Home | Circulation | Checkouts | Reset Test (KBRESET1) | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Check out | Checking out to Reset Test (KBRESET1) | Cannot check out! | Attention | Account restricted since 11/05/2026 | Indefinite restriction kbverify (Manual restriction) | View restrictions | Override restriction temporarily | Messages | Add a new message | Checkouts | Holds | Bookings | Claims | Restrictions | 1 | Patron lists | Patron has nothing checked out. | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:12 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions ok …overridden and scanned → "Patron is restricted" / "Patron has an indefinite restriction." seen: Circulation | Patrons | Search | More | koha Centerville | | Check out | Check out | Check in | Renew | Search catalog | Home | Circulation | Checkouts | Reset Test (KBRESET1) | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Check out | Patron is restricted | Patron has an indefinite restriction. | Restriction overridden temporarily. | Checking out to Reset Test (KBRESET1) | Check out | Checked out: Kbverify refused test (KBVERIFYR1). Due on 11/10/2026 | Attention | Account restricted since 11/05/2026 | Indefinite restriction kbverify (Manual restriction) | View restrictions | Messages | Add a new message | Checkouts | 1 | Holds | Bookings | Claims | Restrictions | 1 | Patron lists | Show checkouts | Always show checkouts automatically | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:12 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions | on loan: 1 ok the patron page has a "Restrictions" tab with a "Remove" button (superlibrarian) seen: tab 1 Circulation | Patrons | Search | More | koha Centerville | | Search patrons | Search patrons | Check out | Check in | Renew | Search catalog | Home | Patrons | Reset Test (KBRESET1) | Details | Help | Edit | Add guarantee | Change password | Duplicate | Print | Search to hold | Add message | More | Attention | Account restricted since 11/05/2026 | Indefinite restriction kbverify (Manual restriction) | View restrictions | Reset Test (KBRESET1) | Contact information | Edit | First name: Reset | Surname: Test | Primary email: kbreset1@example.org | Show checkouts to guarantor: No | Show charges to guarantor: No | Additional attributes and identifiers | Add | Patron messaging preferences | Edit | Days in advance Email Digests only | Hold filled - | Hold reminder - - | Item checkout - - | Auto renewal - | Advance notice | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | | Item due - | Item check-in - - | Library use | Edit | Card number: KBRESET1 | Borrowernumber: 3699 | Category: Patron (PT) | Registration date: 11/05/2026 | Expiration date: 11/05/2027 | Library: Centerville | Username: kbreset1 | Password: ******* | Password expires: Never | Protected: No | Address in doubt: No | Card lost: No | Alternate address | Add | Alternative contact | Add | Checkouts | Holds | Bookings | Claims | Restrictions | 1 | Patron lists | Type Comment Expiration Created   | Manual restriction kbverify Indefinite 11/05/2026 Remove | Add manual restriction | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:12 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions ok with every block removed the same book checks out ("Checked out:") seen: More | Check out | Checking out to Reset Test (KBRESET1) | Check out | Checked out: Kbverify refused test (KBVERIFYR1). Due on 11/10/2026 | Messages | Add a new message | Checkouts | 1 | Holds | Bookings | Claims | Restrictions | Patron lists | Show checkouts | Always show checkouts automatically | Reset Test (KBRESET1) | kbreset1@example.org | No address stored. | No city stored. | No phone stored. | No date of birth stored. | Category: Patron (PT) | Home library: Centerville | Borrowernumber: 3699 | Updated on: 11/05/2026 15:12 | Check out | Details | Accounting | Routing lists | Circulation history | Holds history | Modification log | Notices | Statistics | Purchase suggestions == The check that produced this log (scripts/kb/live/koha-checkout-refused.mjs) == /** * Live check for prisma/ks-kb/39-koha-checkout-refused.ts. On live Koha, with the shared throwaway patron (PT, CPL) * and a record "Kbverify refused test" with three items: KBVERIFYR1 (BK), KBVERIFYR2 (BK, notforloan 1) and * KBVERIFYR3 (a temporary item type KBVNFL marked not for loan). Each refusal is produced on the checkout screen: * a temporary maxissueqty 0 rule (CPL / PT / BK) with AllowTooManyOverride on and off, the two not-for-loan cases, * an expired card, a 10.00 charge against noissuescharge 10 and 5, and an indefinite restriction. "No circulation * rule" is run through CanBookBeIssued inside a transaction that deletes the maxissueqty rules and is rolled back, * so live rules are never touched. Undone: rule, item type, charge, restriction, expiry date, record and items, prefs. */ export const meta = { koha: '26.05.02', passed: '2026-11-05' } const TITLE = 'Kbverify refused test' const R1 = 'KBVERIFYR1' const R2 = 'KBVERIFYR2' const R3 = 'KBVERIFYR3' const NFL = 'KBVNFL' export default async function run(ctx) { const I = ctx.INSTANCE const pid = ctx.patron() const perl = (code) => { ctx.sh(`cat > /tmp/kbv-cr.pl <<'PL'\n${code}\nPL\nchmod 644 /tmp/kbv-cr.pl`) return ctx.sh(`koha-shell ${I} -c "perl /tmp/kbv-cr.pl" 2>&1; rm -f /tmp/kbv-cr.pl`).out.trim().split('\n').pop() } const env = `use C4::Context; use Koha::Patrons; C4::Context->set_userenv(51, 'koha', '', 'Koha', 'Admin', 'CPL', 'CPL', 1);` const oldExpiry = ctx.sqlValue(`SELECT dateexpiry FROM borrowers WHERE borrowernumber = ${pid}`) const firstLine = Number(ctx.sqlValue('SELECT COALESCE(MAX(accountlines_id), 0) FROM accountlines')) ctx.sql(`INSERT INTO itemtypes (itemtype, description, notforloan) VALUES ('${NFL}', 'Kbverify not for loan', 1)`) ctx.restore('remove the temporary item type', () => ctx.sql(`DELETE FROM itemtypes WHERE itemtype = '${NFL}'`)) const bn = Number(perl(`use C4::Biblio qw(AddBiblio); use MARC::Record; use Koha::Item; my $r = MARC::Record->new; $r->leader(' nam a22 7a 4500'); $r->append_fields(MARC::Field->new('245','1','0','a'=>'${TITLE}')); my ($bn) = AddBiblio($r, ''); Koha::Item->new({ biblionumber => $bn, homebranch => 'CPL', holdingbranch => 'CPL', barcode => '${R1}', itype => 'BK' })->store; Koha::Item->new({ biblionumber => $bn, homebranch => 'CPL', holdingbranch => 'CPL', barcode => '${R2}', itype => 'BK', notforloan => 1 })->store; Koha::Item->new({ biblionumber => $bn, homebranch => 'CPL', holdingbranch => 'CPL', barcode => '${R3}', itype => '${NFL}' })->store; print "$bn\\n";`)) ctx.restore('remove charges, restriction and the Kbverify record; expiry date back', () => { ctx.sql(`DELETE FROM account_offsets WHERE debit_id > ${firstLine} OR credit_id > ${firstLine}`) ctx.sql(`DELETE FROM accountlines WHERE accountlines_id > ${firstLine} AND borrowernumber = ${pid}`) ctx.sql(`DELETE FROM borrower_debarments WHERE borrowernumber = ${pid} AND comment = 'kbverify'`) ctx.sql(`UPDATE borrowers SET debarred = NULL, debarredcomment = NULL, dateexpiry = ${oldExpiry ? `'${oldExpiry}'` : 'NULL'} WHERE borrowernumber = ${pid}`) perl(`${env} use C4::Circulation qw(AddReturn); AddReturn('${R1}', 'CPL'); use C4::Biblio qw(DelBiblio); my $b = Koha::Biblios->find(${bn}); $_->delete for $b ? $b->items->as_list : (); DelBiblio(${bn}); print "ok\\n";`) }) ctx.check('test record with KBVERIFYR1 (BK), KBVERIFYR2 (not for loan) and KBVERIFYR3 (item type not for loan)', bn > 0, bn) const staff = await ctx.newPage() await ctx.staffLogin(staff) const open = async (force = false) => { await staff.goto(`${ctx.STAFF}/cgi-bin/koha/circ/circulation.pl?borrowernumber=${pid}${force ? '&forceallow=1' : ''}`) return ctx.pageText(staff) } const box = async () => (await staff.locator('#barcode').count()) > 0 const scan = async (bc, force = false) => { await open(force) await staff.fill('#barcode', bc) await staff.locator('#barcode').press('Enter') await staff.waitForLoadState() return ctx.pageText(staff) } const line = (t, re) => (t.match(new RegExp(`[^\\n]*${re}[^\\n]*`)) ?? [''])[0] const giveBack = () => perl(`${env} use C4::Circulation qw(AddReturn); AddReturn('${R1}', 'CPL'); print "ok\\n";`) const onLoan = () => ctx.sqlValue(`SELECT COUNT(*) FROM issues WHERE itemnumber = (SELECT itemnumber FROM items WHERE barcode = '${R1}')`) // The shipped defaults the article names. const src = (p) => ctx.sh(`grep -E "^\\('${p}'," /kohadevbox/koha/installer/data/mysql/mandatory/sysprefs.sql`).out ctx.check("sysprefs.sql: AllowTooManyOverride '1' and ConsiderOnSiteCheckoutsAsNormalCheckouts '1' on a new Koha", src('AllowTooManyOverride').includes("'1'") && src('ConsiderOnSiteCheckoutsAsNormalCheckouts').includes("'1'"), `${src('AllowTooManyOverride')} ${src('ConsiderOnSiteCheckoutsAsNormalCheckouts')}`) ctx.check("sysprefs.sql: CircControl 'ItemHomeLibrary', AllowFineOverride '0', AllowNotForLoanOverride '0'", src('CircControl').includes("'ItemHomeLibrary'") && src('AllowFineOverride').includes("'0'") && src('AllowNotForLoanOverride').includes("'0'")) // 1. maxissueqty 0. ctx.sql("INSERT INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value) VALUES ('CPL','PT','BK','maxissueqty','0')") ctx.flushCaches() ctx.restore('remove the temporary maxissueqty rule', () => { ctx.sql("DELETE FROM circulation_rules WHERE branchcode = 'CPL' AND categorycode = 'PT' AND itemtype = 'BK' AND rule_name = 'maxissueqty'"); ctx.flushCaches() }) ctx.setPref('AllowTooManyOverride', '1') let t = await scan(R1) ctx.check('rule maxissueqty 0, AllowTooManyOverride Allow → "Please confirm checkout" with "Too many checked out. 0 checked out, only 0 are allowed."', t.includes('Please confirm checkout') && t.includes('Too many checked out. 0 checked out, only 0 are allowed.'), line(t, 'Too many checked out')) ctx.check('…plus "This patron can\'t check out this item per library circulation policy."', t.includes("This patron can't check out this item per library circulation policy.")) ctx.check('…a line naming the rule used: "Maximum checkouts calculated from the circulation rule for …"', t.includes('Maximum checkouts calculated from the circulation rule for'), line(t, 'Maximum checkouts calculated')) ctx.check('…and nothing is lent until staff confirm', onLoan() === '0') ctx.setPref('AllowTooManyOverride', '0') t = await scan(R1) ctx.check("AllowTooManyOverride Don't allow → refused, and the message loses its numbers: \"Too many checked out. checked out, only are allowed.\"", t.includes('Too many checked out. checked out, only are allowed.') && !t.includes('Please confirm checkout') && onLoan() === '0', line(t, 'Too many checked out')) // 2. No rule at all (in a transaction that is rolled back). const nr = perl(`${env} use Koha::Database; use C4::Circulation qw(CanBookBeIssued); use Koha::Items; my $s = Koha::Database->schema; $s->txn_begin; $s->resultset('CirculationRule')->search({ rule_name => [qw(maxissueqty patron_maxissueqty)] })->delete; my ($imp, $conf) = CanBookBeIssued(Koha::Patrons->find(${pid}), '${R1}'); $s->txn_rollback; print $imp->{TOO_MANY} // '', '|', $conf->{TOO_MANY} // '', "\\n";`) ctx.check('no maxissueqty rule anywhere → CanBookBeIssued says NO_RULE_DEFINED (rolled back afterwards)', nr.split('|').includes('NO_RULE_DEFINED'), nr) ctx.check('…which the checkout screen shows as "No circulation rule is defined for this patron and itemtype combination."', ctx.sh("grep -c 'No circulation rule is defined for this patron and itemtype combination.' /kohadevbox/koha/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt").out !== '0') ctx.check('live maxissueqty rules are all still there after the rollback', Number(ctx.sqlValue("SELECT COUNT(*) FROM circulation_rules WHERE rule_name = 'maxissueqty'")) > 0) ctx.sql("DELETE FROM circulation_rules WHERE branchcode = 'CPL' AND categorycode = 'PT' AND itemtype = 'BK' AND rule_name = 'maxissueqty'") ctx.flushCaches() // 3. Not for loan. t = await scan(R3) ctx.check('an item type marked not for loan → "Item type not for loan."', t.includes('Item type not for loan.'), line(t, 'not for loan')) t = await scan(R2) ctx.check('a copy with a not-for-loan status → "Item not for loan(Not for loan)." (no space before the bracket)', t.includes('Item not for loan(Not for loan).'), line(t, 'Item not for loan')) ctx.setPref('AllowNotForLoanOverride', '1') t = await scan(R2) ctx.check('AllowNotForLoanOverride Allow → it asks instead ("Please confirm checkout")', t.includes('Please confirm checkout') && /not for loan/i.test(t), line(t, 'not for loan')) ctx.setPref('AllowNotForLoanOverride', '0') // 4. Expired card. ctx.sql(`UPDATE borrowers SET dateexpiry = CURDATE() - INTERVAL 2 DAY WHERE borrowernumber = ${pid}`) t = await open() ctx.check('expired card → "Patron\'s card has expired." on the checkout screen, with a Renew link', t.includes("Patron's card has expired.") && (await staff.locator('li.expired a, li.expired button').filter({ hasText: 'Renew' }).count()) > 0, line(t, 'card has expired')) ctx.check('…and the checkout box is gone ("Cannot check out!")', !(await box()) && t.includes('Cannot check out!'), `barcode box: ${await box()}`) t = await scan(R1, true) ctx.check('after "Override restriction temporarily", scanning a book → "Patron\'s card is expired"', t.includes("Patron's card is expired"), line(t, 'card is expired') + ` | on loan: ${onLoan()}`) giveBack() ctx.sql(`UPDATE borrowers SET dateexpiry = CURDATE() + INTERVAL 1 YEAR WHERE borrowernumber = ${pid}`) // 5. Fines over the limit. perl(`use Koha::Patrons; Koha::Patrons->find(${pid})->account->add_debit({ amount => 10, type => 'MANUAL', interface => 'intranet', description => 'kbverify' }); print "ok\\n";`) ctx.setPref('noissuescharge', '10') t = await open() ctx.check('owing 10.00 with noissuescharge 10: no block (only GREATER than the limit blocks)', !t.includes('Checkouts are BLOCKED because fine balance is OVER THE LIMIT.') && (await box())) ctx.setPref('noissuescharge', '5') t = await open() ctx.check('owing 10.00 with noissuescharge 5 → "Cannot check out!" and "Charges: Patron has outstanding charges of 10.00.", no checkout box', t.includes('Cannot check out!') && t.includes('Charges: Patron has outstanding charges of 10.00.') && !(await box()), line(t, 'Charges:')) ctx.check('…and NOT "Checkouts are BLOCKED because fine balance is OVER THE LIMIT." (26.05 never prints it for the patron\'s own charges)', !t.includes('OVER THE LIMIT')) const inc = ctx.sh("cat /kohadevbox/koha/koha-tmpl/intranet-tmpl/prog/en/includes/blocked-fines.inc; grep -n \"blocked-fines.inc\" /kohadevbox/koha/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc").out ctx.check('…because blocked-fines.inc tests NoIssuesCharge.limit / .overlimit, and patron_messages.inc passes it a plain amount (NoIssuesCharge = chargesamount)', inc.includes('NoIssuesCharge.limit && NoIssuesCharge.overlimit') && inc.includes("INCLUDE 'blocked-fines.inc' NoIssuesCharge = chargesamount")) ctx.setPref('AllowFineOverride', '1') t = await scan(R1) ctx.check('AllowFineOverride Allow → "The patron has a debt of …" and a confirm box', t.includes('The patron has a debt of') && t.includes('Please confirm checkout'), line(t, 'has a debt of')) ctx.setPref('AllowFineOverride', '0') ctx.sql(`DELETE FROM account_offsets WHERE debit_id > ${firstLine}`) ctx.sql(`DELETE FROM accountlines WHERE accountlines_id > ${firstLine} AND borrowernumber = ${pid}`) // 6. Restriction. perl(`use Koha::Patron::Debarments qw(AddDebarment); AddDebarment({ borrowernumber => ${pid}, type => 'MANUAL', comment => 'kbverify' }); print "ok\\n";`) t = await open() ctx.check('an indefinite restriction → "Account restricted since …" / "Indefinite restriction", no checkout box', t.includes('Account restricted since') && t.includes('Indefinite restriction') && !(await box()), line(t, 'restrict')) t = await scan(R1, true) ctx.check('…overridden and scanned → "Patron is restricted" / "Patron has an indefinite restriction."', t.includes('Patron is restricted') && t.includes('Patron has an indefinite restriction.'), line(t, 'Patron is restricted') + ` | on loan: ${onLoan()}`) giveBack() await staff.goto(`${ctx.STAFF}/cgi-bin/koha/members/moremember.pl?borrowernumber=${pid}`) await staff.locator('#reldebarments-tab').click() await staff.waitForTimeout(500) t = await ctx.pageText(staff) ctx.check('the patron page has a "Restrictions" tab with a "Remove" button (superlibrarian)', (await staff.locator('#reldebarments-tab').count()) > 0 && t.includes('Remove'), `tab ${await staff.locator('#reldebarments-tab').count()} ` + line(t, 'estriction')) ctx.sql(`DELETE FROM borrower_debarments WHERE borrowernumber = ${pid} AND comment = 'kbverify'`) ctx.sql(`UPDATE borrowers SET debarred = NULL, debarredcomment = NULL WHERE borrowernumber = ${pid}`) // 7. With every block gone, it lends. t = await scan(R1) ctx.check('with every block removed the same book checks out ("Checked out:")', t.includes('Checked out:') && onLoan() === '1', t.slice(t.lastIndexOf('More |'), t.lastIndexOf('More |') + 700)) }