diff options
author | Bradley M. Kuhn <bkuhn@ebb.org> | 2012-11-21 13:34:55 -0500 |
---|---|---|
committer | Bradley M. Kuhn <bkuhn@ebb.org> | 2012-11-26 13:54:42 -0500 |
commit | b5316132d44a91ff664b39c194710f5f88051d74 (patch) | |
tree | e30a8b7b8673d68e3eb9a27ecce24078b68ae78e /contrib/non-profit-audit-reports/general-ledger-report.plx | |
parent | 01dc0416b9262905e66887b29ccef31d2867b9df (diff) | |
download | fork-ledger-b5316132d44a91ff664b39c194710f5f88051d74.tar.gz fork-ledger-b5316132d44a91ff664b39c194710f5f88051d74.tar.bz2 fork-ledger-b5316132d44a91ff664b39c194710f5f88051d74.zip |
MANIFEST output file that indicates which files are mentioned in general-ledger.
Due to reporting options given to ledger, not every file will be
referenced by the general-ledger spreadsheet. The generated MANIFEST file
now indicates which files were actually referenced in the general-ledger.
The demo.sh script now uses this MANIFEST to create a zip file that
contains only those files.
Diffstat (limited to 'contrib/non-profit-audit-reports/general-ledger-report.plx')
-rwxr-xr-x | contrib/non-profit-audit-reports/general-ledger-report.plx | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/contrib/non-profit-audit-reports/general-ledger-report.plx b/contrib/non-profit-audit-reports/general-ledger-report.plx index 1c293db9..07f0b9da 100755 --- a/contrib/non-profit-audit-reports/general-ledger-report.plx +++ b/contrib/non-profit-audit-reports/general-ledger-report.plx @@ -44,6 +44,7 @@ if (@ARGV < 3) { print STDERR "usage: $0 <BEGIN_DATE> <END_DATE> <OTHER_LEDGER_OPTS>\n"; exit 1; } +open(MANIFEST, ">", "MANIFEST") or die "Unable to open MANIFEST for writing: $!"; my($beginDate, $endDate, @otherLedgerOpts) = @ARGV; @@ -53,8 +54,6 @@ my(@chartOfAccountsOpts) = ('-F', "%150A\n", '-w', '-s', open(CHART_DATA, "-|", $LEDGER_CMD, @chartOfAccountsOpts) or die "Unable to run $LEDGER_CMD @chartOfAccountsOpts: $!"; -open(CHART_OUTPUT, ">", "chart-of-accounts.txt") or die "unable to write chart-of-accounts.txt: $!"; - my @accounts; while (my $line = <CHART_DATA>) { chomp $line; @@ -65,6 +64,7 @@ while (my $line = <CHART_DATA>) { close(CHART_DATA); die "error reading ledger output for chart of accounts: $!" unless $? == 0; open(CHART_OUTPUT, ">", "chart-of-accounts.txt") or die "unable to write chart-of-accounts.txt: $!"; +print MANIFEST "chart-of-accounts.txt\n"; my @sortedAccounts; foreach my $acct ( @@ -91,7 +91,9 @@ $formattedEndDate = $formattedEndDate->calc($oneDayLess); $formattedEndDate = $formattedEndDate->printf("%Y/%m/%d"); open(GL_TEXT_OUT, ">", "general-ledger.txt") or die "unable to write general-ledger.txt: $!"; +print MANIFEST "general-ledger.txt\n"; open(GL_CSV_OUT, ">", "general-ledger.csv") or die "unable to write general-ledger.csv: $!"; +print MANIFEST "general-ledger.csv\n"; foreach my $acct (@sortedAccounts) { print GL_TEXT_OUT "\n\nACCOUNT: $acct\nFROM: $beginDate TO $formattedEndDate\n\n"; @@ -122,6 +124,14 @@ foreach my $acct (@sortedAccounts) { foreach my $line (<GL_CSV_DATA>) { print GL_CSV_OUT $line; + next if $line =~ /ACCOUNT:.*PERIOD/; # Skip column header lines + $line =~ s/^"[^"]*","[^"]*","[^"]*","[^"]*","[^"]*",//; + while ($line =~ s/^"([^"]*)"(,|$)//) { + my $file = $1; + next if $file =~ /^\s*$/; + warn "$file does not exist and/or is not readable" unless -r $file; + print MANIFEST "$file\n"; + } } close(GL_CSV_DATA); die "error reading ledger output for chart of accounts: $!" unless $? == 0; } |