From 87da7ba3abf4d33d5f080c76b74654b8a6e6b0bc Mon Sep 17 00:00:00 2001 From: Gergely Risko Date: Tue, 9 Jul 2013 16:41:55 +0200 Subject: [PATCH 1/6] Fix comment string --- lisp/ledger-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el index 0dce4f61..387ace97 100644 --- a/lisp/ledger-mode.el +++ b/lisp/ledger-mode.el @@ -174,7 +174,7 @@ Can indent, complete or align depending on context." (ledger-check-version) (ledger-post-setup) - (set (make-local-variable 'comment-start) " ; ") + (set (make-local-variable 'comment-start) "; ") (set (make-local-variable 'comment-end) "") (set (make-local-variable 'indent-tabs-mode) nil) From 524fdf7aba16bad6c701a5fa7ed7d019a876c340 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 10 Jul 2013 17:14:26 -0400 Subject: [PATCH 2/6] The $formattedBeginDate should derive from $beginDate, not $endDate (duh!) --- contrib/non-profit-audit-reports/general-ledger-report.plx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/non-profit-audit-reports/general-ledger-report.plx b/contrib/non-profit-audit-reports/general-ledger-report.plx index dce855b4..0d6b28e6 100755 --- a/contrib/non-profit-audit-reports/general-ledger-report.plx +++ b/contrib/non-profit-audit-reports/general-ledger-report.plx @@ -58,7 +58,7 @@ $formattedEndDate = $formattedEndDate->calc($oneDayLess); $formattedEndDate = $formattedEndDate->printf("%Y/%m/%d"); my $formattedBeginDate = new Date::Manip::Date; -die "badly formatted end date, $endDate" if $formattedBeginDate->parse($endDate); +die "badly formatted end date, $beginDate" if $formattedBeginDate->parse($beginDate); $formattedBeginDate = $formattedBeginDate->printf("%Y/%m/%d"); From 515ae05d6b51d1488615f4fb09fb30fbd8181c3c Mon Sep 17 00:00:00 2001 From: Gergely Risko Date: Fri, 12 Jul 2013 01:07:25 +0200 Subject: [PATCH 3/6] Change ledger-next-amount to be case-sensitive Otherwise if there is an account that's name only has one part, the regex can match it as a currency and as the beginning of an amount. E.g. if we have the line "Expenses 45 USD", then the old ledger-next-amount will jump to Expenses instead of to 45. --- lisp/ledger-post.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lisp/ledger-post.el b/lisp/ledger-post.el index 447a34f8..5d30e954 100644 --- a/lisp/ledger-post.el +++ b/lisp/ledger-post.el @@ -117,11 +117,12 @@ to choose from." Return the width of the amount field as an integer and leave point at beginning of the commodity." ;;(beginning-of-line) - (when (re-search-forward ledger-amount-regex end t) - (goto-char (match-beginning 0)) - (skip-syntax-forward " ") - (- (or (match-end 4) - (match-end 3)) (point)))) + (let ((case-fold-search nil)) + (when (re-search-forward ledger-amount-regex end t) + (goto-char (match-beginning 0)) + (skip-syntax-forward " ") + (- (or (match-end 4) + (match-end 3)) (point))))) (defun ledger-next-account (&optional end) From 8908b032341eaa18c81c43a4792a84cdac05fe36 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Fri, 12 Jul 2013 14:26:29 -0400 Subject: [PATCH 4/6] Use "ledger accounts" command rather than the '-F "%150A\n" reg' report solution. Ledger has had (probably for some time) an "accounts" command that will list all the accounts from all transactions meeting the other criteria set on the command line. That's really what we're looking for here when we build this chart of accounts, and thus that should be used. Note that this corrects a subtle bug that wasn't apparent with the old solution. With the '-F "%150A\n" reg' solution, accounts that balanced out to zero for period (e.g., accrual accounts that were emptied during in the month) did not show up on the reports. This bug that I didn't know I had here is thus now fixed by switching to the "accounts" report. --- .../cash-receipts-and-disbursments-journals.plx | 3 +-- contrib/non-profit-audit-reports/general-ledger-report.plx | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/contrib/non-profit-audit-reports/cash-receipts-and-disbursments-journals.plx b/contrib/non-profit-audit-reports/cash-receipts-and-disbursments-journals.plx index 6234542c..937d2a45 100755 --- a/contrib/non-profit-audit-reports/cash-receipts-and-disbursments-journals.plx +++ b/contrib/non-profit-audit-reports/cash-receipts-and-disbursments-journals.plx @@ -67,8 +67,7 @@ if (@ARGV < 2) { my($beginDate, $endDate, @otherLedgerOpts) = @ARGV; -my(@chartOfAccountsOpts) = ('-V', '-F', "%150A\n", '-w', '-s', - '-b', $beginDate, '-e', $endDate, @otherLedgerOpts, 'reg'); +my(@chartOfAccountsOpts) = ('-b', $beginDate, '-e', $endDate, @otherLedgerOpts, 'accounts'); open(CHART_DATA, "-|", $LEDGER_CMD, @chartOfAccountsOpts) or die "Unable to run $LEDGER_CMD @chartOfAccountsOpts: $!"; diff --git a/contrib/non-profit-audit-reports/general-ledger-report.plx b/contrib/non-profit-audit-reports/general-ledger-report.plx index 0d6b28e6..4a4f89cc 100755 --- a/contrib/non-profit-audit-reports/general-ledger-report.plx +++ b/contrib/non-profit-audit-reports/general-ledger-report.plx @@ -62,8 +62,7 @@ die "badly formatted end date, $beginDate" if $formattedBeginDate->parse($beginD $formattedBeginDate = $formattedBeginDate->printf("%Y/%m/%d"); -my(@chartOfAccountsOpts) = ('-V', '-F', "%150A\n", '-w', '-s', - '-b', $beginDate, '-e', $endDate, @otherLedgerOpts, 'reg'); +my(@chartOfAccountsOpts) = ('-b', $beginDate, '-e', $endDate, @otherLedgerOpts, 'accounts'); open(CHART_DATA, "-|", $LEDGER_CMD, @chartOfAccountsOpts) or die "Unable to run $LEDGER_CMD @chartOfAccountsOpts: $!"; From ce1c3e874791326c55eec4401d97ffa72c58a5c6 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sun, 14 Jul 2013 15:07:29 -0400 Subject: [PATCH 5/6] Add Fraud Receivable to Accrued accounts. Funds lots and expected recoverable from Fraud are in an account called "Accrued:Fraud Receivable". In this report, show this along with the total of Loan Receivables. --- contrib/non-profit-audit-reports/summary-reports.plx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/non-profit-audit-reports/summary-reports.plx b/contrib/non-profit-audit-reports/summary-reports.plx index 53d205b3..1730208a 100755 --- a/contrib/non-profit-audit-reports/summary-reports.plx +++ b/contrib/non-profit-audit-reports/summary-reports.plx @@ -98,7 +98,7 @@ 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 Receivable' => {args => [ '-e', $endDate, 'bal', '/^Accrued:Loans 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/' ]}, @@ -161,7 +161,7 @@ print BALANCE_SHEET "\"BALANCE SHEET\"\n", my $formatStr = "\"\",\"%-42s\",\"\$%13s\"\n"; my $formatStrTotal = "\"\",\"%-45s\",\"\$%13s\"\n"; my $tot = $ZERO; -foreach my $item ('Cash', 'Accounts Receivable', 'Loans Receivable') { +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}; @@ -195,7 +195,7 @@ 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 Receivable'}{total})) - + + $reportFields{'Loans/Fraud Receivable'}{total})) - abs($reportFields{'Accounts Payable'}{total} + $reportFields{'Accrued Expenses'}{total} + $reportFields{'Unearned Income, Conference Registration'}{total} + From 9dc352ad6f8c29ad90db20832f3efae9b75a8aa6 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sun, 14 Jul 2013 15:09:52 -0400 Subject: [PATCH 6/6] Some of the totals rounded via -V cause rounding more than one penny. Use two cents as to test if the amounts are close enough. --- contrib/non-profit-audit-reports/summary-reports.plx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/non-profit-audit-reports/summary-reports.plx b/contrib/non-profit-audit-reports/summary-reports.plx index 1730208a..ddc97737 100755 --- a/contrib/non-profit-audit-reports/summary-reports.plx +++ b/contrib/non-profit-audit-reports/summary-reports.plx @@ -202,12 +202,12 @@ die "Cash+accounts receivable total does not equal net assets and liabilities to $reportFields{'Unearned Income, Other'}{total} + $reportFields{'Liabilities, Credit Cards'}{total} + $reportFields{'Liabilities, Other'}{total} + - $reportFields{'Total Net Assets'}{total}) > $ONE_PENNY); + $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}) > $ONE_PENNY); + $reportFields{'Temporarily Restricted Net Assets'}{total}) > $TWO_CENTS); my %incomeGroups = ('INTEREST INCOME' => { args => ['/^Income.*Interest/' ] }, @@ -280,7 +280,7 @@ print INCOME "\n\n\n", sprintf($formatStrTotal, "OVERALL TOTAL:", Commify($overa 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}) > $ONE_PENNY); + if (abs($overallTotal) - abs($incomeGroups{TOTAL}{total}) > $TWO_CENTS); print STDERR "\n"; @@ -380,7 +380,7 @@ 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) > $ONE_PENNY); + if (abs($overallTotal) - abs($firstTotal) > $TWO_CENTS); print STDERR "\n";