Fix deduplication bug, refactor deduplication to own plugin
(Bumps version to 3.8 because admins should update the plugin list.) Deduplication didn't work on quantified additions, i.e. if you added "20x clubmate" when there was already clubmate in the cart, it would add just ONE item, and have a lingering message that the next thing would be multiplied by 20. This old bug was especially annoying if there is a barcode "20x clubmate" to scan 20 bottles (which is the size of a crate), and this is repeated. The fix also uncovered another bug: newly added entries were selected too early. There are two hooks, hook_add_entry and hook_added_entry, and of course the selection should happen in between, not before the former. No entry in UPGRADING.md, because I think it is extremely unlikely that any plugin author will have used the selection feature yet, which is very new.
This commit is contained in:
parent
248681631d
commit
fffb2d72e9
9 changed files with 65 additions and 42 deletions
|
@ -21,6 +21,8 @@ sub add_entry($self, $entry) {
|
|||
|
||||
push @{ $self->{entries} }, $entry;
|
||||
$self->{changed}++;
|
||||
$self->select($entry);
|
||||
|
||||
RevBank::Plugins::call_hooks("added_entry", $self, $entry);
|
||||
|
||||
return $entry;
|
||||
|
@ -35,9 +37,7 @@ sub add($self, $amount, $description, $data = {}) {
|
|||
# ->add($user, ...) => use $cart->add(...)->add_contra($user, ...)
|
||||
# ->add($entry) => use $cart->add_entry($entry)
|
||||
|
||||
my $entry = $self->add_entry(RevBank::Cart::Entry->new($amount, $description, $data));
|
||||
$self->select($entry);
|
||||
return $entry;
|
||||
return $self->add_entry(RevBank::Cart::Entry->new($amount, $description, $data));
|
||||
}
|
||||
|
||||
sub select($self, $entry) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue