Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def find(self, search_term: str) -> List[Commodity]: query = ( self.query .filter(Commodity.mnemonic.like('%' + search_term + '%') | Commodity.fullname.like('%' + search_term + '%')) ) return query....
[ " Searches for security by part of the name " ]
Please provide a description of the function:def get_all(self) -> List[Commodity]: query = ( self.query .order_by(Commodity.namespace, Commodity.mnemonic) ) return query.all()
[ " Loads all non-currency commodities, assuming they are stocks. " ]
Please provide a description of the function:def get_by_symbol(self, symbol: str) -> Commodity: # handle namespace. Accept GnuCash and Yahoo-style symbols. full_symbol = self.__parse_gc_symbol(symbol) query = ( self.query .filter(Commodity.mnemonic == full_symbo...
[ "\n Returns the commodity with the given symbol.\n If more are found, an exception will be thrown.\n " ]
Please provide a description of the function:def get_stock(self, symbol: str) -> Commodity: # Check if we have the exchange name (namespace). if ":" in symbol: # We have a namespace symbol_parts = symbol.split(":") exchange = symbol_parts[0] symb...
[ "Returns the stock/commodity object for the given symbol" ]
Please provide a description of the function:def get_stocks(self, symbols: List[str]) -> List[Commodity]: query = ( self.query .filter(Commodity.mnemonic.in_(symbols)) ).order_by(Commodity.namespace, Commodity.mnemonic) return query.all()
[ " loads stocks by symbol " ]
Please provide a description of the function:def get_aggregate(self, security: Commodity) -> SecurityAggregate: assert security is not None assert isinstance(security, Commodity) return SecurityAggregate(self.book, security)
[ " Returns the aggregate for the entity " ]
Please provide a description of the function:def get_aggregate_for_symbol(self, symbol: str) -> SecurityAggregate: security = self.get_by_symbol(symbol) if not security: raise ValueError(f"Security not found in GC book: {symbol}!") return self.get_aggregate(security)
[ " Returns the aggregate for the security found by full symbol " ]
Please provide a description of the function:def query(self): query = ( self.book.session.query(Commodity) .filter(Commodity.namespace != "CURRENCY", Commodity.namespace != "template") ) return query
[ " Returns the base query which filters out data for all queries. " ]
Please provide a description of the function:def __parse_gc_symbol(self, gc_symbol: str): result = { "namespace": None, "mnemonic": None } parts = gc_symbol.split(':') if len(parts) > 1: result["namespace"] = parts[0] result["mnem...
[ " Parse GnuCash-style symbol \"namespace:mnemonic\" " ]
Please provide a description of the function:def book(self) -> Book: if not self.__book: # Create/open the book. book_uri = self.settings.database_path self.__book = Database(book_uri).open_book( for_writing=self.__for_writing) return self.__...
[ " GnuCash Book. Opens the book or creates an database, based on settings. " ]
Please provide a description of the function:def settings(self): if not self.__settings: self.__settings: Settings = Settings() return self.__settings
[ " Settings " ]
Please provide a description of the function:def accounts(self) -> AccountsAggregate: if not self.__accounts_aggregate: self.__accounts_aggregate = AccountsAggregate(self.book) return self.__accounts_aggregate
[ " Returns the Accounts aggregate " ]
Please provide a description of the function:def currencies(self) -> CurrenciesAggregate: if not self.__currencies_aggregate: self.__currencies_aggregate = CurrenciesAggregate(self.book) return self.__currencies_aggregate
[ " Returns the Currencies aggregate " ]
Please provide a description of the function:def prices(self): if not self.__prices_aggregate: self.__prices_aggregate = PricesAggregate(self.book) return self.__prices_aggregate
[ " Prices aggregate " ]
Please provide a description of the function:def scheduled(self) -> ScheduledTxsAggregate: if not self.__scheduled_tx_aggregate: self.__scheduled_tx_aggregate = ScheduledTxsAggregate(self.book) return self.__scheduled_tx_aggregate
[ " Scheduled Transactions " ]
Please provide a description of the function:def securities(self): if not self.__securities_aggregate: self.__securities_aggregate = SecuritiesAggregate(self.book) return self.__securities_aggregate
[ " Returns securities aggregate " ]
Please provide a description of the function:def splits(self): ''' Splits ''' if not self.__splits_aggregate: self.__splits_aggregate = SplitsAggregate(self.book) return self.__splits_aggregate
[]
Please provide a description of the function:def transactions(self) -> TransactionsAggregate: if not self.__transactions_aggregate: self.__transactions_aggregate = TransactionsAggregate(self.book) return self.__transactions_aggregate
[ " Transactions aggregate " ]
Please provide a description of the function:def get_currency_symbols(self) -> List[str]: result = [] currencies = self.currencies.get_book_currencies() for cur in currencies: result.append(cur.mnemonic) return result
[ " Returns the used currencies' symbols as an array " ]
Please provide a description of the function:def load_jinja_template(file_name): original_script_path = sys.argv[0] #script_path = os.path.dirname(os.path.realpath(__file__)) script_dir = os.path.dirname(original_script_path) # file_path = os.path.join(script_path, file_name) # with open(file_p...
[ "\n Loads the jinja2 HTML template from the given file.\n Assumes that the file is in the same directory as the script.\n " ]
Please provide a description of the function:def get_days_in_month(year: int, month: int) -> int: month_range = calendar.monthrange(year, month) return month_range[1]
[ " Returns number of days in the given month.\n 1-based numbers as arguments. i.e. November = 11 " ]
Please provide a description of the function:def get_from_gnucash26_date(date_str: str) -> date: date_format = "%Y%m%d" result = datetime.strptime(date_str, date_format).date() return result
[ " Creates a datetime from GnuCash 2.6 date string " ]
Please provide a description of the function:def parse_period(period: str): period = period.split(" - ") date_from = Datum() if len(period[0]) == 10: date_from.from_iso_date_string(period[0]) else: date_from.from_iso_long_date(period[0]) date_from.start_of_day() date_to = ...
[ " parses period from date range picker. The received values are full ISO date " ]
Please provide a description of the function:def get_period(date_from: date, date_to: date) -> str: assert isinstance(date_from, date) assert isinstance(date_to, date) str_from: str = date_from.isoformat() str_to: str = date_to.isoformat() return str_from + " - " + str_to
[ " Returns the period string from the given dates " ]
Please provide a description of the function:def get_period_last_week() -> str: today = Datum() today.start_of_day() # start_date = today - timedelta(days=7) start_date = today.clone() start_date.subtract_days(7) period = get_period(start_date.value, today.value) return period
[ " Returns the last week as a period string " ]
Please provide a description of the function:def get_period_last_30_days() -> str: today = Datum() today.today() # start_date = today - timedelta(days=30) start_date = today.clone() start_date.subtract_days(30) period = get_period(start_date.value, today.value) return period
[ " Returns the last week as a period string " ]
Please provide a description of the function:def get_period_last_3_months() -> str: today = Datum() today.today() # start_date = today - timedelta(weeks=13) start_date = today.clone() start_date.subtract_months(3) period = get_period(start_date.date, today.date) return period
[ " Returns the last week as a period string " ]
Please provide a description of the function:def load_json_file_contents(path: str) -> str: assert isinstance(path, str) content = None file_path = os.path.abspath(path) content = fileutils.read_text_from_file(file_path) json_object = json.loads(content) content = json.dumps(json_object, s...
[ " Loads contents from a json file " ]
Please provide a description of the function:def validate_json(data: str): result = None try: result = json.loads(data) except ValueError as error: log(ERROR, "invalid json: %s", error) return result
[ " Validate JSON by parsing string data. Returns the json dict. " ]
Please provide a description of the function:def get_sql(query): sql = str(query.statement.compile(dialect=sqlite.dialect(), compile_kwargs={"literal_binds": True})) return sql
[ " Returns the sql query " ]
Please provide a description of the function:def save_to_temp(content, file_name=None): #output = "results.html" temp_dir = tempfile.gettempdir() #tempfile.TemporaryDirectory() #tempfile.NamedTemporaryFile(mode='w+t') as f: out_file = os.path.join(temp_dir, file_name) #if os.path.exists(ou...
[ "Save the contents into a temp file." ]
Please provide a description of the function:def read_book_uri_from_console(): db_path: str = input("Enter book_url or leave blank for the default settings value: ") if db_path: # sqlite if db_path.startswith("sqlite://"): db_path_uri = db_path else: # TODO: ...
[ " Prompts the user to enter book url in console " ]
Please provide a description of the function:def run_report_from_console(output_file_name, callback): print("The report uses a read-only access to the book.") print("Now enter the data or ^Z to continue:") #report_method = kwargs["report_method"] result = callback() #output_file_name = kwargs...
[ "\n Runs the report from the command line. Receives the book url from the console.\n " ]
Please provide a description of the function:def parse_prices_from_file_stream(self, file_stream) -> List[PriceModel]: content = file_stream.read().decode("utf-8") file_stream.close() if not content: raise ValueError("The file is empty!") result = self.get_prices_f...
[ "\n Reads a file stream (i.e. from web form) containing a csv prices\n into a list of Price models.\n " ]
Please provide a description of the function:def get_prices_from_csv(self, content: str) -> List[PriceModel]: from gnucash_portfolio.model.price_model import PriceModel_Csv lines = content.splitlines() prices = [] reader = csv.reader(lines) for row in reader: ...
[ " Imports prices from CSV content. See data folder for a sample file/content. " ]
Please provide a description of the function:def get_dividend_sum(book: Book, income_account: Account): splits = book.session.query(Split).filter(Split.account == income_account).all() dividend_sum = Decimal(0) for split in splits: dividend_sum += split.value # debug print split... ...
[ " Adds all distributions (income) " ]
Please provide a description of the function:def get_dividend_sum_for_symbol(book: Book, symbol: str): svc = SecuritiesAggregate(book) security = svc.get_by_symbol(symbol) sec_svc = SecurityAggregate(book, security) accounts = sec_svc.get_income_accounts() total = Decimal(0) for account in...
[ " Calculates all income for a symbol " ]
Please provide a description of the function:def import_file(filename): #file_path = os.path.relpath(filename) file_path = os.path.abspath(filename) log(DEBUG, "Loading prices from %s", file_path) prices = __read_prices_from_file(file_path) with BookAggregate(for_writing=True) as svc: ...
[ "\n Imports the commodity prices from the given .csv file.\n " ]
Please provide a description of the function:def generate_report(book_url): # commodity: CommodityOption( # section="Commodity", # sort_tag="a", # documentation_string="This is a stock", # default_value="...
[ "\n Generates an HTML report content.\n " ]
Please provide a description of the function:def main(symbol: str): print("Displaying the balance for", symbol) with BookAggregate() as svc: security = svc.book.get(Commodity, mnemonic=symbol) #security.transactions, security.prices sec_svc = SecurityAggregate(svc.book, security) ...
[ "\n\tDisplays the balance for the security symbol.\n\t" ]
Please provide a description of the function:def generate_report(book_url): with piecash.open_book(book_url, readonly=True, open_if_lock=True) as book: accounts = [acc.fullname for acc in book.accounts] return f
[ "\n Generates the report HTML.\n ", "<html>\n <body>\n Hello world from python !<br>\n Book : {book_url}<br>\n List of accounts : {accounts}\n </body>\n </html>" ]
Please provide a description of the function:def get_project_files(): if is_git_project(): return get_git_project_files() project_files = [] for top, subdirs, files in os.walk('.'): for subdir in subdirs: if subdir.startswith('.'): subdirs.remove(subdir) ...
[ "Retrieve a list of project files, ignoring hidden files.\n\n :return: sorted list of project files\n :rtype: :class:`list`\n " ]
Please provide a description of the function:def print_success_message(message): try: import colorama print(colorama.Fore.GREEN + message + colorama.Fore.RESET) except ImportError: print(message)
[ "Print a message indicating success in green color to STDOUT.\n\n :param message: the message to print\n :type message: :class:`str`\n " ]
Please provide a description of the function:def print_failure_message(message): try: import colorama print(colorama.Fore.RED + message + colorama.Fore.RESET, file=sys.stderr) except ImportError: print(message, file=sys.stderr)
[ "Print a message indicating failure in red color to STDERR.\n\n :param message: the message to print\n :type message: :class:`str`\n " ]
Please provide a description of the function:def main(): importer = ExchangeRatesImporter() print("####################################") latest_rates_json = importer.get_latest_rates() # translate into an array of PriceModels # TODO mapper = currencyrates.FixerioModelMapper() mapper = No...
[ "\n Default entry point\n " ]
Please provide a description of the function:def get_count(self, query): count_q = query.statement.with_only_columns( [func.count()]).order_by(None) count = query.session.execute(count_q).scalar() return count
[ "\n Returns a number of query results. This is faster than .count() on the query\n " ]
Please provide a description of the function:def generate_asset_allocation_report(book_url): model = load_asset_allocation_model(book_url) # load display template template = templates.load_jinja_template("report_asset_allocation.html") # render template result = template.render(model=model) ...
[ "\n The otput is generated here. Separated from the generate_report function to allow executing\n from the command line.\n " ]
Please provide a description of the function:def parse_euro_date(self, date_string: str): self.date = datetime.strptime(date_string, "%d/%m/%Y") return self.date
[ " Parses dd/MM/yyyy dates " ]
Please provide a description of the function:def parse_value(self, value_string: str): self.value = Decimal(value_string) return self.value
[ "\n Parses the amount string.\n " ]
Please provide a description of the function:def parse(self, csv_row: str): self.date = self.parse_euro_date(csv_row[2]) self.symbol = csv_row[0] self.value = self.parse_value(csv_row[1]) return self
[ " Parses the .csv row into own values " ]
Please provide a description of the function:def get_cash_balance_with_children(self, root_account: Account, currency: Commodity) -> Decimal: total = Decimal(0) svc = CurrenciesAggregate(self.book) # get all child accounts in a list cash_balances = self.load_cash_balances_with_...
[ "\n Loads cash balances in given currency.\n currency: the currency for the total\n " ]
Please provide a description of the function:def load_cash_balances_with_children(self, root_account_fullname: str): assert isinstance(root_account_fullname, str) svc = AccountsAggregate(self.book) root_account = svc.get_by_fullname(root_account_fullname) if not root_account: ...
[ " loads data for cash balances " ]
Please provide a description of the function:def get_start_balance(self, before: date) -> Decimal: assert isinstance(before, datetime) # create a new date without hours datum = Datum() datum.from_date(before) #date_corrected = datetimeutils.start_of_day(before) ...
[ " Calculates account balance " ]
Please provide a description of the function:def get_end_balance(self, after: date) -> Decimal: # create a new date without hours #date_corrected = datetimeutils.end_of_day(after) datum = Datum() datum.from_date(after) datum.end_of_day() #log(DEBUG, "getting bala...
[ " Calculates account balance " ]
Please provide a description of the function:def get_balance(self): on_date = Datum() on_date.today() return self.get_balance_on(on_date.value)
[ " Current account balance " ]
Please provide a description of the function:def get_balance_on(self, on_date: datetime) -> Decimal: assert isinstance(on_date, datetime) total = Decimal(0) splits = self.get_splits_up_to(on_date) for split in splits: total += split.quantity * self.account.sign ...
[ " Returns the balance on (and including) a certain date " ]
Please provide a description of the function:def get_balance_in_period(self, start: Datum, end: Datum): assert isinstance(start, Datum) assert isinstance(end, Datum) total = Decimal(0) splits = self.get_splits_in_period(start, end) for split in splits: tot...
[ "\n Calculates the balance for the given time period.\n The balance is taken to be 0 at the beginning of the period and then all the\n transactions are added together until the end date/time.\n " ]
Please provide a description of the function:def get_splits_query(self): query = ( self.book.session.query(Split) .filter(Split.account == self.account) ) return query
[ " Returns all the splits in the account " ]
Please provide a description of the function:def get_splits_up_to(self, date_to: datetime) -> List[Split]: query = ( self.book.session.query(Split) .join(Transaction) .filter(Split.account == self.account, Transaction.post_date <= date_to.date()) ...
[ " returns splits only up to the given date " ]
Please provide a description of the function:def get_splits_in_period(self, start: Datum, end: Datum) -> List[Split]: # from gnucash_portfolio.lib import generic query = ( self.book.session.query(Split) .join(Transaction) .filter(Split.account == self.accoun...
[ " returns splits only up to the given date " ]
Please provide a description of the function:def get_transactions(self, date_from: datetime, date_to: datetime) -> List[Transaction]: assert isinstance(date_from, datetime) assert isinstance(date_to, datetime) # fix up the parameters as we need datetime dt_from = Datum() ...
[ " Returns account transactions " ]
Please provide a description of the function:def __get_all_child_accounts_as_array(self, account: Account) -> List[Account]: result = [] # ignore placeholders ? - what if a brokerage account has cash/stocks division? # if not account.placeholder: # continue result.append...
[ " Returns the whole tree of child accounts in a list " ]
Please provide a description of the function:def find_by_name(self, term: str, include_placeholders: bool = False) -> List[Account]: query = ( self.query .filter(Account.name.like('%' + term + '%')) .order_by(Account.name) ) # Exclude placeholder acco...
[ " Search for account by part of the name " ]
Please provide a description of the function:def get_aggregate_by_id(self, account_id: str) -> AccountAggregate: account = self.get_by_id(account_id) return self.get_account_aggregate(account)
[ " Returns the aggregate for the given id " ]
Please provide a description of the function:def get_by_fullname(self, fullname: str) -> Account: # get all accounts and iterate, comparing the fullname. :S query = ( self.book.session.query(Account) ) # generic.get_sql() # print(sql) all_accounts = q...
[ " Loads account by full name " ]
Please provide a description of the function:def get_account_id_by_fullname(self, fullname: str) -> str: account = self.get_by_fullname(fullname) return account.guid
[ " Locates the account by fullname " ]
Please provide a description of the function:def get_all_children(self, fullname: str) -> List[Account]: # find the account by fullname root_acct = self.get_by_fullname(fullname) if not root_acct: raise NameError("Account not found in book!") acct_agg = self.get_acc...
[ " Returns the whole child account tree for the account with the given full name " ]
Please provide a description of the function:def get_all(self) -> List[Account]: return [account for account in self.book.accounts if account.parent.name != "Template Root"]
[ " Returns all book accounts as a list, excluding templates. " ]
Please provide a description of the function:def get_favourite_accounts(self) -> List[Account]: from gnucash_portfolio.lib.settings import Settings settings = Settings() favourite_accts = settings.favourite_accounts accounts = self.get_list(favourite_accts) return accou...
[ " Provides a list of favourite accounts " ]
Please provide a description of the function:def get_favourite_account_aggregates(self) -> List[AccountAggregate]: accounts = self.get_favourite_accounts() aggregates = [] for account in accounts: aggregate = self.get_account_aggregate(account) aggregates.append(...
[ " Returns the list of aggregates for favourite accounts " ]
Please provide a description of the function:def get_by_id(self, acct_id) -> Account: return self.book.get(Account, guid=acct_id)
[ " Loads an account entity " ]
Please provide a description of the function:def get_by_name(self, name: str) -> List[Account]: # return self.query.filter(Account.name == name).all() return self.get_by_name_from(self.book.root, name)
[ " Searches accounts by name " ]
Please provide a description of the function:def get_by_name_from(self, root: Account, name: str) -> List[Account]: result = [] if root.name == name: result.append(root) for child in root.children: child_results = self.get_by_name_from(child, name) ...
[ " Searches child accounts by name, starting from the given account " ]
Please provide a description of the function:def get_list(self, ids: List[str]) -> List[Account]: query = ( self.query .filter(Account.guid.in_(ids)) ) return query.all()
[ " Loads accounts by the ids passed as an argument " ]
Please provide a description of the function:def query(self): query = ( self.book.session.query(Account) .join(Commodity) .filter(Commodity.namespace != "template") .filter(Account.type != AccountType.root.value) ) return query
[ " Main accounts query " ]
Please provide a description of the function:def search(self, name: str = None, acc_type: str = None): query = self.query if name is not None: query = query.filter(Account.name == name) if acc_type is not None: # account type is capitalized ...
[ " Search accounts by passing parameters.\n name = exact name\n name_part = part of name\n parent_id = id of the parent account\n type = account type\n " ]
Please provide a description of the function:def get_stock_model_from(book: Book, commodity: Commodity, as_of_date: date) -> StockViewModel: from decimal import Decimal from pydatum import Datum svc = SecurityAggregate(book, commodity) model = StockViewModel() model.exchange = commodity.names...
[ " Parses stock/commodity and returns the model for display " ]
Please provide a description of the function:def get_price_as_of(self, stock: Commodity, on_date: datetime): # return self.get_price_as_of_query(stock, on_date).first() prices = PriceDbApplication() prices.get_prices_on(on_date.date().isoformat(), stock.namespace, stock.mnemonic)
[ " Gets the latest price on or before the given date. " ]
Please provide a description of the function:def import_prices(self, prices: List[PriceModel]): result = {} for price in prices: result[price.symbol] = self.import_price(price) return result
[ " Import prices (from csv) " ]
Please provide a description of the function:def import_price(self, price: PriceModel): # Handle yahoo-style symbols with extension. symbol = price.symbol if "." in symbol: symbol = price.symbol.split(".")[0] stock = SecuritiesAggregate(self.book).get_by_symbol(symbo...
[ " Import individual price " ]
Please provide a description of the function:def __create_price_for(self, commodity: Commodity, price: PriceModel): logging.info("Adding a new price for %s, %s, %s", commodity.mnemonic, price.datetime.strftime("%Y-%m-%d"), price.value) # safety check. Compare currencies. ...
[ " Creates a new Price entry in the book, for the given commodity " ]
Please provide a description of the function:def get_splits_query(self): query = ( self.book.session.query(Split) # .join(Transaction) .filter(Split.transaction_guid == self.transaction.guid) ) return query
[ " Returns the query for related splits " ]
Please provide a description of the function:def get_value_of_splits_for_account(self, account_id: str) -> Decimal: splits = self.get_split_for_account(account_id) result = Decimal(0) for split in splits: result += split.value return result
[ " Returns the sum of values for all splits for the given account " ]
Please provide a description of the function:def get_quantity_of_splits_for_account(self, account_id: str) -> Decimal: splits = self.get_split_for_account(account_id) result = Decimal(0) for split in splits: result += split.quantity return result
[ " Returns the sum of values for all splits for the given account " ]
Please provide a description of the function:def get(self, tx_id: str) -> Transaction: query = ( self.book.session.query(Transaction) .filter(Transaction.guid == tx_id) ) return query.one()
[ " load transaction by id " ]
Please provide a description of the function:def generate_report( book_url, fund_ids: StringOption( section="Funds", sort_tag="c", documentation_string="Comma-separated list of fund ids.", default_value="8123,8146,8148,8147") ): return render_...
[ "Generates the report output" ]
Please provide a description of the function:def searchAccount(searchTerm, book): print("Search results:\n") found = False # search for account in book.accounts: # print(account.fullname) # name if searchTerm.lower() in account.fullname.lower(): print(account.f...
[ "Searches through account names" ]
Please provide a description of the function:def display_db_info(self): with self.open_book() as book: default_currency = book.default_currency print("Default currency is ", default_currency.mnemonic)
[ "Displays some basic info about the GnuCash book" ]
Please provide a description of the function:def open_book(self, for_writing=False) -> piecash.Book: filename = None # check if the file path is already a URL. file_url = urllib.parse.urlparse(self.filename) if file_url.scheme == "file" or file_url.scheme == "sqlite": ...
[ "\n Opens the database. Call this using 'with'.\n If database file is not found, an in-memory database will be created.\n " ]
Please provide a description of the function:def read_text_from_file(path: str) -> str: with open(path) as text_file: content = text_file.read() return content
[ " Reads text file contents " ]
Please provide a description of the function:def save_text_to_file(content: str, path: str): with open(path, mode='w') as text_file: text_file.write(content)
[ " Saves text to file " ]
Please provide a description of the function:def get_amount_in_base_currency(self, currency: str, amount: Decimal) -> Decimal: assert isinstance(amount, Decimal) # If this is already the base currency, do nothing. if currency == self.get_default_currency().mnemonic: return ...
[ " Calculates the amount in base currency " ]
Please provide a description of the function:def get_default_currency(self) -> Commodity: result = None if self.default_currency: result = self.default_currency else: def_currency = self.__get_default_currency() self.default_currency = def_currency ...
[ " returns the book default currency " ]
Please provide a description of the function:def get_book_currencies(self) -> List[Commodity]: query = ( self.currencies_query .order_by(Commodity.mnemonic) ) return query.all()
[ " Returns currencies used in the book " ]
Please provide a description of the function:def get_currency_aggregate_by_symbol(self, symbol: str) -> CurrencyAggregate: currency = self.get_by_symbol(symbol) result = self.get_currency_aggregate(currency) return result
[ " Creates currency aggregate for the given currency symbol " ]
Please provide a description of the function:def get_by_symbol(self, symbol: str) -> Commodity: assert isinstance(symbol, str) query = ( self.currencies_query .filter(Commodity.mnemonic == symbol) ) return query.one()
[ " Loads currency by symbol " ]
Please provide a description of the function:def import_fx_rates(self, rates: List[PriceModel]): have_new_rates = False base_currency = self.get_default_currency() for rate in rates: assert isinstance(rate, PriceModel) currency = self.get_by_symbol(rate.symbol...
[ " Imports the given prices into database. Write operation! " ]
Please provide a description of the function:def __get_default_currency(self): # If we are on Windows, read from registry. if sys.platform == "win32": # read from registry def_curr = self.book["default-currency"] = self.__get_default_currency_windows() else: ...
[ "Read the default currency from GnuCash preferences" ]
Please provide a description of the function:def __get_registry_key(self, key): import winreg root = winreg.OpenKey( winreg.HKEY_CURRENT_USER, r'SOFTWARE\GSettings\org\gnucash\general', 0, winreg.KEY_READ) [pathname, regtype] = (winreg.QueryValueEx(root, key)) winre...
[ " Read currency from windows registry " ]
Please provide a description of the function:def get(self, split_id: str) -> Split: query = ( self.query .filter(Split.guid == split_id) ) return query.one()
[ " load transaction by id " ]