From b378359f5f4fbfad3475f362699e3d353c1f7e80 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 20 Feb 2013 07:47:33 -0500 Subject: Use a Math::BigFloat() rather than a regular float for Adjustment comparison. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on patch review by Loïc Dachary , we discovered that this script inconsistently used 0.02 as a float when comparing against numbers from the Math::BigFloat() package. While there were no known bugs related to this (presumably the 0.02 got coerced into a BigFloat (or vice-versa) and compared properly), this change nevertheless normalizes to use of a BigFloat for comparison. --- contrib/non-profit-audit-reports/summary-reports.plx | 7 ++++--- 1 file changed, 4 insertions(+), 3 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 78848dc5..f710d765 100755 --- a/contrib/non-profit-audit-reports/summary-reports.plx +++ b/contrib/non-profit-audit-reports/summary-reports.plx @@ -80,6 +80,7 @@ sub ParseNumber($) { 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 \n"; @@ -249,7 +250,7 @@ foreach my $type (keys %incomeGroups) { my($account, $amount) = ($1, $2); $amount = ParseNumber($amount); $account =~ s/\s+$//; - next if $account =~ /\/ and (abs($amount) <= 0.02); + next if $account =~ /\/ and (abs($amount) <= $TWO_CENTS); die "Weird account found, $account with amount of $amount in income command\n" unless $account =~ /^\s*Income:/; @@ -321,7 +322,7 @@ foreach my $line () { my($account, $amount) = ($1, $2); $amount = ParseNumber($amount); $account =~ s/\s+$//; - next if $account =~ /\/ and (abs($amount) <= 0.02); + next if $account =~ /\/ and (abs($amount) <= $TWO_CENTS); die "Weird account found, $account, with amount of $amount in expenses command\n" unless $account =~ /^\s*Expenses:/; @@ -416,7 +417,7 @@ foreach my $id (keys %commands) { my($account, $amount) = ($1, $2); $amount = ParseNumber($amount); $account =~ s/\s+$//; - next if $account =~ /\/ and (abs($amount) <= 0.02); + next if $account =~ /\/ and (abs($amount) <= $TWO_CENTS); next if $account =~ /^Equity:/; # Stupid auto-account made by ledger. $trialBalanceData{$id}{$account} = $amount; $fullAccountList{$account} = $id; -- cgit v1.2.3 From e606dfd72f7b19b8733e7dc22cd82d8a36006298 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 20 Feb 2013 07:48:30 -0500 Subject: Fix typo in error output. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit HT Loïc Dachary , who noticed this. --- contrib/non-profit-audit-reports/summary-reports.plx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 f710d765..5caef4f0 100755 --- a/contrib/non-profit-audit-reports/summary-reports.plx +++ b/contrib/non-profit-audit-reports/summary-reports.plx @@ -379,7 +379,7 @@ 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 equal $firstTotal" +die "calculated total of $overallTotal does *not* equal $firstTotal" if (abs($overallTotal) - abs($firstTotal) > $ONE_PENNY); print STDERR "\n"; -- cgit v1.2.3 From a8403eac53c069ec7db434f41df0505543985086 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 20 Feb 2013 07:59:11 -0500 Subject: Include better explanation of what this report is for in the comments. --- .../cash-receipts-and-disbursments-journals.plx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'contrib/non-profit-audit-reports') 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 58cc75a9..2ca9e3b8 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 @@ -1,9 +1,21 @@ #!/usr/bin/perl # cash-receipts-and-disbursments-journals -*- Perl -*- # -# Script to generate a General Ledger report that accountants like +# Script to generate a cash receipts and disbursement joural reports # using Ledger. # +# Accountants sometimes ask for a report called the "cash receipts and +# disbursements journals". From a programmer's perspective, these are two +# reports that have the following properties: +# +# * Receipts: "a list of all transactions in the period where funds +# enter a cash account (i.e., the amount reconciled +# against the cash account is > 0" +# +# * Disbursements: "a list of all transactions in the period where +# funds leave a cash account (i.e., the amount +# reconciled against the cash account is < 0) +# # Copyright (C) 2011, 2012, 2013 Bradley M. Kuhn # # This program gives you software freedom; you can copy, modify, convey, -- cgit v1.2.3 From 88667ca0c5c8ca467153d163961865a572050516 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 20 Feb 2013 08:10:27 -0500 Subject: Comment to expound more on what it means for entries to be ignored by these reports. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Loïc Dachary , during patch review, pondered whether the ignoring of by these scripts could ever be used to hide funds, ala the movies Superman III and Office Space. After discussion, we both concluded that it would not be possible to hide funds merely with this report. Such hiding would have to also dig into the main Ledger codebase and muck with how it handles auto-generated entries. --- .../cash-receipts-and-disbursments-journals.plx | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'contrib/non-profit-audit-reports') 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 2ca9e3b8..6234542c 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 @@ -145,6 +145,19 @@ foreach my $typeData ({ name => 'disbursements', query => 'a<=0' }, next if $line =~ /^\s*"[^"]*","[^"]*","[^"]*","(\s*\<\s*Adjustment\s*\>\s*|Equity:)/; + # Note that we don't do our usual "$TWO_CENTS" check on Adjustment + # here. That's by design: if we consistently ignore Adjustements in + # the same way, it might have the appearance that a Superman + # III/Office Space -style movement of funds is going on. By just + # straight "ignoring" them here, and not doing the TWO_CENTS test, it + # helps to assure that. + + # However, it's worth noting that the ignoring of "Adjustment" in these + # scripts is not that meaningful and doesn't indicate as Superman + # III/Office Space -style scheme, because such a scheme would also have + # to be implemented in the main Ledger codebase. + + my $date = $line; chomp $date; $date =~ s/^\s*"([^"]*)"\s*,.*$/$1/; if (defined $date and $date !~ /^\s*$/ and -- cgit v1.2.3