########################################### package Plugger::TaxedPosition; # 2004, Mike Schilli ########################################### use strict; use warnings; use Log::Log4perl qw(:easy); ########################################### sub AUTOLOAD { ########################################### no strict qw(vars refs); (my $func = $AUTOLOAD) =~ s/.*::/Plugger::Position::/; $func->(@_); } ########################################### sub init { ########################################### my($class, $ctx) = @_; $ctx->register_cmd("txstock", undef, \&process, undef); } ########################################### sub process { ########################################### my($ctx, $cmd, @args) = @_; my $value = price($args[0]) * $args[1]; my $gain = $value - $args[2] * $args[1]; my $tax = $gain / 2; $value -= $tax if $gain > 0; $gain -= $tax if $gain > 0; Plugger::Account::position( ucfirst($cmd), @args[0..2], price($args[0]), $value, $gain); my $mem = $ctx->mem(); $mem->{account_subtotal} += $value; $mem->{account_total} += $value; } 1;