Skip to content
Open
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
13 changes: 13 additions & 0 deletions jal/data_import/broker_statements/ibkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def __init__(self):
('reportDate', 'reported', datetime, None),
('amount', 'amount', float, None),
('tradeID', 'number', str, ''),
('actionID', 'actionid', str, ''),
('transactionID', 'tid', str, ''),
('description', 'description', str, None)],
'loader': self.load_cash_transactions},
Expand Down Expand Up @@ -979,6 +980,12 @@ def aggregate_dividends(self, dividends: list) -> list:
t_payment['description'] = t_payment['description'].replace(self.CancelPrefix, '')
t_payment['amount'] = -t_payment['amount']
if t_payment not in payments:
# IB, April 2022: ActionID field added to Activity Flex to allow simple mapping of corporate actions, dividends, dividend accruals, and withholding tax.
no_report_no_description = lambda x: {i: x[i] for i in x if i != 'reported' and i != 'description'}
m_payments = [x for x in payments if x['actionid'] != '' and no_report_no_description(x) == no_report_no_description(t_payment)]
if len(m_payments):
payments.remove(m_payments[0])
continue
no_description = lambda x: {i:x[i] for i in x if i != 'description'}
m_payments = [x for x in payments if no_description(x) == no_description(t_payment)]
if len(m_payments):
Expand Down Expand Up @@ -1011,6 +1018,12 @@ def aggregate_taxes(self, taxes: list) -> list:
t_payment['description'] = t_payment['description'].replace(self.CancelPrefix, '')
t_payment['amount'] = -t_payment['amount']
if t_payment not in payments:
# IB, April 2022: ActionID field added to Activity Flex to allow simple mapping of corporate actions, dividends, dividend accruals, and withholding tax.
no_report_no_description = lambda x: {i: x[i] for i in x if i != 'reported' and i != 'description'}
m_payments = [x for x in payments if x['actionid'] != '' and no_report_no_description(x) == no_report_no_description(t_payment)]
if len(m_payments):
payments.remove(m_payments[0])
continue
no_report = lambda x: {i: x[i] for i in x if i != 'reported'}
m_payments = [x for x in payments if no_report(x) == no_report(t_payment)]
if len(m_payments):
Expand Down