diff --git a/CHANGELOG.md b/CHANGELOG.md index e6165c619..5c7ff40d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ * Set initial sorting column for "Related invoice lines" MCL. Refs UIOR-1581. * Add Order email templates settings with token picker and Handlebars backend-rendered preview. Refs UIOR-1492, UIOR-1493, UIOR-1495. * Do not show metadata fields in "Version history" for PO and PO Lines. Refs UIOR-1585. +* Preserve the "Create inventory" and "Receiving workflow" fields values according to the form value precedence rules. Refs UIOR-1582. ## [9.0.5](https://github.com/folio-org/ui-orders/tree/v9.0.5) (2026-07-20) [Full Changelog](https://github.com/folio-org/ui-orders/compare/v9.0.4...v9.0.5) diff --git a/src/common/POLFields/DetailsFields/FieldOrderFormat.js b/src/common/POLFields/DetailsFields/FieldOrderFormat.js index ff1f34834..16f901f45 100644 --- a/src/common/POLFields/DetailsFields/FieldOrderFormat.js +++ b/src/common/POLFields/DetailsFields/FieldOrderFormat.js @@ -8,6 +8,7 @@ import { ORDER_FORMATS, } from '@folio/stripes-acq-components'; +import { OPTION_VALUE_WITH_BINDERY_ACTIVE } from '../../../components/POLine/const'; import { POL_FORM_FIELDS } from '../../constants'; const ORDER_FORMAT_OPTIONS = Object.keys(ORDER_FORMATS).map((key) => ({ @@ -35,8 +36,13 @@ const handleElectronic = (change, settings, formValues, vendor) => { } }; -const handlePhysical = (change, settings) => { - change(POL_FORM_FIELDS.physicalCreateInventory, settings.physical); +const handlePhysical = (change, settings, formValues) => { + // Bindery's required inventory takes precedence over tenant defaults in both physical formats. + const createInventory = get(formValues, POL_FORM_FIELDS.isBinderyActive) + ? OPTION_VALUE_WITH_BINDERY_ACTIVE + : settings.physical; + + change(POL_FORM_FIELDS.physicalCreateInventory, createInventory); }; const handleOther = (change, settings) => { @@ -48,17 +54,17 @@ export const formatHandlers = { change(POL_FORM_FIELDS.physical, undefined); handleElectronic(change, settings, formValues, vendor); }, - [ORDER_FORMATS.physicalResource]: (change, settings) => { + [ORDER_FORMATS.physicalResource]: (change, settings, formValues, _vendor) => { change(POL_FORM_FIELDS.eresource, undefined); - handlePhysical(change, settings); + handlePhysical(change, settings, formValues); }, - [ORDER_FORMATS.other]: (change, settings) => { + [ORDER_FORMATS.other]: (change, settings, _formValues, _vendor) => { change(POL_FORM_FIELDS.eresource, undefined); handleOther(change, settings); }, [ORDER_FORMATS.PEMix]: (change, settings, formValues, vendor) => { handleElectronic(change, settings, formValues, vendor); - handlePhysical(change, settings); + handlePhysical(change, settings, formValues); }, }; diff --git a/src/common/POLFields/DetailsFields/FieldOrderFormat.test.js b/src/common/POLFields/DetailsFields/FieldOrderFormat.test.js index 72f253bbc..380eb1a6c 100644 --- a/src/common/POLFields/DetailsFields/FieldOrderFormat.test.js +++ b/src/common/POLFields/DetailsFields/FieldOrderFormat.test.js @@ -2,10 +2,11 @@ import { Form } from 'react-final-form'; import user from '@folio/jest-config-stripes/testing-library/user-event'; import { + act, render, screen, } from '@folio/jest-config-stripes/testing-library/react'; -import { ORDER_FORMATS } from '@folio/stripes-acq-components'; +import { INVENTORY_RECORDS_TYPE, ORDER_FORMATS } from '@folio/stripes-acq-components'; import { vendor } from 'fixtures'; import FieldOrderFormat from './FieldOrderFormat'; @@ -20,17 +21,23 @@ const defaultProps = { disabled: false, }; -const renderFieldOrderFormat = (props = {}) => render( -