Bug 30650: Add filter_by_scheduled_today
A bit of cleaning Sponsored-by: Association KohaLa - https://koha-fr.org/ Signed-off-by: Koha Team University Lyon 3 <koha@univ-lyon3.fr> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
78b96996f5
commit
b6fd2ece23
6 changed files with 25 additions and 16 deletions
|
@ -68,9 +68,8 @@ sub new {
|
|||
branchcode => $params->{branchcode},
|
||||
borrowernumber => $params->{borrowernumber},
|
||||
delivered_datetime => undef,
|
||||
scheduled_pickup_datetime => { '>' => \'DATE(NOW())' },
|
||||
}
|
||||
);
|
||||
)->filter_by_scheduled_today;
|
||||
Koha::Exceptions::CurbsidePickup::TooManyPickups->throw(
|
||||
branchcode => $params->{branchcode},
|
||||
borrowernumber => $params->{borrowernumber}
|
||||
|
|
|
@ -20,6 +20,7 @@ use Modern::Perl;
|
|||
use Carp;
|
||||
|
||||
use Koha::Database;
|
||||
use Koha::DateUtils qw( dt_from_string );
|
||||
|
||||
use Koha::CurbsidePickup;
|
||||
|
||||
|
@ -82,6 +83,17 @@ sub filter_by_delivered {
|
|||
return $self->search( { delivered_datetime => { -not => undef } } );
|
||||
}
|
||||
|
||||
=head3 filter_by_scheduled_today
|
||||
|
||||
Filter by pickups that are scheduled today
|
||||
|
||||
=cut
|
||||
sub filter_by_scheduled_today {
|
||||
my ($self) = @_;
|
||||
my $dtf = Koha::Database->new->schema->storage->datetime_parser;
|
||||
return $self->search( { scheduled_pickup_datetime => { '>' => $dtf->format_date(dt_from_string) } } );
|
||||
}
|
||||
|
||||
=head2 Internal Methods
|
||||
|
||||
=cut
|
||||
|
|
|
@ -61,9 +61,8 @@ if ( $op eq 'find-patron' ) {
|
|||
branchcode => $branchcode,
|
||||
borrowernumber => $patron->id,
|
||||
delivered_datetime => undef,
|
||||
scheduled_pickup_datetime => { '>' => \'DATE(NOW())' },
|
||||
}
|
||||
);
|
||||
)->filter_by_scheduled_today;
|
||||
} else {
|
||||
push @messages, {
|
||||
type => 'error',
|
||||
|
@ -143,10 +142,9 @@ $template->param(
|
|||
policy => Koha::CurbsidePickupPolicies->find({ branchcode => $branchcode }),
|
||||
curbside_pickups => Koha::CurbsidePickups->search(
|
||||
{
|
||||
branchcode => $branchcode,
|
||||
scheduled_pickup_datetime => { '>' => \'DATE(NOW())' },
|
||||
branchcode => $branchcode,
|
||||
}
|
||||
),
|
||||
)->filter_by_scheduled_today,
|
||||
);
|
||||
|
||||
|
||||
|
|
|
@ -114,9 +114,8 @@ if ( C4::Context->preference('CurbsidePickup') ) {
|
|||
new_curbside_pickups => Koha::CurbsidePickups->search(
|
||||
{
|
||||
branchcode => $homebranch,
|
||||
scheduled_pickup_datetime => { '>' => \'DATE(NOW())' },
|
||||
}
|
||||
)->filter_by_to_be_staged
|
||||
)->filter_by_to_be_staged->filter_by_scheduled_today,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,20 +108,17 @@ $template->param(
|
|||
patron_curbside_pickups => Koha::CurbsidePickups->search(
|
||||
{
|
||||
borrowernumber => $logged_in_patron->borrowernumber,
|
||||
scheduled_pickup_datetime => { '>' => \'DATE(NOW())' },
|
||||
},
|
||||
{
|
||||
order_by => { -asc => 'scheduled_pickup_datetime' }
|
||||
}
|
||||
),
|
||||
)->filter_by_scheduled_today,
|
||||
curbside_pickups => Koha::CurbsidePickups->search(
|
||||
{
|
||||
scheduled_pickup_datetime => { '>' => \'DATE(NOW())' },
|
||||
},
|
||||
{},
|
||||
{
|
||||
order_by => { -asc => 'scheduled_pickup_datetime' }
|
||||
}
|
||||
),
|
||||
)->filter_by_scheduled_today,
|
||||
);
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output, undef,
|
||||
|
|
|
@ -147,7 +147,7 @@ subtest 'Create a pickup' => sub {
|
|||
};
|
||||
|
||||
subtest 'workflow' => sub {
|
||||
plan tests => 9;
|
||||
plan tests => 11;
|
||||
|
||||
my $pickups =
|
||||
Koha::CurbsidePickups->search( { branchcode => $library->branchcode } );
|
||||
|
@ -184,6 +184,10 @@ subtest 'workflow' => sub {
|
|||
is( $cp->status, 'delivered' );
|
||||
is( $pickups->filter_by_delivered->count, 1 );
|
||||
|
||||
is( $pickups->filter_by_scheduled_today->count, 1 );
|
||||
$cp->scheduled_pickup_datetime($today->clone->subtract(days => 1))->store;
|
||||
is( $pickups->filter_by_scheduled_today->count, 0 );
|
||||
|
||||
$cp->delete;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue