frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.73k stars 7.3k forks source link

bug: Plaid Update Link function required #24676

Closed nameduser0 closed 3 years ago

nameduser0 commented 3 years ago

Description of the issue

No way to refresh Plaid Link credentials

Context information (for bug reports)

Output of bench version

ERPNext: v12.9.4 (stable-12)
Frappe Framework: v12.6.2 (stable-12)

Steps to reproduce the issue

  1. Leave a bank account connected for long enough

Observed result

No way to refresh credentials

Expected result

Re-authenticate Link button on the Bank Account

Stacktrace / full error message

Original error

Traceback (most recent call last):
  File "/home/erp/production/apps/erpnext/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_connector.py", line 70, in get_transactions
    response = self.client.Transactions.get(self.access_token, start_date=start_date, end_date=end_date, account_ids=account_ids)
  File "/home/erp/production/env/lib/python3.6/site-packages/plaid/api/transactions.py", line 49, in get
    'options': options,
  File "/home/erp/production/env/lib/python3.6/site-packages/plaid/client.py", line 98, in post
    return self._post(path, post_data, is_json)
  File "/home/erp/production/env/lib/python3.6/site-packages/plaid/client.py", line 123, in _post
    headers=headers,
  File "/home/erp/production/env/lib/python3.6/site-packages/plaid/requester.py", line 68, in http_request
    raise PlaidError.from_response(response_body)
plaid.errors.ItemError: the login details of this item have changed (credentials, MFA, or required user action) and a user login is required to update this information. use Link's update mode to restore the item to a good state

Error when using existing functionality to set up new bank account over the top of the existing

Duplicate name Bank Account [REDACTED BANK ACCOUNT NAME] - Business
Traceback (most recent call last):
File "/home/erp/production/apps/frappe/frappe/model/base_document.py", line 325, in db_insert ), list(d.values()))
File "/home/erp/production/apps/frappe/frappe/database/database.py", line 156, in sql self._cursor.execute(query, values)
File "/home/erp/production/env/lib/python3.6/site-packages/pymysql/cursors.py", line 170, in execute result = self._query(query)
File "/home/erp/production/env/lib/python3.6/site-packages/pymysql/cursors.py", line 328, in _query conn.query(q)
File "/home/erp/production/env/lib/python3.6/site-packages/pymysql/connections.py", line 517, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/home/erp/production/env/lib/python3.6/site-packages/pymysql/connections.py", line 732, in _read_query_result result.read()
File "/home/erp/production/env/lib/python3.6/site-packages/pymysql/connections.py", line 1075, in read first_packet = self.connection._read_packet()
File "/home/erp/production/env/lib/python3.6/site-packages/pymysql/connections.py", line 684, in _read_packet packet.check_error()
File "/home/erp/production/env/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error err.raise_mysql_exception(self._data)
File "/home/erp/production/env/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1062, "Duplicate entry '[REDACTED BANK ACCOUNT NAME] - Business' for key 'PRIMARY'")

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/erp/production/apps/erpnext/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py", line 92, in add_bank_accounts new_account.insert()
File "/home/erp/production/apps/frappe/frappe/model/document.py", line 248, in insert raise e
File "/home/erp/production/apps/frappe/frappe/model/document.py", line 245, in insert self.db_insert()
File "/home/erp/production/apps/frappe/frappe/model/base_document.py", line 335, in db_insert raise frappe.DuplicateEntryError(self.doctype, self.name, e)
frappe.exceptions.DuplicateEntryError: ('Bank Account', '[REDACTED BANK ACCOUNT NAME] - Business', IntegrityError(1062, "Duplicate entry '[REDACTED BANK ACCOUNT NAME] - Business' for key 'PRIMARY'"))
Alchez commented 3 years ago

@casesolved-co-uk, we saw this issue as well. You can actually refresh the Plaid links on each Bank record. I'm guessing this happens for banks that force-require passwords to be changed every so often, but I'm not 100% sure.

nameduser0 commented 3 years ago

You can actually refresh the Plaid links on each Bank record.

@Alchez Hi Rohan, do you mean on the Bank Account? All I get is a button saying Unlink external integrations. Which version are you using?

Alchez commented 3 years ago

Ah, if it's not Bank, then it could be Bank Account. We're using Plaid on v12.

nameduser0 commented 3 years ago

Ah, looks like I need an upgrade! I see it on the Bank on v13 but not on v12.9.4. Thanks for the tip!

nateriches commented 3 years ago

Thanks so much for the tip! I was pulling my hair out. This definitely needs to be highlighted somewhere in the user guide. Cheers!