frappe / erpnext

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

Failure to select and view Account Receivable entries in General Ledger #42663

Closed remigius974 closed 3 months ago

remigius974 commented 3 months ago

Information about bug

Provides this error

App Versions

{
    "erpnext": "15.14.4",
    "frappe": "15.15.0",
    "hrms": "15.12.0"
}

Route

query-report/General Ledger

Traceback

Syntax error in query:
select
            name as gl_entry, posting_date, account, party_type, party,
            voucher_type, voucher_subtype, voucher_no, 
            cost_center, project, 
            against_voucher_type, against_voucher, account_currency,
            against, is_opening, creation , debit, credit, debit_in_account_currency,
        credit_in_account_currency 
        from `tabGL Entry`
        where company=%(company)s and account in %(account)s and (posting_date >=%(from_date)s or is_opening = 'Yes') and (posting_date <=%(to_date)s or is_opening = 'Yes') and (finance_book in (%(company_fb)s, '') OR finance_book IS NULL) and is_cancelled = 0
        order by posting_date, creation {'company': 'STARLINK GULF LIMITED', 'from_date': '2024-07-22', 'to_date': '2024-07-28', 'account': [], 'party': [], 'group_by': 'Group by Voucher (Consolidated)', 'cost_center': [], 'project': [], 'include_dimensions': 1, 'include_default_book_entries': 1, 'company_currency': 'TZS', 'account_currency': 'TZS', 'company_fb': None}
Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1682, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 863, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/query_report.py", line 219, in run
    result = generate_report_result(report, filters, user, custom_columns, is_tree, parent_field)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 863, in wrapper_fn
    retval = fn(*args, **get_newargs(fn, kwargs))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/query_report.py", line 81, in generate_report_result
    res = get_report_result(report, filters) or []
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/query_report.py", line 62, in get_report_result
    res = report.execute_script_report(filters)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/core/doctype/report/report.py", line 162, in execute_script_report
    res = self.execute_module(filters)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/core/doctype/report/report.py", line 179, in execute_module
    return frappe.get_attr(method_name)(frappe._dict(filters))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/report/general_ledger/general_ledger.py", line 49, in execute
    res = get_result(filters, account_details)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/report/general_ledger/general_ledger.py", line 152, in get_result
    gl_entries = get_gl_entries(filters, accounting_dimensions)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/report/general_ledger/general_ledger.py", line 199, in get_gl_entries
    gl_entries = frappe.db.sql(
                 ^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/database.py", line 234, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 558, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 822, in _read_query_result
    result.read()
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 1200, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 772, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.11/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.11/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') and (posting_date >='2024-07-22' or is_opening = 'Yes') and (posting_date <...' at line 9")

Request Data

{
    "type": "GET",
    "args": {
        "report_name": "General Ledger",
        "filters": "{\"company\":\"STARLINK GULF LIMITED\",\"from_date\":\"2024-07-22\",\"to_date\":\"2024-07-28\",\"account\":[\"Account receivable - STGL\"],\"party\":[],\"group_by\":\"Group by Voucher (Consolidated)\",\"cost_center\":[],\"project\":[],\"include_dimensions\":1,\"include_default_book_entries\":1}",
        "ignore_prepared_report": false,
        "are_default_filters": false
    },
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/frappe.desk.query_report.run",
    "request_id": null
}

Response Data

{
    "exception": "pymysql.err.ProgrammingError: (1064, \"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') and (posting_date >='2024-07-22' or is_opening = 'Yes') and (posting_date <...' at line 9\")",
    "exc_type": "ProgrammingError"
}

Module

accounts

Version

Frappe Version - 15.15.0 ERPNext Version - 15.14.0

Installation method

None

Relevant log output / Stack trace / Full Error Message.

No response

Nihantra-Patel commented 3 months ago

Kindly upgrade your version 15 because everything is working fine because lots of bugs fixed in the new version. No problems were encountered in the latest version 15.

remigius974 commented 3 months ago

well my erpnext version is up to date with v15.14.4 unless this is not the updated version. And this happened once this week and i cant seem to reproduce it cause it doesnt appear anymore

Nihantra-Patel commented 3 months ago

So please update your version because currently erpnext version running v15.32.1

remigius974 commented 3 months ago

thank you