Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where/How do I add this kvp for factories.create_stock_accounts #207

Open
tim-rohrer opened this issue Mar 30, 2023 · 4 comments
Open

Where/How do I add this kvp for factories.create_stock_accounts #207

tim-rohrer opened this issue Mar 30, 2023 · 4 comments

Comments

@tim-rohrer
Copy link

I create a commodity:

  xyz = Commodity(
      namespace="Stocks",
      mnemonic="XYZ",
      fullname="XYZ, Inc.",
      fraction=10000,
      book=book,
  )

But when I try to use it in the subject factory

print(factories.create_stock_accounts(xyz, brokerage, income))

I get:

piecash._common.GnucashException: The commodity 'XYZ' has no information about its base currency. Add a kvp item named 'quoted_currency' with the mnemonic of the currency to have proper behavior

I've tried various ways to add the kvp, but is isn't clear where or how I should do it?

@sdementen
Copy link
Owner

I would say
XYZ["quoted_currency"]=your commodity object representing a currency
but not 100% sure

@tim-rohrer
Copy link
Author

Thank you for the reply.

Yes, xyz["quoted_currency"] = usd where usd = book.commodities(mnemonic="USD") was my first guess.

But, it throws off

self = <[AttributeError("'NoneType' object has no attribute 'query'") raised in repr()] SlotGUID object at 0x11ad5d750>

    @property
    def Class(self):
        name, guid = self.name, self.guid_val
        if name.startswith("CURRENCY::"):
            # handle capital gain account
            class_to_retrieve = "piecash.core.account.Account"
        else:
            class_to_retrieve = self._mapping_name_class.get(name, None)
            if class_to_retrieve is None:
>               raise ValueError(
                    "Smart retrieval of GUID slot with name '{}' is not yet supported. "
                    "Need to retrieve proper object type in kvp module "
                    "(add in SlotGUID._mapping_name_class)".format(name)
                )
E               ValueError: Smart retrieval of GUID slot with name 'quoted_currency' is not yet supported. Need to retrieve proper object type in kvp module (add in SlotGUID._mapping_name_class)

../../../.local/share/virtualenvs/move2gnucash-cDrekBd3/lib/python3.11/site-packages/piecash/kvp.py:346: ValueError

which I don't understand.

When this first happened, because I thought I might be doing it wrong, I started looking at other options. Now that you've guided me back to the approach, I suspect the above error is the real issue?

Again, I appreciate your help. Being able to process the import of investment transaction is my last major hurdle to get my app working.

@tim-rohrer
Copy link
Author

Hi @sdementen,

Do you have any thoughts on the above error?

Thanks.

@sdementen
Copy link
Owner

sdementen commented Apr 12, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants