Close book + new file

Doug Pastorello SpiderDad10 at comcast.net
Mon Jan 12 20:13:49 EST 2009


John,
It sounds like you are looking to split up your GC file so that you get
a set of files, each with a year's worth of transactions. The script I
sent currently only removes old transactions. To do what you want, you
will also need to delete transactions newer than a given date (year). I
have not tried this, but if you modify the subroutine that detects
deletable transactions, it may result in the kind of file you want. Here
is my suggested change;

sub splitIsDeletable {
  my ($inSplit, $xctYear) = @_;
  my ($splAcnt) = $accounts{$inSplit->{accountId}};
  my ($splAcntType) = $splAcnt->{type};
  my ($rslt) = 0;
  # Work only on splits not marked for delete
  if ($inSplit->{toDelete} == 0) {
    if (($xctYear < $delYear) || ($xctYear > $delYear)) {
      if (($splAcntType eq "BANK") ||
	  ($splAcntType eq "CASH") ||
	  ($splAcntType eq "CREDIT") ||
	  ($splAcntType eq "EXPENSE") ||
	  ($splAcntType eq "EQUITY") ||
	  ($splAcntType eq "LIABILITY") ||
	  ($splAcntType eq "INCOME") ||
	  ($xctYear > $delYear)) {
	$splAcnt->{newXactCnt}--;
	$rslt = 1;
	$inSplit->{toDelete} = 1;
      }
    }
  }
  #print "DEBUG: $inSplit->{id}, $splAcntType, $xctYear, $rslt\n";
  return($rslt);
}

With this change, only transactions of the given year will remain in the
new file. You can then make a new file for each year, based on your
original file. You will need to set the starting balances in each new
file.

As far as cleaning up the imbalances goes, you can transfer them to what
ever account makes sense in your accounting system. I just use it as a
way to total my carry-over from previous years.

Finally, the CSV files created by the script are just for debug. You can
delete them, or change the script to not create them.

	-- Doug.


On Sun, 2009-01-11 at 18:16 -0700, John R. Carter, Sr. wrote:
> I guess I was thinking that by using this tool I would be left with  
> one file that had the older (prior to the split) transactions in it  
> and a new file with all the new transactions in it. The original file  
> is left intact. That leaves me to delete all transactions newer than  
> the split date in the original file so it isn't cluttered with  
> transactions that don't apply.
> 
> Here's my process. I haven't done any splits since I started with  
> Quicken back in 1986.  I have lots of stock transactions since then. I  
> was hoping to start splitting with year 1987 and archive the 1986  
> transactions. Then split on 1988 and archive the 1987 transactions.  
> And so on. I know it's going to be a lot of manual work to clean up  
> the Imbalance each year, but I'm retired with nothing else to worry  
> about. Without being left with two files, one with the old  
> transactions and one with the new transactions, I have a whole lot  
> more work to do.
> 
> I'm also guessing that when you say to clean up the Imbalances by  
> transferring them to "Retained Earnings" that you mean to create that  
> account - because it doesn't exist in my file. Would "Retained  
> Earnings" be a top level account, or under Assets:Fixed? And since the  
> definition of "Retained Earnings" really applies to net income that a  
> company doesn't distribute to stockholders, it makes me think that I  
> should rather transfer Imbalance to "Equity:Opening Balance".
> 
> And now the final question. What do I do with the two CSV files that  
> are created with each split?
> 
> On Jan 7, 2009, at 8:06 PM, Doug Pastorello wrote:
> 
> > For those who expressed interest in this, I've attached my perl  
> > script.
> > It is not the cleanest way to clear out old transactions, but should  
> > be
> > O.K. until one of us gets around to doing the real thing in GnuCash.
> >
> > Here is how I use it;
> > o Create an account summary report up to the end of <year>
> >  - This will be used to create the initial account balances in the
> >    new file, so export it so you can use it later.
> > o gunzip the GC file (may need to add a ".gz" to the name)
> > o run gcCull.pl <file> <year>
> >  - This removes all transactions older than last day of <year>
> >    (except for stock and mutual fund accounts)
> >  - new_<file> is created
> > o Open the new file in GC
> > o Run Actions/Check&repair/Check&Repair all
> > o Delete any unused accounts, sub-account, and transactions
> > o zero out the "imbalance" accounts using transfers from
> >  "Retained Earnings". (optional)
> > o Create starting balances for cleaned accounts using the account
> >  summary created from the original database.
> >
> > There are 2 subroutines that determine when splits should be  
> > removed, so
> > the script should be easy to customize to your needs.
> >
> > Let me know how things work out :)
> > 	-- Doug.
> 
> --
> John Carter
> 
> 



More information about the gnucash-user mailing list