You need a state machine. When the scan occurs, check the state and process
accordingly.
State 0. Timer is disabled. Confirm the scan was the admin id, change state
to 1 and enable timer. If scan is not an admin id then report an error and
stay at state 0 with timer disabled.
State 1. Timer is enabled. Confirm that the scan was an item and process
it, then remain at state 1 with timer time re-initialized. If it was the
last item, set the state to 2 and re-initialise timer time. If the scan was
a receiver id and not all items have been processed, or an invalid item,
report an error, clear your tables and set timer to disabled and state to
0.
State 2. Confirm the scan is a receiver id. If not, clear tables, report an
error and set state to 0, otherwise process checkout, disable timer and set
state to 0.
If a timer tick occurs report a timeout error, clear all variables and set
timer to disabled and state to 0.