Bug 39438

Summary: Add additional fields to agreements periods
Product: Koha Reporter: Mathieu Saby <mathsabypro>
Component: ERMAssignee: Matt Blenkinsop <matt.blenkinsop>
Status: Pushed to main --- QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: enhancement    
Priority: P5 - low CC: andrew.auld, jonathan.druart, jonathan.field, lucas, martin.renvoize, matt.blenkinsop, michaela.sieber, pedro.amorim
Version: MainKeywords: release-notes-needed
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: Sponsored Comma delimited list of Sponsors: Karlsruhe Institute of Technology (KIT)
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
26.05.00
Circulation function:
Bug Depends on: 40192    
Bug Blocks:    
Attachments: Bug 39438: Add additional fields to agreement periods
Bug 39438: Add additional fields support to ERM agreement periods
Bug 39438: Add DBIC schema relationships for agreement period additional fields
Bug 39438: Add additional fields support to ERM agreement periods
Bug 39438: Add DBIC schema relationships for agreement period additional fields
Bug 39438: (bug 38446 follow-up) Add agreement_period to /erm/extended_attribute_types
Bug 39438: (bug 38446 follow-up) Add agreement_period to /erm/extended_attribute_types
Bug 39438: (follow-up) Remove agreement_id from periods before comparing to result
Bug 39438: (RM follow-up): Fix failing test

Description Mathieu Saby 2025-03-24 17:45:51 UTC
It could be discussed... But it would probably be useful to give this possiblity to libraries
Comment 1 Matt Blenkinsop 2025-10-23 08:15:01 UTC
Created attachment 188307 [details] [review]
Bug 39438: Add additional fields to agreement periods
Comment 2 Martin Renvoize (ashimema) 2025-10-31 09:20:10 UTC
Created attachment 188778 [details] [review]
Bug 39438: Add additional fields support to ERM agreement periods

This patch enables additional fields functionality for agreement periods
in the ERM (Electronic Resource Management) module, allowing libraries
to define custom metadata fields for agreement period records.

Changes include:
- Update Koha::AdditionalField to support erm_agreement_periods table
- Modify API definitions to include extended_attributes in responses
- Add erm_agreement_periods option to additional fields admin interface
- Enhance Vue components to display and manage additional field values
- Update ShowElement component to handle period-specific attributes

Test plan:
1. Navigate to Administration > Additional fields
2. Create new fields for "Agreement periods"
3. Edit an ERM agreement and add/edit period information
4. Verify additional fields appear and can be populated
5. Confirm values are saved and displayed correctly

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Comment 3 Martin Renvoize (ashimema) 2025-10-31 09:20:12 UTC
Created attachment 188779 [details] [review]
Bug 39438: Add DBIC schema relationships for agreement period additional fields

This patch adds the required DBIx::Class relationship definitions to
Koha::Schema::Result::ErmAgreementPeriod to support additional fields
and extended attributes on agreement periods.

Two has_many relationships are added:
- additional_field_values: links to all additional field values
- extended_attributes: alias for additional_field_values

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Comment 4 Martin Renvoize (ashimema) 2025-10-31 09:20:54 UTC
Takes the same well-trodden road as the rest of these, works as expected.. Passing QA
Comment 5 Jonathan Druart 2025-11-04 15:21:44 UTC
Created attachment 189021 [details] [review]
Bug 39438: Add additional fields support to ERM agreement periods

This patch enables additional fields functionality for agreement periods
in the ERM (Electronic Resource Management) module, allowing libraries
to define custom metadata fields for agreement period records.

Changes include:
- Update Koha::AdditionalField to support erm_agreement_periods table
- Modify API definitions to include extended_attributes in responses
- Add erm_agreement_periods option to additional fields admin interface
- Enhance Vue components to display and manage additional field values
- Update ShowElement component to handle period-specific attributes

Test plan:
1. Navigate to Administration > Additional fields
2. Create new fields for "Agreement periods"
3. Edit an ERM agreement and add/edit period information
4. Verify additional fields appear and can be populated
5. Confirm values are saved and displayed correctly

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Comment 6 Jonathan Druart 2025-11-04 15:21:46 UTC
Created attachment 189022 [details] [review]
Bug 39438: Add DBIC schema relationships for agreement period additional fields

This patch adds the required DBIx::Class relationship definitions to
Koha::Schema::Result::ErmAgreementPeriod to support additional fields
and extended attributes on agreement periods.

