Bug 40391 - EDI: Add support for GIR:LSL field
Summary: EDI: Add support for GIR:LSL field
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Martin Renvoize (ashimema)
QA Contact: Kyle M Hall (khall)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-07-15 14:01 UTC by Martin Renvoize (ashimema)
Modified: 2025-08-07 16:39 UTC (History)
2 users (show)

See Also:
GIT URL:
Change sponsored?: Sponsored
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40391: Add unit tests for GIR:LSL support in EDI (12.11 KB, patch)
2025-08-01 14:44 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 40391: Add support for GIR:LSL (Library Sub-Location) in EDIFACT processing (16.63 KB, patch)
2025-08-01 14:44 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 40391: Add unit tests for GIR:LSL support in EDI (14.49 KB, patch)
2025-08-07 16:37 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 40391: Add support for GIR:LSL (Library Sub-Location) in EDIFACT processing (16.63 KB, patch)
2025-08-07 16:37 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 2025-07-15 14:01:47 UTC
More recent versions of the EDIFACT EDItEUR/BiC profiles added support for an LSL (Library sub-location) field.

This new field would allow people to 'have their cake and eat it' with regards to location + collection handling.

Currently, we have the `EdifactLSQ` system preference which allows you to set the 'GIR:LSQ' field content to map to either the Location or Collection for a Koha item.  Adding 'GIR:LSL' parsing would allow us to support vendors passing both codes.
Comment 1 Martin Renvoize (ashimema) 2025-08-01 14:44:33 UTC Comment hidden (obsolete)
Comment 2 Martin Renvoize (ashimema) 2025-08-01 14:44:35 UTC Comment hidden (obsolete)
Comment 3 Martin Renvoize (ashimema) 2025-08-07 16:37:27 UTC
Created attachment 185233 [details] [review]
Bug 40391: Add unit tests for GIR:LSL support in EDI

This adds unit tests for adding supprt for the new LSL field support:

- GIR segment extraction tests in t/Edifact.t for sub_location_code field mapping
- Validation function tests in t/db_dependent/Koha/EDI.t for location/collection code validation
- gir_segments generation tests in t/db_dependent/Koha/Edifact/Order.t for preference handling

Tests cover:
- LSL field extraction from GIR segments alongside existing LSQ fields
- Independent LSQ/LSL preference mapping (location/ccode/empty combinations)
- Validation of location and collection codes against authorised values
- Error handling and message formatting
- Backwards compatibility with existing LSQ-only configurations
- Edge cases including missing data and invalid preference values

Test plan:
1. Apply this patch
2. Run: prove t/Edifact.t
   - Should pass with 8 new LSL-related tests included
3. Run: prove t/db_dependent/Koha/EDI.t
   - Should pass with 16 new validation function tests
4. Run: prove t/db_dependent/Koha/Edifact/Order.t
   - Should pass with 14 new gir_segments LSL/LSQ tests
5. Verify all existing tests still pass - no regression
Comment 4 Martin Renvoize (ashimema) 2025-08-07 16:37:29 UTC
Created attachment 185234 [details] [review]
Bug 40391: Add support for GIR:LSL (Library Sub-Location) in EDIFACT processing

This implements support for the new EDItEUR/BiC GIR:LSL (Library Sub-Location)
field to complement the existing GIR:LSQ (Library Sequence) functionality,
allowing flexible mapping of both fields to location and collection item fields.

Changes:
- Add LSL mapping to GIR field extraction in Koha::Edifact::Line
- Update gir_segments() in Koha::Edifact::Order to handle both LSL and LSQ preferences independently
- Add validation functions in Koha::EDI using Koha::AuthorisedValues for location/collection codes
- Add EdifactLSL system preference for independent LSL field mapping
- Update EdifactLSQ to include empty option for ignore functionality
- Add admin interface configuration for LSL preference

The implementation provides maximum flexibility:
- EdifactLSQ can be set to: location, ccode, or empty (ignore)
- EdifactLSL can be set to: location, ccode, or empty (ignore)
- Both fields can be mapped independently or to same target field
- Validation ensures codes exist in LOC/CCODE authorised values
- Maintains full backwards compatibility with existing LSQ-only setups

Test plan:
1. Apply both patches
2. Update database: installer/data/mysql/updatedatabase.pl
3. Verify new system preferences in Administration > System preferences > Acquisitions:
   - EdifactLSQ: "Map EDI sequence code (GIR+LSQ) to Koha Item field"
   - EdifactLSL: "Map EDI sub-location code (GIR+LSL) to Koha Item field"
4. Create test authorised values:
   - LOC category: Add values like FICTION, REFERENCE
   - CCODE category: Add values like ADULT, CHILD
5. Set preferences to test combinations:
   - EdifactLSQ=location, EdifactLSL=ccode
   - EdifactLSQ=ccode, EdifactLSL=location
   - EdifactLSQ=location, EdifactLSL="" (empty)
6. Process EDIFACT messages containing GIR+LSL and GIR+LSQ segments
7. Verify items created with correct location/ccode values per preferences
8. Test invalid codes generate appropriate error messages
9. Confirm existing LSQ-only configurations continue working unchanged
10. Run: prove t/Edifact.t t/db_dependent/Koha/EDI.t t/db_dependent/Koha/Edifact/Order.t