From 76292d08d92365a10964255a01a60ee1f6aa7448 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Fri, 23 Nov 2012 09:07:12 -0500 Subject: Calculate dates in a reusable way throughout script. --- contrib/non-profit-audit-reports/summary-reports.plx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'contrib/non-profit-audit-reports') diff --git a/contrib/non-profit-audit-reports/summary-reports.plx b/contrib/non-profit-audit-reports/summary-reports.plx index 154662f1..b49e6bdd 100755 --- a/contrib/non-profit-audit-reports/summary-reports.plx +++ b/contrib/non-profit-audit-reports/summary-reports.plx @@ -53,6 +53,14 @@ if (@ARGV < 2) { } my($startDate, $endDate, @mainLedgerOptions) = @ARGV; +my $err; +my $formattedEndDate = UnixDate(DateCalc(ParseDate($endDate), ParseDateDelta("- 1 day"), \$err), + "%B %e, %Y"); +die "Date calculation error on $endDate" if ($err); + +my $formattedStartDate = UnixDate(ParseDate($endDate), "%B %e, %Y"), +die "Date calculation error on $startDate" if ($err); + my %reportFields = ('Cash' => { args => [ '-e', $endDate, 'bal', '/^Assets/' ] }, 'Accounts Receivable' => {args => [ '-e', $endDate, 'bal', '/^Accrued:Accounts Receivable/' ]}, @@ -109,16 +117,12 @@ foreach my $item (keys %reportFields) { print STDERR "$item: $reportFields{$item}{total}\n" if $VERBOSE; } -my $err; open(BALANCE_SHEET, ">", "balance-sheet.txt") or die "unable to open balance-sheet.txt for writing: $!"; print BALANCE_SHEET " BALANCE SHEET\n", - " Ending ", - UnixDate(DateCalc(ParseDate($endDate), ParseDateDelta("- 1 day"), \$err), - "%B %e, %Y\n"), + " Ending ", $formattedEndDate, "\n", "\n\nASSETS\n\n"; -die "Date calculation error" if ($err); my $formatStr = " %-42s \$%13s\n"; my $formatStrTotal = "%-45s \$%13s\n"; -- cgit v1.2.3