PageSourceSearch

https://mycpapracticehub.com/assets/CloseChecklistTab-CSII9K2E.js

js mycpapracticehub.com collected 2026-10-09 22:04:23 UTC 16,247 bytes, 1 lines download raw bytes

1import{g as we,c as o,r as i,a as c,b as A,f as K,s as G,j as e,o as Ne,e as h,p as g,t as _,S as Se,q as ae,C as Ce,$ as _e}from"./index-Dvey7Sg9.js";import{B as w}from"./button-yo04L6Md.js";import{B as f}from"./badge-DxCDbbUo.js";import{I as H}from"./input-D4Weeu9C.js";import{T as te}from"./textarea-CCcjtihd.js";import{P as ye}from"./progress-DwFm8lYk.js";import{S as ne,a as re,b as de,c as oe,d as E}from"./select-DyijKDYc.js";import{l as ke}from"./staff.functions-BL-HroTs.js";import{T as Re}from"./triangle-alert-CEwboT6S.js";import{C as Pe}from"./clock-Ck2G_hex.js";import{C as Ae}from"./chevron-down-Bm13uYTU.js";import{C as ze}from"./chevron-right-f0ujhgR8.js";import{C as Ie}from"./circle-check-MBnQeT0E.js";import{C as Te}from"./circle-CNzLyaIX.js";import{P as ie}from"./paperclip-B8fxwqti.js";import{U as Oe}from"./undo-2-Cy5eal7N.js";import"./index-3uZSQLAZ.js";import"./index-BxcMImAA.js";import"./check-CLv-ZXz5.js";import"./chevron-up-4IbsSCjl.js";const Fe=[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]],qe=we("skip-forward",Fe),Ee=o({method:"POST"}).middleware([i]).handler(c("496abf2dce34126ec33d38e942d7bd552f70034f5e309c2cab1cc32174f0dd9f")),De=o({method:"POST"}).middleware([i]).handler(c("22655bbcb7e0f6821a6589b0c53f0c10bf1c216b343c5d05e9b9eec503e95a36")),Le=o({method:"POST"}).middleware([i]).handler(c("b5486f3b671796619844162ac17754621535d3a434cf4890debdd3df9a0fcdb4")),Ue=o({method:"POST"}).middleware([i]).handler(c("86d7edd5c8cf938aa87d64df856fc4679c9792f8e8a2a4ae9bab13e770eb36b6"));o({method:"POST"}).middleware([i]).handler(c("f511a7e000e24fc8f7018f577d477238f0f1a3fdfad5ade9b4236e5a8dd61620"));const Be=o({method:"POST"}).middleware([i]).handler(c("9c39debdcbe10cce6788e11fa142298678b3bf6a727eeed4ea2ecf3a70c7e0e8")),Qe=o({method:"POST"}).middleware([i]).handler(c("15372ec88941f30c107fbcbd5a18946c73e640659abb185d0667318bf28c4111"));o({method:"POST"}).middleware([i]).handler(c("4190e6bf3d2ed0b8174e5ebe94b969f6de067697c586bb6cfd9802406133351e"));o({method:"POST"}).middleware([i]).handler(c("5f76b1610d35d32a1827f73504d6e63f16877f80e48451b6c7018d40ec37e076"));const Ve=o({method:"POST"}).middleware([i]).handler(c("005a0d48abf990587695e20ea6bf0fb1e675660e3f3fca8e03a6b9aef44fe345")),Me=o({method:"POST"}).middleware([i]).handler(c("5884ba3e3814346cee8e7424321d49f8d16f9e9fa4a5ea5fe3f9ee67e9b47170")),$e=o({method:"POST"}).middleware([i]).handler(c("6b18b5b64c0ee8647e54ca69b9d3799b26fc6948e60032b79db39b3d8be4d629")),Ke=o({method:"POST"}).middleware([i]).handler(c("76ddbe1863dd5a87f4bace141e83aece52e37397a5833b1e6a737c81dd55686f")),Ge=o({method:"POST"}).middleware([i]).handler(c("1a7a869c0932d41991e0c6a0035cb5b052d495ec6ca2009a1925bf8d557fd0a0")),He=o({method:"POST"}).middleware([i]).handler(c("5ae219625a0767fa5db2e837503d2a926f1d1ed0f961be7dae568c931d99cf48")),ce={recon:"1. Reconcile",adjust:"2. Adjust",review:"3. Review",lock:"4. Lock",report:"5. Report"},P="__none__";function gs({clientId:a}){const[n,j]=A.useState(null),p=K({queryKey:["accounting-periods",a],queryFn:async()=>{const{data:l,error:y}=await G.from("accounting_periods").select("id, label, start_date, end_date, status").eq("client_id",a).order("end_date",{ascending:!1}).limit(24);if(y)throw new Error(y.message);return l??[]}}),b=n??p.data?.[0]?.id??null;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Period"}),e.jsx("select",{className:"border rounded px-2 py-1 text-sm bg-background",value:b??"",onChange:l=>j(l.target.value||null),children:(p.data??[]).map(l=>e.jsxs("option",{value:l.id,children:[l.label," ",l.status==="closed"?"· closed":""]},l.id))})]}),b?e.jsx(We,{clientId:a,periodId:b}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"Create an accounting period first."})]})}function We({clientId:a,periodId:n}){const j=Ne(),p=h(Ee),b=h(De),l=h(Le),y=h(Ue),k=h(Be),T=h(Qe),D=h(Ve),L=h(Me),U=h($e),z=h(Ke),B=h(Ge),I=h(He),Q=h(ke),N=K({queryKey:["close-run",a,n],queryFn:()=>p({data:{clientId:a,periodId:n}})}),R=K({queryKey:["assignable-staff"],queryFn:()=>Q()}).data?.staff??[],S=s=>s?R.find(v=>v.id===s)?.full_name??"Unknown user":null,x=()=>j.invalidateQueries({queryKey:["close-run",a,n]}),m=s=>_.error(s.message),t=g({mutationFn:s=>b({data:{itemId:s}}),onSuccess:x,onError:m}),O=g({mutationFn:s=>l({data:s}),onSuccess:x,onError:m}),le=g({mutationFn:s=>y({data:{itemId:s}}),onSuccess:x,onError:m}),me=g({mutationFn:s=>D({data:s}),onSuccess:x,onError:m}),ue=g({mutationFn:s=>L({data:s}),onSuccess:()=>{_.success("Review recorded"),x()},onError:m}),xe=g({mutationFn:s=>U({data:s}),onSuccess:x,onError:m}),he=g({mutationFn:s=>z({data:s}),onSuccess:x,onError:m}),fe=g({mutationFn:s=>B({data:s}),onSuccess:x,onError:m}),V=g({mutationFn:s=>I({data:{runId:s}}),onSuccess:s=>{_.success(`AI verification complete — quality score ${s.score}/100`),x()},onError:m}),X=g({mutationFn:s=>k({data:{runId:s}}),onSuccess:()=>{_.success("Month locked"),x()},onError:m}),pe=g({mutationFn:s=>T({data:s}),onSuccess:()=>{_.success("Month reopened"),x()},onError:m});async function ve(s,v){const r=`close/${a}/${s}/${Date.now()}-${v.name}`,{error:u}=await G.storage.from("documents").upload(r,v);if(u){_.error(u.message);return}xe.mutate({itemId:s,name:v.name,path:r})}async function ge(s){const{data:v,error:r}=await G.storage.from("documents").createSignedUrl(s,60);if(r||!v){_.error(r?.message??"Could not open file");return}window.open(v.signedUrl,"_blank")}if(N.isLoading)return e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading closing center…"});if(!N.data)return null;const d=N.data.run,C=N.data.items,M=d.status==="locked",J={};for(const s of C)(J[s.phase]??=[]).push(s);const $=C.length,Y=C.filter(s=>s.status==="done"||s.status==="skipped").length,Z=$?Math.round(Y/$*100):0,F=C.filter(s=>s.ai_status==="fail").length,q=C.filter(s=>s.ai_status==="warn").length,ee=C.filter(s=>s.review_status==="pending"&&(s.status==="done"||s.status==="skipped")).length,je=new Date().toISOString().slice(0,10),se=C.filter(s=>s.due_date&&s.due_date<je&&s.status==="pending").length;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-card p-4 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-[240px] flex-1",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Completion · Phase: ",ce[d.current_phase]??d.current_phase]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsxs("div",{className:"text-2xl font-semibold",children:[Z,"%"]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Y," / ",$," items"]})]}),e.jsx(ye,{value:Z,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Quality score"}),e.jsx("div",{className:"text-2xl font-semibold",children:d.quality_score!=null?`${Math.round(d.quality_score)}/100`:"—"}),d.ai_verified_at&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Verified ",new Date(d.ai_verified_at).toLocaleStr
1ing()]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground mb-1",children:"Close due date"}),e.jsx(H,{type:"date",className:"h-8 w-[150px]",value:d.due_date??"",disabled:M,onChange:s=>fe.mutate({runId:d.id,due_date:s.target.value||null})})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(w,{size:"sm",variant:"outline",onClick:()=>V.mutate(d.id),disabled:V.isPending,children:[e.jsx(Se,{className:"size-4 mr-1"})," ",V.isPending?"Verifying…":"AI verification"]}),M?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(f,{variant:"secondary",children:[e.jsx(ae,{className:"size-3 mr-1"})," Locked"]}),e.jsx(Je,{onConfirm:s=>pe.mutate({runId:d.id,reason:s})})]}):e.jsxs(w,{size:"sm",onClick:()=>X.mutate(d.id),disabled:X.isPending,children:[e.jsx(ae,{className:"size-4 mr-1"})," Lock month"]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[F>0&&e.jsxs(f,{variant:"destructive",children:[e.jsx(Re,{className:"size-3 mr-1"}),F," failing check",F>1?"s":""]}),q>0&&e.jsxs(f,{variant:"outline",children:[q," warning",q>1?"s":""]}),ee>0&&e.jsxs(f,{variant:"outline",children:[e.jsx(Pe,{className:"size-3 mr-1"}),ee," awaiting review"]}),se>0&&e.jsxs(f,{variant:"destructive",children:[se," overdue"]}),F===0&&q===0&&d.ai_verified_at&&e.jsxs(f,{variant:"secondary",children:[e.jsx(Ce,{className:"size-3 mr-1"})," No AI exceptions"]})]}),d.quality_notes&&e.jsx("div",{className:"rounded-md bg-muted/50 p-3 text-sm whitespace-pre-wrap",children:d.quality_notes})]}),["recon","adjust","review","lock","report"].map(s=>{const v=(J[s]??[]).slice().sort((r,u)=>r.seq-u.seq);return v.length===0?null:e.jsxs("div",{className:"rounded-lg border border-border bg-card p-4",children:[e.jsx("div",{className:"text-sm font-semibold mb-3",children:ce[s]}),e.jsx("ul",{className:"divide-y divide-border",children:v.map(r=>e.jsx(Xe,{item:r,locked:M,staff:R,staffName:S,onComplete:()=>t.mutate(r.id),onSkip:u=>O.mutate({itemId:r.id,reason:u}),onReopen:()=>le.mutate(r.id),onUpdate:u=>me.mutate({itemId:r.id,...u}),onReview:(u,be)=>ue.mutate({itemId:r.id,decision:u,review_notes:be}),onUpload:u=>ve(r.id,u),onOpenFile:ge,onRemoveFile:u=>he.mutate({itemId:r.id,path:u})},r.id))})]},s)})]})}function Xe({item:a,locked:n,staff:j,staffName:p,onComplete:b,onSkip:l,onReopen:y,onUpdate:k,onReview:T,onUpload:D,onOpenFile:L,onRemoveFile:U}){const[z,B]=A.useState(!1),[I,Q]=A.useState(a.notes??""),[N,W]=A.useState(a.review_notes??""),R=Array.isArray(a.attachments)?a.attachments:[],S=a.status==="done"||a.status==="skipped",x=new Date().toISOString().slice(0,10),m=a.due_date&&a.due_date<x&&a.status==="pending";return e.jsxs("li",{className:"py-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("button",{type:"button",className:"mt-0.5",onClick:()=>B(t=>!t),"aria-label":"Toggle details",children:z?e.jsx(Ae,{className:"size-4 text-muted-foreground"}):e.jsx(ze,{className:"size-4 text-muted-foreground"})}),e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:a.status==="done"?e.jsx(Ie,{className:"size-5 text-green-600"}):a.status==="skipped"?e.jsx(qe,{className:"size-5 text-muted-foreground"}):e.jsx(Te,{className:"size-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:a.title}),a.blocks_lock&&e.jsx(f,{variant:"outline",className:"text-xs",children:"Required"}),a.ai_status==="fail"&&e.jsx(f,{variant:"destructive",className:"text-xs",children:"AI: fail"}),a.ai_status==="warn"&&e.jsx(f,{variant:"outline",className:"text-xs",children:"AI: warning"}),a.ai_status==="pass"&&e.jsx(f,{variant:"secondary",className:"text-xs",children:"AI: pass"}),a.review_status==="pending"&&S&&e.jsx(f,{variant:"outline",className:"text-xs",children:"Awaiting review"}),a.review_status==="approved"&&e.jsx(f,{variant:"secondary",className:"text-xs",children:"Reviewed"}),a.review_status==="rejected"&&e.jsx(f,{variant:"destructive",className:"text-xs",children:"Rejected"}),R.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground inline-flex items-center gap-1",children:[e.jsx(ie,{className:"size-3"}),R.length]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5 flex flex-wrap gap-x-3",children:[e.jsxs("span",{children:["Owner: ",p(a.assignee)??"unassigned"]}),e.jsxs("span",{children:["Reviewer: ",p(a.reviewer)??"none"]}),e.jsxs("span",{className:m?"text-destructive font-medium":"",children:["Due: ",a.due_date??"—",m?" (overdue)":""]})]}),a.skip_reason&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Skipped: ",a.skip_reason]}),a.ai_verdict&&z&&e.jsxs("div",{className:"text-xs mt-2 rounded bg-muted/50 p-2",children:[e.jsx("span",{className:"font-medium",children:"AI verification: "}),a.ai_verdict]})]}),e.jsxs("div",{className:"flex gap-1",children:[a.status==="pending"&&!n&&e.jsxs(e.Fragment,{children:[e.jsx(w,{size:"sm",variant:"outline",onClick:b,children:"Done"}),e.jsx(w,{size:"sm",variant:"ghost",onClick:()=>{const t=window.prompt("Reason for skipping?");t&&l(t)},children:"Skip"})]}),S&&!n&&e.jsx(w,{size:"sm",variant:"ghost",onClick:y,title:"Reopen",children:e.jsx(Oe,{className:"size-4"})})]})]}),z&&e.jsxs("div",{className:"mt-3 ml-10 grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Responsible staff"}),e.jsxs(ne,{value:a.assignee??P,onValueChange:t=>k({assignee:t===P?null:t}),disabled:n,children:[e.jsx(re,{className:"h-8",children:e.jsx(de,{placeholder:"Unassigned"})}),e.jsxs(oe,{children:[e.jsx(E,{value:P,children:"Unassigned"}),j.map(t=>e.jsx(E,{value:t.id,children:t.full_name},t.id))]})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Reviewer"}),e.jsxs(ne,{value:a.reviewer??P,onValueChange:t=>k({reviewer:t===P?null:t}),disabled:n,children:[e.jsx(re,{className:"h-8",children:e.jsx(de,{placeholder:"No reviewer"})}),e.jsxs(oe,{children:[e.jsx(E,{value:P,children:"No reviewer"}),j.map(t=>e.jsx(E,{value:t.id,children:t.full_name},t.id))]})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Due date"}),e.jsx(H,{type:"date",className:"h-8",value:a.due_date??"",disabled:n,onChange:t=>k({due_date:t.target.value||null})})]}),e.jsxs("div",{className:"md:col-span-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Preparer notes"}),e.jsx(te,{rows:2,value:I,disabled:n,onChange:t=>Q(t.target.value),onBlur:()=>I!==(a.notes??"")&&k({notes:I}),placeholder:"What was done, sources used, exceptions…"})]}),e.jsxs("div",{className:"md:col-span-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Attachments"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[R.map(t=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded border px-2 py-1 text-xs",children:[e.jsx("button",{type:"button",className:"underline",onClick:()=>L(t.path),children:t.name}),!n&&e.jsx("button",{type:"button",onClick:()=>U(t.path),"aria-label":"Remove attachment",children:e.jsx(_e,{className:"size-3"})})]},t.path)),!n&&e.jsxs("label",{className:"text-xs inline-flex items-center gap-1 cursor-pointer rounded border px-2 py-1 hover:bg-accent",children:[e.jsx(ie,{className:"size-3"})," Attach file",e.jsx("input",{type:"file",className:"hidden",onChange:t=>{const O=t.target.files?.[0];O&&D(O),t.target.value=""}})]})]})]}),e.jsxs("div",{className:"md:col-span-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Review notes"}),e.jsx(te,{rows:2,value:N,disabled:n,onChange:t=>W(t.target.value),placeholder:"Reviewer comments…"}),!n&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(w,{size:"sm",variant:"outline",disabled:!S,onClick:()=>T("approved",N),children:"Approve"}),e.jsx(w,{size:"sm",variant:"ghost",disabled:!S,onClick:()=>T("rejected",N),children:"Send back"}),!S&&e.jsx("span",{className:"text-xs text-muted-foreground self-center",children:"Complete the item to review it."})]}),a.reviewed_at&&e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[a.review_status==="approved"?"Approved":"Reviewed"," by ",p(a.reviewer)??"reviewer"," on"," ",new Date(a.reviewed_at).toLocaleStr
1ing()]})]})]})]})}function Je({onConfirm:a}){const[n,j]=A.useState(!1),[p,b]=A.useState("");return n?e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(H,{placeholder:"Reason",value:p,onChange:l=>b(l.target.value),className:"h-8 w-40"}),e.jsx(w,{size:"sm",variant:"outline",disabled:!p.trim(),onClick:()=>{a(p.trim()),j(!1),b("")},children:"Confirm reopen"}),e.jsx(w,{size:"sm",variant:"ghost",onClick:()=>j(!1),children:"Cancel"})]}):e.jsx(w,{size:"sm",variant:"outline",onClick:()=>j(!0),children:"Reopen"})}export{gs as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.