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

Issue with OFXTransaction is_ fields #192

Closed
jantman opened this issue Apr 14, 2018 · 1 comment
Closed

Issue with OFXTransaction is_ fields #192

jantman opened this issue Apr 14, 2018 · 1 comment
Assignees

Comments

@jantman
Copy link
Owner

jantman commented Apr 14, 2018

Using the current development Docker build (the 19023fc8_1521979679 tag), there's a bug with the OFXTransaction is_ fields introduced in #183. The fields update properly when editing an Account via the modal, but not when new OFXTransactions are inserted.

2018-04-13 21:16:06,156 [ERROR db_event_handlers.py:186 - biweeklybudget.db_event_handlers.handle_ofx_transaction_new_or_change() ] Error setting OFXTransaction is_ fields
Traceback (most recent call last):
  File "/app/lib/python3.6/site-packages/biweeklybudget/db_event_handlers.py", line 183, in handle_ofx_transaction_new_or_change
    obj.update_is_fields()
  File "/app/lib/python3.6/site-packages/biweeklybudget/models/ofx_transaction.py", line 267, in update_is_fields
    r_str = getattr(acct, acct_attr)
AttributeError: 'NoneType' object has no attribute 're_interest_charge'

The bug seems to be where the handle_ofx_transaction_new_or_change() before_flush DB even handler calls OFXTransaction.update_is_fields(). It appears that when that is called, the self.account relationship is not loaded and is returning None.

OFXTransaction insert via ofxgetter

2018-04-13 21:16:05,923 [INFO local.py:126 - biweeklybudget.ofxapi.local.update_statement_ofx() ] Updating Account 1 with OFX Statement filename="MyBank_2018-04-13_17-15-46.ofx" (mtime None)
2018-04-13 21:16:05,931 [DEBUG local.py:195 - biweeklybudget.ofxapi.local._create_statement() ] Creating new OFXStatement account_id=1 filename=MyBank_2018-04-13_17-15-46.ofx as_of=2018-04-13 21:16:04+00:00
2018-04-13 21:16:05,931 [DEBUG local.py:228 - biweeklybudget.ofxapi.local._update_bank_or_credit() ] Updating Bank/Credit account
2018-04-13 21:16:06,152 [DEBUG db.py:230 - biweeklybudget.db.upsert_record() ] Matching record exists; updating
2018-04-13 21:16:06,152 [INFO db.py:222 - biweeklybudget.db.upsert_record() ] Upserting <class 'biweeklybudget.models.ofx_transaction.OFXTransaction'> key=(1, '0009432030865.0001803083558.25'): {'account_id': 1, 'statement': <OFXStatement(id=None, account_id=1, as_of='2018-04-13 21:16:04+00:00')>, 'memo': '', 'name': 'Zelle Transfer', 'amount': Decimal('65.00'), 'trans_type': 'credit', 'date_posted': datetime.datetime(2018, 3, 8, 12, 0, tzinfo=<UTC>), 'fitid': '0009432030865.0001803083558.25', 'sic': None, 'mcc': ''}
2018-04-13 21:16:06,155 [DEBUG db.py:230 - biweeklybudget.db.upsert_record() ] Matching record exists; updating
2018-04-13 21:16:06,155 [DEBUG db_event_handlers.py:263 - biweeklybudget.db_event_handlers.handle_before_flush() ] handle_before_flush handler
2018-04-13 21:16:06,155 [DEBUG db_event_handlers.py:137 - biweeklybudget.db_event_handlers.handle_new_or_deleted_budget_transaction() ] Done handling new BudgetTransactions; updated 0 standing budgets
2018-04-13 21:16:06,155 [DEBUG db_event_handlers.py:166 - biweeklybudget.db_event_handlers.handle_new_or_deleted_budget_transaction() ] Done handling deleted BudgetTransactions; updated 0 standing budgets
2018-04-13 21:16:06,156 [ERROR db_event_handlers.py:186 - biweeklybudget.db_event_handlers.handle_ofx_transaction_new_or_change() ] Error setting OFXTransaction is_ fields
Traceback (most recent call last):
  File "/app/lib/python3.6/site-packages/biweeklybudget/db_event_handlers.py", line 183, in handle_ofx_transaction_new_or_change
    obj.update_is_fields()
  File "/app/lib/python3.6/site-packages/biweeklybudget/models/ofx_transaction.py", line 267, in update_is_fields
    r_str = getattr(acct, acct_attr)
AttributeError: 'NoneType' object has no attribute 're_interest_charge'
2018-04-13 21:16:06,157 [ERROR db_event_handlers.py:186 - biweeklybudget.db_event_handlers.handle_ofx_transaction_new_or_change() ] Error setting OFXTransaction is_ fields
Traceback (most recent call last):
  File "/app/lib/python3.6/site-packages/biweeklybudget/db_event_handlers.py", line 183, in handle_ofx_transaction_new_or_change
    obj.update_is_fields()
  File "/app/lib/python3.6/site-packages/biweeklybudget/models/ofx_transaction.py", line 267, in update_is_fields
    r_str = getattr(acct, acct_attr)
