diff options
author | Bradley M. Kuhn <bkuhn@ebb.org> | 2013-01-03 11:44:55 -0500 |
---|---|---|
committer | Bradley M. Kuhn <bkuhn@ebb.org> | 2013-01-03 11:44:55 -0500 |
commit | bfdf20b31cbb60b5d92c82ecd3a5192059a0c7b1 (patch) | |
tree | 280ac724e5c214e45c0a1ef20b57ebef0f95c980 /contrib/non-profit-audit-reports/summary-reports.plx | |
parent | 269d0fdd5efe2dc9de148f845f97ad95ddc1b8e9 (diff) | |
download | fork-ledger-bfdf20b31cbb60b5d92c82ecd3a5192059a0c7b1.tar.gz fork-ledger-bfdf20b31cbb60b5d92c82ecd3a5192059a0c7b1.tar.bz2 fork-ledger-bfdf20b31cbb60b5d92c82ecd3a5192059a0c7b1.zip |
Updated sorting function based on advice of auditing accountants.
Our auditing accounts tell us they want accounts sorted by:
Assets
Liabilities
Net Assets
Income
Expenses
in a general ledger report. Generally, I think we should just apply the
same sorting.
Since Ledger doesn't use account codes by default, this is my hack to
solve this problem for now. Maybe there should be an account code tag for
sorting purposes at least?
Diffstat (limited to 'contrib/non-profit-audit-reports/summary-reports.plx')
-rwxr-xr-x | contrib/non-profit-audit-reports/summary-reports.plx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/contrib/non-profit-audit-reports/summary-reports.plx b/contrib/non-profit-audit-reports/summary-reports.plx index ce6d56da..30b27505 100755 --- a/contrib/non-profit-audit-reports/summary-reports.plx +++ b/contrib/non-profit-audit-reports/summary-reports.plx @@ -39,6 +39,36 @@ sub Commify ($) { return scalar reverse $text; } +sub preferredAccountSorting ($$) { + if ($_[0] =~ /^Assets/) { + return -1; + } elsif ($_[1] =~ /^Assets/) { + return 1; + } elsif ($_[0] =~ /^Liabilities/ and $_[1] !~ /^Assets/) { + return -1; + } elsif ($_[1] =~ /^Liabilities/ and $_[0] !~ /^Assets/) { + return 1; + } elsif ($_[0] =~ /^(Accrued)/ and $_[1] !~ /^(Assets|Liabilities)/) { + return -1; + } elsif ($_[1] =~ /^(Accrued)/ and $_[0] !~ /^(Assets|Liabilities)/) { + return 1; + } elsif ($_[0] =~ /^(Unearned Income)/ and $_[1] !~ /^(Assets|Liabilities|Accrued)/) { + return -1; + } elsif ($_[1] =~ /^(Unearned Income)/ and $_[0] !~ /^(Assets|Liabilities|Accrued)/) { + return 1; + } elsif ($_[0] =~ /^Income/ and $_[1] !~ /^(Assets|Liabilities|Accrued|Unearned Income)/) { + return -1; + } elsif ($_[1] =~ /^Income/ and $_[0] !~ /^(Assets|Liabilities|Accrued|Unearned Income)/) { + return 1; + } elsif ($_[0] =~ /^Expense/ and $_[1] !~ /^(Assets|Liabilities|Accrued|Unearned Income|Expense)/) { + return -1; + } elsif ($_[1] =~ /^Expense/ and $_[0] !~ /^(Assets|Liabilities|Accrued|Unearned Income|Expense)/) { + return 1; + } else { + return $_[0] cmp $_[1]; + } +} + sub ParseNumber($) { $_[0] =~ s/,//g; return Math::BigFloat->new($_[0]); |