frappe / erpnext

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

Plaid transactions sync error when reference number exceeds 140 characters #36148

Open mluessi opened 1 year ago

mluessi commented 1 year ago

Information about bug

I have a bank transaction on my account that has a very long reference number and the transaction import via Plaid fails. The error message says it will get truncated to 140 characters, but instead of doing so it fails. Error message below.

Module

accounts

Version

ERPNext: v14.28.0 Frappe Framework: v14.40.1

Installation method

docker

Relevant log output / Stack trace / Full Error Message.

Traceback (most recent call last):
File "apps/erpnext/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py", line 273, in new_bank_transaction
    new_transaction.insert()
File "apps/frappe/frappe/model/document.py", line 260, in insert
    self._validate()
File "apps/frappe/frappe/model/document.py", line 532, in _validate
    self._validate_length()
File "apps/frappe/frappe/model/base_document.py", line 917, in _validate_length
    self.throw_length_exceeded_error(df, max_length, value)
File "apps/frappe/frappe/model/base_document.py", line 951, in throw_length_exceeded_error
    frappe.throw(
File "apps/frappe/frappe/__init__.py", line 526, in throw
    msgprint(
File "apps/frappe/frappe/__init__.py", line 494, in msgprint
    _raise_exception()
File "apps/frappe/frappe/__init__.py", line 443, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.CharacterLengthExceededError: Bank Transaction ACC-BTN-2023-00732: 'Reference Number' (OMITED) will get truncated, as max characters allowed is 140

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "apps/erpnext/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py", line 183, in sync_transactions
    result += new_bank_transaction(transaction)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "apps/erpnext/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py", line 282, in new_bank_transaction
    frappe.throw(_("Bank transaction creation error"))
File "apps/frappe/frappe/__init__.py", line 526, in throw
    msgprint(
File "apps/frappe/frappe/__init__.py", line 494, in msgprint
    _raise_exception()
File "apps/frappe/frappe/__init__.py", line 443, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.ValidationError: Bank transaction creation error
ahandlen commented 1 year ago

Bumping as same issue here, also noted in #35657

mrPauwHaan commented 1 year ago

Changing the field type helped me to overcome the error. Atleast, I am now able to use the integration without issues.

However, there should still be a fix for this issue of course.

ahandlen commented 1 year ago

Beautiful solution that my tired brain couldn't think of. I sincerely thank you.

Changing the field type from data to text in bank transactions seemed to do the trick but I agree a permanent fix should still be implemented.