admin: mark-filed action to advance manual/admin-assisted orders to completed

Admin-assisted services (UCR, MC authority, etc.) have no automated submission,
so approving them only flips to authorization_signed and then sits there -- there
was no way to advance to completed. Add POST /mark-filed (filed_waiting_state |
completed, optional confirmation #, transactional + audit-logged) and drawer
buttons 'Mark as filed (waiting on agency)' / 'Mark completed' shown for orders in
authorization_signed / ready_to_file / filed_waiting_state. Confirmation number
is recorded into intake_data.filing_status.manual_confirmation.
This commit is contained in:
justin 2026-06-16 03:12:57 -05:00
parent 6c10c6a6cd
commit bf69960e8c
2 changed files with 94 additions and 0 deletions

View file

@ -345,6 +345,18 @@
refresh();
} catch (e) { alert("Re-arm failed: " + e.message); }
}
async function markFiled(orderNumber, status) {
const label = status === "completed" ? "completed" : "filed (waiting on the agency)";
const conf = ($("drawer-confirmation") && $("drawer-confirmation").value.trim()) || "";
if (!confirm(`Mark ${orderNumber} as ${label}?` + (conf ? `\nConfirmation #: ${conf}` : ""))) return;
try {
await api("/api/v1/admin/compliance-orders/" + encodeURIComponent(orderNumber) + "/mark-filed",
{ method: "POST", body: JSON.stringify({ status, confirmation: conf }) });
alert(`Marked ${label}.`);
$("drawer").classList.add("hidden");
refresh();
} catch (e) { alert("Mark failed: " + e.message); }
}
async function openDetail(orderNumber) {
$("drawer").classList.remove("hidden");
@ -377,6 +389,16 @@
+ `<button id="drawer-approve" class="btn btn-blue wfull" style="margin-top:8px;">Approve &amp; file this order</button>`)
: "") +
((order.payment_status === "paid" && !order.intake_data_validated) ? `<button id="drawer-rearm" class="btn btn-amber wfull" style="margin-top:8px;">Re-arm intake reminder</button>` : "") +
// Manual filing controls: once an order is approved/awaiting agency, let
// the admin record that they've filed it (admin-assisted services have
// no automated submission, so this is how they reach completed).
(["authorization_signed", "ready_to_file", "filed_waiting_state"].includes(order.fulfillment_status)
? `<div class="section-h">Manual filing</div>`
+ `<input id="drawer-confirmation" class="field" type="text" placeholder="Confirmation # (optional)" style="margin-bottom:6px;" />`
+ (order.fulfillment_status !== "filed_waiting_state"
? `<button id="drawer-mark-waiting" class="btn btn-outline wfull" style="margin-bottom:6px;">Mark as filed (waiting on agency)</button>` : "")
+ `<button id="drawer-mark-completed" class="btn btn-primary wfull">Mark completed</button>`
: "") +
`<div class="section-h">Intake data</div><pre>${esc(JSON.stringify(intake, null, 2))}</pre>` +
`<div class="section-h">Documents</div><div id="drawer-docs"><div class="muted" style="font-size:12px;">Loading documents…</div></div>` +
`<div class="section-h">Audit log</div>${auditHtml}`;
@ -384,6 +406,10 @@
if (da) da.addEventListener("click", () => approveOrder(order.order_number, order.service_name || order.service_slug, !!order.intake_data_validated));
const dr = $("drawer-rearm");
if (dr) dr.addEventListener("click", () => rearmIntake(order.order_number));
const mw = $("drawer-mark-waiting");
if (mw) mw.addEventListener("click", () => markFiled(order.order_number, "filed_waiting_state"));
const mc = $("drawer-mark-completed");
if (mc) mc.addEventListener("click", () => markFiled(order.order_number, "completed"));
loadDocuments(order.order_number);
} catch (e) { $("drawer-body").innerHTML = `<div style="color:#b91c1c;">Failed to load: ${esc(e.message)}</div>`; }
}