AttributeError: 'NoneType' object has no attribute 're_interest_charge'
2018-04-13 21:16:06,157 [ERROR db_event_handlers.py:186 - biweeklybudget.db_event_handlers.handle_ofx_transaction_new_or_change() ] Error setting OFXTransaction is_ fields
Traceback (most recent call last):
  File "/app/lib/python3.6/site-packages/biweeklybudget/db_event_handlers.py", line 183, in handle_ofx_transaction_new_or_change
    obj.update_is_fields()
  File "/app/lib/python3.6/site-packages/biweeklybudget/models/ofx_transaction.py", line 267, in update_is_fields
    r_str = getattr(acct, acct_attr)
AttributeError: 'NoneType' object has no attribute 're_interest_charge'
2018-04-13 21:16:06,157 [ERROR db_event_handlers.py:186 - biweeklybudget.db_event_handlers.handle_ofx_transaction_new_or_change() ] Error setting OFXTransaction is_ fields
Traceback (most recent call last):
  File "/app/lib/python3.6/site-packages/biweeklybudget/db_event_handlers.py", line 183, in handle_ofx_transaction_new_or_change
    obj.update_is_fields()
  File "/app/lib/python3.6/site-packages/biweeklybudget/models/ofx_transaction.py", line 267, in update_is_fields
    r_str = getattr(acct, acct_attr)
AttributeError: 'NoneType' object has no attribute 're_interest_charge'
2018-04-13 21:16:06,161 [DEBUG db_event_handlers.py:267 - biweeklybudget.db_event_handlers.handle_before_flush() ] handle_before_flush done

Editing an Account

2018-04-14 11:39:30,534 [INFO accounts.py:231 - biweeklybudget.flaskapp.views.accounts.submit() ] updating Account 4: {'id': 4, 're_interest_paid': None, 'acct_type': <AcctType.Credit: 2>, 'name': 'Discover', 're_payment': '^INTERNET PAYMENT - THANK YOU', 'credit_limit': Decimal('1'), 're_late_fee': '^Late Fee', 'description': None, 'apr': None, 'ofx_cat_memo_to_name': False, 're_other_fee': None, 'prime_rate_margin': Decimal('0.1574'), 'vault_creds_path': 'foo', 'interest_class_name': 'AdbCompoundedDaily', 'ofxgetter_config_json': '{}', 'min_payment_class_name': 'MinPaymentDiscover', 'negate_ofx_amounts': True, 'is_active': True, 'reconcile_trans': True, 're_interest_charge': '^INTEREST CHARGE ON PURCHASES'}
2018-04-14 11:39:30,534 [DEBUG db_event_handlers.py:263 - biweeklybudget.db_event_handlers.handle_before_flush() ] handle_before_flush handler
2018-04-14 11:39:30,534 [DEBUG db_event_handlers.py:137 - biweeklybudget.db_event_handlers.handle_new_or_deleted_budget_transaction() ] Done handling new BudgetTransactions; updated 0 standing budgets
2018-04-14 11:39:30,535 [DEBUG db_event_handlers.py:166 - biweeklybudget.db_event_handlers.handle_new_or_deleted_budget_transaction() ] Done handling deleted BudgetTransactions; updated 0 standing budgets
2018-04-14 11:39:30,535 [DEBUG db_event_handlers.py:232 - biweeklybudget.db_event_handlers.handle_account_re_change() ] <Account(id=4, name='Discover')> re_late_fee changed from [None] to ['^Late Fee']
2018-04-14 11:39:30,535 [DEBUG db_event_handlers.py:239 - biweeklybudget.db_event_handlers.handle_account_re_change() ] <Account(id=4, name='Discover')> has regex changes; triggering update_is_fields() on all child OFXTransactions.
2018-04-14 11:39:31,143 [DEBUG db_event_handlers.py:244 - biweeklybudget.db_event_handlers.handle_account_re_change() ] Done with update_is_fields() for <Account(id=4, name='Discover')>
2018-04-14 11:39:31,144 [DEBUG db_event_handlers.py:267 - biweeklybudget.db_event_handlers.handle_before_flush() ] handle_before_flush done
2018-04-14 11:39:31,172 [DEBUG db.py:177 - biweeklybudget.db.cleanup_db() ] Closing DB session
@jantman jantman mentioned this issue Apr 16, 2018
@jantman jantman assigned jantman and unassigned jantman Apr 16, 2018
jantman added a commit that referenced this issue Apr 17, 2018
@jantman jantman reopened this Apr 17, 2018
@jantman
Copy link
Owner Author

jantman commented Jul 7, 2018

Released today in 1.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant