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

Error on Saving Loan Restructure | 1054, \"Unknown column 'tabLoan Charges.event' in 'where clause' #153

Open
umarless opened this issue Dec 11, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@umarless
Copy link

Information about bug

When I am creating Loan Restructure below error is showing.

1054, "Unknown column 'tabLoan Charges.event' in 'where clause'

Module

Loan Management

Version

erpnext -14.x.x-develop develop
frappe -15.x.x-develop develop
hrms - 16.0.0-dev develop
lending - 0.0.1 develop

Installation method

manual install

Relevant log output / Stack trace / Full Error Message.

### App Versions

{
	"erpnext": "16.0.0-dev",
	"frappe": "16.0.0-dev",
	"hrms": "16.0.0-dev",
	"lending": "0.0.1"
}

Route

Form/Loan Restructure/new-loan-restructure-vsybeqlieg

Traceback

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 1704, 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/desk/form/save.py", line 39, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 334, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 356, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 286, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1081, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 950, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1316, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1298, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 947, in fn
    return method_object(*args, **kwargs)
  File "apps/lending/lending/loan_management/doctype/loan_restructure/loan_restructure.py", line 37, in validate
    self.add_restructure_charges()
  File "apps/lending/lending/loan_management/doctype/loan_restructure/loan_restructure.py", line 154, in add_restructure_charges
    for charge in frappe.get_all(
  File "apps/frappe/frappe/__init__.py", line 1995, in get_all
    return get_list(doctype, *args, **kwargs)
  File "apps/frappe/frappe/__init__.py", line 1970, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
  File "apps/frappe/frappe/model/db_query.py", line 199, in execute
    result = self.build_and_run()
  File "apps/frappe/frappe/model/db_query.py", line 239, in build_and_run
    return frappe.db.sql(
  File "apps/frappe/frappe/database/database.py", line 217, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 153, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 558, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 822, in _read_query_result
    result.read()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1200, in read
    first_packet = self.connection._read_packet()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 772, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1054, "Unknown column 'tabLoan Charges.event' in 'where clause'")

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"docstatus\":0,\"doctype\":\"Loan Restructure\",\"name\":\"new-loan-restructure-vsybeqlieg\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"applicant_type\":\"Employee\",\"restructure_type\":\"Normal Restructure\",\"status\":\"\",\"company\":\"\",\"waive_off_restructure_charges\":1,\"treatment_of_normal_interest\":\"Add To First EMI\",\"unaccrued_interest_treatment\":\"Add To First EMI\",\"treatment_of_penal_interest\":\"Capitalize\",\"treatment_of_other_charges\":\"Capitalize\",\"new_repayment_method\":\"Repay Over Number of Periods\",\"applicant\":\"W003\",\"repayment_method\":\"Repay Over Number of Periods\",\"total_amount_paid\":0,\"total_principal_paid\":0,\"loan_product\":\"PL\",\"old_rate_of_interest\":0,\"old_loan_amount\":120000,\"old_emi\":5000,\"current_restructure_count\":0,\"pre_restructure_dpd\":0,\"disbursed_amount\":120000,\"loan\":\"ACC-LOAN-2023-00003\",\"idx\":0,\"old_tenure\":0,\"completed_tenure\":0,\"total_overdue_amount\":0,\"restructure_charges\":0,\"pending_principal_amount\":120000,\"available_security_deposit\":null,\"principal_overdue\":0,\"principal_adjusted\":0,\"balance_principal\":0,\"interest_overdue\":0,\"unaccrued_interest\":0,\"penalty_overdue\":0,\"charges_overdue\":0,\"adjusted_interest_amount\":0,\"adjusted_unaccrued_interest\":0,\"interest_waiver_amount\":0,\"unaccrued_interest_waiver\":0,\"penal_interest_waiver\":0,\"other_charges_waiver\":0,\"balance_interest_amount\":0,\"balance_unaccrued_interest\":0,\"balance_penalty_amount\":0,\"balance_charges\":0,\"new_rate_of_interest\":0,\"new_repayment_period_in_months\":48,\"new_monthly_repayment_amount\":0,\"new_loan_amount\":0,\"restructure_date\":\"2023-12-11\",\"repayment_start_date\":\"2024-01-01\"}",
		"action": "Save"
	},
	"btn": {
		"jQuery3700076979342372257561": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 1215,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs",
	"request_id": null
}

Response Data

{
	"exception": "pymysql.err.OperationalError: (1054, \"Unknown column 'tabLoan Charges.event' in 'where clause'\")",
	"exc_type": "OperationalError",
	"_exc_source": "lending (app)"
}


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
@umarless umarless added the bug Something isn't working label Dec 11, 2023
@chrisdent
Copy link

error also appears while cancelling Journal Entry that cancels Salary Slips and Payroll Entry:

App Versions

