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

Fix/forex case error #70

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions ods_tools/oed/forex.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ def get_path(name):
elif currency_conversion.get("source_type") == 'parquet':
return DictBasedCurrencyRates.from_parquet(get_path('file_path'),
**currency_conversion.get("read_parameters", {}))
elif currency_conversion.get("source_type", '').lower() == 'dict':
elif currency_conversion.get("source_type", '').lower() == 'dict': # doesn't work in json as key must be single value
return DictBasedCurrencyRates(currency_conversion['currency_rates'])
elif currency_conversion.get("source_type", '').lower() == 'list': # option to write directly the rate in the json file
return DictBasedCurrencyRates.from_list(currency_conversion['currency_rates'])
else:
raise OdsException(
f"Unsupported currency_conversion source type : {currency_conversion.get('source_type')}")
Expand Down Expand Up @@ -253,21 +255,23 @@ def convert_currency(oed_df, oed_type, reporting_currency, currency_rate, oed_sc
oed_df.loc[orig_cur_rows, 'RateOfExchange'] *= rate
for field, column in field_to_column.items():
field_type = ods_fields[field.lower()].get('Back End DB Field Name', '').lower()
if (field_type in ['tax', 'grosspremium', 'netpremium', 'brokerage', 'extraexpenselimit', 'minded',
'maxded']
or field.endswith('tiv')):

if (
field_type in ['tax', 'grosspremium', 'netpremium', 'brokerage', 'extraexpenselimit', 'minded', 'maxded']
or field.lower().endswith('tiv')
or field in ['LayerLimit', 'LayerAttachment']):
row_filter = orig_cur_rows
elif field_type == 'ded':
column_type_name = field.replace('ded', 'dedtype')
column_type_name = field.replace('Ded', 'DedType')
row_filter = orig_cur_rows & (oed_df[field_to_column[column_type_name]] == 0)
elif field_type == 'limit':
column_type_name = field.replace('limit', 'limittype')
column_type_name = field.replace('Limit', 'LimitType')
row_filter = orig_cur_rows & (oed_df[field_to_column[column_type_name]] == 0)
elif field_type in ['payoutstart', 'payoutend', 'payoutlimit']:
column_type_name = 'payouttype'
column_type_name = 'PayoutType'
row_filter = orig_cur_rows & (oed_df[field_to_column[column_type_name]] == 0)
elif field_type in ['triggerstart', 'triggerend']:
column_type_name = 'triggertype'
column_type_name = 'TriggerType'
row_filter = orig_cur_rows & (oed_df[field_to_column[column_type_name]] == 0)
else: # not a currency unit column we go to the next one
continue
Expand Down