Bulk transaction mover

Glen Ditchfield gjditchfield@acm.org
Thu, 27 Jul 2000 22:36:55 -0500

It doesn't bother me that the UI find-and-replace operation might be less
powerful than the programming API. The important thing is that UI
must make sense to J. Q. Ickenuser, who is probably not used to structured
data, and whose mental model for find-and-replace comes from a word processor. 
J. Q. uses find-and-replace to do insertions (by including the found text in
the replacement string) and deletions (by using an empty replacement).

When thinking about the UI find-and-and-replace, what confused me was
the "find" part.  Does it find transactions, or splits?  Consider a transaction
that contains three splits, and a find-and-replace that gives a split
as the replacement value and a set of search criteria that match two of the
splits.  What does the "find" show the user? 

1) The transaction, with all three splits?
2) The transaction, but only the two matching splits?
3) The matching splits, treating each as a separately found thing?

Does the replacement replace

1) the whole transaction (yielding a transaction with one split)
2) both matched splits at once (yielding a transaction with two splits)
3) each matched split separately (yielding a transaction with three splits)

I'd go with option 3.  The "find" part of the find-and-replace dialog lets
you specify search criteria for fields of transactions (i.e. "description") and
splits (i.e. "memo"). The "replace" part of the find-and-replace dialog should
contain something that looks like a multi-line transaction, except that it can
have 0 splits.  The default value of each replacement field should be a special
marker meaning "copy the field from what was found".  Press a [Find] button, and
GnuCash finds a split that matches the split criteria, in a transaction that
matches the transaction criteria, and selects that split in a register window
using a multi-line view.  Press [Replace], and GnuCash replaces the found
transaction fields, and replaces the found split with all (0 or more)
replacement splits.  If successive [Find]s find two splits in the same
transaction, the transaction fields might get replaced twice -- "you asked for
it, you got it".  If [Replace] deletes the only split in a transaction, the
whole transaction gets deleted.

Example: I use splits to record my pay.  Each payday is a transaction with one
split going to my bank account and the other going to a stock plan.  I really
should record withheld taxes, too.  I want to use find-and-replace to insert
splits for them.

Find account = 'salary'
 and income  = $500.00     (A)
 [Add a Rule]

Replace with
     date   num    description  account  R      Charge  Income  Balance
    (copy) (copy)  (copy)       (copy)   (copy) (copy)  (copy)  (copy)

            action   memo       account         Charge  Income
            (copy)   (copy)     (copy)          (copy)  (copy)           (B)
            payment  withheld   taxes                   $200.00          (C)

[Find]  [Replace]  [Replace & Find]  [Quit]

Notes: (A) matches the deposit, not the stock plan.  (B) preserves the deposit.
(C) inserts the new split.

What should we allow in the replacement fields, besides the marker that I've
typed as "(copy)"?  I'd like to allow references to other fields, for instance
to allow a replacement to move the contents of "description" into "memo". 
Perhaps the replacement fields could be combo boxes that would let
J. Q. Ickenuser either type some replacement text or select a field name?