From f0c8bdadb73be3aad44e7bd234cdf9ab1a15ea23 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 17 Jul 2018 10:07:35 -0400 Subject: [PATCH] Bug 14570 [QA Followup]: Remove ability to add multiple non-koha patrons as guarantors, bring back contact fields --- Koha/Patron.pm | 32 +-- Koha/Patrons/Import.pm | 9 +- Koha/Schema/Result/BorrowerRelationship.pm | 18 +- installer/data/mysql/atomicupdate/bug_14570.sql | 10 +- installer/data/mysql/kohastructure.sql | 10 +- .../prog/en/modules/members/memberentrygen.tt | 253 ++++++++++----------- .../prog/en/modules/members/moremember-brief.tt | 41 ++-- .../prog/en/modules/members/moremember.tt | 10 +- koha-tmpl/intranet-tmpl/prog/js/members.js | 67 +++--- .../bootstrap/en/modules/opac-memberentry.tt | 4 +- .../opac-tmpl/bootstrap/en/modules/opac-privacy.tt | 2 +- members/memberentry.pl | 10 +- t/db_dependent/Patron/Relationships.t | 18 +- 13 files changed, 204 insertions(+), 280 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 366be8684c..825fae0c88 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1059,13 +1059,11 @@ sub generate_userid { my @relationships = $patron->add_guarantor( { borrowernumber => $borrowernumber, - surname => $surname, - firstname => $firstname, relationships => $relationship, } ); - Adds a new guarantor to a patron, requires either an id ( borrowernumber ) or surname. + Adds a new guarantor to a patron. =cut @@ -1073,29 +1071,15 @@ sub add_guarantor { my ( $self, $params ) = @_; my $guarantor_id = $params->{guarantor_id}; - my $surname = $params->{surname}; - my $firstname = $params->{firstname}; my $relationship = $params->{relationship}; - if ($guarantor_id) { - return Koha::Patron::Relationship->new( - { - guarantee_id => $self->id, - guarantor_id => $guarantor_id, - relationship => $relationship - } - )->store(); - } - elsif ($surname) { - return Koha::Patron::Relationship->new( - { - guarantee_id => $self->id, - surname => $surname, - firstname => $firstname, - relationship => $relationship - } - )->store(); - } + return Koha::Patron::Relationship->new( + { + guarantee_id => $self->id, + guarantor_id => $guarantor_id, + relationship => $relationship + } + )->store(); } =head2 Internal methods diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm index 007b427e58..4d17bde3bf 100644 --- a/Koha/Patrons/Import.pm +++ b/Koha/Patrons/Import.pm @@ -215,12 +215,8 @@ sub import_patrons { my $relationship = $borrower{relationship}; my $guarantor_id = $borrower{guarantor_id}; - my $guarantor_firstname = $borrower{guarantor_firstname}; - my $guarantor_surname = $borrower{guarantor_surname}; delete $borrower{relationship}; delete $borrower{guarantor_id}; - delete $borrower{guarantor_firstname}; - delete $borrower{guarantor_surname}; if ($borrowernumber) { @@ -359,15 +355,12 @@ sub import_patrons { } # Add a guarantor if we are given a relationship - if ( $relationship ) { - $guarantor_id ||= undef; + if ( $guarantor_id ) { Koha::Patron::Relationship->new( { guarantee_id => $borrowernumber, relationship => $relationship, guarantor_id => $guarantor_id, - firstname => $guarantor_firstname, - surname => $guarantor_surname, } )->store(); } diff --git a/Koha/Schema/Result/BorrowerRelationship.pm b/Koha/Schema/Result/BorrowerRelationship.pm index 5445d44f10..88cef4f294 100644 --- a/Koha/Schema/Result/BorrowerRelationship.pm +++ b/Koha/Schema/Result/BorrowerRelationship.pm @@ -47,16 +47,6 @@ __PACKAGE__->table("borrower_relationships"); is_nullable: 0 size: 100 -=head2 surname - - data_type: 'mediumtext' - is_nullable: 1 - -=head2 firstname - - data_type: 'mediumtext' - is_nullable: 1 - =cut __PACKAGE__->add_columns( @@ -68,10 +58,6 @@ __PACKAGE__->add_columns( { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, "relationship", { data_type => "varchar", is_nullable => 0, size => 100 }, - "surname", - { data_type => "mediumtext", is_nullable => 1 }, - "firstname", - { data_type => "mediumtext", is_nullable => 1 }, ); =head1 PRIMARY KEY @@ -124,8 +110,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-07-17 11:22:45 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YKFiZSR3WRi1nvtLOdGV9A +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-07-18 10:52:59 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:R8RThgcrct40Zq0UMW3TWQ # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/installer/data/mysql/atomicupdate/bug_14570.sql b/installer/data/mysql/atomicupdate/bug_14570.sql index 9c8e987a96..b0bb359d43 100644 --- a/installer/data/mysql/atomicupdate/bug_14570.sql +++ b/installer/data/mysql/atomicupdate/bug_14570.sql @@ -3,8 +3,6 @@ CREATE TABLE `borrower_relationships` ( guarantor_id INT(11) NULL DEFAULT NULL, guarantee_id INT(11) NOT NULL, relationship VARCHAR(100) COLLATE utf8_unicode_ci NOT NULL, - surname MEDIUMTEXT COLLATE utf8_unicode_ci NULL DEFAULT NULL, - firstname MEDIUMTEXT COLLATE utf8_unicode_ci NULL DEFAULT NULL, PRIMARY KEY (id), CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE @@ -12,8 +10,8 @@ CREATE TABLE `borrower_relationships` ( UPDATE borrowers LEFT JOIN borrowers guarantor ON ( borrowers.guarantorid = guarantor.borrowernumber ) SET borrowers.guarantorid = NULL WHERE guarantor.borrowernumber IS NULL; -INSERT INTO borrower_relationships ( guarantor_id, guarantee_id, relationship, surname, firstname ) SELECT guarantorid, borrowernumber, relationship, contactname, contactfirstname FROM borrowers WHERE guarantorid IS NOT NULL OR contactname != ""; +INSERT INTO borrower_relationships ( guarantor_id, guarantee_id, relationship ) SELECT guarantorid, borrowernumber, relationship FROM borrowers WHERE guarantorid IS NOT NULL; -ALTER TABLE borrowers DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle; -ALTER TABLE deletedborrowers DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle; -ALTER TABLE borrowermodification DROP guarantorid, DROP relationship, DROP contactname, DROP contactfirstname, DROP contacttitle; +ALTER TABLE borrowers DROP guarantorid; +ALTER TABLE deletedborrowers DROP guarantorid; +ALTER TABLE borrowermodification DROP guarantorid; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 3d04f5b68e..f590ed4d77 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -579,7 +579,11 @@ CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYYY-MM-DD) `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of patron + `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name + `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor + `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client + `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor `sex` varchar(1) default NULL, -- patron/borrower's gender `password` varchar(60) default NULL, -- patron/borrower's encrypted password `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions @@ -1604,7 +1608,11 @@ CREATE TABLE `borrowers` ( -- this table includes information about your patrons `lost` tinyint(1) default NULL, -- set to 1 for yes and 0 for no, flag to note that library marked this patron/borrower as having lost their card `debarred` date default NULL, -- until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYYY-MM-DD) `debarredcomment` VARCHAR(255) DEFAULT NULL, -- comment on the stop of the patron + `contactname` LONGTEXT, -- used for children and profesionals to include surname or last name of guarantor or organization name + `contactfirstname` MEDIUMTEXT, -- used for children to include first name of guarantor + `contacttitle` MEDIUMTEXT, -- used for children to include title (Mr., Mrs., etc) of guarantor `borrowernotes` LONGTEXT, -- a note on the patron/borrower's account that is only visible in the staff client + `relationship` varchar(100) default NULL, -- used for children to include the relationship to their guarantor `sex` varchar(1) default NULL, -- patron/borrower's gender `password` varchar(60) default NULL, -- patron/borrower's Bcrypt encrypted password `flags` int(11) default NULL, -- will include a number associated with the staff member's permissions @@ -4106,8 +4114,6 @@ CREATE TABLE `borrower_relationships` ( guarantor_id INT(11) NULL DEFAULT NULL, guarantee_id INT(11) NOT NULL, relationship VARCHAR(100) COLLATE utf8_unicode_ci NOT NULL, - surname MEDIUMTEXT COLLATE utf8_unicode_ci NULL DEFAULT NULL, - firstname MEDIUMTEXT COLLATE utf8_unicode_ci NULL DEFAULT NULL, PRIMARY KEY (id), CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index 21cb5b7bad..e57a1deac3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -308,45 +308,31 @@
    [% IF category_type == 'P' %] - [% IF ( r.guarantor_id ) %] -
  1. - [% ELSE %] -
  2. Organization #: [% IF ( r.guarantor_id ) %] [% r.guarantor_id %][% END %]
  3. - [% IF ( r.guarantor_id ) %] - [% r.guarantor.surname %] - [% END %] + [% r.guarantor.surname %]
  4. [% ELSE %] - [% IF ( r.guarantor_id ) %] -
  5. - [% ELSE %] -
  6. Patron #: - [% IF ( r.guarantor_id ) %] - [% r.guarantor_id %] - [% END %] - + [% r.guarantor_id %]
  7. - [% IF r.surname || r.guarantor.surname %] + [% IF r.guarantor.surname %]
  8. - [% r.surname || r.guarantor.surname %] + [% r.guarantor.surname %]
  9. [% END %] - [% IF r.firstname || r.guarantor.firstname %] + [% IF r.guarantor.firstname %]
  10. - [% r.firstname || r.guarantor.firstname %] + [% r.guarantor.firstname %]
  11. [% END %] @@ -401,44 +387,13 @@
-
- Add new guarantor
    - - - [% IF catetory_type == 'P' %] -
  1. - - -
  2. - [% ELSE %] -
  3. - - -
  4. - -
  5. - - -
  6. - - [% IF ( possible_relationships ) %] -
  7. - - -
  8. - [% END %] - [% END %] + + +
  9. -   - Add guarantor - Set to patron - Clear + Search
  10. [% IF relationships && Koha.Preference('AllowStaffToSetCheckoutsVisibilityForGuarantor') %] @@ -457,7 +412,6 @@ [% END %]
-
[% END %] @@ -471,84 +425,132 @@ [% END # nostreet && nocity etc group%] [% UNLESS nophone && nophonepro && nomobile && noemail && noemailpro && nofax %] -
- Contact
    - [% UNLESS nophone %] -
  1. - [% IF ( mandatoryphone ) %] -
+
[%END # hide fieldset %] @@ -1254,9 +1256,6 @@ [% IF guarantor %] select_user( '[% guarantor.borrowernumber %]', [% To.json( guarantor.unblessed ) %] ); - $('#guarantor_add').ready(function() { - $('#guarantor_add').click(); - }); [% END %] }); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt index 398756638a..e15f0e3c31 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt @@ -42,35 +42,26 @@ [% IF ( dateofbirth ) %]
  • Date of birth:[% dateofbirth | $KohaDates %]
  • [% END %] [% IF ( sex ) %]
  • Gender:[% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
  • [% END %][% END %] [% END %] - [% IF ( isguarantee ) %] - [% IF ( guaranteeloop ) %] -
  • Guarantees:
  • - [% END %] - [% ELSE %] - [% IF guarantees %] -
  • - Guarantees: - -
  • - [% ELSIF guarantor_relationships %] - [% FOREACH gr IN guarantor_relationships %] + + [% IF guarantees %]
  • - Guarantor: - [% IF gr.guarantor_id %] + Guarantees: + +
  • + [% ELSIF guarantor_relationships %] + [% FOREACH gr IN guarantor_relationships %] +
  • + Guarantor: [% SET guarantor = gr.guarantor %] [% guarantor.firstname %] [% guarantor.surname %] - [% ELSE %] - [% gr.firstname %] [% gr.surname %] - [% END %] -
  • + + [% END %] [% END %] - [% END %] - [% END %] - + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index cffd512ef6..86da08482c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -222,13 +222,9 @@ [% FOREACH gr IN guarantor_relationships %]
  • Guarantor: - [% IF gr.guarantor_id %] - [% SET guarantor = gr.guarantor %] - [% IF logged_in_user.can_see_patron_infos( guarantor ) %] - [% guarantor.firstname | html %] [% guarantor.surname | html %] - [% END %] - [% ELSE %] - [% gr.firstname | html %] [% gr.surname | html %] + [% SET guarantor = gr.guarantor %] + [% IF logged_in_user.can_see_patron_infos( guarantor ) %] + [% guarantor.firstname | html %] [% guarantor.surname | html %] [% END %]
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index 8ef5707474..7f1774e7df 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -170,7 +170,34 @@ function select_user(borrowernumber, borrower) { $('#guarantor_surname').val(borrower.surname); $('#guarantor_firstname').val(borrower.firstname); - $('#guarantor_add').click(); + var fieldset = $('#guarantor_template').clone(); + fieldset.removeAttr('id'); + + var guarantor_id = $('#guarantor_id').val(); + if ( guarantor_id ) { + fieldset.find('.new_guarantor_id').first().val( guarantor_id ); + fieldset.find('.new_guarantor_id_text').first().text( guarantor_id ); + } else { + fieldset.find('.guarantor_id').first().hide(); + } + $('#guarantor_id').val(""); + + var guarantor_surname = $('#guarantor_surname').val(); + fieldset.find('.new_guarantor_surname').first().val( guarantor_surname ); + fieldset.find('.new_guarantor_surname_text').first().text( guarantor_surname ); + $('#guarantor_surname').val(""); + + var guarantor_firstname = $('#guarantor_firstname').val(); + fieldset.find('.new_guarantor_firstname').first().val( guarantor_firstname ); + fieldset.find('.new_guarantor_firstname_text').first().text( guarantor_firstname ); + $('#guarantor_firstname').val(""); + + var guarantor_relationship = $('#relationship').val(); + fieldset.find('.new_guarantor_relationship').first().val( guarantor_relationship ); + $('#relationship').find('option:eq(0)').prop('selected', true);; + + $('#guarantor_relationships').append( fieldset ); + fieldset.show(); return 0; } @@ -256,44 +283,6 @@ $(document).ready(function(){ $(this).parents('fieldset').first().remove(); }); - $('#guarantor_add').on('click', function(e) { - e.preventDefault(); - var fieldset = $('#guarantor_template').clone(); - fieldset.removeAttr('id'); - - var guarantor_id = $('#guarantor_id').val(); - if ( guarantor_id ) { - fieldset.find('.new_guarantor_id').first().val( guarantor_id ); - fieldset.find('.new_guarantor_id_text').first().text( guarantor_id ); - } else { - fieldset.find('.guarantor_id').first().hide(); - } - $('#guarantor_id').val(""); - - var guarantor_surname = $('#guarantor_surname').val(); - fieldset.find('.new_guarantor_surname').first().val( guarantor_surname ); - fieldset.find('.new_guarantor_surname_text').first().text( guarantor_surname ); - $('#guarantor_surname').val(""); - - var guarantor_firstname = $('#guarantor_firstname').val(); - fieldset.find('.new_guarantor_firstname').first().val( guarantor_firstname ); - fieldset.find('.new_guarantor_firstname_text').first().text( guarantor_firstname ); - $('#guarantor_firstname').val(""); - - var guarantor_relationship = $('#relationship').val(); - fieldset.find('.new_guarantor_relationship').first().val( guarantor_relationship ); - $('#relationship').find('option:eq(0)').prop('selected', true);; - - $('#guarantor_relationships').append( fieldset ); - fieldset.show(); - }); - - $("#guarantor_clear").click(function(e) { - e.preventDefault(); - $("#contact-details").hide().find('a').remove(); - $("#guarantor_id, #guarantor_surname, #guarantor_firstname").val(""); - }); - $(document.body).on('change','select[name="select_city"]',function(){ $('select[name="select_city"]').val( $(this).val() ); var myRegEx=new RegExp(/(.*)\|(.*)\|(.*)\|(.*)/); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index 28221dc944..3c83be47f7 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -121,7 +121,7 @@ Guaranteed by [% FOREACH gr IN patron.guarantor_relationships %] [% SET g = gr.guarantor %] - [% g.firstname || gr.firstname %] [% g.surname || gr.surname %] + [% g.firstname %] [% g.surname %] [%- IF ! loop.last %], [% END %] [% END %] @@ -1002,7 +1002,7 @@ } }); - [% IF borrower.guarantorid && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %] + [% IF patron.guarantor_relationships && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %] $('#update_privacy_guarantor_checkouts').click( function() { $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }, null, 'json') .done(function( data ) { diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt index 99314bd261..71a4724d54 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt @@ -87,7 +87,7 @@ Guaranteed by [% FOREACH gr IN borrower.guarantor_relationships %] [% SET g = gr.guarantor %] - [% g.firstname || gr.firstname %] [% g.surname || gr.surname %] + [% g.firstname %] [% g.surname %] [%- IF ! loop.last %], [% END %] [% END %] diff --git a/members/memberentry.pl b/members/memberentry.pl index 00b79b1909..a954779548 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -896,23 +896,19 @@ sub add_guarantors { my ( $patron, $input ) = @_; my @new_guarantor_id = $input->multi_param('new_guarantor_id'); - my @new_guarantor_surname = $input->multi_param('new_guarantor_surname'); - my @new_guarantor_firstname = $input->multi_param('new_guarantor_firstname'); my @new_guarantor_relationship = $input->multi_param('new_guarantor_relationship'); for ( my $i = 0 ; $i < scalar @new_guarantor_id; $i++ ) { my $guarantor_id = $new_guarantor_id[$i]; - my $surname = $new_guarantor_surname[$i]; - my $firstname = $new_guarantor_firstname[$i]; my $relationship = $new_guarantor_relationship[$i]; + next unless $guarantor_id; + $patron->add_guarantor( { guarantee_id => $patron->id, guarantor_id => $guarantor_id, - surname => $surname, - firstname => $firstname, - relationship => $relationship + relationship => $relationship, } ); } diff --git a/t/db_dependent/Patron/Relationships.t b/t/db_dependent/Patron/Relationships.t index 4aec07af88..5bc5b2308b 100755 --- a/t/db_dependent/Patron/Relationships.t +++ b/t/db_dependent/Patron/Relationships.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 67; +use Test::More tests => 59; use C4::Context; @@ -92,10 +92,6 @@ Koha::Patron::Relationship->new({ guarantor_id => $kyle->id, guarantee_id => $da Koha::Patron::Relationship->new({ guarantor_id => $kyle->id, guarantee_id => $kylie->id, relationship => 'father' })->store(); Koha::Patron::Relationship->new({ guarantor_id => $chelsea->id, guarantee_id => $daria->id, relationship => 'mother' })->store(); Koha::Patron::Relationship->new({ guarantor_id => $chelsea->id, guarantee_id => $kylie->id, relationship => 'mother' })->store(); -Koha::Patron::Relationship->new({ firstname => 'John', surname => 'Hall', guarantee_id => $daria->id, relationship => 'grandfather' })->store(); -Koha::Patron::Relationship->new({ firstname => 'Debra', surname => 'Hall', guarantee_id => $daria->id, relationship => 'grandmother' })->store(); -Koha::Patron::Relationship->new({ firstname => 'John', surname => 'Hall', guarantee_id => $kylie->id, relationship => 'grandfather' })->store(); -Koha::Patron::Relationship->new({ firstname => 'Debra', surname => 'Hall', guarantee_id => $kylie->id, relationship => 'grandmother' })->store(); my @gr; @@ -136,7 +132,7 @@ is( ref($gr[1]->guarantor), 'Koha::Patron', 'Method guarantor returns a Koha::Pa is( $gr[1]->guarantor->id, $chelsea->id, 'Koha::Patron returned is the correct guarantor' ); @gr = $daria->guarantor_relationships(); -is( @gr, 4, 'Found 4 guarantor relationships for child' ); +is( @gr, 2, 'Found 4 guarantor relationships for child' ); is( $gr[0]->guarantor_id, $kyle->id, 'Guarantor matches for first relationship' ); is( $gr[0]->guarantee_id, $daria->id, 'Guarantee matches for first relationship' ); is( $gr[0]->relationship, 'father', 'Relationship is father' ); @@ -153,16 +149,6 @@ is( $gr[1]->guarantee->id, $daria->id, 'Koha::Patron returned is the correct gua is( ref($gr[1]->guarantor), 'Koha::Patron', 'Method guarantor returns a Koha::Patron' ); is( $gr[1]->guarantor->id, $chelsea->id, 'Koha::Patron returned is the correct guarantor' ); -is( $gr[2]->guarantor_id, undef, 'Grandfather has no id, not a Koha patron' ); -is( $gr[2]->firstname, 'John', 'Grandfather has first name of John' ); -is( $gr[2]->surname, 'Hall', 'Grandfather has surname of Hall' ); -is( $gr[2]->guarantor, undef, 'Calling guarantor method for Grandfather returns undef' ); - -is( $gr[3]->guarantor_id, undef, 'Grandmother has no id, not a Koha patron' ); -is( $gr[3]->firstname, 'Debra', 'Grandmother has first name of John' ); -is( $gr[3]->surname, 'Hall', 'Grandmother has surname of Hall' ); -is( $gr[3]->guarantor, undef, 'Calling guarantor method for Grandmother returns undef' ); - my @siblings = $daria->siblings; is( @siblings, 1, 'Method siblings called in list context returns list' ); is( ref($siblings[0]), 'Koha::Patron', 'List contains a Koha::Patron' ); -- 2.11.0