Remove "pfand" plugin
Originally written as a proof of concept demo. Reportedly it's broken and cumbersome to use anyway, because of the external config file. I don't think anyone is actually using this right now.
This commit is contained in:
parent
c34caf434a
commit
8998566068
2 changed files with 0 additions and 57 deletions
|
@ -1,56 +0,0 @@
|
||||||
#!perl
|
|
||||||
|
|
||||||
HELP "pfand" => "Pfand zurueck";
|
|
||||||
|
|
||||||
# This is a demo plugin. It's called "pfand" because "deposit" would be
|
|
||||||
# confusing and only the Germans are crazy enough to have deposits on small
|
|
||||||
# bottles anyway ;)
|
|
||||||
#
|
|
||||||
# ^^ aged like milk - the netherlands has deposits on small bottles now.
|
|
||||||
# (but we're allowed to sell them without, for immediate consumption)
|
|
||||||
|
|
||||||
# The file format for 'revbank.pfand' is simply two whitespace separated
|
|
||||||
# columns: product id and pfand amount.
|
|
||||||
|
|
||||||
sub _read_pfand() {
|
|
||||||
return {
|
|
||||||
map { split " " } grep /\S/, grep !/^\s*#/, slurp 'revbank.pfand'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
sub command :Tab(pfand) ($self, $cart, $command, @) {
|
|
||||||
return NEXT if $command ne 'pfand';
|
|
||||||
|
|
||||||
return "Pfand zurueck fuer", \&product;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub product :Tab(&tab) ($self, $cart, $product, @) {
|
|
||||||
my $pfand = parse_amount(_read_pfand->{ $product })
|
|
||||||
or return REJECT, "Invalid pfand amount for $product";
|
|
||||||
|
|
||||||
if ($pfand) {
|
|
||||||
$cart
|
|
||||||
->add(+$pfand, "Pfand zurueck", { is_return => 1 })
|
|
||||||
->add_contra("-pfand", -$pfand, "Pfand fuer \$you");
|
|
||||||
} else {
|
|
||||||
say "$product: Kein Pfand";
|
|
||||||
}
|
|
||||||
return ACCEPT;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub tab {
|
|
||||||
return keys %{ _read_pfand() };
|
|
||||||
}
|
|
||||||
|
|
||||||
sub hook_add_entry ($class, $cart, $entry, @) {
|
|
||||||
return if $entry->has_attribute('is_return');
|
|
||||||
return if not $entry->has_attribute('product_id');
|
|
||||||
|
|
||||||
my $pfand = _read_pfand->{ $entry->attribute('product_id') } or return;
|
|
||||||
|
|
||||||
$cart
|
|
||||||
->add(-$pfand, "Pfand", { is_pfand => 1 })
|
|
||||||
->add_contra("-pfand", +$pfand, "Pfand von \$you");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
|
@ -13,7 +13,6 @@ give
|
||||||
grandtotal
|
grandtotal
|
||||||
take
|
take
|
||||||
split
|
split
|
||||||
#pfand # makes little sense in a self service environment
|
|
||||||
#cash # cash tracking also requires deposit_methods to make sense
|
#cash # cash tracking also requires deposit_methods to make sense
|
||||||
#skim # cash tracking also requires deposit_methods to make sense
|
#skim # cash tracking also requires deposit_methods to make sense
|
||||||
stock
|
stock
|
||||||
|
|
Loading…
Add table
Reference in a new issue