Fix ledger options and be sure starting is set to zero for new funds.

This commit is contained in:
Bradley M. Kuhn 2011-11-01 12:15:25 -04:00
parent 89caa8296e
commit 8ac2e9d3c6

View file

@ -44,7 +44,8 @@ if (@ARGV < 2) {
my($startDate, $endDate, @mainLedgerOptions) = @ARGV; my($startDate, $endDate, @mainLedgerOptions) = @ARGV;
# First, get fund list from ending balance # First, get fund list from ending balance
my(@ledgerOptions) = ('--wide-register-format', "%-.70A %22.108t\n", '-w', '-s', my(@ledgerOptions) = (@mainLedgerOptions,
'--wide-register-format', "%-.70A %22.108t\n", '-w', '-s',
'-e', $endDate, 'reg', '^Funds:Restricted:'); '-e', $endDate, 'reg', '^Funds:Restricted:');
@ -64,7 +65,8 @@ while (my $fundLine = <LEDGER_FUNDS>) {
close LEDGER_FUNDS; close LEDGER_FUNDS;
# First, get fund list from ending balance # First, get fund list from ending balance
@ledgerOptions = ('--wide-register-format', "%-.70A %22.108t\n", '-w', '-s', @ledgerOptions = (@mainLedgerOptions,
'--wide-register-format', "%-.70A %22.108t\n", '-w', '-s',
'-e', $startDate, 'reg', '^Funds:Restricted:'); '-e', $startDate, 'reg', '^Funds:Restricted:');
open(LEDGER_FUNDS, "-|", $LEDGER_CMD, @ledgerOptions) open(LEDGER_FUNDS, "-|", $LEDGER_CMD, @ledgerOptions)
@ -78,16 +80,19 @@ while (my $fundLine = <LEDGER_FUNDS>) {
$account =~ s/^\s+Funds:Restricted://; $account =~ s/\s+$//; $account =~ s/^\s+Funds:Restricted://; $account =~ s/\s+$//;
$funds{$account}{starting} = $amount; $funds{$account}{starting} = $amount;
} }
close LEDGER_FUNDS; close LEDGER_FUNDS;
foreach my $fund (keys %funds) {
$funds{$fund}{starting} = $ZERO if not defined $funds{$fund}{starting};
}
my $format = "%-${ACCT_WIDTH}.${ACCT_WIDTH}s \$%11.2f \$%11.2f\n"; my $format = "%-${ACCT_WIDTH}.${ACCT_WIDTH}s \$%11.2f \$%11.2f\n";
my($totDeb, $totCred) = ($ZERO, $ZERO); my($totDeb, $totCred) = ($ZERO, $ZERO);
foreach my $fund (sort keys %funds) { foreach my $fund (sort keys %funds) {
print "Fund: $fund\n"; print "Fund: $fund\n";
print " Balance as of $startDate: ", sprintf("\$11.2f\n", $funds{$fund}{starting}); print " Balance as of $startDate: ", sprintf("\$%11.2f\n", $funds{$fund}{starting});
print " Balance as of $endDate: ", sprintf("\$11.2f\n", $funds{$fund}{ending}); print " Balance as of $endDate: ", sprintf("\$%11.2f\n", $funds{$fund}{ending});
print "\n\n"; print "\n\n";
} }
############################################################################### ###############################################################################