X-Git-Url: https://git.donarmstrong.com/?p=bin.git;a=blobdiff_plain;f=make_invoice;h=0047d45079b0544e92a4c1121489629ad1c55a02;hp=c0d79badc06b6b03eae696a6560d05ba18b6decc;hb=HEAD;hpb=bdc133cce25309bc160f37da6232bfdc4dbb0ec0 diff --git a/make_invoice b/make_invoice index c0d79ba..0047d45 100755 --- a/make_invoice +++ b/make_invoice @@ -65,6 +65,14 @@ Time granularity, defaults to 0. Hourly fee, defaults to 50.00 +=item B<--tex-only> + +Only output the LaTeX file + +=item B<--log-only> + +Only output the log file + =item B<--debug, -d> Debug verbosity. (Default 0) @@ -105,6 +113,7 @@ my %options = (log => undef, help => 0, man => 0, log_only => 0, + tex_only => 0, ); GetOptions(\%options, @@ -113,6 +122,7 @@ GetOptions(\%options, 'time_interval|min-time-interval|T=s', 'hourly_fee|hourly-fee|f=s', 'log_only|log-only', + 'tex_only|tex-only', 'debug|d+','help|h|?','man|m'); pod2usage() if $options{help}; @@ -166,6 +176,7 @@ while (<$log_fh>) { chomp; next if /^Total: \d+\.\d{2}$/; if (/^\s*\* /) { + print STDERR $_."\n"; if (defined $time) { $tex_log .= format_events(date => $date, date2 => $date2, @@ -176,11 +187,24 @@ while (<$log_fh>) { $date = undef; $time = undef; } - s/\s*\[[\.\d]+\]\s*\[[\.\d]+\]\s*$//; - my $string = $_; - my ($d1,$d2) = map {s/^\s*\*\s*//; - UnixDate(ParseDate($_),'%s') - } split /\s*-\s*/; + s/\s*\[[\.\d]+\]\s*\[[\.\d]+\]\s*$//; + my ($d1,$d2); + if (/\s*\*\s*CLOCK:\s+\[([^\]]+)\]--\[([^\]]+)\]/ or + /^\s*\*\s*(.+)?\s* - \s*(.+)?\s*$/ + ) { + $d1 = UnixDate(ParseDate($1),'%s'); + $d2 = UnixDate(ParseDate($2),'%s'); + if (not defined $d1) { + die "Invalid date: $1"; + } + if (not defined $d2) { + die "Invalid date: $2"; + } + } else { + die "malformed line $_"; + } + my $string = '* '.strftime('%A, %B %e, %H:%M:%S',localtime($d1)).' - '. + strftime('%A, %B %e, %H:%M:%S',localtime($d2)); if (not defined $first_date) { $first_date = $d1; } @@ -197,7 +221,7 @@ while (<$log_fh>) { } $time = $hours; $totaldelta += $delta; - $calc_log .= qq($string [).sprintf('%.2f',$hours).qq(] [).sprintf('%.2f',$totaldelta/(60*60)).qq(]\n); + $calc_log .= $string.q( [).sprintf('%.2f',$hours).qq(] [).sprintf('%.2f',$totaldelta/(60*60)).qq(]\n); } elsif (/^\s+-\s*(.+)/) { my $event = $1; @@ -263,6 +287,12 @@ if ($options{log_only}) { exit 0; } +if ($options{tex_only}) { + print $tex_invoice; + exit 0; +} + + my $invoice_date = strftime('%Y_%m_%d',localtime($last_date)); my $invoice_dir = "invoice_$invoice_date";