summaryrefslogtreecommitdiff
path: root/contrib/non-profit-audit-reports
diff options
context:
space:
mode:
authorBradley M. Kuhn <bkuhn@ebb.org>2013-02-20 07:47:33 -0500
committerBradley M. Kuhn <bkuhn@ebb.org>2013-02-20 07:49:50 -0500
commitb378359f5f4fbfad3475f362699e3d353c1f7e80 (patch)
tree1fd9bf9a8528de9c4e74b78e4a3c00f99a064475 /contrib/non-profit-audit-reports
parentf33d232ba34e46e17a39e08ee2f2ad78b5aafb1a (diff)
downloadfork-ledger-b378359f5f4fbfad3475f362699e3d353c1f7e80.tar.gz
fork-ledger-b378359f5f4fbfad3475f362699e3d353c1f7e80.tar.bz2
fork-ledger-b378359f5f4fbfad3475f362699e3d353c1f7e80.zip
Use a Math::BigFloat() rather than a regular float for Adjustment comparison.
Based on patch review by Loïc Dachary <loic@dachary.org>, 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.
Diffstat (limited to 'contrib/non-profit-audit-reports')
-rwxr-xr-xcontrib/non-profit-audit-reports/summary-reports.plx7
1 files changed, 4 insertions, 3 deletions
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 <START_DATE> <END_DATE> <LEDGER_OPTIONS>\n";
@@ -249,7 +250,7 @@ foreach my $type (keys %incomeGroups) {
my($account, $amount) = ($1, $2);
$amount = ParseNumber($amount);
$account =~ s/\s+$//;
- next if $account =~ /\<Adjustment\>/ and (abs($amount) <= 0.02);
+ 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:/;
@@ -321,7 +322,7 @@ foreach my $line (<FILE>) {
my($account, $amount) = ($1, $2);
$amount = ParseNumber($amount);
$account =~ s/\s+$//;
- next if $account =~ /\<Adjustment\>/ and (abs($amount) <= 0.02);
+ 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:/;
@@ -416,7 +417,7 @@ foreach my $id (keys %commands) {
my($account, $amount) = ($1, $2);
$amount = ParseNumber($amount);
$account =~ s/\s+$//;
- next if $account =~ /\<Adjustment\>/ and (abs($amount) <= 0.02);
+ 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;