On 18/07/23 04:47, Eric Altendorf wrote:
I've got my first importer running, mostly works, but the cost I'm
providing doesn't seem to be making it all the way through. A debug
print shows this as the transaction I'm returning:
Transaction(meta={'filename': '/home/...csv', 'lineno': 1},
date=datetime.date(2018, 1, 1), flag='*', payee=None, narration='Bought
2.0 ABC for $204.00 USD', tags=frozenset(), links={None},
postings=[Posting(account='Assets:MyInstitution:ABC', units=2.0 ABC,
*cost=Cost(number='102.00', currency='USD', date=None, label=None)*,
price=102.00 USD, flag=None, meta=None),
Posting(account='Assets:MyInstitution:USD', units=-204.00 USD,
cost=None, price=None, flag=None, meta=None)])
But the final transaction printed by the importer has no cost:
2018-01-01 * "Bought 2.0 ABC for $204.00 USD" ^None
Assets:MyInstitution:ABC 2.0 ABC*{} *@ 102.00 USD
Assets:MyInstitution:USD -204.00 USD
Any ideas?
The number member in the Cost class should be a Decimal, not a string.
The entry printer should probably error out if this is not the case, but
it does not.
(PS: Also not sure how to omit links. If I return `None`, `""`, or
`{}`, the importer crashes. If I return `{None}` it complete but
renders the annoying ^None link....)
links and tags are sets. If you don't want any links or tags just assign
an empty set. Somehow you figured this out for tags but not for links.
One way to discover the data structure corresponding to a given
transaction is to write its text representation and parse it with the
beancount parser:
from beancount.parser import parser
entries, errors, options = parser.parse_string("""
2018-01-01 * "Bought 2.0 ABC for $204.00 USD"
Assets:MyInstitution:ABC 2.0 ABC {102.00 USD} @ 102.00 USD
Assets:MyInstitution:USD -204.00 USD
""")
print(entries)
Cheers,
Dan
--
You received this message because you are subscribed to the Google Groups
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to beancount+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/beancount/5385377a-06a9-be25-50d3-d2d88fd8329f%40grinta.net.