Browse Source

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>
22.11.x
Jonathan Druart 9 months ago
committed by Tomas Cohen Arazi
parent
commit
b6fd2ece23
Signed by: tomascohen GPG Key ID: 0A272EA1B2F3C15F
  1. 3
      Koha/CurbsidePickup.pm
  2. 12
      Koha/CurbsidePickups.pm
  3. 8
      circ/curbside_pickups.pl
  4. 3
      mainpage.pl
  5. 9
      opac/opac-curbside-pickups.pl
  6. 6
      t/db_dependent/Koha/CurbsidePickups.t

3
Koha/CurbsidePickup.pm

@ -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}

12
Koha/CurbsidePickups.pm

@ -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

8
circ/curbside_pickups.pl

@ -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,
);

3
mainpage.pl

@ -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,
);
}

9
opac/opac-curbside-pickups.pl

@ -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,

6
t/db_dependent/Koha/CurbsidePickups.t

@ -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…
Cancel
Save