This commit is contained in:
Juerd Waalboer 2020-03-01 06:16:08 +01:00
parent 31a1aa5c45
commit f7a7a19d8d
5 changed files with 18 additions and 6 deletions

View file

@ -75,6 +75,12 @@ sub size {
sub checkout {
my ($self, $user) = @_;
if ($self->entries('refuse_checkout')) {
warn "Refusing to finalize deficient transaction.\n";
$self->display;
return;
}
my $entries = $self->{entries};
my %deltas;
@ -98,6 +104,7 @@ sub checkout {
$self->empty;
sleep 1; # Ensure new timestamp/id for new transaction
return 1;
}
sub entries {

View file

@ -27,9 +27,11 @@ sub hook_cart_changed {
say "Pending:";
$cart->display;
my $sum = $cart->sum;
my $what = $sum > 0 ? "add %.2f" : "pay %.2f";
say sprintf "Enter username to $what; type 'abort' to abort.", abs $sum;
if (not $cart->entries('refuse_checkout')) {
my $sum = $cart->sum;
my $what = $sum > 0 ? "add %.2f" : "pay %.2f";
say sprintf "Enter username to $what; type 'abort' to abort.", abs $sum;
}
}
sub hook_abort {