diff options
author | Bradley M. Kuhn <bkuhn@ebb.org> | 2012-11-21 14:52:39 -0500 |
---|---|---|
committer | Bradley M. Kuhn <bkuhn@ebb.org> | 2012-11-26 13:54:44 -0500 |
commit | 60f45c3e2cff809f6c9356e9853cf38070bd3ec6 (patch) | |
tree | e3a2275dec30a2309cd9bdda2aa4581675920be0 /contrib/non-profit-audit-reports/fund-report.plx | |
parent | 5305642e4dafcd662c3c6842a383aaf4b27938d4 (diff) | |
download | fork-ledger-60f45c3e2cff809f6c9356e9853cf38070bd3ec6.tar.gz fork-ledger-60f45c3e2cff809f6c9356e9853cf38070bd3ec6.tar.bz2 fork-ledger-60f45c3e2cff809f6c9356e9853cf38070bd3ec6.zip |
Ignore <Adjustment> entries in the report.
With the advent of multi-currency in accounts, <Adjustment> lines can be
generated in reports. I don't know if there's a way to turn these off on
the Ledger command line or not at the moment, but if they're there, they
clearly should be ignored by this script.
Diffstat (limited to 'contrib/non-profit-audit-reports/fund-report.plx')
-rwxr-xr-x | contrib/non-profit-audit-reports/fund-report.plx | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/contrib/non-profit-audit-reports/fund-report.plx b/contrib/non-profit-audit-reports/fund-report.plx index 673263d7..a463bccf 100755 --- a/contrib/non-profit-audit-reports/fund-report.plx +++ b/contrib/non-profit-audit-reports/fund-report.plx @@ -40,26 +40,26 @@ if (@ARGV < 2) { print STDERR "usage: $0 <START_DATE> <END_DATE> <LEDGER_OPTIONS>\n"; exit 1; } - my($startDate, $endDate, @mainLedgerOptions) = @ARGV; # First, get fund list from ending balance my(@ledgerOptions) = (@mainLedgerOptions, '-V', '-X', '$', '-F', "%-.70A %22.108t\n", '-s', '-e', $endDate, 'reg', '/^Funds:Restricted:/'); - - my %funds; open(LEDGER_FUNDS, "-|", $LEDGER_CMD, @ledgerOptions) or die "Unable to run $LEDGER_CMD for funds: $!"; while (my $fundLine = <LEDGER_FUNDS>) { - die "Unable to parse output line from funds command: \"$fundLine\"" - unless $fundLine =~ /^\s*([^\$]+)\s+\$\s*\s*([\d\.\,]+)/; + die "Unable to parse output line from first funds command: \"$fundLine\"" + unless $fundLine =~ /^\s*([^\$]+)\s+\$\s*\s*([\-\d\.\,]+)/; my($account, $amount) = ($1, $2); $amount = ParseNumber($amount); - $account =~ s/^\s*Funds:Restricted://; $account =~ s/\s+$//; + $account =~ s/\s+$//; + next if $account =~ /\<Adjustment\>/ and (abs($amount) <= 0.02); + die "Weird account found, $account with amount of $amount in first funds command\n" + unless $account =~ s/^\s*Funds:Restricted://; $funds{$account}{ending} = $amount; } close LEDGER_FUNDS; @@ -73,11 +73,14 @@ open(LEDGER_FUNDS, "-|", $LEDGER_CMD, @ledgerOptions) or die "Unable to run $LEDGER_CMD for funds: $!"; while (my $fundLine = <LEDGER_FUNDS>) { - die "Unable to parse output line from funds command: $fundLine" - unless $fundLine =~ /^\s*([^\$]+)\s+\$\s*\s*([\d\.\,]+)/; + die "Unable to parse output line from second funds command: $fundLine" + unless $fundLine =~ /^\s*([^\$]+)\s+\$\s*([\-\d\.\,]+)/; my($account, $amount) = ($1, $2); $amount = ParseNumber($amount); - $account =~ s/^\s*Funds:Restricted://; $account =~ s/\s+$//; + $account =~ s/\s+$//; + next if $account =~ /\<Adjustment\>/ and (abs($amount) <= 0.02); + die "Weird account found, $account with amount of $amount in first second command\n" + unless $account =~ s/^\s*Funds:Restricted://; $funds{$account}{starting} = $amount; } close LEDGER_FUNDS; |