On 29/09/24 03:41, Rick Flower wrote:
> Thanks Martin! I'll keep that suggestion in mind but before I saw your
> reply I started playing with the custom directive and was able to get an
> example that passes muster with bean-check. The example is below:
>
> 2013-01-01 open Assets:US:WellsFargo:Checking4431
> institution: "Wells Fargo Bank NA"
> address: "123 America Street, LargeTown, USA"
> phone: "+1.012.345.6789"
>
> 2013-01-01 open Income:US:Donations
>
> ;; fields are as follows :
> ;; donor-id : a string defining a unique identifier that can be
> used to identify this donor
> ;; donor-name : a string containing the name of the donor
> ;; donor-address : a string of the address for the donor
> ;; donor-city : a string containing the city the donor lives in
> ;; donor -state : donor's state
> ;; donor-zipcode : donor's zip code
> ;; donor-phone : donors phone number
> ;; donor-email : email address of donor
> 2024-09-28 custom "Donor" "john-smith" "John Smith" "123 First Street"
> "Palo Alto" "CA" "93501" "123-456-7890" "
f...@bar.com"
>
> 2024-09-28 txn "john-smith"
> Assets:US:WellsFargo:Checking4431-100.00 USD
> Income:US:Donations
>
> The big question for me is can bean-query search in the custom directive
> fields and so forth -- such that I could potentially run a report
> against my file asking for any donations by a specific donor (e.g.
> "john-smith")? I did a quick internet search for bean-query and custom
> but didn't really find anything.
How you structure the data is mostly determined by how you foresee
querying the data. From your example above, you can easily use
bean-query for getting all the donations by a donor:
SELECT *
FROM #postings
WHERE
account = 'Income:US:Donations' AND
narration = 'john-smith'
You choose to have the donor name in the narration field, but you could
have it in a metadata entry:
2024-09-28 * "Donation"
donor: "john-smith"
Assets:US:WellsFargo:Checking4431-100.00 USD
Income:US:Donations
In this case, the query would be:
SELECT *
FROM #postings
WHERE
account = 'Income:US:Donations' AND
entry.meta['donor'] = 'john-smith'
And you could use the narration to record other relevant information,
for example the circumstance in which the donation was collected
(particular donation campaign, or event, for example).
On the other hand, keeping the donor information into a custom directive
does not seem optimal to me. As your big comment block above the custom
directive suggests, the custom directive does not enforce any structure
on the fields (and allows only strings and not more complex data types,
but this may not be a limitation of this specific use).
If you want to keep all data in the ledger, one way of doing it is to
assign a sub-account to every donor and record the donor data in the
account open directive:
2013-01-01 open Income:US:Donations
2024-09-28 open Income:US:Donations:John-Smith
name: "John Smith"
address: "123 First Street"
city: "Palo Alto"
state: "CA"
zipcode: "93501"
phone: "123-456-7890"
email: "
f...@bar.com"
2024-09-28 * "Donation"
Assets:US:WellsFargo:Checking4431 -100.00 USD
Income:US:Donations:John-Smith
However, I think using a software dedicated to record personal data to
keep donor information and simply mark transactions with an unique donor
id. You can then use an external script for collating the ledger and
roster information to generate the reports.
Cheers,
Dan