On Tue, Jul 18, 2023 at 12:31 PM Eric Altendorf <[email protected]>
wrote:

> On Tue, Jul 18, 2023 at 9:57 AM Daniele Nicolodi <[email protected]>
> wrote:
>
>> 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.
>
>
Do you know where in the code this was getting checked and dropped?
I'm encountering a similar problem with trying to set a {USD} marker
CostSpec, as the workaround for transferring cost basis through account
tranfsers, as described here:
https://github.com/beancount/beancount/issues/476

I've updated my importer to add such a CostSpec to transfer postings,
and it appears in the transactions I create:

Transaction(meta={'filename':
'/home/eric/crypto-taxes/beancount-crypto-importers/tests/Coinbase-d34db33f-TransactionsHistoryReport-2020-01-01-00-00-00.csv',
'lineno': 1}, date=datetime.date(2020, 2, 20), flag='*', payee=None,
narration='CB: Sent 0.01BTC to adh547SDFhs7SDKJFkdfh4KS95hsdkfs6s',
tags=frozenset(), links=set(),
postings=[Posting(account='Assets:Coinbase:BTC', units=-0.01 BTC,
cost=*CostSpec(number_per=None,
number_total=None, currency='USD', date=None, label=None, merge=None)*,
price=None, flag=None, meta=None),
Posting(account='Assets:ALLEXTERNAL:BTC', units=0.01 BTC,
cost=*CostSpec(number_per=None,
number_total=None, currency='USD', date=None, label=None, merge=None)*,
price=None, flag=None, meta=None)])

However in the final output from the importer, it's missing:

2020-02-20 * "CB: Sent 0.01BTC to adh547SDFhs7SDKJFkdfh4KS95hsdkfs6s"
  Assets:Coinbase:BTC     -0.01 BTC {}
  Assets:ALLEXTERNAL:BTC   0.01 BTC {}

Test input/output:

https://github.com/ericaltendorf/beancount-crypto-importers/tree/master/tests
Code:

https://github.com/ericaltendorf/beancount-crypto-importers/blob/master/importer-coinbase.py#L118

https://github.com/ericaltendorf/beancount-crypto-importers/blob/master/common.py

thanks,
eric

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAFXPr0tNTf%3DOJbcs95usA0DYTdRW%2BZeSJ7zmJ0YDtg284BC6%2Bw%40mail.gmail.com.

Reply via email to