Two has_many relationships are added:
- additional_field_values: links to all additional field values
- extended_attributes: alias for additional_field_values

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Comment 7 Jonathan Druart 2025-11-04 15:21:49 UTC
Created attachment 189023 [details] [review]
Bug 39438: (bug 38446 follow-up) Add agreement_period to /erm/extended_attribute_types

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Comment 8 Jonathan Druart 2026-01-23 08:16:53 UTC
Created attachment 191895 [details] [review]
Bug 39438: (bug 38446 follow-up) Add agreement_period to /erm/extended_attribute_types

Sponsored-by: Karlsruhe Institute of Technology (KIT)
Comment 9 Lucas Gass (lukeg) 2026-01-30 17:55:51 UTC
Nice work everyone!

Pushed to main for 26.05
Comment 10 Lucas Gass (lukeg) 2026-01-30 18:03:43 UTC
Please add release notes
Comment 11 Lucas Gass (lukeg) 2026-01-30 19:42:02 UTC
failing test now:

kohadev-koha@kohadevbox:koha(main)$ prove -v /kohadevbox/koha/t/db_dependent/Koha/ERM/Agreements.t
/kohadevbox/koha/t/db_dependent/Koha/ERM/Agreements.t .. 
1..3
# Subtest: periods
    1..4
    ok 1 - no period yet
    ok 2
    not ok 3

    #   Failed test at /kohadevbox/koha/t/db_dependent/Koha/ERM/Agreements.t line 63.
    #     Structures begin differing at:
    #          $got->[0]{agreement_id} = Does not exist
    #     $expected->[0]{agreement_id} = '3'
    ok 4
    # Looks like you failed 1 test of 4.
not ok 1 - periods
# Subtest: user_role

#   Failed test 'periods'
#   at /kohadevbox/koha/t/db_dependent/Koha/ERM/Agreements.t line 68.
    1..4
    ok 1 - no user yet
    ok 2
    ok 3
    ok 4
ok 2 - user_role
ok 3 - no warnings
# Looks like you failed 1 test of 3.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/3 subtests
Comment 12 Lucas Gass (lukeg) 2026-01-30 19:46:26 UTC
and another:

prove -v /kohadevbox/koha/t/db_dependent/api/v1/extended_attribute_types.t
/kohadevbox/koha/t/db_dependent/api/v1/extended_attribute_types.t .. 
1..3
# Subtest: list() tests
    1..23
    ok 1 - GET //GgljRpal44DqriBvVqcJA_aZx1RUtEVSnKw7hgGBFf0KFKBasjcxnvvFCC0A9OEEdvCpOkOn47y:thePassword123@/api/v1/extended_attribute_types
    ok 2 - 200 OK
    ok 3 - exact match for JSON Pointer ""
    ok 4 - GET //GgljRpal44DqriBvVqcJA_aZx1RUtEVSnKw7hgGBFf0KFKBasjcxnvvFCC0A9OEEdvCpOkOn47y:thePassword123@/api/v1/extended_attribute_types
    ok 5 - 200 OK
    ok 6 - exact match for JSON Pointer ""
    ok 7 - GET //GgljRpal44DqriBvVqcJA_aZx1RUtEVSnKw7hgGBFf0KFKBasjcxnvvFCC0A9OEEdvCpOkOn47y:thePassword123@/api/v1/extended_attribute_types
    ok 8 - 200 OK
    ok 9 - exact match for JSON Pointer ""
    ok 10 - GET //GgljRpal44DqriBvVqcJA_aZx1RUtEVSnKw7hgGBFf0KFKBasjcxnvvFCC0A9OEEdvCpOkOn47y:thePassword123@/api/v1/extended_attribute_types
    ok 11 - 200 OK
    ok 12 - exact match for JSON Pointer ""
    ok 13 - GET //GgljRpal44DqriBvVqcJA_aZx1RUtEVSnKw7hgGBFf0KFKBasjcxnvvFCC0A9OEEdvCpOkOn47y:thePassword123@/api/v1/extended_attribute_types?resource_type=invoice
    ok 14 - 200 OK
    ok 15 - exact match for JSON Pointer ""
    ok 16 - GET //GgljRpal44DqriBvVqcJA_aZx1RUtEVSnKw7hgGBFf0KFKBasjcxnvvFCC0A9OEEdvCpOkOn47y:thePassword123@/api/v1/extended_attribute_types?resource_type=subscription
    ok 17 - 200 OK
    ok 18 - exact match for JSON Pointer ""
    ok 19 - GET //GgljRpal44DqriBvVqcJA_aZx1RUtEVSnKw7hgGBFf0KFKBasjcxnvvFCC0A9OEEdvCpOkOn47y:thePassword123@/api/v1/extended_attribute_types?blah=blah
    ok 20 - 400 Bad Request
    ok 21 - exact match for JSON Pointer ""
    ok 22 - GET //n_ekc3J_VWNHzx4HFQwcjRswVN444sJAgXpZVYJLIbFXw0RCu7LsV_ZSeNJPbtcuWZE1ZoR:thePassword123@/api/v1/extended_attribute_types
    ok 23 - 403 Forbidden
