From 8998566068ebc079e82c6a4c4e6a8376f0b256c3 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Sat, 24 Dec 2022 23:22:13 +0100 Subject: [PATCH] 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. --- plugins/pfand | 56 ------------------------------------------------- revbank.plugins | 1 - 2 files changed, 57 deletions(-) delete mode 100644 plugins/pfand diff --git a/plugins/pfand b/plugins/pfand deleted file mode 100644 index c95eabc..0000000 --- a/plugins/pfand +++ /dev/null @@ -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; -} diff --git a/revbank.plugins b/revbank.plugins index 30faa9e..2573345 100644 --- a/revbank.plugins +++ b/revbank.plugins @@ -13,7 +13,6 @@ give grandtotal take split -#pfand # makes little sense in a self service environment #cash # cash tracking also requires deposit_methods to make sense #skim # cash tracking also requires deposit_methods to make sense stock