From 8a68a3cda742794e2a2d554b233316e20f94ff68 Mon Sep 17 00:00:00 2001 From: Andrii Nugged Date: Tue, 18 Aug 2026 11:47:28 +0300 Subject: [PATCH] Bug 42605: Preserve acquisition preference string values Bug 41563 converted AcqCreateItem and UniqueItemFields to booleans when adding them to Koha.prefs. Both preferences are strings: AcqCreateItem controls where items are created, while UniqueItemFields contains a pipe-separated list. When a basket inherits AcqCreateItem=ordering, the boolean value matches none of the receiving page branches and existing items are hidden. When items are created on receiving, the numeric UniqueItemFields value also fails when the page calls split(). Preserve both string values in Koha.prefs. Add a Cypress regression test which renders orderreceive.pl and verifies the values exposed to JavaScript. Test plan: Before applying the patch: 1. Set AcqCreateItem to "placing an order" and UniqueItemFields to "barcode". 2. Create a basket that inherits the system preference. Add an order with one item, close the basket, and start receiving it. 3. Confirm that the Items table has no existing item row and no Receive checkbox. 4. Set AcqCreateItem to "receiving an order" and open the same order for receiving. 5. Confirm that the Items section is empty: no item-entry fields and no Add item button are shown. Apply the patch. After applying the patch: 1. Set AcqCreateItem back to "placing an order" and open the order for receiving again. 2. Confirm that its existing item is listed and has a Receive checkbox. 3. Set AcqCreateItem to "receiving an order" and open the same order again. 4. Confirm that the Items section contains item-entry fields and an Add item button. Co-Authored-By: Loontik Signed-off-by: David Nind Signed-off-by: Jonathan Druart Signed-off-by: Lucas Gass --- .../prog/en/modules/acqui/orderreceive.tt | 2 +- .../OrderReceivePreferences_spec.ts | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 t/cypress/integration/Acquisitions/OrderReceivePreferences_spec.ts diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt index 44cc6c14a0..d7f34377f1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt @@ -461,7 +461,7 @@ const multiple_orders = "[% multiple_orders | html %]"; const only_one_order = [% only_one_order ? 1 : 0 | html %]; Koha.addPrefs({ - AcqCreateItem: [% Koha.Preference('AcqCreateItem') ? 1 : 0 | html %], + AcqCreateItem: "[% Koha.Preference('AcqCreateItem') | html %]", UniqueItemFields: [% Koha.Preference('UniqueItemFields') ? 1 : 0 | html %], }); Koha.addPermissions({ diff --git a/t/cypress/integration/Acquisitions/OrderReceivePreferences_spec.ts b/t/cypress/integration/Acquisitions/OrderReceivePreferences_spec.ts new file mode 100644 index 0000000000..de525c5db7 --- /dev/null +++ b/t/cypress/integration/Acquisitions/OrderReceivePreferences_spec.ts @@ -0,0 +1,68 @@ +describe("Order receive preferences", () => { + beforeEach(() => { + cy.login(); + cy.title().should("eq", "Koha staff interface"); + + cy.task("buildSampleObject", { + object: "vendor", + values: { active: 1 }, + }) + .then(generatedVendor => { + delete generatedVendor.list_currency; + delete generatedVendor.invoice_currency; + return cy.task("insertObject", { + type: "vendor", + object: generatedVendor, + }); + }) + .then(vendor => { + cy.wrap(vendor).as("vendor"); + return cy.task("buildSampleObject", { + object: "invoice", + values: { vendor_id: vendor.id }, + }); + }) + .then(generatedInvoice => { + return cy.task("insertObject", { + type: "invoice", + object: generatedInvoice, + }); + }) + .then(invoice => { + cy.wrap(invoice).as("invoice"); + }); + + cy.task("query", { + sql: "SELECT value FROM systempreferences WHERE variable='AcqCreateItem'", + }).then(value => { + cy.wrap(value).as("syspref_AcqCreateItem"); + }); + cy.task("query", { + sql: "SELECT value FROM systempreferences WHERE variable='UniqueItemFields'", + }).then(value => { + cy.wrap(value).as("syspref_UniqueItemFields"); + }); + }); + + afterEach(function () { + cy.task("deleteSampleObjects", [ + { vendor: this.vendor, invoice: this.invoice }, + ]); + cy.set_syspref("AcqCreateItem", this.syspref_AcqCreateItem); + cy.set_syspref("UniqueItemFields", this.syspref_UniqueItemFields); + }); + + it("preserves string-valued system preferences", function () { + cy.set_syspref("AcqCreateItem", "ordering"); + cy.set_syspref("UniqueItemFields", "barcode|itemcallnumber"); + cy.visit( + `/cgi-bin/koha/acqui/orderreceive.pl?invoiceid=${this.invoice.invoice_id}&multiple_orders=999999998,999999999` + ); + + cy.window().then(win => { + const prefs = (win as any).Koha.prefs; + expect(prefs.AcqCreateItem).to.equal("ordering"); + expect(prefs.UniqueItemFields).to.equal("barcode|itemcallnumber"); + }); + }); +});