ok 1 - list() tests
# Subtest: list_erm() tests
    1..23
    ok 1 - GET //ZHehvjvEcJFim1YS00YEfwGLS7uz_qhEhRrXDlez5N3t:thePassword123@/api/v1/erm/extended_attribute_types
    ok 2 - 200 OK
    ok 3 - exact match for JSON Pointer ""
    ok 4 - GET //ZHehvjvEcJFim1YS00YEfwGLS7uz_qhEhRrXDlez5N3t:thePassword123@/api/v1/erm/extended_attribute_types
    ok 5 - 200 OK
    ok 6 - exact match for JSON Pointer ""
    ok 7 - GET //ZHehvjvEcJFim1YS00YEfwGLS7uz_qhEhRrXDlez5N3t:thePassword123@/api/v1/erm/extended_attribute_types
    ok 8 - 200 OK
    ok 9 - exact match for JSON Pointer ""
    ok 10 - GET //ZHehvjvEcJFim1YS00YEfwGLS7uz_qhEhRrXDlez5N3t:thePassword123@/api/v1/erm/extended_attribute_types?resource_type=license
    ok 11 - 200 OK
    ok 12 - exact match for JSON Pointer ""
    ok 13 - GET //ZHehvjvEcJFim1YS00YEfwGLS7uz_qhEhRrXDlez5N3t:thePassword123@/api/v1/erm/extended_attribute_types?resource_type=order
    ok 14 - 400 Bad Request
    not ok 15 - exact match for JSON Pointer "/errors"

    #   Failed test 'exact match for JSON Pointer "/errors"'
    #   at /kohadevbox/koha/t/db_dependent/api/v1/extended_attribute_types.t line 215.
    #     Structures begin differing at:
    #          $got->[0]{message} = 'Not in enum list: license, agreement, agreement_period, package, title.'
    #     $expected->[0]{message} = 'Not in enum list: license, agreement, package, title.'
    ok 16 - GET //ZHehvjvEcJFim1YS00YEfwGLS7uz_qhEhRrXDlez5N3t:thePassword123@/api/v1/erm/extended_attribute_types?blah=blah
    ok 17 - 400 Bad Request
    ok 18 - exact match for JSON Pointer ""
    ok 19 - GET //ZHehvjvEcJFim1YS00YEfwGLS7uz_qhEhRrXDlez5N3t:thePassword123@/api/v1/erm/extended_attribute_types
    ok 20 - 200 OK
    ok 21 - exact match for JSON Pointer ""
    ok 22 - GET //URaLdafLHOxpnKnvYefhr6PTbcU0b_gNvufoD17ZTPUZJOYauFMi32URCd6:thePassword123@/api/v1/extended_attribute_types
    ok 23 - 403 Forbidden
    # Looks like you failed 1 test of 23.
not ok 2 - list_erm() tests

#   Failed test 'list_erm() tests'
#   at /kohadevbox/koha/t/db_dependent/api/v1/extended_attribute_types.t line 235.
ok 3 - no warnings
# Looks like you failed 1 test of 3.
Comment 13 Matt Blenkinsop 2026-02-02 09:30:24 UTC
Created attachment 192284 [details] [review]
Bug 39438: (follow-up) Remove agreement_id from periods before comparing to result
Comment 14 Matt Blenkinsop 2026-02-02 09:30:53 UTC
The second of those tests passes fine for me but the first is now fixed
Comment 15 Lucas Gass (lukeg) 2026-02-06 14:22:44 UTC
follow-up pushed to main
Comment 16 Lucas Gass (lukeg) 2026-02-06 17:28:26 UTC
Created attachment 192653 [details] [review]
Bug 39438: (RM follow-up): Fix failing test
Comment 17 Lucas Gass (lukeg) 2026-02-06 17:44:19 UTC
follow-up pushed to main