Skip to content
2 changes: 1 addition & 1 deletion audit_management/audit_management/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_dashboard_stats(pending_start=0, recent_start=0):

total_pending = frappe.db.count("My Audits", {**filters, "status": "Pending"})
high_risk = frappe.db.count("My Audits", {**filters, "risk": "High"})
closed_count = frappe.db.count("My Audits", {**filters, "status": "Close"})
closed_count = frappe.db.count("My Audits", {**filters, "status": "Closed"})
draft_count = frappe.db.count("My Audits", {**filters, "status": "Draft"})

recent_list = []
Expand Down
32 changes: 16 additions & 16 deletions audit_management/audit_management/doctype/my_audits/my_audits.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ frappe.ui.form.on("My Audits", {

date_html += item("Created", created_date);

if (frm.doc.status === "Close" && frm.doc.closing_date) {
if (frm.doc.status === "Closed" && frm.doc.closing_date) {
const closed_date = frappe.datetime.str_to_user(frm.doc.closing_date);
date_html += item("Closed", closed_date);
}
Expand All @@ -84,7 +84,7 @@ frappe.ui.form.on("My Audits", {

// Correct status label text from 'Close' to 'Closed'
let status_pill = frm.page.wrapper.find(".indicator-pill").first();
if (status_pill.text().trim() === "Close") {
if (status_pill.text().trim() === "Closed") {
status_pill.text("Closed");
}
}, 500);
Expand Down Expand Up @@ -331,7 +331,7 @@ frappe.ui.form.on("My Audits", {
.css({ "background-color": "#28a745", color: "white" });
}

if (frm.doc.status === "Close") {
if (frm.doc.status === "Closed") {
frm.disable_form();
}

Expand Down Expand Up @@ -493,7 +493,7 @@ frappe.ui.form.on("My Audits", {
},

// setup_dynamic_buttons: function (frm) {
// if (frm.is_new() || frm.doc.status === "Close") return;
// if (frm.is_new() || frm.doc.status === "Closed") return;
// const is_audit_team =
// frappe.user.has_role("Audit Manager") ||
// frappe.user.has_role("Audit Member");
Expand Down Expand Up @@ -569,7 +569,7 @@ frappe.ui.form.on("My Audits", {
// },

// setup_dynamic_buttons: function (frm) {
// if (frm.is_new() || frm.doc.status === "Close") return;
// if (frm.is_new() || frm.doc.status === "Closed") return;

// const is_audit_team =
// frappe.user.has_role("Audit Manager") ||
Expand Down Expand Up @@ -672,7 +672,7 @@ frappe.ui.form.on("My Audits", {

// current working
// setup_dynamic_buttons: function (frm) {
// if (frm.is_new() || frm.doc.status === "Close") return;
// if (frm.is_new() || frm.doc.status === "Closed") return;

// const current_user = frappe.session.user;

Expand Down Expand Up @@ -766,7 +766,7 @@ frappe.ui.form.on("My Audits", {

// my current working
// setup_dynamic_buttons: function (frm) {
// if (frm.is_new() || frm.doc.status === "Close") return;
// if (frm.is_new() || frm.doc.status === "Closed") return;

// const is_audit_team = frappe.user.has_role("Audit Manager") || frappe.user.has_role("Audit Member");
// const current_user = frappe.session.user;
Expand Down Expand Up @@ -933,7 +933,7 @@ frappe.ui.form.on("My Audits", {

// setup_dynamic_buttons: function (frm) {
// // Return early if it's a completely new, unsaved document, or if it's closed.
// if (frm.is_new() || frm.doc.status === "Close") return;
// if (frm.is_new() || frm.doc.status === "Closed") return;

// const is_audit_team = frappe.user.has_role("Audit Manager") || frappe.user.has_role("Audit Member");
// const current_user = frappe.session.user;
Expand Down Expand Up @@ -1076,7 +1076,7 @@ frappe.ui.form.on("My Audits", {
// 0. REOPEN LOGIC: Only Audit Team can reopen a Closed query
frm.trigger("reopen_query");

if (frm.doc.status === "Close") return;
if (frm.doc.status === "Closed") return;

// 1. DRAFT STATE: Only Audit Team can see "Raise Request" Action
if (frm.doc.status === "Draft" && is_audit_team) {
Expand Down Expand Up @@ -1327,7 +1327,7 @@ frappe.ui.form.on("My Audits", {
// frm.refresh_field("current_response_box");
// frm.refresh_field("current_response_attach");

// if (frm.doc.status === "Close") {
// if (frm.doc.status === "Closed") {
// frm.disable_form();
// }
// },
Expand Down Expand Up @@ -1381,7 +1381,7 @@ frappe.ui.form.on("My Audits", {
}

// Show the resolution section ONLY when the query is closed
frm.toggle_display("resolution_section", frm.doc.status === "Close");
frm.toggle_display("resolution_section", frm.doc.status === "Closed");
// ---------------------------------------------------------

// 5. Freeze Completed Stage Response Boxes
Expand Down Expand Up @@ -1410,7 +1410,7 @@ frappe.ui.form.on("My Audits", {
frm.set_df_property("current_response_attach", "hidden", 1);
frm.toggle_display("response_section", false);

if (frm.doc.status === "Close") {
if (frm.doc.status === "Closed") {
frm.disable_form();
}
},
Expand Down Expand Up @@ -1478,7 +1478,7 @@ frappe.ui.form.on("My Audits", {
default: frm.doc.closing_remark,
},
],
primary_action_label: __("Close"),
primary_action_label: __("Closed"),
primary_action(data) {
d.hide();
frm.set_value("rca_category", data.rca_category);
Expand All @@ -1487,7 +1487,7 @@ frappe.ui.form.on("My Audits", {
frm.set_value("recommendations", data.recommendations);
frm.set_value("closing_remark", data.closing_remark);
frm.set_value("closing_date", frappe.datetime.nowdate());
frm.set_value("status", "Close");
frm.set_value("status", "Closed");
frm.save().then((r) => {
if (!r.exc) {
frappe.show_alert({
Expand Down Expand Up @@ -2097,7 +2097,7 @@ frappe.ui.form.on("My Audits", {
},

close_query: function (frm) {
if (frm.doc.status !== "Close") {
if (frm.doc.status !== "Closed") {
frm
.add_custom_button(__("Close Query"), function () {
frm.trigger("handle_close_query");
Expand All @@ -2107,7 +2107,7 @@ frappe.ui.form.on("My Audits", {
},

reopen_query: function (frm) {
if (frm.doc.status === "Close") {
if (frm.doc.status === "Closed") {
const is_audit_team =
frappe.user.has_role("Audit Manager") ||
frappe.user.has_role("Audit Member");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@
"states": [
{
"color": "Green",
"title": "Close"
"title": "Closed"
},
{
"color": "Gray",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class MyAudits(Document):
def validate(self):
update_audit_aging(self)
if self.status == "Close":
if self.status == "Closed":
self.validate_resolution_fields()

# Enforce mandatory fields for new records
Expand Down Expand Up @@ -599,7 +599,7 @@ def submit_response(docname, response_text, attachment=None):
# stage_names.append(n_row.stage_name)
# doc.query_status = f"Pending From {', '.join(stage_names)}"
# else:
# doc.status = "Close"
# doc.status = "Closed"
# doc.query_status = "Completed"

# doc.save(ignore_permissions=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_audit_counts(is_admin=None):
counts["total_count"] = frappe.db.count("My Audits", filters)
counts["draft_count"] = frappe.db.count("My Audits", {**filters, "status": "Draft"})
counts["pending_count"] = frappe.db.count("My Audits", {**filters, "status": "Pending"})
counts["close_count"] = frappe.db.count("My Audits", {**filters, "status": "Close"})
counts["close_count"] = frappe.db.count("My Audits", {**filters, "status": "Closed"})

if is_new:
child_filters = ""
Expand Down
2 changes: 1 addition & 1 deletion audit_management/audit_management/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_working_days(start_date, end_date):
def update_audit_aging(doc):
"""Calculates aging from creation date to now (or closure date)."""
start_date = getdate(doc.creation)
end_date = getdate(doc.modified) if doc.status == "Close" else getdate(nowdate())
end_date = getdate(doc.modified) if doc.status == "Closed" else getdate(nowdate())

doc.aging = get_working_days(start_date, end_date)

Expand Down
4 changes: 2 additions & 2 deletions audit_management/www/audit_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_dashboard_number_cards():
total_count = frappe.db.count("My Audits", filters)
draft_count = frappe.db.count("My Audits", {**filters, "status": "Draft"})
pending_count = frappe.db.count("My Audits", {**filters, "status": "Pending"})
completed_count = frappe.db.count("My Audits", {**filters, "status": "Close"})
completed_count = frappe.db.count("My Audits", {**filters, "status": "Closed"})

# The current model does not have a dedicated due-date field yet.
# For now, we surface overdue as pending audits with aging recorded.
Expand Down Expand Up @@ -84,7 +84,7 @@ def get_audits(start=0, limit=20, filters=None):

# Add metadata for UI
for audit in audits:
audit.statusClass = "progress" if audit.status == "Pending" else "completed" if audit.status == "Close" else "overdue"
audit.statusClass = "progress" if audit.status == "Pending" else "completed" if audit.status == "Closed" else "overdue"
audit.riskClass = (audit.risk or "Normal").lower()
audit.dueDate = frappe.utils.formatdate(audit.creation)
audit.dueMeta = f"{audit.aging} days" if audit.aging else "Due soon"
Expand Down
Loading