Bug 31328: Make Koha::Item->get_transfer* use Koha::Item::Transfers->filter_by_current
This patch makes the get_transfer and get_transfers methods internally use the new ->filter_by_current method. To test: 1. Run: $ kshell k$ prove t/db_dependent/Koha/Item.t => SUCCESS: Tests pass! 2. Apply this rewriting patch 3. Repeat 1 => SUCCESS: Tests still pass! 4. Sign off :-D Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
b3d8941c34
commit
e58bb3d605
1 changed files with 14 additions and 24 deletions
38
Koha/Item.pm
38
Koha/Item.pm
|
@ -569,19 +569,13 @@ we still expect the item to end up at a final location eventually.
|
|||
|
||||
sub get_transfer {
|
||||
my ($self) = @_;
|
||||
my $transfer_rs = $self->_result->branchtransfers->search(
|
||||
{
|
||||
datearrived => undef,
|
||||
datecancelled => undef
|
||||
},
|
||||
{
|
||||
order_by =>
|
||||
[ { -desc => 'datesent' }, { -asc => 'daterequested' } ],
|
||||
rows => 1
|
||||
}
|
||||
)->first;
|
||||
return unless $transfer_rs;
|
||||
return Koha::Item::Transfer->_new_from_dbic($transfer_rs);
|
||||
|
||||
my $transfers_rs = Koha::Item::Transfers
|
||||
->_new_from_dbic(scalar $self->_result->branchtransfers)
|
||||
->filter_by_current
|
||||
->search( {}, { order_by => [ { -desc => 'datesent' }, { -asc => 'daterequested' } ], rows => 1 } );
|
||||
|
||||
return $transfers_rs->next;
|
||||
}
|
||||
|
||||
=head3 get_transfers
|
||||
|
@ -603,17 +597,13 @@ we still expect the item to end up at a final location eventually.
|
|||
|
||||
sub get_transfers {
|
||||
my ($self) = @_;
|
||||
my $transfer_rs = $self->_result->branchtransfers->search(
|
||||
{
|
||||
datearrived => undef,
|
||||
datecancelled => undef
|
||||
},
|
||||
{
|
||||
order_by =>
|
||||
[ { -desc => 'datesent' }, { -asc => 'daterequested' } ],
|
||||
}
|
||||
);
|
||||
return Koha::Item::Transfers->_new_from_dbic($transfer_rs);
|
||||
|
||||
my $transfer_rs = $self->_result->branchtransfers;
|
||||
|
||||
return Koha::Item::Transfers
|
||||
->_new_from_dbic($transfer_rs)
|
||||
->filter_by_current
|
||||
->search( {}, { order_by => [ { -desc => 'datesent' }, { -asc => 'daterequested' } ], } );
|
||||
}
|
||||
|
||||
=head3 last_returned_by
|
||||
|
|
Loading…
Reference in a new issue