Example #1
0
def get_all_lots(account):
    """Return all lots in account and descendants"""
    ltotal = []
    descs = account.get_descendants()
    for desc in descs:
        if type(desc).__name__ == 'SwigPyObject':
            desc = gnucash.Account(instance=desc)
        ll = desc.GetLotList()
        ltotal += ll
    return ltotal
Example #2
0
  root = ET.parse(sys.argv[1]).getroot()
  if root.tag != 'moneyguru-file':
    logging.fatal('Urecognized file format')
    sys.exit(1)

  # - destination file
  session = gnucash.Session(sys.argv[2], is_new=True)
  DEFAULT_CCY = session.book.get_table().lookup("CURRENCY", "EUR")

  # The parsing itself
  for child in root: 
    if child.tag == 'group': # Groups
      groupName = unidecode(unicode(child.attrib['name']))
      groupType = child.attrib['type']

      acc = gnucash.Account(session.book)
      acc.SetName(groupName)
      acc.SetType(moneyGuruToGnuCashAccountType[groupType]) 
      acc.SetCommodity(DEFAULT_CCY)

      session.book.get_root_account().append_child(acc)

      markMigrated(child.tag)
    elif child.tag == 'account': # Accounts
      acctName = unidecode(unicode(child.attrib['name']))
      acctType = child.attrib['type']
      acctCcy  = child.attrib['currency']

      acc = gnucash.Account(session.book)
      acc.SetName(acctName)
      acc.SetType(moneyGuruToGnuCashAccountType[acctType])