1 # Copyright 2002-2007 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 # $Id: summary.tag,v 1.5 2007-03-30 23:40:57 pajamian Exp $
10 # [summary amount=n.nn
18 # Calculates column totals (if used properly. 8-\)
21 UserTag summary Order amount
22 UserTag summary PosNumber 1
23 UserTag summary addAttr
24 UserTag summary Version $Revision: 1.5 $
25 UserTag summary Routine <<EOF
27 my ($amount, $opt) = @_;
28 my $summary_hash = $::Instance->{tag_summary_hash} ||= {};
30 unless ($name = $opt->{name} ) {
32 %$summary_hash = () if Vend::Util::is_yes($opt->{reset});
35 $summary_hash->{$name} = 0 if Vend::Util::is_yes($opt->{reset});
37 $summary_hash->{$name} += $amount if length $amount;
38 $amount = $summary_hash->{$name} if Vend::Util::is_yes($opt->{total});
39 return '' if $opt->{hide};
40 return sprintf($opt->{format}, $amount) if $opt->{format};
41 return Vend::Util::currency($amount) if $opt->{currency};