mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-15 09:53:09 +00:00
refactor: parse native JSON request args in accounts/doctype/bank_statement_import_log/bank_statement_import_log.py
Use frappe.parse_json instead of json.loads so the whitelisted endpoints accept native JSON types (list/dict/bool) in addition to JSON strings.
This commit is contained in:
@@ -1183,8 +1183,7 @@ def update_pdf_tables(statement_import_id: str, tables: list | str):
|
|||||||
if doc.status == "Completed":
|
if doc.status == "Completed":
|
||||||
frappe.throw(_("This statement has already been imported."), title=_("Already Imported"))
|
frappe.throw(_("This statement has already been imported."), title=_("Already Imported"))
|
||||||
|
|
||||||
if isinstance(tables, str):
|
tables = frappe.parse_json(tables)
|
||||||
tables = json.loads(tables)
|
|
||||||
|
|
||||||
doc.apply_pdf_tables(tables)
|
doc.apply_pdf_tables(tables)
|
||||||
|
|
||||||
@@ -1204,8 +1203,7 @@ def reextract_pdf_table(statement_import_id: str, page: int, table_index: int, b
|
|||||||
if doc.status == "Completed":
|
if doc.status == "Completed":
|
||||||
frappe.throw(_("This statement has already been imported."), title=_("Already Imported"))
|
frappe.throw(_("This statement has already been imported."), title=_("Already Imported"))
|
||||||
|
|
||||||
if isinstance(bbox, str):
|
bbox = frappe.parse_json(bbox)
|
||||||
bbox = json.loads(bbox)
|
|
||||||
|
|
||||||
page = int(page)
|
page = int(page)
|
||||||
table_index = int(table_index)
|
table_index = int(table_index)
|
||||||
@@ -1290,8 +1288,7 @@ def update_column_mapping(statement_import_id: str, column_mapping: list | str):
|
|||||||
if doc.status == "Completed":
|
if doc.status == "Completed":
|
||||||
frappe.throw(_("This statement has already been imported."), title=_("Already Imported"))
|
frappe.throw(_("This statement has already been imported."), title=_("Already Imported"))
|
||||||
|
|
||||||
if isinstance(column_mapping, str):
|
column_mapping = frappe.parse_json(column_mapping)
|
||||||
column_mapping = json.loads(column_mapping)
|
|
||||||
|
|
||||||
doc.apply_column_mapping(column_mapping)
|
doc.apply_column_mapping(column_mapping)
|
||||||
doc.save()
|
doc.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user