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>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2025-10-31 09:15:31 +00:00 committed by Lucas Gass
parent 080fccc0c5
commit b44f85e1b2
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 33 additions and 0 deletions

View File

@ -120,6 +120,39 @@ __PACKAGE__->belongs_to(
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-05-25 11:46:59
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NCQpSw+rp/9B/yOrtLtK6g
__PACKAGE__->has_many(
"additional_field_values",
"Koha::Schema::Result::AdditionalFieldValue",
sub {
my ($args) = @_;
return {
"$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.agreement_period_id" },
"$args->{foreign_alias}.field_id" =>
{ -in => \'(SELECT id FROM additional_fields WHERE tablename="erm_agreement_periods")' },
};
},
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"extended_attributes",
"Koha::Schema::Result::AdditionalFieldValue",
sub {
my ($args) = @_;
return {
"$args->{foreign_alias}.record_id" => { -ident => "$args->{self_alias}.agreement_period_id" },
"$args->{foreign_alias}.field_id" =>
{ -in => \'(SELECT id FROM additional_fields WHERE tablename="erm_agreement_periods")' },
};
},
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 koha_object_class
Missing POD for koha_object_class.