diff --git a/cli.py b/cli.py index 4957c27..bfd9680 100644 --- a/cli.py +++ b/cli.py @@ -39,7 +39,8 @@ if args.pp_rates_file: rate_provider = PortfolioPerformanceRateProvider(args.pp_rates_file, currency_mapping=args.currency_mapping, - fiat_currency=args.fiat_currency) + fiat_currency=args.fiat_currency, + language=args.language) else: rate_provider = None diff --git a/src/ledger_processor.py b/src/ledger_processor.py index a72642c..2aedb82 100644 --- a/src/ledger_processor.py +++ b/src/ledger_processor.py @@ -32,7 +32,7 @@ def __init__(self, filename=None, csv_sep=",", dataframe=None, self._i18n = I18n(language) # shortcuts for i18n values self.DELIVERY_INBOUND = self._i18n.get("portfolio.DELIVERY_INBOUND") - self.BUY = self._i18n.get("portfolio.BUY") + self.BUY = self._i18n.get("account.BUY") self.SELL = self._i18n.get("account.SELL") self.FEES = self._i18n.get("account.FEES") diff --git a/src/portfolio_performance_rate_provider.py b/src/portfolio_performance_rate_provider.py index 98641ff..9d0e628 100644 --- a/src/portfolio_performance_rate_provider.py +++ b/src/portfolio_performance_rate_provider.py @@ -9,11 +9,19 @@ import locale class PortfolioPerformanceRateProvider: - def __init__(self, export_file, fiat_currency="EUR", time_format="%Y-%m-%d %H:%M:%S", currency_mapping=None): + def __init__(self, export_file, fiat_currency="EUR", time_format="%Y-%m-%d %H:%M:%S", language="de", currency_mapping=None): + if language == "de": + self._thousands = "." + self._decimal = "," + self._sep = ";" + if language == "en": + self._thousands = "," + self._decimal = "." + self._sep = "," self._export_file = export_file self._fiat_currency = fiat_currency self._time_format = time_format - self.__df = pd.read_csv(export_file, sep=";", index_col=0, parse_dates=[0]) + self.__df = pd.read_csv(export_file, sep=self._sep, index_col=0, parse_dates=[0], thousands=self._thousands, decimal=self._decimal) if currency_mapping is not None: self.__df.rename(columns=currency_mapping, inplace=True) locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8') # TODO: Cleanup locale stuff @@ -39,6 +47,7 @@ def get_rate(self, crypto_currency, timestr=None, timeobj=None): else: raise ValueError(f'Could not find rate for currency {column_name} in export loaded from {self._export_file}\nFound columns: ' + "\n".join(self.__df.columns)) - rate = rate.replace(".", "") # Need to remove thousands-sep, locale stuff does not work ... 15.426,75 - - return locale.atof(rate) + # TODO: Cleanup locale stuff + # rate = rate.replace(self._thousands, "") # Need to remove thousands-sep, locale stuff does not work ... 15.426,75 + # return locale.atof(rate) + return rate