1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
#!/usr/bin/perl
# fund-report.plx -*- Perl -*-
#
# Script to generate end-of-year summary reports.
#
# Copyright (C) 2011, 2012, 2013, Bradley M. Kuhn
#
# This program gives you software freedom; you can copy, modify, convey,
# and/or redistribute it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program in a file called 'GPLv3'. If not, write to the:
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor
# Boston, MA 02110-1301, USA.
use strict;
use warnings;
use Math::BigFloat;
use Date::Manip;
my $VERBOSE = 0;
my $DEBUG = 0;
my $LEDGER_BIN = "/usr/local/bin/ledger";
my $ACCT_WIDTH = 70;
sub Commify ($) {
my $text = reverse $_[0];
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
return scalar reverse $text;
}
sub preferredAccountSorting ($$) {
if ($_[0] =~ /^Assets/ and $_[1] !~ /^Assets/) {
return -1;
} elsif ($_[1] =~ /^Assets/ and $_[0] !~ /^Assets/) {
return 1;
} elsif ($_[0] =~ /^Liabilities/ and $_[1] !~ /^(Assets|Liabilities)/) {
return -1;
} elsif ($_[1] =~ /^Liabilities/ and $_[0] !~ /^(Assets|Liabilities)/) {
return 1;
} elsif ($_[0] =~ /^(Accrued:[^:]+Receivable)/ and $_[1] !~ /^(Assets|Liabilities|Accrued:[^:]+Receivable)/) {
return -1;
} elsif ($_[1] =~ /^(Accrued:[^:]+Receivable)/ and $_[0] !~ /^(Assets|Liabilities|Accrued:[^:]+Receivable)/) {
return 1;
} elsif ($_[0] =~ /^(Accrued)/ and $_[1] !~ /^(Assets|Liabilities|Accrued)/) {
return -1;
} elsif ($_[1] =~ /^(Accrued)/ and $_[0] !~ /^(Assets|Liabilities|Accrued)/) {
return 1;
} elsif ($_[0] =~ /^(Unearned Income)/ and $_[1] !~ /^(Assets|Liabilities|Accrued|Unearned Income)/) {
return -1;
} elsif ($_[1] =~ /^(Unearned Income)/ and $_[0] !~ /^(Assets|Liabilities|Accrued|Unearned Income)/) {
return 1;
} elsif ($_[0] =~ /^Income/ and $_[1] !~ /^(Assets|Liabilities|Accrued|Unearned Income|Income)/) {
return -1;
} elsif ($_[1] =~ /^Income/ and $_[0] !~ /^(Assets|Liabilities|Accrued|Unearned Income|Income)/) {
return 1;
} elsif ($_[0] =~ /^Expense/ and $_[1] !~ /^(Assets|Liabilities|Accrued|Income|Unearned Income|Expense)/) {
return -1;
} elsif ($_[1] =~ /^Expense/ and $_[0] !~ /^(Assets|Liabilities|Accrued|Income|Unearned Income|Expense)/) {
return 1;
} else {
return $_[0] cmp $_[1];
}
}
sub ParseNumber($) {
$_[0] =~ s/,//g;
return Math::BigFloat->new($_[0]);
}
Math::BigFloat->precision(-2);
my $ZERO = Math::BigFloat->new("0.00");
my $ONE_PENNY = Math::BigFloat->new("0.01");
my $TWO_CENTS = Math::BigFloat->new("0.02");
if (@ARGV < 2) {
print STDERR "usage: $0 <START_DATE> <END_DATE> <LEDGER_OPTIONS>\n";
exit 1;
}
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($startDate), "%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/' ]},
'Loans/Fraud Receivable' => {args => [ '-e', $endDate, 'bal', '/^Accrued:(Loans|Fraud) Receivable/' ]},
'Accounts Payable' => {args => [ '-e', $endDate, 'bal', '/^Accrued.*Accounts Payable/' ]},
'Accrued Expenses' => {args => [ '-e', $endDate, 'bal', '/^Accrued.*Expenses/' ]},
'Liabilities, Credit Cards' => {args => [ '-e', $endDate, 'bal', '/^Liabilities:Credit Card/' ]},
'Liabilities, Other' => {args => [ '-e', $endDate, 'bal', '/^Liabilities/',
'and', 'not', '/^Liabilities:Credit Card/']},
'Unearned Income, Conference Registration' => {args => [ '-e', $endDate, 'bal',
'/^Unearned Income.*Reg/' ]},
'Unearned Income, Other' => {args => [ '-e', $endDate, 'bal', '/^Unearned Income/', 'and', 'not',
'/^Unearned Income.*Reg/' ]},
'Unrestricted Net Assets' => {args => [ '-e', $endDate, 'bal', '/^(Income|Expenses):Conservancy/' ]},
'Temporarily Restricted Net Assets' => {args => [ '-e', $endDate, 'bal', '/^(Income|Expenses)/',
'and', 'not', '/^(Unearned Income|(Income|Expenses):Conservancy)/' ]},
'Total Net Assets' => {args => [ '-e', $endDate, 'bal', '/^(Income|Expenses)/' ]},
);
foreach my $item (keys %reportFields) {
my(@fullCommand) = ($LEDGER_BIN, @mainLedgerOptions,
'-V', '-X', '$', '-S', 'T', '-s', '-d', 'T', @{$reportFields{$item}{args}});
open(FILE, "-|", @fullCommand)
or die "unable to run command ledger command: @fullCommand: $!";
my $foundBalance;
my $seenTotalLine = 0;
print STDERR ($VERBOSE ? "Running: @fullCommand\n" : ".");
print STDERR " Output of @fullCommand\n" if $DEBUG;
while (my $line = <FILE>) {
print STDERR $line if ($DEBUG);
$seenTotalLine = 1 if $line =~ /^\s*\-+\s*/; # Skip lines until the total line
$foundBalance = $1
if (not $seenTotalLine and $line =~ /^\s*[^0-9\-]+\s*([\-\d,\.]+)\s+/);
if ($line =~ /^\s*\$\s*([\-\d,\.]+)\s*$/) {
$foundBalance = $1;
last;
}
}
close FILE;
die "problem running ledger command: @fullCommand: $!" unless ($? == 0);
if (not defined $foundBalance) {
$foundBalance = $ZERO;
} else {
$foundBalance =~ s/,//g;
$foundBalance = Math::BigFloat->new($foundBalance);
}
$foundBalance = $ZERO if not defined $foundBalance;
$reportFields{$item}{total} = abs($foundBalance);
print STDERR "$item: $reportFields{$item}{total}\n" if $VERBOSE;
}
open(BALANCE_SHEET, ">", "balance-sheet.csv")
or die "unable to open balance-sheet.csv for writing: $!";
print BALANCE_SHEET "\"BALANCE SHEET\"\n",
"\"Ending\",\"", $formattedEndDate, "\"\n",
"\n\n\"ASSETS\"\n\n";
my $formatStr = "\"\",\"%-42s\",\"\$%13s\"\n";
my $formatStrTotal = "\"\",\"%-45s\",\"\$%13s\"\n";
my $tot = $ZERO;
foreach my $item ('Cash', 'Accounts Receivable', 'Loans/Fraud Receivable') {
next if $reportFields{$item}{total} == $ZERO;
print BALANCE_SHEET sprintf($formatStr, "$item:", Commify($reportFields{$item}{total}));
$tot += $reportFields{$item}{total};
}
print BALANCE_SHEET "\n", sprintf($formatStrTotal, "TOTAL ASSETS", Commify($tot)), "\n\nLIABILITIES\n\n";
my $totLiabilities = $ZERO;
foreach my $item ('Accounts Payable', 'Accrued Expenses',
'Liabilities, Credit Cards', 'Liabilities, Other',
'Unearned Income, Conference Registration', 'Unearned Income, Other') {
next if $reportFields{$item}{total} == $ZERO;
print BALANCE_SHEET sprintf($formatStr, "$item:", Commify($reportFields{$item}{total}));
$totLiabilities += $reportFields{$item}{total};
}
print BALANCE_SHEET "\n", sprintf($formatStr, "TOTAL LIABILTIES", Commify($totLiabilities)),
"\n\nNET ASSETS\n\n";
my $totNetAssets = $ZERO;
foreach my $item ('Unrestricted Net Assets', 'Temporarily Restricted Net Assets') {
next if $reportFields{$item}{total} == $ZERO;
print BALANCE_SHEET sprintf($formatStr, "$item:", Commify($reportFields{$item}{total}));
$totNetAssets += $reportFields{$item}{total};
}
print BALANCE_SHEET "\n", sprintf($formatStr, "TOTAL NET ASSETS", Commify($totNetAssets)), "\n\n",
sprintf($formatStrTotal, "TOTAL LIABILITIES AND NET ASSETS",
Commify($totNetAssets + $totLiabilities));
close BALANCE_SHEET;
print STDERR "\n";
die "unable to write to balance-sheet.csv: $!" unless ($? == 0);
die "Cash+accounts receivable total does not equal net assets and liabilities total"
if (abs( ($reportFields{'Cash'}{total} + $reportFields{'Accounts Receivable'}{total}
+ $reportFields{'Loans/Fraud Receivable'}{total})) -
abs($reportFields{'Accounts Payable'}{total} +
$reportFields{'Accrued Expenses'}{total} +
$reportFields{'Unearned Income, Conference Registration'}{total} +
$reportFields{'Unearned Income, Other'}{total} +
$reportFields{'Liabilities, Credit Cards'}{total} +
$reportFields{'Liabilities, Other'}{total} +
$reportFields{'Total Net Assets'}{total}) > $TWO_CENTS);
die "Total net assets doesn't equal sum of restricted and unrestricted ones!"
if (abs($reportFields{'Total Net Assets'}{total}) -
abs($reportFields{'Unrestricted Net Assets'}{total} +
$reportFields{'Temporarily Restricted Net Assets'}{total}) > $TWO_CENTS);
my %incomeGroups = ('INTEREST INCOME' => { args => ['/^Income.*Interest/' ] },
'DONATIONS' => { args => [ '/^Income.*Donation/' ] },
'BOOK ROYALTIES & AFFILIATE PROGRAMS' =>
{ args => [ '/^Income.*(Royalt|Affiliate)/' ] },
'CONFERENCES, REGISTRATION' => {args => [ '/^Income.*Reg/' ] },
'CONFERENCES, RELATED BUSINESS INCOME' => { args => [ '/^Income.*(Conferences?:.*Sponsor|Booth|RBI)/'] },
'LICENSE COMPLIANCE' => { args => [ '/^Income.*(Enforce|Compliance)/' ]},
'TRADEMARKS' => {args => [ '/^Income.*Trademark/' ]},
'ADVERSITING' => {args => [ '/^Income.*Advertising/' ]});
my @otherArgs;
foreach my $type (keys %incomeGroups) {
@otherArgs = ("/^Income/") if @otherArgs == 0;
push(@otherArgs, 'and', 'not', @{$incomeGroups{$type}{args}});
}
$incomeGroups{"OTHER"}{args} = \@otherArgs;
$incomeGroups{"TOTAL"}{args} = ['/^Income/'];
open(INCOME, ">", "income.csv") or die "unable to open income.csv for writing: $!";
foreach my $type (keys %incomeGroups) {
my(@fullCommand) = ($LEDGER_BIN, @mainLedgerOptions, '-V', '-X', '$',
'-b', $startDate, '-e', $endDate,
'-F', '%-.80A %22.108t\n', '-s',
'reg', @{$incomeGroups{$type}{args}});
open(FILE, "-|", @fullCommand)
or die "unable to run command ledger command: @fullCommand: $!";
print STDERR ($VERBOSE ? "Running: @fullCommand\n" : ".");
$incomeGroups{$type}{total} = $ZERO;
$incomeGroups{$type}{output} = "";
foreach my $line (<FILE>) {
die "Unable to parse output line from second funds command: $line"
unless $line =~ /^\s*([^\$]+)\s+\$\s*([\-\d\.\,]+)/;
my($account, $amount) = ($1, $2);
$amount = ParseNumber($amount);
$account =~ s/\s+$//;
next if $account =~ /\<Adjustment\>/ and (abs($amount) <= $TWO_CENTS);
die "Weird account found, $account with amount of $amount in income command\n"
unless $account =~ /^\s*Income:/;
$incomeGroups{$type}{total} += $amount;
$incomeGroups{$type}{output} .= "\"$account\",\"\$$amount\"\n";
}
}
print INCOME "\"INCOME\",",
"\"STARTING:\",\"$formattedStartDate\",\"ENDING:\",\"$formattedEndDate\"\n\n";
my $overallTotal = $ZERO;
$formatStrTotal = "\"%-90s\",\"\$%14s\"\n";
foreach my $type ('DONATIONS', 'LICENSE COMPLIANCE',
'CONFERENCES, REGISTRATION', 'CONFERENCES, RELATED BUSINESS INCOME',
'BOOK ROYALTIES & AFFILIATE PROGRAMS', 'ADVERSITING',
'TRADEMARKS', 'INTEREST INCOME', 'OTHER') {
next if ($incomeGroups{$type}{output} =~ /^\s*$/ and $incomeGroups{$type}{total} == $ZERO);
print INCOME "\n\"$type\"\n",
$incomeGroups{$type}{output}, "\n",
sprintf($formatStrTotal, "TOTAL $type:", Commify($incomeGroups{$type}{total}));
$overallTotal += $incomeGroups{$type}{total};
}
print INCOME "\n\n\n", sprintf($formatStrTotal, "OVERALL TOTAL:", Commify($overallTotal));
close INCOME; die "unable to write to income.csv: $!" unless ($? == 0);
die "calculated total of $overallTotal does equal $incomeGroups{TOTAL}{total}"
if (abs($overallTotal) - abs($incomeGroups{TOTAL}{total}) > $TWO_CENTS);
print STDERR "\n";
my %expenseGroups = ('BANKING FEES' => { regex => '^Expenses.*(Banking Fees|Currency Conversion)' },
'COMPUTING, HOSTING AND EQUIPMENT' => { regex => '^Expenses.*(Hosting|Computer Equipment)' },
'CONFERENCES' => { regex => '^Expenses.*(Conferences|Sprint)' },
'DEVELOPER MENTORING' => {regex => '^Expenses.*Mentor' },
'LICENSE COMPLIANCE' => { regex => '^Expenses.*(Enforce|Compliance)' },
'ACCOUNTING' => { regex => '^Expenses.*(Accounting|Annual Audit)' },
'PAYROLL' => { regex => '^Expenses.*Payroll' },
'OFFICE' => { regex => '^Expenses.*(Office|Phones)' },
'RENT' => { regex => '^Expenses.*Rent' },
'SOFTWARE DEVELOPMENT' => { regex => '^Expenses.*Development' },
'OTHER PROGRAM ACTIVITY' => {regex => '^Expenses.*Gould' },
'ADVOCACY AND PROMOTION' => {regex => '^Expenses.*(Slipstream|Advocacy Merchandise|Promotional)' },
'ADVERSITING' => {regex => '^Expenses.*Advertising' });
foreach my $type (keys %expenseGroups, 'TRAVEL') {
$expenseGroups{$type}{total} = $ZERO;
$expenseGroups{$type}{output} = "";
}
open(EXPENSE, ">", "expense.csv") or die "unable to open expense.csv for writing: $!";
my(@fullCommand) = ($LEDGER_BIN, @mainLedgerOptions, '-V', '-X', '$',
'-b', $startDate, '-e', $endDate,
'-F', '%-.80A %22.108t\n', '-s',
'reg', '/^Expenses/');
open(FILE, "-|", @fullCommand)
or die "unable to run command ledger command: @fullCommand: $!";
print STDERR ($VERBOSE ? "Running: @fullCommand\n" : ".");
my $firstTotal = $ZERO;
foreach my $line (<FILE>) {
die "Unable to parse output line from second funds command: $line"
unless $line =~ /^\s*([^\$]+)\s+\$\s*([\-\d\.\,]+)/;
my($account, $amount) = ($1, $2);
$amount = ParseNumber($amount);
$account =~ s/\s+$//;
next if $account =~ /\<Adjustment\>/ and (abs($amount) <= $TWO_CENTS);
die "Weird account found, $account, with amount of $amount in expenses command\n"
unless $account =~ /^\s*Expenses:/;
my $outputLine = "\"$account\",\"\$$amount\"\n";
my $taken = 0;
# Note: Prioritize to put things under conference expenses if they were for a conference.
foreach my $type ('CONFERENCES', keys %expenseGroups) {
last if $taken;
next if $type eq 'TRAVEL' or $type eq 'OTHER';
next unless $line =~ /$expenseGroups{$type}{regex}/;
$taken = 1;
$expenseGroups{$type}{total} += $amount;
$expenseGroups{$type}{output} .= $outputLine;
}
if (not $taken) {
if ($account =~ /Travel/) {
$expenseGroups{'TRAVEL'}{total} += $amount;
$expenseGroups{'TRAVEL'}{output} .= $outputLine;
} else {
$expenseGroups{'OTHER'}{total} += $amount;
$expenseGroups{'OTHER'}{output} .= $outputLine;
}
}
$firstTotal += $amount;
}
print EXPENSE "\"EXPENSES\",",
"\"STARTING:\",\"$formattedStartDate\",\"ENDING:\",\"$formattedEndDate\"\n\n";
$overallTotal = $ZERO;
$formatStrTotal = "\"%-90s\",\"\$%14s\"\n";
my %verifyAllGroups;
foreach my $key (keys %expenseGroups) {
$verifyAllGroups{$key} = 1;
}
foreach my $type ('PAYROLL', 'SOFTWARE DEVELOPMENT', 'LICENSE COMPLIANCE', 'CONFERENCES',
'DEVELOPER MENTORING', 'TRAVEL', 'BANKING FEES', 'ADVOCACY AND PROMOTION',
'COMPUTING, HOSTING AND EQUIPMENT', 'ACCOUNTING',
'OFFICE', 'RENT', 'ADVERSITING', 'OTHER PROGRAM ACTIVITY', 'OTHER') {
delete $verifyAllGroups{$type};
die "$type is not defined!" if not defined $expenseGroups{$type};
next if ($expenseGroups{$type}{output} =~ /^\s*$/ and $expenseGroups{$type}{total} == $ZERO);
print EXPENSE "\n\"$type\"\n",
$expenseGroups{$type}{output}, "\n",
sprintf($formatStrTotal, "TOTAL $type:", Commify($expenseGroups{$type}{total}));
$overallTotal += $expenseGroups{$type}{total};
}
print EXPENSE "\n\n\n", sprintf($formatStrTotal, "OVERALL TOTAL:", Commify($overallTotal));
close EXPENSE; die "unable to write to expense.csv: $!" unless ($? == 0);
die "GROUPS NOT INCLUDED : ", join(keys(%verifyAllGroups), ", "), "\n"
unless (keys %verifyAllGroups == 0);
die "calculated total of $overallTotal does *not* equal $firstTotal"
if (abs($overallTotal) - abs($firstTotal) > $TWO_CENTS);
print STDERR "\n";
open(TRIAL, ">", "trial-balance.csv") or die "unable to open accrued.txt for writing: $!";
print TRIAL "\"TRIAL BALANCE REPORT\",\"ENDING: $formattedEndDate\"\n\n",
"\"ACCOUNT\",\"BALANCE AT $formattedStartDate\",\"CHANGE DURING PERIOD\",\"BALANCE AT $formattedEndDate\"\n\n";
my %commands = (
'totalEndFY' => [ $LEDGER_BIN, @mainLedgerOptions, '-V', '-X', '$',
'-e', $endDate, '-F', '%-.80A %22.108t\n', '-s',
'reg' ],
'amountInYear' => [ $LEDGER_BIN, @mainLedgerOptions, '-V', '-X', '$',
'-b', $startDate, '-e', $endDate, '-F', '%-.80A %22.108t\n',
'-s', 'reg' ],
'totalBeginFY' => [ $LEDGER_BIN, @mainLedgerOptions, '-V', '-X', '$',
'-e', $startDate, '-F', '%-.80A %22.108t\n',
'-s', 'reg' ]);
my %trialBalanceData;
my %fullAccountList;
foreach my $id (keys %commands) {
my(@command) = @{$commands{$id}};
open(FILE, "-|", @command)
or die "unable to run command ledger command: @command: $!";
print STDERR ($VERBOSE ? "Running: @command\n" : ".");
foreach my $line (<FILE>) {
die "Unable to parse output line from trial balance $id command: $line"
unless $line =~ /^\s*([^\$]+)\s+\$\s*([\-\d\.\,]+)/;
my($account, $amount) = ($1, $2);
$amount = ParseNumber($amount);
$account =~ s/\s+$//;
next if $account =~ /\<Adjustment\>/ and (abs($amount) <= $TWO_CENTS);
next if $account =~ /^Equity:/; # Stupid auto-account made by ledger.
$trialBalanceData{$id}{$account} = $amount;
$fullAccountList{$account} = $id;
}
close FILE;
die "unable to run trial balance ledger command, @command: $!" unless ($? == 0);
}
my $curOn = 'Assets';
foreach my $account (sort preferredAccountSorting keys %fullAccountList) {
# Blank lines right
if ($account !~ /^$curOn/) {
print TRIAL "pagebreak\n";
$curOn = $account;
if ($curOn =~ /(Accrued:[^:]+):.*$/) {
$curOn = $1;
} else {
$curOn =~ s/^([^:]+):.*$/$1/;
}
}
if ($account =~ /^Assets|Liabilities|Accrued|Unearned Income/) {
foreach my $id (qw/totalBeginFY totalEndFY amountInYear/) {
$trialBalanceData{$id}{$account} = $ZERO
unless defined $trialBalanceData{$id}{$account};
}
print TRIAL "\"$account\",\"\$$trialBalanceData{totalBeginFY}{$account}\",",
"\"\$$trialBalanceData{amountInYear}{$account}\",\"\$$trialBalanceData{totalEndFY}{$account}\"\n"
unless $trialBalanceData{totalBeginFY}{$account} == $ZERO and
$trialBalanceData{amountInYear}{$account} == $ZERO and
$trialBalanceData{totalEndFY}{$account} == $ZERO;
} else {
print TRIAL "\"$account\",\"\",\"\$$trialBalanceData{amountInYear}{$account}\",\"\"\n"
if defined $trialBalanceData{amountInYear}{$account} and
$trialBalanceData{amountInYear}{$account} != $ZERO;
}
}
close TRIAL;
die "unable to write trial-balance.csv: $!" unless ($? == 0);
###############################################################################
#
# Local variables:
# compile-command: "perl -c summary-reports.plx"
# End:
|