Open AlexTheWizardL opened 2 months ago
revaluations
(add and optional price
, review column names) and then need to map this definition not CashCtrl.date, adjust, credit, debit, price, text
2023-01-31, 1400:1499, 3270, 3270, , FX adjustment Portfolio
2023-02-28, 1400:1499, 3270, 3270, , FX adjustment Portfolio
2023-01-31, 0000:1999 - 1400:1499, 6949, 6949, , FX adjustment
2023-02-28, 0000:1999 - 1400:1499, 6949, 6949, , FX adjustment
def fx_revaluation(self, cash_ctrl: LedgerEngine) -> pd.DataFrame:
adjustment = self.fx_adjustments()
base_currency = self.base_currency
for row in adjustment.to_dict('records'):
date = row['date']
accounts = self.account_range(row['adjust'])
accounts = set(accounts['add']) - set(accounts['subtract'])
accounts = list(accounts)
df = pd.DataFrame({
"foreign_currency_account": accounts,
"currency": [self.account_currency(account) for account in accounts],
"fx_gain_loss_account": row['credit'] # TODO: if amount > 0 else row['debit']
})
df = df.loc[df['currency'] != base_currency, :]
fx_rate = {}
for currency in df['currency'].unique():
price = self.price(currency, date=date, currency=base_currency)
assert price[0] == base_currency
fx_rate[currency] = price[1]
df['exchange_rate'] = [fx_rate[currency] for currency in df['currency']]
cash_ctrl.FX_revaluation(df, date=date)
date, foreign_currency_account, currency, fx_gain_loss_account, exchange_rate
2023-01-31, 1400, CHF, 3270, 1.00
2023-01-31, 1401, EUR, 3270, 0.93
price
column.
adjust
, credit
, debit
credit
and debit
accounts differ (CashCtrl allows us to solely specify a singl account)currency
from the foreign_currency_account as shown in above exampletext
(cashctrl has a hard-coded text)
Current state:
We already created working FX_revaluation() method that covers our needs in the #72.
Tasks: