mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-28 23:51:48 +01:00
@@ -120,52 +120,64 @@ frappe.ui.form.on("Bank Statement Import", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
show_import_status(frm) {
|
show_import_status(frm) {
|
||||||
let import_log = JSON.parse(frm.doc.statement_import_log || "[]");
|
frappe.call({
|
||||||
let successful_records = import_log.filter((log) => log.success);
|
method: "erpnext.accounts.doctype.bank_statement_import.bank_statement_import.get_import_status",
|
||||||
let failed_records = import_log.filter((log) => !log.success);
|
args: {
|
||||||
if (successful_records.length === 0) return;
|
docname: frm.doc.name,
|
||||||
|
},
|
||||||
|
callback: function (r) {
|
||||||
|
let successful_records = cint(r.message.success);
|
||||||
|
let failed_records = cint(r.message.failed);
|
||||||
|
let total_records = cint(r.message.total_records);
|
||||||
|
|
||||||
let message;
|
if (!total_records) {
|
||||||
if (failed_records.length === 0) {
|
return;
|
||||||
let message_args = [successful_records.length];
|
}
|
||||||
if (frm.doc.import_type === "Insert New Records") {
|
|
||||||
message =
|
let message;
|
||||||
successful_records.length > 1
|
if (failed_records === 0) {
|
||||||
? __("Successfully imported {0} records.", message_args)
|
let message_args = [successful_records];
|
||||||
: __("Successfully imported {0} record.", message_args);
|
if (frm.doc.import_type === "Insert New Records") {
|
||||||
} else {
|
message =
|
||||||
message =
|
successful_records > 1
|
||||||
successful_records.length > 1
|
? __("Successfully imported {0} records.", message_args)
|
||||||
? __("Successfully updated {0} records.", message_args)
|
: __("Successfully imported {0} record.", message_args);
|
||||||
: __("Successfully updated {0} record.", message_args);
|
} else {
|
||||||
}
|
message =
|
||||||
} else {
|
successful_records > 1
|
||||||
let message_args = [successful_records.length, import_log.length];
|
? __("Successfully updated {0} records.", message_args)
|
||||||
if (frm.doc.import_type === "Insert New Records") {
|
: __("Successfully updated {0} record.", message_args);
|
||||||
message =
|
}
|
||||||
successful_records.length > 1
|
} else {
|
||||||
? __(
|
let message_args = [successful_records, total_records];
|
||||||
"Successfully imported {0} records out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
if (frm.doc.import_type === "Insert New Records") {
|
||||||
message_args
|
message =
|
||||||
)
|
successful_records > 1
|
||||||
: __(
|
? __(
|
||||||
"Successfully imported {0} record out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
"Successfully imported {0} records out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
||||||
message_args
|
message_args
|
||||||
);
|
)
|
||||||
} else {
|
: __(
|
||||||
message =
|
"Successfully imported {0} record out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
||||||
successful_records.length > 1
|
message_args
|
||||||
? __(
|
);
|
||||||
"Successfully updated {0} records out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
} else {
|
||||||
message_args
|
message =
|
||||||
)
|
successful_records > 1
|
||||||
: __(
|
? __(
|
||||||
"Successfully updated {0} record out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
"Successfully updated {0} records out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
||||||
message_args
|
message_args
|
||||||
);
|
)
|
||||||
}
|
: __(
|
||||||
}
|
"Successfully updated {0} record out of {1}. Click on Export Errored Rows, fix the errors and import again.",
|
||||||
frm.dashboard.set_headline(message);
|
message_args
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
frm.dashboard.set_headline(message);
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
show_report_error_button(frm) {
|
show_report_error_button(frm) {
|
||||||
|
|||||||
@@ -242,6 +242,34 @@ def write_xlsx(data, sheet_name, wb=None, column_widths=None, file_path=None):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_import_status(docname):
|
||||||
|
import_status = {}
|
||||||
|
|
||||||
|
data_import = frappe.get_doc("Bank Statement Import", docname)
|
||||||
|
import_status["status"] = data_import.status
|
||||||
|
|
||||||
|
logs = frappe.get_all(
|
||||||
|
"Data Import Log",
|
||||||
|
fields=["count(*) as count", "success"],
|
||||||
|
filters={"data_import": docname},
|
||||||
|
group_by="success",
|
||||||
|
)
|
||||||
|
|
||||||
|
total_payload_count = 0
|
||||||
|
|
||||||
|
for log in logs:
|
||||||
|
total_payload_count += log.get("count", 0)
|
||||||
|
if log.get("success"):
|
||||||
|
import_status["success"] = log.get("count")
|
||||||
|
else:
|
||||||
|
import_status["failed"] = log.get("count")
|
||||||
|
|
||||||
|
import_status["total_records"] = total_payload_count
|
||||||
|
|
||||||
|
return import_status
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def upload_bank_statement(**args):
|
def upload_bank_statement(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|||||||
Reference in New Issue
Block a user