Handle cancelled arrival at checkout when departure at checkin is not cancelled
This commit is contained in:
parent
ee38d48a55
commit
a830acc698
3 changed files with 49 additions and 2 deletions
|
@ -817,7 +817,6 @@ sub startup {
|
||||||
arr_platform => $train->platform,
|
arr_platform => $train->platform,
|
||||||
sched_arrival => $train->sched_arrival,
|
sched_arrival => $train->sched_arrival,
|
||||||
real_arrival => $train->arrival,
|
real_arrival => $train->arrival,
|
||||||
cancelled => $train->arrival_is_cancelled ? 1 : 0,
|
|
||||||
route =>
|
route =>
|
||||||
$json->encode( [ $self->route_diff($train) ] ),
|
$json->encode( [ $self->route_diff($train) ] ),
|
||||||
messages => $json->encode(
|
messages => $json->encode(
|
||||||
|
@ -861,6 +860,39 @@ sub startup {
|
||||||
}
|
}
|
||||||
$self->invalidate_stats_cache( $cache_ts, $db, $uid );
|
$self->invalidate_stats_cache( $cache_ts, $db, $uid );
|
||||||
}
|
}
|
||||||
|
elsif ( defined $train and $train->arrival_is_cancelled ) {
|
||||||
|
|
||||||
|
# This branch is only taken if the deparure was not cancelled,
|
||||||
|
# i.e., if the train was supposed to go here but got
|
||||||
|
# redirected or cancelled on the way and not from the start on.
|
||||||
|
# If the departure itself was cancelled, the user route is
|
||||||
|
# cancelled_from action -> 'cancelled journey' panel on main page
|
||||||
|
# -> cancelled_to action -> force checkout (causing the
|
||||||
|
# previous branch to be taken due to $force)
|
||||||
|
$journey->{edited} = 0;
|
||||||
|
$journey->{checkout_time} = $now;
|
||||||
|
$journey->{cancelled} = 1;
|
||||||
|
delete $journey->{data};
|
||||||
|
$db->insert( 'journeys', $journey );
|
||||||
|
|
||||||
|
$journey
|
||||||
|
= $db->select( 'in_transit', ['data'],
|
||||||
|
{ user_id => $uid } )->expand->hash;
|
||||||
|
$journey->{data}{cancelled_destination} = $train->station;
|
||||||
|
|
||||||
|
$db->update(
|
||||||
|
'in_transit',
|
||||||
|
{
|
||||||
|
checkout_station_id => undef,
|
||||||
|
checkout_time => undef,
|
||||||
|
arr_platform => undef,
|
||||||
|
sched_arrival => undef,
|
||||||
|
real_arrival => undef,
|
||||||
|
data => JSON->new->encode( $journey->{data} ),
|
||||||
|
},
|
||||||
|
{ user_id => $uid }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$tx->commit;
|
$tx->commit;
|
||||||
};
|
};
|
||||||
|
|
|
@ -134,7 +134,15 @@ sub run {
|
||||||
checkout_station_id => $arr
|
checkout_station_id => $arr
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$self->app->add_route_timestamps( $uid, $train, 0 );
|
if ( $train->arrival_is_cancelled ) {
|
||||||
|
|
||||||
|
# check out (adds a cancelled journey and resets journey state
|
||||||
|
# to destination selection)
|
||||||
|
$self->app->checkout( $arr, 0, $uid );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$self->app->add_route_timestamps( $uid, $train, 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elsif ( $entry->{real_arr_ts} ) {
|
elsif ( $entry->{real_arr_ts} ) {
|
||||||
my ( undef, $error ) = $self->app->checkout( $arr, 1, $uid );
|
my ( undef, $error ) = $self->app->checkout( $arr, 1, $uid );
|
||||||
|
|
|
@ -163,6 +163,13 @@
|
||||||
</div>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
% }
|
% }
|
||||||
|
% if ($journey->{extra_data}{cancelled_destination}) {
|
||||||
|
<p style="margin-bottom: 2ex;">
|
||||||
|
Der Halt in <b><%= $journey->{extra_data}{cancelled_destination} %></b>
|
||||||
|
entfällt. Der Zugausfall wurde bereits vermerkt. Bitte wähle ein
|
||||||
|
neues Reiseziel.
|
||||||
|
</p>
|
||||||
|
% }
|
||||||
% if (@{$journey->{messages} // []} or @{$journey->{extra_data}{qos_msg} // []}) {
|
% if (@{$journey->{messages} // []} or @{$journey->{extra_data}{qos_msg} // []}) {
|
||||||
<p style="margin-bottom: 2ex;">
|
<p style="margin-bottom: 2ex;">
|
||||||
<ul>
|
<ul>
|
||||||
|
|
Loading…
Reference in a new issue