Merge pull request #159 from bkuhn/non-profit-audit-reports-updates-20130220
A few minor cleanups in non-profit-audit reports
This commit is contained in:
commit
e9416ca017
2 changed files with 31 additions and 5 deletions
|
|
@ -1,9 +1,21 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
# cash-receipts-and-disbursments-journals -*- 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.
|
# 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
|
# Copyright (C) 2011, 2012, 2013 Bradley M. Kuhn
|
||||||
#
|
#
|
||||||
# This program gives you software freedom; you can copy, modify, convey,
|
# This program gives you software freedom; you can copy, modify, convey,
|
||||||
|
|
@ -133,6 +145,19 @@ foreach my $typeData ({ name => 'disbursements', query => 'a<=0' },
|
||||||
next if $line =~
|
next if $line =~
|
||||||
/^\s*"[^"]*","[^"]*","[^"]*","(\s*\<\s*Adjustment\s*\>\s*|Equity:)/;
|
/^\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;
|
my $date = $line; chomp $date;
|
||||||
$date =~ s/^\s*"([^"]*)"\s*,.*$/$1/;
|
$date =~ s/^\s*"([^"]*)"\s*,.*$/$1/;
|
||||||
if (defined $date and $date !~ /^\s*$/ and
|
if (defined $date and $date !~ /^\s*$/ and
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ sub ParseNumber($) {
|
||||||
Math::BigFloat->precision(-2);
|
Math::BigFloat->precision(-2);
|
||||||
my $ZERO = Math::BigFloat->new("0.00");
|
my $ZERO = Math::BigFloat->new("0.00");
|
||||||
my $ONE_PENNY = Math::BigFloat->new("0.01");
|
my $ONE_PENNY = Math::BigFloat->new("0.01");
|
||||||
|
my $TWO_CENTS = Math::BigFloat->new("0.02");
|
||||||
|
|
||||||
if (@ARGV < 2) {
|
if (@ARGV < 2) {
|
||||||
print STDERR "usage: $0 <START_DATE> <END_DATE> <LEDGER_OPTIONS>\n";
|
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);
|
my($account, $amount) = ($1, $2);
|
||||||
$amount = ParseNumber($amount);
|
$amount = ParseNumber($amount);
|
||||||
$account =~ s/\s+$//;
|
$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"
|
die "Weird account found, $account with amount of $amount in income command\n"
|
||||||
unless $account =~ /^\s*Income:/;
|
unless $account =~ /^\s*Income:/;
|
||||||
|
|
||||||
|
|
@ -321,7 +322,7 @@ foreach my $line (<FILE>) {
|
||||||
my($account, $amount) = ($1, $2);
|
my($account, $amount) = ($1, $2);
|
||||||
$amount = ParseNumber($amount);
|
$amount = ParseNumber($amount);
|
||||||
$account =~ s/\s+$//;
|
$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"
|
die "Weird account found, $account, with amount of $amount in expenses command\n"
|
||||||
unless $account =~ /^\s*Expenses:/;
|
unless $account =~ /^\s*Expenses:/;
|
||||||
|
|
||||||
|
|
@ -378,7 +379,7 @@ close EXPENSE; die "unable to write to expense.csv: $!" unless ($? == 0);
|
||||||
die "GROUPS NOT INCLUDED : ", join(keys(%verifyAllGroups), ", "), "\n"
|
die "GROUPS NOT INCLUDED : ", join(keys(%verifyAllGroups), ", "), "\n"
|
||||||
unless (keys %verifyAllGroups == 0);
|
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);
|
if (abs($overallTotal) - abs($firstTotal) > $ONE_PENNY);
|
||||||
|
|
||||||
print STDERR "\n";
|
print STDERR "\n";
|
||||||
|
|
@ -416,7 +417,7 @@ foreach my $id (keys %commands) {
|
||||||
my($account, $amount) = ($1, $2);
|
my($account, $amount) = ($1, $2);
|
||||||
$amount = ParseNumber($amount);
|
$amount = ParseNumber($amount);
|
||||||
$account =~ s/\s+$//;
|
$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.
|
next if $account =~ /^Equity:/; # Stupid auto-account made by ledger.
|
||||||
$trialBalanceData{$id}{$account} = $amount;
|
$trialBalanceData{$id}{$account} = $amount;
|
||||||
$fullAccountList{$account} = $id;
|
$fullAccountList{$account} = $id;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue