@@ -, +, @@ --- Koha/Biblio.pm | 15 +++++++++++++++ t/db_dependent/Koha/Biblios.t | 13 +++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -370,6 +370,21 @@ sub biblioitem { return $self->{_biblioitem}; } +=head3 title_remainder + +my $field = $self->title_remainder + +Returns the Remainder of title, 245$b. + +=cut + +sub title_remainder { + my ($self) = @_; + + return unless my $record = C4::Biblio::GetMarcBiblio($self->biblionumber); + return $record->subfield('245','b'); +} + =head3 type =cut --- a/t/db_dependent/Koha/Biblios.t +++ a/t/db_dependent/Koha/Biblios.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 2; +use Test::More tests => 3; use C4::Biblio; use C4::Items; @@ -116,6 +116,15 @@ subtest 'can_be_transferred' => sub { .' invalid library is given.'); }; +subtest 'title_remainder' => sub { + plan tests => 1; + + my ($bibnum, $title, $bibitemnum) = create_helper_biblio('BK'); + + my $biblio = Koha::Biblios->find($bibnum); + is($biblio->title_remainder, 'Remainder', 'Got remainder of title'); +}; + $schema->storage->txn_rollback; @@ -127,7 +136,7 @@ sub create_helper_biblio { $title = 'Silence in the library'; $bib->append_fields( MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), - MARC::Field->new('245', ' ', ' ', a => $title), + MARC::Field->new('245', ' ', ' ', a => $title, b => 'Remainder'), MARC::Field->new('942', ' ', ' ', c => $itemtype), ); return ($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); --