1import{u as b,e as de,r as ie,j as e}from"./vendor-data-Z5doMMu-.js";import{b as oe,r as $}from"./vendor-react-zNM0AU50.js";import{u as me,d as P}from"./index-D1K3lVhu.js";import{k as W,j as xe,K as te,A as ae}from"./vendor-firebase-Da9KY1q_.js";import{o as ce,C as D,S as re,p as ue}from"./financeConstants-CXKUiVP8.js";import{M as T}from"./MemberSearchInput-CkBMsjbg.js";import{i as ne}from"./incomeBudgetService-JIhgONuP.js";import{d as F,bQ as he,r as ge,I as q,x as pe,D as be,a8 as je,A as z,T as fe,aa as Ne,bm as ye,U as ve,_ as we,ag as Ae,ae as Se,a as ke,z as R}from"./vendor-ui-CW5bJ11U.js";import"./vendor-charts-08G1rM8P.js";function Ce(j){const y=b.book_new(),d=String(parseInt(j)-1),i=[[`${j}ë
ë ìì
ìì°`,"","","","(ë¨ì: ì)"],[],["â» ìì°(ì) ì´ì ê¸ì¡ì ì
ë ¥íì¸ì. í목ì½ëë ìì íì§ ë§ì¸ì."],[],["í목ì½ë","ë¶ë¥","í목ëª
",`${j}ë
ìì°`,`${d}ë
ê²°ì°`,"ì¦ê°","ë¹ê³ "]],x=[{id:"carryover",name:"ì´ìê¸"},{id:"regular",name:"ì 기íê¸"},{id:"thanksgiving",name:"ê°ì¬íê¸"},{id:"seasonal",name:"ì 기íê¸"},{id:"special",name:"í¹ë³íê¸"},{id:"other",name:"기íìì
"}],v=[];let u=6;x.forEach(m=>{v.push([`ã${m.name}ã`,"","","","","",""]),u++,ce.filter(N=>N.category===m.id&&N.isActive).forEach(N=>{v.push([N.code,m.name,N.name,0,0,`=D${u}-E${u}`,""]),u++}),v.push(["","","","","","",""]),u++}),v.push(["","","ã ìì
í©ê³ ã",`=SUMIF(A6:A${u-1},"I-*",D6:D${u-1})`,`=SUMIF(A6:A${u-1},"I-*",E6:E${u-1})`,`=D${u}-E${u}`,""]);const A=b.aoa_to_sheet([...i,...v]);A["!cols"]=[{wch:12},{wch:12},{wch:18},{wch:15},{wch:15},{wch:12},{wch:30}],b.book_append_sheet(y,A,"ìì
ìì°");const f=[[`${j}ë
ë ì§ì¶ìì° ìì½`,"","","","(ë¨ì: ì²ì)"],[],["ë¶ìì½ë","ë¶ìëª
",`${j}ë
ìì°`,`${d}ë
ê²°ì°`,"ì¦ê°","ë¹ê³ "]],I=D.map(m=>{const Y=re.filter(N=>N.departmentId===m.id).reduce((N,C)=>N+C.amount,0);return[m.code,m.name,Y,0,`=C${4+D.indexOf(m)}-D${4+D.indexOf(m)}`,""]}),t=4+D.length;I.push(["","ã ì§ì¶ í©ê³ ã",`=SUM(C4:C${t-1})`,`=SUM(D4:D${t-1})`,`=C${t}-D${t}`,""]);const l=b.aoa_to_sheet([...f,...I]);l["!cols"]=[{wch:10},{wch:18},{wch:15},{wch:15},{wch:12},{wch:25}],b.book_append_sheet(y,l,"ì§ì¶ìì°ìì½"),D.forEach(m=>{const Y=re.filter(_=>_.departmentId===m.id);if(Y.length===0)return;const N=[[`(${m.code}) ${m.name}`,"","","","","","","(ë¨ì: ì²ì)"],[],["과목","",`${j}ë
ìì°`,"ì°ì¶ë´ì","","","",""],["í목ì½ë","ê³ì ëª
","ìì°ì¡","ë´ì1","ë´ì2","ë´ì3","ë´ì4","ë¹ê³ "]],C=[];Y.forEach(_=>{const E=_.details||[];C.push([_.subCode,_.name,_.amount,E[0]||"",E[1]||"",E[2]||"",E[3]||"",E.slice(4).join(", ")||""])});const M=5,O=M+C.length-1;C.push([]),C.push(["","ã ì ê³ ã",`=SUM(C${M}:C${O})`,"","","","",""]);const H=b.aoa_to_sheet([...N,...C]);H["!cols"]=[{wch:10},{wch:20},{wch:12},{wch:22},{wch:22},{wch:22},{wch:22},{wch:20}];const k=`${m.code}_${m.name}`.slice(0,31);b.book_append_sheet(y,H,k)});const S=[[`${j}ë
ë ìíê³ì¢ ë±ë¡`],[],["â» êµíìì ì¬ì©íë ê³ì¢ë¥¼ ë±ë¡íì¸ì"],[],["ìíëª
","ê³ì¢ë²í¸","ìê¸ì£¼","ì©ë","ë©ëª¨"]],B=[["êµë¯¼ìí","","","ì¼ë°",""],["","","","",""],["","","","",""]],c=b.aoa_to_sheet([...S,...B]);c["!cols"]=[{wch:15},{wch:22},{wch:15},{wch:15},{wch:25}],b.book_append_sheet(y,c,"ìíê³ì¢");const h=[[`${j}ë
ë ì¬ì 기본ì¤ì `],[],["ì¤ì í목","ê°","ì¤ëª
"],["íê³ì°ë",j,"íì¬ íê³ì°ë"],["íê³ì°ëììì","1","1~12 ì¤ ì í (ëë¶ë¶ 1ì)"],["ì 기ì´ìê¸","0","ì ë
ë ì´ì ìì¡ (ì ë¨ì)"],["íê³ë°©ì","ê°í¸íê³","ê°í¸íê³ ëë ì 문íê³"]],o=b.aoa_to_sheet(h);o["!cols"]=[{wch:18},{wch:20},{wch:35}],b.book_append_sheet(y,o,"기본ì¤ì ");const U=de(y,{bookType:"xlsx",type:"array"});return new Blob([U],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}function _e(j){return new Promise((y,d)=>{const i=new FileReader;i.onload=x=>{var v;try{const u=new Uint8Array((v=x.target)==null?void 0:v.result),A=ie(u,{type:"array"}),f={settings:{fiscalYear:new Date().getFullYear().toString(),fiscalYearStart:1,carryoverAmount:0,accountingMode:"simple"},incomeBudgets:[],expenseBudgets:[],bankAccounts:[]},I=A.Sheets.기본ì¤ì ;I&&b.sheet_to_json(I,{header:1}
1).forEach(c=>{const h=String(c[0]||"").trim(),o=c[1];h==="íê³ì°ë"&&(f.settings.fiscalYear=String(o)),h==="íê³ì°ëììì"&&(f.settings.fiscalYearStart=Number(o)||1),h==="ì 기ì´ìê¸"&&(f.settings.carryoverAmount=Number(o)||0),h==="íê³ë°©ì"&&(f.settings.accountingMode=String(o).includes("ì 문")?"double":"simple")});const t=A.Sheets.ìì
ìì°;t&&b.sheet_to_json(t,{header:1}).forEach(c=>{const h=String(c[0]||"").trim();h.startsWith("I-")&&f.incomeBudgets.push({code:h,name:String(c[2]||""),amount:Number(c[3])||0})});const l=A.Sheets.ì§ì¶ìì°ìì½;l&&b.sheet_to_json(l,{header:1}).forEach(c=>{const h=String(c[0]||"").trim(),o=D.find(U=>U.code===h);o&&f.expenseBudgets.push({departmentId:o.id,departmentName:String(c[1]||o.name),amount:Number(c[2])||0})});const S=A.Sheets.ìíê³ì¢;S&&b.sheet_to_json(S,{header:1}).slice(5).forEach(c=>{const h=String(c[0]||"").trim(),o=String(c[1]||"").trim();h&&o&&f.bankAccounts.push({bankName:h,accountNumber:o,accountHolder:String(c[2]||""),purpose:String(c[3]||"ì¼ë°"),notes:String(c[4]||"")})}),y(f)}catch(u){d(u)}},i.onerror=d,i.readAsArrayBuffer(j)})}function $e(j,y){const d=URL.createObjectURL(j),i=document.createElement("a");i.href=d,i.download=y,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(d)}const w=[{id:"mode",title:"íê³ ë°©ì",description:"ë¨ìë¶ê¸° ëë ë³µìë¶ê¸°ë¥¼ ì íí©ëë¤"},{id:"fiscal",title:"íê³ì°ë",description:"íê³ì°ë ìììì ì¤ì í©ëë¤"},{id:"carryover",title:"ì´ìê¸",description:"ì 기ì´ìê¸ì ì
ë ¥í©ëë¤"},{id:"income",title:"ìì
ìì°",description:"ìì
ìì° í목ì ì¤ì í©ëë¤"},{id:"expense",title:"ì§ì¶ìì°",description:"ì§ì¶ìì° í목ì ì¤ì í©ëë¤"},{id:"bank",title:"ìíê³ì¢",description:"êµí ê³ì¢ë¥¼ ë±ë¡í©ëë¤"},{id:"managers",title:"ë´ë¹ì",description:"ì¬ì ë´ë¹ì를 ì§ì í©ëë¤"},{id:"departments",title:"ë¶ì",description:"ë¶ìë³ íê³ ë´ë¹ì를 ì¤ì í©ëë¤"},{id:"complete",title:"ìë£",description:"ì¤ì ì íì¸íê³ ì ì¥í©ëë¤"}],De=["êµë¯¼ìí","ì íìí","ì°ë¦¬ìí","íëìí","NHëíìí","기ì
ìí","SCì ì¼ìí","ì¨í°ìí","ì¼ì´ë±
í¬","ì¹´ì¹´ì¤ë±
í¬","í ì¤ë±
í¬","ìë§ìê¸ê³ ","ì í","ì°ì²´êµ","ìí","기í"],Ie=["ì¼ë°","íê¸","í¹ë³íê¸","ì 립ê¸","ì êµë¹","ê±´ì¶íê¸","기í"];function Te({embedded:j=!1}){var _,E,G,K,Q,J,V,X,Z,ee,se;const y=oe(),{user:d}=me(),i=(d==null?void 0:d.churchId)||"seodoon-church",[x,v]=$.useState("mode"),[u,A]=$.useState(!0),[f,I]=$.useState(!1),[t,l]=$.useState({accountingMode:"simple",fiscalYearStart:1,currentFiscalYear:new Date().getFullYear().toString(),carryoverAmount:0,bankAccounts:[],departmentAccountants:{},requireDeptHeadApproval:!0,autoApproveUnderAmount:0,isConfigured:!1}),[S,B]=$.useState(ce.map(s=>({code:s.code,name:s.name,category:s.category,budgetAmount:0,isActive:s.isActive}))),[c,h]=$.useState(D.reduce((s,a)=>(s[a.id]=ue(a.id)*1e3,s),{})),o=$.useRef(null),[U,m]=$.useState(!1),Y=()=>{try{const s=Ce(t.currentFiscalYear);$e(s,`${t.currentFiscalYear}ë
ë_ìì°ì¤ì _í
í릿.xlsx`),R.success("í
íë¦¿ì´ ë¤ì´ë¡ëëììµëë¤")}catch(s){console.error("í
í릿 ìì± ì¤í¨:",s),R.error("í
í릿 ìì±ì ì¤í¨íìµëë¤")}},N=async s=>{var r;const a=(r=s.target.files)==null?void 0:r[0];if(a)try{m(!0);const n=await _e(a);if(l(g=>({...g,fiscalYearStart:n.settings.fiscalYearStart,currentFiscalYear:n.settings.fiscalYear,carryoverAmount:n.settings.carryoverAmount,accountingMode:n.settings.accountingMode,bankAccounts:n.bankAccounts.map((p,L)=>({id:`bank_${Date.now()}_${L}`,bankName:p.bankName,accountNumber:p.accountNumber,accountHolder:p.accountHolder,purpose:p.purpose,isActive:!0}))})),n.incomeBudgets.length>0&&B(g=>g.map(p=>{const L=n.incomeBudgets.find(le=>le.code===p.code);return L?{...p,budgetAmount:L.amount}:p})),n.expenseBudgets.length>0){const g={...c};n.expenseBudgets.forEach(p=>{g[p.departmentId]=p.amount}),h(g)}R.success("ìì
íì¼ì´ ì±ê³µì ì¼ë¡ ì ì©ëììµëë¤")}catch(n){console.error("íì¼ íì± ì¤í¨:",n),R.error("íì¼ íìì´ ì¬ë°ë¥´ì§ ììµëë¤")}finally{m(!1),o.current&&(o.current.value="")}};$.useEffect(()=>{C()},[i]);const C=async()=>{try{A(!0);
1const s=W(P,"churches",i,"finance_settings","config"),a=await xe(s);if(a.exists()){const r=a.data();l({...r,carryoverAmount:r.carryoverAmount??0,bankAccounts:r.bankAccounts??[],departmentAccountants:r.departmentAccountants||{}}),r.isConfigured&&v("complete")}}catch(s){console.error("ì¤ì ë¡ë ì¤í¨:",s)}finally{A(!1)}},M=async()=>{try{I(!0);const s=W(P,"churches",i,"finance_settings","config");await te(s,{...t,isConfigured:!0,configuredAt:ae(),configuredBy:d==null?void 0:d.uid});const a={};S.forEach(r=>{r.budgetAmount>0&&(a[r.code]=r.budgetAmount)}),Object.keys(a).length>0&&(await ne.initializeIncomeBudgets(i,t.currentFiscalYear),await ne.updateBudgetAmounts(i,t.currentFiscalYear,a));for(const[r,n]of Object.entries(c))if(n>0){const g=W(P,"churches",i,"budgets",`${t.currentFiscalYear}_${r}`);await te(g,{fiscalYear:t.currentFiscalYear,departmentId:r,totalAmount:n,status:"approved",createdAt:ae(),createdBy:d==null?void 0:d.uid},{merge:!0})}R.success("ì¬ì ì¤ì ì´ ì ì¥ëììµëë¤"),y("/finance")}catch(s){console.error("ì¤ì ì ì¥ ì¤í¨:",s),R.error("ì¤ì ì ì¥ì ì¤í¨íìµëë¤")}finally{I(!1)}},O=()=>{const s=w.findIndex(a=>a.id===x);s<w.length-1&&v(w[s+1].id)},H=()=>{const s=w.findIndex(a=>a.id===x);s>0&&v(w[s-1].id)},k=w.findIndex(s=>s.id===x);return u?e.jsx("div",{className:"p-6 flex items-center justify-center min-h-[400px]",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):e.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"ì¬ì ê´ë¦¬ ì¤ì "}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"ì¬ì ê´ë¦¬ë¥¼ ììí기 ì ì 기본 ì¤ì ì ìë£í´ì£¼ì¸ì"})]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("div",{className:"flex items-center justify-center gap-1",children:w.map((s,a)=>e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-medium ${a<k?"bg-green-500 text-white":a===k?"bg-blue-600 text-white":"bg-gray-200 text-gray-500"}`,children:a<k?e.jsx(F,{className:"w-4 h-4"}):a+1}),a<w.length-1&&e.jsx("div",{className:`w-6 h-0.5 ${a<k?"bg-green-500":"bg-gray-200"}`})]},s.id))}),e.jsxs("div",{className:"text-center mt-3",children:[e.jsxs("p",{className:"text-sm font-medium text-blue-600",children:[k+1,"/",w.length," - ",(_=w[k])==null?void 0:_.title]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:(E=w[k])==null?void 0:E.description})]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-100 p-6 min-h-[400px]",children:[x==="mode"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"íê³ ë°©ìì ì ííì¸ì"}),e.jsx("p",{className:"text-sm text-gray-500",children:"êµí ê·ëª¨ì íìì ë°ë¼ ì í©í ë°©ìì ì ííì¸ì"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{onClick:()=>l({...t,accountingMode:"simple"}),className:`p-6 rounded-lg border-2 cursor-pointer transition-all ${t.accountingMode==="simple"?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center",children:e.jsx(he,{className:"w-6 h-6 text-green-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900",children:"ê°í¸ íê³"}),e.jsx("p",{className:"text-xs text-gray-500",children:"ë¨ìë¶ê¸°"})]})]}),e.jsxs("ul",{className:"space-y-2 text-sm text-gray-600",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4 text-green-500"}),"ê°ë¨í ìì
/ì§ì¶ ê´ë¦¬"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4 text-green-500"}),"ì¬ì©í기 ì¬ì"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4 text-green-500"}),"ìê·ëª¨ êµíì ì í©"]})]}),e.jsx("div",{className:"mt-4 px-3 py-2 bg-green-100 rounded text-sm text-green-700",children:"ê¶ì¥
1: ëë¶ë¶ì êµí"})]}),e.jsxs("div",{onClick:()=>l({...t,accountingMode:"double"}),className:`p-6 rounded-lg border-2 cursor-pointer transition-all ${t.accountingMode==="double"?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center",children:e.jsx(ge,{className:"w-6 h-6 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-900",children:"ì 문 íê³"}),e.jsx("p",{className:"text-xs text-gray-500",children:"ë³µìë¶ê¸°"})]})]}),e.jsxs("ul",{className:"space-y-2 text-sm text-gray-600",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4 text-purple-500"}),"ì íí ì¬ë¬´ì í ìì±"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4 text-purple-500"}),"ê³ì 과목 ê¸°ë° ê´ë¦¬"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4 text-purple-500"}),"ëê·ëª¨ êµíì ì í©"]})]}),e.jsx("div",{className:"mt-4 px-3 py-2 bg-yellow-100 rounded text-sm text-yellow-700",children:"íê³ ì 문ì§ì íì"})]})]})]}),x==="fiscal"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"íê³ì°ë를 ì¤ì íì¸ì"}),e.jsx("p",{className:"text-sm text-gray-500",children:"íê³ì°ëì ìììì ì ííì¸ì. ëë¶ë¶ì êµíë 1ìì ì¬ì©í©ëë¤."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"íê³ì°ë ììì"}),e.jsx("select",{value:t.fiscalYearStart,onChange:s=>l({...t,fiscalYearStart:parseInt(s.target.value)}),className:"w-full px-3 py-2 border border-gray-200 rounded-lg",children:[1,2,3,4,5,6,7,8,9,10,11,12].map(s=>e.jsxs("option",{value:s,children:[s,"ì"]},s))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"íì¬ íê³ì°ë"}),e.jsx("select",{value:t.currentFiscalYear,onChange:s=>l({...t,currentFiscalYear:s.target.value}),className:"w-full px-3 py-2 border border-gray-200 rounded-lg",children:[2024,2025,2026].map(s=>e.jsxs("option",{value:s.toString(),children:[s,"ë
"]},s))})]})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(q,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-800",children:[e.jsx("p",{className:"font-medium",children:"íê³ì°ë ì¤ì ìë´"}),e.jsxs("p",{className:"mt-1",children:["íê³ì°ë ìììì´ ",t.fiscalYearStart,"ìì¸ ê²½ì°,"," ",t.currentFiscalYear,"ë
íê³ì°ëë"," ",t.currentFiscalYear,"ë
",t.fiscalYearStart,"ì 1ì¼ë¶í°"," ",t.fiscalYearStart===1?`${t.currentFiscalYear}ë
12ì 31ì¼`:`${parseInt(t.currentFiscalYear)+1}ë
${t.fiscalYearStart-1}ì ë§ì¼`,"ê¹ì§ì
ëë¤."]})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-green-50 border border-green-200 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx(pe,{className:"w-6 h-6 text-green-600"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-green-900",children:"ìì
ë¡ ìì° ì¤ì í기"}),e.jsx("p",{className:"text-xs text-green-700",children:"í
í릿ì ë¤ì´ë¡ëíì¬ ìì í ì
ë¡ëíë©´ í ë²ì ì¤ì í ì ììµëë¤"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:Y,className:"flex items-center gap-2 px-4 py-2 bg-white border border-green-300 text-green-700 rounded-lg hover:bg-green-100 text-sm",children:[e.jsx(be,{className:"w-4 h-4"}),"í
í릿 ë¤ì´ë¡ë"]}),e.jsxs("label",{className:"flex items-center gap-2 px-4 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 text-sm cursor-pointer",children:[e.jsx(je,{className:"w-4 h-4"}
1),U?"ì
ë¡ë ì¤...":"ìì
íì¼ ì
ë¡ë",e.jsx("input",{ref:o,type:"file",accept:".xlsx,.xls",onChange:N,disabled:U,className:"hidden"})]})]})]})]}),x==="carryover"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"ì 기ì´ìê¸ì ì
ë ¥íì¸ì"}),e.jsx("p",{className:"text-sm text-gray-500",children:"ì ë
ëìì ì´ìë ìì¡ì ì
ë ¥í©ëë¤. ì²ì ììíë ê²½ì° íì¬ ë³´ì ìì¡ì ì
ë ¥íì¸ì."})]}),e.jsxs("div",{className:"max-w-md",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"ì 기ì´ìê¸ (ì)"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:(t.carryoverAmount??0).toLocaleString(),onChange:s=>{const a=s.target.value.replace(/[^0-9]/g,"");l({...t,carryoverAmount:parseInt(a)||0})},className:"w-full px-3 py-3 border border-gray-200 rounded-lg text-right text-xl font-semibold",placeholder:"0"}),e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-500",children:"ì"})]}),e.jsxs("p",{className:"mt-2 text-sm text-gray-500",children:["= ",((t.carryoverAmount??0)/1e4).toLocaleString()," ë§ì"]})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(q,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-800",children:[e.jsx("p",{className:"font-medium",children:"ì 기ì´ìê¸ì´ë?"}),e.jsx("p",{className:"mt-1",children:'ì ë
ë íê³ì°ë ë§ì ë¨ì ìì¡ì¼ë¡, ì íê³ì°ëì ìì
첫 í목ì¼ë¡ 기ë¡ë©ëë¤. ì íí ê¸ì¡ì ì ë
ë ê²°ì°ìì "차기ì´ìê¸"ì ì°¸ê³ íì¸ì.'})]})]})]}),x==="income"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"ìì
ìì° í목ì ì¤ì íì¸ì"}),e.jsx("p",{className:"text-sm text-gray-500",children:"ì¬í´ ììëë ìì
ìì°ì í목ë³ë¡ ì
ë ¥í©ëë¤. ëì¤ì ìì í ì ììµëë¤."})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto space-y-2",children:S.filter(s=>s.isActive).map((s,a)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 border border-gray-100 rounded-lg hover:bg-gray-50",children:[e.jsx("div",{className:"w-16 text-xs text-gray-400",children:s.code}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm font-medium text-gray-900",children:s.name})}),e.jsx("div",{className:"w-40",children:e.jsx("input",{type:"text",value:s.budgetAmount.toLocaleString(),onChange:r=>{const n=r.target.value.replace(/[^0-9]/g,""),g=[...S];g[a]={...s,budgetAmount:parseInt(n)||0},B(g)},className:"w-full px-2 py-1 border border-gray-200 rounded text-right text-sm",placeholder:"0"})}),e.jsx("span",{className:"text-xs text-gray-500 w-6",children:"ì"})]},s.code))}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-50 rounded-lg",children:[e.jsx("span",{className:"font-medium text-gray-900",children:"ìì
ìì° í©ê³"}),e.jsxs("span",{className:"text-lg font-bold text-blue-600",children:[S.reduce((s,a)=>s+a.budgetAmount,0).toLocaleString(),"ì"]})]}),e.jsxs("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(z,{className:"w-5 h-5 text-yellow-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-yellow-800",children:'ìì
ìì°ì ëì¤ì "ìì
ìì° ê´ë¦¬" ë©ë´ìì ì¸ì ë ì§ ìì í ì ììµëë¤. ì§ê¸ì ëëµì ì¸ ê¸ì¡ë§ ì
ë ¥í´ë ë©ëë¤.'})]})]}),x==="expense"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"ì§ì¶ìì°ì íì¸íì¸ì"}),e.jsx("p",{className:"text-sm text-gray-500",children:"ë¶ìë³ ì§ì¶ìì°ì´ 기본ê°ì¼ë¡ ì¤ì ëì´ ììµëë¤. íìì ìì íì¸ì."})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto space-y-2",children:D.map(s=>e.jsxs("div",{className:"flex items-center gap-3 p-3 border border-gray-100 rounded-lg hover:bg-gray-50",children:[e.jsx("div",{className:"w-10 h-10 bg-gray-100 rounded flex items-center justify-center text-sm font-medium text-gray-600",children:s.code}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm font-medium text-gray-900",children:s.name})}),e.jsx("div",{className:"w-40",children:e.jsx("input",{type:"text",value:(c[s.id]||0).toLocaleStr
1ing(),onChange:a=>{const r=a.target.value.replace(/[^0-9]/g,"");h({...c,[s.id]:parseInt(r)||0})},className:"w-full px-2 py-1 border border-gray-200 rounded text-right text-sm",placeholder:"0"})}),e.jsx("span",{className:"text-xs text-gray-500 w-6",children:"ì"})]},s.id))}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-gray-50 rounded-lg",children:[e.jsx("span",{className:"font-medium text-gray-900",children:"ì§ì¶ìì° í©ê³"}),e.jsxs("span",{className:"text-lg font-bold text-red-600",children:[Object.values(c).reduce((s,a)=>s+a,0).toLocaleString(),"ì"]})]}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(q,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-blue-800",children:'ì¸ë¶ ìì° í목ì "ì§ì¶ìì° ê´ë¦¬" ë©ë´ìì ë¶ìë³ë¡ ìì¸íê² ì¤ì í ì ììµëë¤.'})]})]}),x==="bank"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"êµí ìíê³ì¢ë¥¼ ë±ë¡íì¸ì"}),e.jsx("p",{className:"text-sm text-gray-500",children:"íê¸ ì
ê¸ ë° ì§ì¶ì ì¬ì©íë ê³ì¢ë¥¼ ë±ë¡í©ëë¤. ëì¤ì ì¶ê°í ì ììµëë¤."})]}),e.jsx("div",{className:"space-y-3",children:(t.bankAccounts??[]).map((s,a)=>e.jsx("div",{className:"p-4 border border-gray-200 rounded-lg",children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"ìí"}),e.jsxs("select",{value:s.bankName,onChange:r=>{const n=[...t.bankAccounts];n[a]={...s,bankName:r.target.value},l({...t,bankAccounts:n})},className:"w-full px-2 py-1.5 border border-gray-200 rounded text-sm",children:[e.jsx("option",{value:"",children:"ì í"}),De.map(r=>e.jsx("option",{value:r,children:r},r))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"ê³ì¢ë²í¸"}),e.jsx("input",{type:"text",value:s.accountNumber,onChange:r=>{const n=[...t.bankAccounts];n[a]={...s,accountNumber:r.target.value},l({...t,bankAccounts:n})},className:"w-full px-2 py-1.5 border border-gray-200 rounded text-sm",placeholder:"ê³ì¢ë²í¸"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"ìê¸ì£¼"}),e.jsx("input",{type:"text",value:s.accountHolder,onChange:r=>{const n=[...t.bankAccounts];n[a]={...s,accountHolder:r.target.value},l({...t,bankAccounts:n})},className:"w-full px-2 py-1.5 border border-gray-200 rounded text-sm",placeholder:"ìê¸ì£¼"})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"ì©ë"}),e.jsx("select",{value:s.purpose,onChange:r=>{const n=[...t.bankAccounts];n[a]={...s,purpose:r.target.value},l({...t,bankAccounts:n})},className:"w-full px-2 py-1.5 border border-gray-200 rounded text-sm",children:Ie.map(r=>e.jsx("option",{value:r,children:r},r))})]}),e.jsx("button",{onClick:()=>{const r=t.bankAccounts.filter((n,g)=>g!==a);l({...t,bankAccounts:r})},className:"p-1.5 text-red-500 hover:bg-red-50 rounded",children:e.jsx(fe,{className:"w-4 h-4"})})]})]})},s.id))}),e.jsxs("button",{onClick:()=>{const s={id:`bank_${Date.now()}`,bankName:"",accountNumber:"",accountHolder:"",purpose:"ì¼ë°",isActive:!0};l({...t,bankAccounts:[...t.bankAccounts,s]})},className:"w-full py-3 border-2 border-dashed border-gray-300 rounded-lg text-gray-500 hover:border-blue-400 hover:text-blue-600 flex items-center justify-center gap-2",children:[e.jsx(Ne,{className:"w-4 h-4"}),"ê³ì¢ ì¶ê°"]}),(t.bankAccounts??[]).length===0&&e.jsxs("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(z,{className:"w-5 h-5 text-yellow-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-yellow-800",children:'ê³ì¢ ë±ë¡ì ì íì¬íì
ëë¤. ëì¤ì "ìíê³ì¢ ê´ë¦¬" ë©ë´ìì ë±ë¡í ì ììµëë¤.'})]})]}),x==="managers"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"ì¬ì ë´ë¹ì를 ì§ì íì¸ì"}),e.jsx("p",{className:"text-sm text-gray-500",children:"êµì ë¶ìì ë´ë¹ì를 ê²ìíì¬ ì§ì í©ëë¤"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 border border-gray-200 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 bg-red-100 rounded-lg flex items-center justify-center",children:e.jsx(ye,{className:"w-5 h-5 text-red-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-900",children:"본íê³ *"}),e.jsx("p",{className:"text-xs text-gray-500",children:"ìµì¢
ì¹ì¸ ê¶í, ì ì²´ ì¬ì ê´ë¦¬"})]})]}),e.jsx(T,{memberId:(G=t.mainAccountant)==null?void 0:G.uid,memberName:(K=t.mainAccountant)==null?void 0:K.name,onChange:s=>l({...t,mainAccountant:s?{uid:s.id,name:s.name}:void 0}),placeholder:"êµì¸ ì´ë¦ì¼ë¡ ê²ì..."})]}),e.jsxs("div",{className:"p-4 border border-gray-200 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 rounded-lg flex items-center justify-center",children:e.jsx(ve,{className:"w-5 h-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-900",children:"ë¶íê³ (ì í)"}),e.jsx("p",{className:"text-xs text-gray-500",children:"본íê³ ë³´ì¡°, ì
ë ¥ ë° ì¡°í ê¶í"})]})]}),e.jsx(T,{memberId:(Q=t.subAccountant)==null?void 0:Q.uid,memberName:(J=t.subAccountant)==null?void 0:J.name,onChange:s=>l({...t,subAccountant:s?{uid:s.id,name:s.name}:void 0}),placeholder:"êµì¸ ì´ë¦ì¼ë¡ ê²ì..."})]}),e.jsxs("div",{className:"p-4 border border-gray-200 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 bg-purple-100 rounded-lg flex items-center justify-center",children:e.jsx(we,{className:"w-5 h-5 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-gray-900",children:"ì¬ì ë¶ì¥ (ì í)"}),e.jsx("p",{className:"text-xs text-gray-500",children:"ì ì²´ ì¬ì ì ì±
ê´ë¦¬, ìì° í¸ì±"})]})]}),e.jsx(T,{memberId:(V=t.financeDirector)==null?void 0:V.uid,memberName:(X=t.financeDirector)==null?void 0:X.name,onChange:s=>l({...t,financeDirector:s?{uid:s.id,name:s.name}:void 0}),placeholder:"êµì¸ ì´ë¦ì¼ë¡ ê²ì..."})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-gray-50 rounded-lg",children:[e.jsx("h3",{className:"font-medium text-gray-900 mb-3",children:"ì¹ì¸ ì¤ì "}),e.jsx("div",{className:"space-y-3",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t.requireDeptHeadApproval??!0,onChange:s=>l({...t,requireDeptHeadApproval:s.target.checked}),className:"w-4 h-4 rounded"}),e.jsx("span",{className:"text-sm text-gray-700",children:"ìì° ì ì² ì ë¶ì¥ ì¹ì¸ íì"})]})})]})]}),x==="departments"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"ë¶ìë³ íê³ ë´ë¹ì (ì í)"}),e.jsx("p",{className:"text-sm text-gray-500",children:"ê° ë¶ìì ìì°ì ê´ë¦¬í ë´ë¹ì를 êµì ë¶ìì ê²ìíì¬ ì§ì í©ëë¤. ëì¤ì ì¤ì í ìë ììµëë¤."})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto space-y-3",children:(D||[]).slice(0,10).map(s=>{var a,r,n,g;return e.jsxs("div",{className:"flex items-center gap-3 p-3 border border-gray-200 rounded-lg",children:[e.jsx("div",{className:"w-10 h-10 bg-gray-100 rounded flex items-center justify-center text-sm font-medium text-gray-600",children:s.code}),e.jsx("div",{className:"w-28",children:e.jsx("p",{className:"text-sm font-medium text-gray-900",children:s.name})}),e.jsx("div",{className:"flex-1",children:e.jsx(T,{memberId:(r=(a=t.departmentAccountants)==null?void 0:a[s.id])==null?void 0:r.uid,memberName:(g=(n=t.departmentAccountants)==null?void 0:n[s.id])==null?void 0:g.name,onChange:p=>l({...t,departmentAccountants:{...t.departmentAccountants||{},[s.id]:p?{uid:p.id,name:p.name}:void 0}}),placeholder:"ë´ë¹ì ê²ì..."})})]},s.id)})}),e.jsxs("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(z,{className:"w-5 h-5 text-yellow-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-yellow-800",children:"ë¶ì íê³ ë´ë¹ìë ì¤ì íìë ë³ê²½í ì ììµëë¤. ì§ê¸ ë¹ìëì
ë ë©ëë¤."})]})]}),x==="complete"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(F,{className:"w-8 h-8 text-green-600"})}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900 mb-2",children:"ì¤ì íì¸"}),e.jsx("p",{className:"text-sm text-gray-500",children:"ìë ë´ì©ì íì¸íê³ ì ì¥íì¸ì"})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 space-y-3",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"íê³ ë°©ì"}),e.jsx("span",{className:"text-sm font-medium",children:t.accountingMode==="simple"?"ê°í¸ íê³ (ë¨ìë¶ê¸°)":"ì 문 íê³ (ë³µìë¶ê¸°)"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"íê³ì°ë"}),e.jsxs("span",{className:"text-sm font-medium",children:[t.currentFiscalYear,"ë
(",t.fiscalYearStart,"ì ìì)"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"ì 기ì´ìê¸"}),e.jsxs("span",{className:"text-sm font-medium",children:[(t.carryoverAmount??0).toLocaleStr
1ing(),"ì"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"ìì
ìì° í©ê³"}),e.jsxs("span",{className:"text-sm font-medium text-blue-600",children:[S.reduce((s,a)=>s+a.budgetAmount,0).toLocaleString(),"ì"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"ì§ì¶ìì° í©ê³"}),e.jsxs("span",{className:"text-sm font-medium text-red-600",children:[Object.values(c).reduce((s,a)=>s+a,0).toLocaleString(),"ì"]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"ë±ë¡ ê³ì¢"}),e.jsxs("span",{className:"text-sm font-medium",children:[(t.bankAccounts??[]).length,"ê°"]})]}),e.jsx("hr",{className:"border-gray-200"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"본íê³"}),e.jsx("span",{className:"text-sm font-medium",children:((Z=t.mainAccountant)==null?void 0:Z.name)||"미ì§ì "})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"ë¶íê³"}),e.jsx("span",{className:"text-sm font-medium",children:((ee=t.subAccountant)==null?void 0:ee.name)||"미ì§ì "})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"ì¬ì ë¶ì¥"}),e.jsx("span",{className:"text-sm font-medium",children:((se=t.financeDirector)==null?void 0:se.name)||"미ì§ì "})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"ë¶ì¥ ì¹ì¸ íì"}),e.jsx("span",{className:"text-sm font-medium",children:t.requireDeptHeadApproval?"ì":"ìëì¤"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"ë¶ìë³ ë´ë¹ì"}),e.jsxs("span",{className:"text-sm font-medium",children:[Object.values(t.departmentAccountants||{}).filter(Boolean).length,"ê° ë¶ì ì§ì "]})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between mt-6",children:[e.jsxs("button",{onClick:H,disabled:k===0,className:"flex items-center gap-2 px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(Ae,{className:"w-4 h-4"}),"ì´ì "]}),x==="complete"?e.jsx("button",{onClick:M,disabled:f,className:"flex items-center gap-2 px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50",children:f?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white"}),"ì ì¥ ì¤..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"w-4 h-4"}),"ì¤ì ì ì¥"]})}):e.jsxs("button",{onClick:O,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700",children:["ë¤ì",e.jsx(ke,{className:"w-4 h-4"})]})]})]})}export{Te as FinanceSetupPage};
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.