{
	"cambiare_gtq": "14.0.1",
	"cargo_agent": "14.0.1",
	"danmar": "0.0.1",
	"df_felapp": "14.1.02",
	"emolus_asignaciones_automaticas": "14.0.6",
	"erpnext": "15.5.0",
	"frappe": "15.4.1",
	"frappe_s3_attachment": "14.0.4",
	"frappe_whatsapp": "0.0.2",
	"hrms": "15.5.0",
	"lending": "0.0.1"
}

Route

Form/Journal Entry/ACC-JV-2023-00024

Traceback

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 1715, 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/desk/form/linked_with.py", line 378, in cancel_all_linked_docs
    linked_doc.cancel()
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1043, in cancel
    return self._cancel()
  File "apps/frappe/frappe/model/document.py", line 1024, in _cancel
    return self.save()
  File "apps/frappe/frappe/model/document.py", line 334, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 386, in _save
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1123, in run_post_save_methods
    self.run_method("on_cancel")
  File "apps/frappe/frappe/model/document.py", line 950, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1316, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1298, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 947, in fn
    return method_object(*args, **kwargs)
  File "apps/hrms/hrms/payroll/doctype/salary_slip/salary_slip.py", line 220, in on_cancel
    cancel_loan_repayment_entry(self)
  File "apps/hrms/hrms/payroll/doctype/salary_slip/salary_slip_loan_utils.py", line 18, in wrapper
    return function(*args, **kwargs)
  File "apps/hrms/hrms/payroll/doctype/salary_slip/salary_slip_loan_utils.py", line 134, in cancel_loan_repayment_entry
    repayment_entry.cancel()
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1043, in cancel
    return self._cancel()
  File "apps/frappe/frappe/model/document.py", line 1024, in _cancel
    return self.save()
  File "apps/frappe/frappe/model/document.py", line 334, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 386, in _save
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1123, in run_post_save_methods
    self.run_method("on_cancel")
  File "apps/frappe/frappe/model/document.py", line 950, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1316, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1298, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 947, in fn
    return method_object(*args, **kwargs)
  File "apps/lending/lending/loan_management/doctype/loan_repayment/loan_repayment.py", line 76, in on_cancel
    self.make_gl_entries(cancel=1)
  File "apps/lending/lending/loan_management/doctype/loan_repayment/loan_repayment.py", line 634, in make_gl_entries
    "Loan Product",
  File "apps/frappe/frappe/database/database.py", line 466, in get_value
    result = self.get_values(
  File "apps/frappe/frappe/database/database.py", line 563, in get_values
    out = self._get_values_from_table(
  File "apps/frappe/frappe/database/database.py", line 827, in _get_values_from_table
    return query.run(as_dict=as_dict, debug=debug, update=update, run=run, pluck=pluck)
  File "apps/frappe/frappe/query_builder/utils.py", line 87, in execute_query
    result = frappe.db.sql(query, params, *args, **kwargs)  # nosemgrep
  File "apps/frappe/frappe/database/database.py", line 217, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 153, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 558, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 822, in _read_query_result
    result.read()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1200, in read
    first_packet = self.connection._read_packet()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 772, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1054, "Unknown column 'charges_receivable_account' in 'field list'")

Request Data

{
	"type": "POST",
	"args": {
		"docs": "[{\"doctype\":\"Salary Slip\",\"name\":\"Sal Slip/HR-EMP-00010/00002\",\"docstatus\":1},{\"doctype\":\"Salary Slip\",\"name\":\"Sal Slip/HR-EMP-00009/00002\",\"docstatus\":1},{\"doctype\":\"Salary Slip\",\"name\":\"Sal Slip/HR-EMP-00011/00002\",\"docstatus\":1},{\"doctype\":\"Salary Slip\",\"name\":\"Sal Slip/HR-EMP-00012/00002\",\"docstatus\":1}]",
		"ignore_doctypes_on_cancel_all": "[\"Sales Invoice\",\"Purchase Invoice\",\"Journal Entry\",\"Repost Payment Ledger\",\"Asset\",\"Asset Movement\",\"Asset Depreciation Schedule\",\"Repost Accounting Ledger\",\"Unreconcile Payment\",\"Unreconcile Payment Entries\"]"
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.linked_with.cancel_all_linked_docs",
	"request_id": null
}

Response Data

{
	"exception": "pymysql.err.OperationalError: (1054, \"Unknown column 'charges_receivable_account' in 'field list'\")",
	"exc_type": "OperationalError",
	"_exc_source": "lending (app)"
}

@umarless
Copy link
Author

@chrisdent I was getting the same error before, I reinstalled the app and the issue of Unknown column 'charges_receivable_account' is solved.

but after fresh install when I am creating Loan Restructure this Unknown column 'tabLoan Charges.event' in 'where clause' is showing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants