make_invoice [options]
Options:
- --log, the log file to use to make the invoice
- --template, the template to use to make the invoice
- --svn, whether to use subversion or not
+ --log,-l the log file to use to make the invoice
+ --template,-t the template to use to make the invoice
+ --min-time-interval, -m minimum time to bill, default 0
+ --time-granularity, -g time granularity, default 0
+ --hourly-fee, -f hourly fee, default 50.00
+ --svn,-s whether to use subversion or not
--debug, -d debugging level (Default 0)
--help, -h display this help
--man, -m display manual
use Cwd qw(cwd);
use Text::Template;
+use Params::Validate qw(validate_with :types);
+
my %options = (log => undef,
template => undef,
svn => undef,
invoice => undef,
- time_interval => 0,
- time_granularity => 0,
+ time_interval => 0.00,
+ time_granularity => 0.00,
hourly_fee => '50.00',
debug => 0,
help => 0,
my $calc_log = '';
-my $tex_log = '';
+my $tex_log = <<'EOF';
+\setlength\LTleft{0pt plus 1fill minus 1fill}%
+\let\LTright\LTleft
+\begin{longtable}{|p{9cm}|r|r|r|r|}%
+% \caption*{}
+\hline
+ \mbox{Description} & Item Cost & Quantity & Cost & Total \\
+\endhead
+EOF
my $totaldelta = undef;
+my $total = 0;
+
my $first_date = undef;
my $last_date = undef;
my $time = undef;
chomp;
if (/^\s*\* /) {
if (defined $time) {
- $tex_log .= format_events($date,$date2,$time,@events);
+ $tex_log .= format_events(date => $date,
+ date2 => $date2,
+ time => $time,
+ total => \$total,
+ events => \@events);
@events = ();
$date = undef;
$time = undef;
}
$calc_log .= "\nTotal: ".Delta_Format($totaldelta,2,q(%ht)).qq(\n);
if (defined $time) {
- $tex_log .= format_events($date,$date2,$time,@events);
+ $tex_log .= format_events(date => $date,
+ date2 => $date2,
+ time => $time,
+ total => \$total,
+ events => \@events);
@events = ();
$date = undef;
$date2 = undef;
$time = undef;
}
+$tex_log .= <<'EOF';
+\hline\hline
+\multicolumn{4}{|r|}{\textbf{Total}} & \$%
+EOF
+
+$tex_log .= sprintf('%.2f',$total)."%\n";
+
+$tex_log .= <<'EOF';
+\\
+\hline
+\end{longtable}
+EOF
my $template;
{
"invoice_${invoice_date}.tex",
) == 0 or die "Unable to add log and invoice to svn";
system('svn','propset','svn:ignore',
- "*.aux\n*.log\n*.dvi\n*.ps\n*.pdf\n",
+ "*.aux\n*.log\n*.dvi\n*.ps\n*.pdf\nauto\n",
'.'
) == 0 or die "Unable to set svn:ignore";
}
sub format_events{
- my ($date,$date2,$time,@events) = @_;
- my $output = ' \Fee{'.strftime('%A, %B %e, %H:%M',localtime(UnixDate($date,'%s'))).
- ' to '.strftime('%H:%M %Z',localtime(UnixDate($date2,'%s')))."\n".
- ' \begin{itemize*}'."\n";
- $output .= join('',map {" \\item $_\n"} @events);
- $output .= ' \end{itemize*}}{50.00}{'.$time.'}'."\n";
+ my %param = validate_with(params => \@_,
+ spec => {time => {type => SCALAR,
+ },
+ date => {type => SCALAR,
+ },
+ date2 => {type => SCALAR,
+ },
+ total => {type => SCALARREF,
+ },
+ events => {type => ARRAYREF,
+ },
+ },
+ );
+ ${$param{total}} += $param{time} * $options{hourly_fee};
+
+# $param{date} =~ s/\s+\d+\:\d+\:\d+\s+[A-Z]{0,3}\s*//;
+ my $output = '\hline'."\n".' \mbox{'.strftime('%A, %B %e, %H:%M',localtime(UnixDate($param{date},'%s'))).
+ ' to '.strftime('%H:%M %Z',localtime(UnixDate($param{date2},'%s')))."}\n\n".
+ ' \begin{itemize*}'."\n";
+ $output .= join('',map { s/_/\\_/g; " \\item $_\n";} @{$param{events}});
+ $output .= ' \end{itemize*} & \$'.sprintf('%.2f',$options{hourly_fee}).' & '.sprintf('%.2f',$param{time}).
+ ' & \$'.sprintf('%.2f',$param{time}*$options{hourly_fee}).' & \$'.
+ sprintf('%.2f',${$param{total}}) .
+ " \\\\\n";
return $output;
}
+## sub format_events{
+## my ($date,$date2,$time,@events) = @_;
+## my $output = ' \Fee{'.strftime('%A, %B %e, %H:%M',localtime(UnixDate($date,'%s'))).
+## ' to '.strftime('%H:%M %Z',localtime(UnixDate($date2,'%s')))."\n".
+## ' \begin{itemize*}'."\n";
+## $output .= join('',map {" \\item $_\n"} @events);
+## $output .= ' \end{itemize*}}{50.00}{'.$time.'}'."\n";
+## return $output;
+## }
+
__END__