mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-19 01:18:43 +00:00
refactor: parse native JSON request args in accounts/doctype/bank_transaction/bank_transaction_upload.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:
@@ -35,12 +35,12 @@ def upload_bank_statement():
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_bank_entries(columns: str, data: str, bank_account: str):
|
||||
def create_bank_entries(columns: str, data: str | list, bank_account: str):
|
||||
header_map = get_header_mapping(columns, bank_account)
|
||||
|
||||
success = 0
|
||||
errors = 0
|
||||
for d in json.loads(data):
|
||||
for d in frappe.parse_json(data):
|
||||
if all(item is None for item in d) is True:
|
||||
continue
|
||||
fields = {}
|
||||
@@ -66,7 +66,7 @@ def get_header_mapping(columns, bank_account):
|
||||
mapping = get_bank_mapping(bank_account)
|
||||
|
||||
header_map = {}
|
||||
for column in json.loads(columns):
|
||||
for column in frappe.parse_json(columns):
|
||||
if column["content"] in mapping:
|
||||
header_map.update({mapping[column["content"]]: column["colIndex"]})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user