PageSourceSearch

https://seodoon-church-admin.web.app/assets/FinanceSetupPage-DzfB3jkA.js

js seodoon-church-admin.web.app collected 2026-10-03 12:37:29 UTC 34,893 bytes, 1 lines download raw bytes

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.