1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7623],{40327:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/accounting/expenses",function(){return a(12122)}])},12122:function(e,t,a){"use strict";a.r(t);var l=a(85893),s=a(41664),r=a.n(s),n=a(67294),i=a(91444),c=a(90723),d=a(2881),o=a(16053),u=a(67827),x=a(21168);let m="bg-white text-slate-900 placeholder:text-slate-400 border border-slate-300 rounded-xl px-3 py-2 text-sm",p={category:"",company:"",method:"",payment_status:"",status:"",q:"",from:"",to:"",min_amount:"",max_amount:""};function h(){let{can:e,site:t}=(0,c.uu)(),[a,s]=(0,n.useState)([]),[h,b]=(0,n.useState)([]),[j,g]=(0,n.useState)(p),[v,y]=(0,n.useState)({}),[f,N]=(0,n.useState)(1),[_,k]=(0,n.useState)([]),[w,C]=(0,n.useState)(0),[S,O]=(0,n.useState)(null),[A,E]=(0,n.useState)(""),[q,M]=(0,n.useState)({doc_date:t.today_jalali,title:"",category:"",amount:"",payer:"",method:"bank",company:t.brand,payment_status:"paid",description:""}),[V,P]=(0,n.useState)({}),[Z,z]=(0,n.useState)(!1),[Y,D]=(0,n.useState)(null),[J,F]=(0,n.useState)(null),[R,X]=(0,n.useState)(null),[G,I]=(0,n.useState)(""),T=(0,n.useRef)(null),$=e("manage_expenses"),B=(0,n.useCallback)(async()=>{let e=await (0,o.Og)({...v,page:f,page_size:50});e.ok?(k(e.data.results),C(e.data.count),O(e.data.totals),b(e.data.allowed_companies||[]),E("")):(k([]),E(e.error.detail))},[v,f]);(0,n.useEffect)(()=>{B()},[B]),(0,n.useEffect)(()=>{(0,o.If)().then(e=>{e.ok&&s(e.data)})},[]);let Q=async e=>{let t=await (0,o.f4)(e);t.ok&&D(t.data)},W=async()=>{let e=(0,x.NR)(q);if(!e.ok){P(e.errors);return}P({}),z(!0);let t=await (0,o._Q)(e.body);if(z(!1),t.ok){i.Am.success("ÙØ²ÛÙÙÙ ".concat(t.data.display_number," ثبت شد.")),M({...q,title:"",amount:"",description:""}),B(),D(t.data);return}i.Am.error(t.error.detail)},H=async()=>{if(!Y||!J)return;let e=(0,x.Y0)(J);if(!e.ok){P(e.errors);return}P({}),z(!0);let t=await (0,o.So)(Y.id,e.body);z(!1),t.ok?(i.Am.success("Ø³ÙØ¯ بÙâØ±ÙØ² شد."),D(t.data),F(null),B()):i.Am.error(t.error.detail)},K=async e=>{if(!Y||!e)return;let t=(0,x.ai)(e);if(t){i.Am.error(t);return}z(!0);let a=await (0,o.tJ)(Y.id,e);z(!1),T.current&&(T.current.value=""),a.ok?(i.Am.success("Ù¾ÛÙØ³Øª ثبت شد."),Q(Y.id),B()):i.Am.error(a.error.detail)},L=async e=>{if(!Y)return;z(!0);let t=await (0,o.C6)(Y.id,e);z(!1),t.ok?(i.Am.success("Ù¾ÛÙØ³Øª ØØ°Ù شد (ÙØ§ÛÙ Ø¨Ø±Ø§Û Ø³Ø§Ø¨ÙÙ Ùگ٠داشت٠Ù
ÛâØ´ÙØ¯)."),Q(Y.id),B()):i.Am.error(t.error.detail)},U=async()=>{if(!R)return;z(!0);let e=await (0,o.yw)(R.id,G);z(!1),e.ok?(i.Am.success("Ø³ÙØ¯ ".concat(R.display_number," ابطا٠شد.")),X(null),I(""),(null==Y?void 0:Y.id)===R.id&&D(e.data),B()):i.Am.error(e.error.detail)},ee=e=>{e.preventDefault();let t=(0,x.Mz)(j);if(!t.ok){i.Am.error(t.error);return}N(1),y(t.params)},et=Math.max(1,Math.ceil(w/50)),ea=h.length?h:[{value:t.brand,label:x.Zq[t.brand]||t.brand_label}];return(0,l.jsxs)(c.D2,{title:"ÙØ²ÛÙÙâÙØ§",subtitle:"ثبت Ø±ÛØ² Ù Ø±ÙØ²Ø§ÙÙÙ ÙØ²ÛÙÙâÙØ§ با Ù¾ÛÙØ³Øª Ù
Ø³ØªÙØ¯Ø§ØªØ ØªØ§Ø±ÛØ®Ø Ù
Ø¨ÙØºØ دست٠٠شرکت Ø³ÙØ¯ پس از ثبت تغÛÛØ± ÙÙ
ÛâÚ©ÙÙØ¯",actions:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(r(),{href:"/admin/accounting/reports/expenses",className:"px-4 py-2 rounded-xl border border-slate-300 text-sm",children:"گزارش تÙÚ©ÛÚ©Û"}),(0,l.jsx)(r(),{href:"/admin/accounting/expense-categories",className:"px-4 py-2 rounded-xl border border-slate-300 text-sm",children:"دستÙâØ¨ÙØ¯ÛâÙØ§"})]}),children:[$&&(0,l.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-4 space-y-3","data-testid":"expense-form",children:[(0,l.jsx)("h2",{className:"font-bold",children:"ثبت ÙØ²ÛÙÙÙ Ø¬Ø¯ÛØ¯"}),(0,l.jsxs)("div",{className:"grid gap-2 md:grid-cols-4",children:[(0,l.jsx)("input",{className:m,value:q.title,placeholder:"عÙÙØ§Ù ÙØ²ÛÙÙ","aria-label":"عÙÙØ§Ù ÙØ²ÛÙÙ",onChange:e=>M({...q,title:e.target.value})}),(0,l.jsxs)("select",{className:m,value:q.category,"aria-label":"دستÙâØ¨ÙØ¯Û",onChange:e=>M({...q,category:e.target.value}),children:[(0,l.jsx)("option",{value:"",children:"دستÙâØ¨ÙØ¯Û ÙØ²ÛÙÙ"}),a.filter(e=>e.is_active).map(e=>(0,l.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,l.jsx)("input",{className:m,value:q.amount,inputMode:"numeric",placeholder:"Ù
Ø¨ÙØº (تÙÙ
اÙ)","aria-label":"Ù
Ø¨ÙØº",onChange:e=>M({...q,amount:e.target.value})}),(0,l.jsx)("input",{className:m,value:q.doc_date,placeholder:"ØªØ§Ø±ÛØ® Û±Û´Û°Ûµ/Û°Û¶/Û²Ûµ","aria-label":"ØªØ§Ø±ÛØ® ÙØ²ÛÙÙ",onChange:e=>M({...q,doc_date:e.target.value})}),(0,l.jsx)("input",{className:m,value:q.payer,placeholder:"پرداختâÚ©ÙÙØ¯Ù","aria-label":"پرداختâÚ©ÙÙØ¯Ù",onChange:e=>M({...q,payer:e.target.value})}),(0,l.jsx)("select",{className:m,value:q.method,"aria-label":"Ø±ÙØ´ پرداخت",onChange:e=>M({...q,method:e.target.value}),children:Object.entries(x.Jg).map(e=>
1{let[t,a]=e;return(0,l.jsx)("option",{value:t,children:a},t)})}),(0,l.jsx)("select",{className:m,value:q.payment_status,"aria-label":"ÙØ¶Ø¹Ûت پرداخت",onChange:e=>M({...q,payment_status:e.target.value}),children:Object.entries(x.tV).map(e=>{let[t,a]=e;return(0,l.jsx)("option",{value:t,children:a},t)})}),(0,l.jsx)("select",{className:m,value:q.company,"aria-label":"شرکت Ù
رتبط",onChange:e=>M({...q,company:e.target.value}),children:ea.map(e=>(0,l.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,l.jsx)("input",{className:"".concat(m," md:col-span-4"),value:q.description,placeholder:"Ø´Ø±Ø Ù ØªÙØ¶ÛØØ§Øª (Ø§Ø®ØªÛØ§Ø±Û)","aria-label":"ØªÙØ¶ÛØØ§Øª",onChange:e=>M({...q,description:e.target.value})})]}),Object.entries(V).map(e=>{let[t,a]=e;return(0,l.jsx)("div",{className:"text-xs text-rose-700",role:"alert",children:a},t)}),(0,l.jsx)("button",{className:"px-4 py-2 rounded-xl bg-slate-900 text-white text-sm disabled:opacity-50",disabled:Z,onClick:W,children:"ثبت ÙØ²ÛÙÙ"})]}),(0,l.jsxs)("form",{onSubmit:ee,className:"bg-white rounded-2xl border border-slate-200 p-4 grid gap-2 md:grid-cols-5",children:[(0,l.jsxs)("select",{className:m,value:j.category,"aria-label":"ÙÛÙØªØ± دستÙ",onChange:e=>g({...j,category:e.target.value}),children:[(0,l.jsx)("option",{value:"",children:"ÙÙ
Ù٠دستÙâÙØ§"}),a.map(e=>(0,l.jsx)("option",{value:e.id,children:e.name},e.id))]}),(0,l.jsxs)("select",{className:m,value:j.company,"aria-label":"ÙÛÙØªØ± شرکت",onChange:e=>g({...j,company:e.target.value}),children:[(0,l.jsx)("option",{value:"",children:"ÙÙ
Ù٠شرکتâÙØ§"}),Object.entries(x.Zq).map(e=>{let[t,a]=e;return(0,l.jsx)("option",{value:t,children:a},t)})]}),(0,l.jsxs)("select",{className:m,value:j.method,"aria-label":"ÙÛÙØªØ± Ø±ÙØ´",onChange:e=>g({...j,method:e.target.value}),children:[(0,l.jsx)("option",{value:"",children:"ÙÙ
ÙÙ Ø±ÙØ´âÙØ§"}),Object.entries(x.Jg).map(e=>{let[t,a]=e;return(0,l.jsx)("option",{value:t,children:a},t)})]}),(0,l.jsxs)("select",{className:m,value:j.payment_status,"aria-label":"ÙÛÙØªØ± ÙØ¶Ø¹Ûت پرداخت",onChange:e=>g({...j,payment_status:e.target.value}),children:[(0,l.jsx)("option",{value:"",children:"Ù¾Ø±Ø¯Ø§Ø®ØªâØ´Ø¯Ù Ù ÙØ´Ø¯Ù"}),Object.entries(x.tV).map(e=>{let[t,a]=e;return(0,l.jsx)("option",{value:t,children:a},t)})]}),(0,l.jsxs)("select",{className:m,value:j.status,"aria-label":"ÙÛÙØªØ± ÙØ¶Ø¹Ûت Ø³ÙØ¯",onChange:e=>g({...j,status:e.target.value}),children:[(0,l.jsx)("option",{value:"",children:"Ø§Ø³ÙØ§Ø¯ Ø«Ø¨ØªâØ´Ø¯Ù"}),(0,l.jsx)("option",{value:"active",children:"ÙÙØ· Ø«Ø¨ØªâØ´Ø¯Ù"}),(0,l.jsx)("option",{value:"cancelled",children:"ÙÙØ· ابطاÙâØ´Ø¯Ù"})]}),(0,l.jsx)("input",{className:m,value:j.from,placeholder:"از ØªØ§Ø±ÛØ®","aria-label":"از ØªØ§Ø±ÛØ®",onChange:e=>g({...j,from:e.target.value})}),(0,l.jsx)("input",{className:m,value:j.to,placeholder:"تا ØªØ§Ø±ÛØ®","aria-label":"تا ØªØ§Ø±ÛØ®",onChange:e=>g({...j,to:e.target.value})}),(0,l.jsx)("input",{className:m,value:j.min_amount,inputMode:"numeric",placeholder:"از Ù
Ø¨ÙØº","aria-label":"از Ù
Ø¨ÙØº",onChange:e=>g({...j,min_amount:e.target.value})}),(0,l.jsx)("input",{className:m,value:j.max_amount,inputMode:"numeric",placeholder:"تا Ù
Ø¨ÙØº","aria-label":"تا Ù
Ø¨ÙØº",onChange:e=>g({...j,max_amount:e.target.value})}),(0,l.jsx)("input",{className:m,value:j.q,placeholder:"جستج٠در عÙÙØ§ÙØ Ø´Ø±ØØ پرداختâÚ©ÙÙØ¯Ù ÛØ§ Ø´Ù
ارÙÙ Ø³ÙØ¯","aria-label":"جستجÙ",onChange:e=>g({...j,q:e.target.value})}),(0,l.jsx)("button",{type:"submit",className:"px-4 py-2 rounded-xl bg-slate-900 text-white text-sm",children:"اعÙ
ا٠ÙÛÙØªØ±"})]}),A&&(0,l.jsx)(c.qX,{tone:"error",children:A}),S&&(0,l.jsxs)("div",{className:"text-sm text-slate-700","data-testid":"expense-totals",children:[(0,u.YS)(S.count)," Ø³ÙØ¯ \xb7 جÙ
ع: ",(0,l.jsx)("b",{children:(0,u.dw)(S.total)})," تÙÙ
اÙ",S.unpaid>0&&(0,l.jsxs)(l.Fragment,{children:[" \xb7 پرداختâÙØ´Ø¯Ù: ",(0,l.jsx)("b",{className:"text-rose-700",children:(0,u.dw)(S.unpaid)})," تÙÙ
اÙ"]})]}),(0,l.jsx)("div",{className:"bg-white rounded-2xl border border-slate-200 overflow-x-auto",children:(0,l.jsxs)("table",{className:"w-full text-sm",children:[(0,l.jsx)("thead",{className:"bg-slate-50 text-slate-600",children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{className:"p-3 text-right",children:"Ø³ÙØ¯"}),(0,l.jsx)("th",{className:"p-3 text-right",children:"عÙÙØ§Ù"}),(0,l.jsx)("th",{className:"p-3 text-right",children:"دستÙ"}),(0,l.jsx)("th",{className:"p-3",children:"Ù
Ø¨ÙØº (تÙÙ
اÙ)"}),(0,l.jsx)("th",{className:"p-3",children:"ØªØ§Ø±ÛØ®"}),(0,l.jsx)("th",{className:"p-3",children:"شرکت"}),(0,l.jsx)("th",{className:"p-3",children:"پرداخت"}),(0,l.jsx)("th",{className:"p-3"})]})}),(0,l.jsxs)("tbody",{children:[_.map(e=>(0,l.jsxs)("tr",{className:"border-t border-slate-100","data-testid":"expense-".concat(e.id),children:[(0,l.jsxs)("td",{className:"p-3",children:[(0,l.jsx)("span",{dir:"ltr",className:"whitespace-nowrap",children:e.display_number}),"cancelled"===e.status&&(0,l.jsx)("div",{className:"text-[11px] text-rose-700",children:"ابطاÙâØ´Ø¯Ù"})]}),(0,l.jsxs)("td",{className:"p-3",children:[(0,l.jsx)("button",{className:"text-sky-800 hover:underline",onClick:()=>{D(e),F(null),Q(e.id)},children:e.title}),(0,l.jsx)("div",{className:"text-xs text-slate-500",children:e.payer})]}),(0,l.jsx)("td",{className:"p-3",children:e.category.name}),(0,l.jsx)("td",{className:"p-3 text-center font-bold",children:(0,u.dw)(e.amount)}),(0,l.jsx)("td",{className:"p-3 text-center",children:(0,u.YS)(e.doc_date_jalali)}),(0,l.jsx)("td",{className:"p-3 text-center",children:e.company_label}),(0,l.jsxs)("td",{className:"p-3 text-center",children:[(0,l.jsx)("span",{className:"unpaid"===e.payment_status?"text-rose-700":"",children:e.payment_status_label}),(0,l.jsx)("div",{className:"text-xs text-slate-500",children:e.method_label})]}),(0,l.jsxs)("td",{className:"p-3 text-center whitespace-nowrap",children:[e.attachment_count>0&&(0,l.jsxs)("span",{className:"text-xs text-slate-500",children:["\uD83D\uDCCE ",(0,u.YS)(e.attachment_count)]}),"active"===e.status&&(0,l.jsx)(d.Z,{compact:!0,kind:"expense",id:e.id,displayNumber:e.display_number,onSaved:B,fields:[{key:"doc_date",label:"ØªØ§Ø±ÛØ®",type:"date",value:e.doc_date_jalali},{key:"amount",label:"Ù
Ø¨ÙØº (تÙÙ
اÙ)",type:"amount",value:e.amount},{key:"category",label:"دستÙ",type:"select",value:String(e.category.id),numeric:!0,options:a.filter(t=>t.is_active||t.id===e.category.id).map(e=>[String(e.id),e.name])},{key:"company",label:"شرکت",type:"select",value:e.company,options:ea.map(e=>[e.value,e.label])},{key:"title",label:"عÙÙØ§Ù",type:"text",value:e.title},{key:"payer",label:"پرداختâÚ©ÙÙØ¯Ù",type:"text",value:e.payer},{key:"method",label:"Ø±ÙØ´ پرداخت",type:"select",value:e.method,options:Object.entries(x.Jg)},{key:"payment_status",label:"ÙØ¶Ø¹Ûت پرداخت",type:"select",value:e.payment_status,options:Object.entries(x.tV)},{key:"description",label:"ØªÙØ¶ÛØØ§Øª",type:"text",value:e.description}]}),$&&"active"===e.status&&(0,l.jsx)("button",{className:"text-xs text-rose-700 mr-2",onClick:()=>{X(e),I("")},children:"ابطاÙ"})]})]},e.id)),0===_.length&&!A&&(0,l.jsx)("tr",{children:(0,l.jsx)("td",{colSpan:8,className:"p-6 text-center text-slate-500",children:"ÙØ²ÛÙÙâØ§Û ÛØ§Ùت ÙØ´Ø¯."})})]})]})}),et>1&&(0,l.jsxs)("div",{className:"flex items-center justify-center gap-3 text-sm",children:[(0,l.jsx)("button",{className:"px-3 py-1 rounded-lg border border-slate-300 disabled:opacity-40",disabled:f<=1,onClick:()=>N(f-1),children:"ÙØ¨ÙÛ"}),(0,l.jsxs)("span",{children:["ØµÙØÙÙ ",(0,u.YS)(f)," از ",(0,u.YS)(et)]}),(0,l.jsx)("button",{className:"px-3 py-1 rounded-lg border border-slate-300 disabled:opacity-40",disabled:f>=et,onClick:()=>N(f+1),children:"بعدÛ"})]}),Y&&(0,l.jsx)("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 bg-black/40 flex items-center justify-center z-50 p-4",children:(0,l.jsxs)("div",{className:"bg-white rounded-2xl p-6 w-full max-w-2xl space-y-3 max-h-[90vh] overflow-y-auto",dir:"rtl",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h2",{className:"font-bold text-lg",children:Y.title}),(0,l.jsx)("div",{className:"text-xs text-slate-500",dir:"ltr",children:Y.display_number})]}),(0,l.jsx)("button",{className:"text-sm text-slate-500",onClick:()=>{D(null),F(null)},children:"بستÙ"})]}),"cancelled"===Y.status&&(0,l.jsxs)(c.qX,{tone:"warn",children:["اÛÙ Ø³ÙØ¯ ابطا٠شد٠است: ",Y.cancel_reason]}),(0,l.jsxs)("dl",{className:"grid grid-cols-2 gap-2 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("dt",{className:"text-xs text-slate-500",children:"Ù
Ø¨ÙØº"}),(0,l.jsxs)("dd",{className:"font-bold",children:[(0,u.dw)(Y.amount)," تÙÙ
اÙ"]})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("dt",{className:"text-xs text-slate-500",children:"ØªØ§Ø±ÛØ®"}),(0,l.jsx)("dd",{children:(0,u.YS)(Y.doc_date_jalali)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("dt",{className:"text-xs text-slate-500",children:"دستÙ"}),(0,l.jsx)("dd",{children:Y.category.name})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("dt",{className:"text-xs text-slate-500",children:"شرکت"}),(0,l.jsx)("dd",{children:Y.company_label})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("dt",{className:"text-xs text-slate-500",children:"ثبتâÚ©ÙÙØ¯Ù"}),(0,l.jsx)("dd",{children:Y.created_by})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("dt",{className:"text-xs text-slate-500",children:"ÙØ¶Ø¹Ûت پرداخت"}),(0,l.jsxs)("dd",{children:[Y.payment_status_label," (",Y.method_label,")"]})]})]}),J?(0,l.jsxs)("div",{className:"space-y-2 border-t border-slate-100 pt-3",children:[(0,l.jsxs)("div",{className:"grid gap-2 md:grid-cols-2",children:[(0,l.jsx)("input",{className:m,value:J.title,"aria-label":"ÙÛØ±Ø§ÛØ´ عÙÙØ§Ù",onChange:e=>F({...J,title:e.target.value})}),(0,l.jsx)("input",{className:m,value:J.payer,"aria-label":"ÙÛØ±Ø§ÛØ´ پرداختâÚ©ÙÙØ¯Ù",onChange:e=>F({...J,payer:e.target.value})}),(0,l.jsx)("select",{className:m,value:J.method,"aria-label":"ÙÛØ±Ø§ÛØ´ Ø±ÙØ´ پرداخت",onChange:e=>F({...J,method:e.target.value}),children:Object.entries(x.Jg).map(e=>
1{let[t,a]=e;return(0,l.jsx)("option",{value:t,children:a},t)})}),(0,l.jsx)("select",{className:m,value:J.payment_status,"aria-label":"ÙÛØ±Ø§ÛØ´ ÙØ¶Ø¹Ûت پرداخت",onChange:e=>F({...J,payment_status:e.target.value}),children:Object.entries(x.tV).map(e=>{let[t,a]=e;return(0,l.jsx)("option",{value:t,children:a},t)})}),(0,l.jsx)("textarea",{className:"".concat(m," md:col-span-2"),rows:2,value:J.description,"aria-label":"ÙÛØ±Ø§ÛØ´ ØªÙØ¶ÛØØ§Øª",onChange:e=>F({...J,description:e.target.value})})]}),(0,l.jsx)("p",{className:"text-xs text-slate-500",children:"ØªØ§Ø±ÛØ®Ø Ù
Ø¨ÙØºØ دست٠٠شرکت تغÛÛØ± ÙÙ
ÛâÚ©ÙÙØ¯Ø Ø¨Ø±Ø§Û Ø§ØµÙØ§Ø Ø¢ÙâÙØ§ Ø³ÙØ¯ را Ø§Ø¨Ø·Ø§Ù Ù Ø¯ÙØ¨Ø§Ø±Ù ثبت Ú©ÙÛØ¯."}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)("button",{className:"px-4 py-2 rounded-xl bg-slate-900 text-white text-sm disabled:opacity-50",disabled:Z,onClick:H,children:"Ø°Ø®ÛØ±Ù"}),(0,l.jsx)("button",{className:"px-4 py-2 rounded-xl border border-slate-300 text-sm",onClick:()=>F(null),children:"Ø§ÙØµØ±Ø§Ù"})]})]}):(0,l.jsxs)(l.Fragment,{children:[Y.description&&(0,l.jsx)("p",{className:"text-sm text-slate-700",children:Y.description}),$&&"active"===Y.status&&(0,l.jsx)("button",{className:"text-sm text-sky-800",onClick:()=>F({title:Y.title,payer:Y.payer,method:Y.method,payment_status:Y.payment_status,description:Y.description}),children:"ÙÛØ±Ø§ÛØ´ عÙÙØ§ÙØ Ù¾Ø±Ø¯Ø§Ø®ØªâÚ©ÙÙØ¯ÙØ Ø±ÙØ´ Ù ÙØ¶Ø¹Ûت"})]}),(0,l.jsxs)("div",{className:"border-t border-slate-100 pt-3 space-y-2",children:[(0,l.jsx)("h3",{className:"font-bold text-sm",children:"Ù
Ø³ØªÙØ¯Ø§Øª"}),(0,l.jsxs)("ul",{className:"text-sm space-y-1",children:[(Y.attachments||[]).map(e=>(0,l.jsxs)("li",{className:"flex items-center justify-between gap-2",children:[e.url?(0,l.jsx)("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"text-sky-800 hover:underline",children:e.name}):(0,l.jsx)("span",{children:e.name}),(0,l.jsxs)("span",{className:"text-xs text-slate-500",children:[(0,u.YS)(Math.max(1,Math.round(e.size/1024)))," Ú©ÛÙÙØ¨Ø§Ûت"]}),$&&"active"===Y.status&&(0,l.jsx)("button",{className:"text-xs text-rose-700",disabled:Z,onClick:()=>L(e.id),children:"ØØ°Ù"})]},e.id)),0===(Y.attachments||[]).length&&(0,l.jsx)("li",{className:"text-slate-500",children:"Ù¾ÛÙØ³ØªÛ ثبت ÙØ´Ø¯Ù است."})]}),$&&"active"===Y.status&&(0,l.jsx)("input",{ref:T,type:"file","aria-label":"Ø§ÙØ²Ùد٠پÛÙØ³Øª",className:"text-sm",accept:"image/jpeg,image/png,image/webp,application/pdf",onChange:e=>{var t;return K(null===(t=e.target.files)||void 0===t?void 0:t[0])}})]})]})}),R&&(0,l.jsx)("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 bg-black/40 flex items-center justify-center z-50 p-4",children:(0,l.jsxs)("div",{className:"bg-white rounded-2xl p-6 w-full max-w-lg space-y-3",dir:"rtl",children:[(0,l.jsxs)("h2",{className:"font-bold text-lg",children:["Ø§Ø¨Ø·Ø§Ù Ø³ÙØ¯ ",R.display_number]}),(0,l.jsx)("p",{className:"text-sm text-slate-700",children:"Ø³ÙØ¯ ØØ°Ù ÙÙ
ÛâØ´ÙØ¯ Ù Ø´Ù
ارÙÙ Ø®ÙØ¯ را ÙÚ¯Ù Ù
ÛâØ¯Ø§Ø±Ø¯Ø ÙÙØ· از گزارشâÙØ§ Ú©ÙØ§Ø± گذاشت٠Ù
ÛâØ´ÙØ¯."}),(0,l.jsx)("textarea",{className:"".concat(m," w-full"),rows:2,value:G,"aria-label":"دÙÛ٠ابطاÙ",placeholder:"دÙÛ٠ابطا٠(Ø§ÙØ²Ø§Ù
Û)",onChange:e=>I(e.target.value)}),(0,l.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,l.jsx)("button",{className:"px-4 py-2 rounded-xl border border-slate-300 text-sm",disabled:Z,onClick:()=>X(null),children:"Ø§ÙØµØ±Ø§Ù"}),(0,l.jsx)("button",{className:"px-4 py-2 rounded-xl bg-rose-700 text-white text-sm disabled:opacity-50",disabled:Z,onClick:U,children:"Ø§Ø¨Ø·Ø§Ù Ø³ÙØ¯"})]})]})})]})}let b=()=>(0,l.jsx)(c.ZP,{require:["view_expenses"],children:(0,l.jsx)(h,{})});b.layout="accounting",t.default=b},90723:function(e,t,a){"use strict";a.d(t,{D2:function(){return o},ZP:function(){return x},qX:function(){return u},uu:function(){return d}});var l=a(85893),s=a(67294),r=a(41664),n=a.n(r),i=a(16053);let c=(0,s.createContext)(null);function d(){let e=(0,s.useContext)(c);if(!e)throw Error("useAccounting must be used inside <AccountingGate>");return e}function o(e){let{title:t,subtitle:a,actions:s,children:r}=e;return(0,l.jsxs)("div",{dir:"rtl",className:"space-y-6 [color-scheme:light]",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)("h1",{className:"text-2xl font-bold text-slate-900",children:t}),a&&(0,l.jsx)("p",{className:"text-sm text-slate-500 mt-1",children:a})]}),s&&(0,l.jsx)("div",{className:"flex flex-wrap gap-2",children:s})]}),r]})}function u(e){let{tone:t="info",children:a}=e;return(0,l.jsx)("div",{className:"border rounded-xl px-4 py-3 text-sm ".concat({info:"bg-sky-50 border-sky-200 text-sky-900",warn:"bg-amber-50 border-amber-200 text-amber-900",error:"bg-rose-50 border-rose-200 text-rose-900"}[t]),children:a})}function x(e){let{require:t=[],requireAny:a=[],children:r}
1=e,[d,o]=(0,s.useState)({phase:"loading"}),x=(0,s.useCallback)(async()=>{let[e,t]=await Promise.all([(0,i.Mg)(),(0,i.Mf)()]);if(!e.ok){o({phase:"error",message:e.error.detail,code:e.error.code});return}if(!t.ok){o({phase:"error",message:t.error.detail,code:t.error.code});return}o({phase:"ready",site:e.data,isSuperuser:!!t.data.is_superuser,permissions:t.data.permissions||[]})},[]);if((0,s.useEffect)(()=>{x()},[x]),"loading"===d.phase)return(0,l.jsx)("div",{className:"flex justify-center py-20",role:"status","aria-label":"در ØØ§Ù بارگذارÛ",children:(0,l.jsx)("div",{className:"w-8 h-8 border-2 border-slate-300 border-t-slate-700 rounded-full animate-spin"})});if("error"===d.phase)return(0,l.jsx)("div",{dir:"rtl",className:"[color-scheme:light] max-w-xl mx-auto py-16",children:(0,l.jsx)(u,{tone:"error",children:d.message})});let m=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return d.isSuperuser||t.every(e=>d.permissions.includes(e))};return m(...t)&&(!(a.length>0)||a.some(e=>m(e)))?(0,l.jsx)(c.Provider,{value:{site:d.site,isSuperuser:d.isSuperuser,permissions:d.permissions,can:m,reload:x},children:r}):(0,l.jsxs)("div",{dir:"rtl",className:"[color-scheme:light] max-w-xl mx-auto py-16 space-y-4",children:[(0,l.jsx)(u,{tone:"warn",children:"Ø´Ù
ا Ø¯Ø³ØªØ±Ø³Û ÙØ§Ø²Ù
Ø¨Ø±Ø§Û Ù
Ø´Ø§ÙØ¯Ù٠اÛ٠بخش را ÙØ¯Ø§Ø±Ûد."}),(0,l.jsx)(n(),{href:"/admin/accounting",className:"text-sm text-sky-700 underline",children:"بازگشت Ø¨Ù ØØ³Ø§Ø¨Ø¯Ø§Ø±Û"})]})}},2881:function(e,t,a){"use strict";a.d(t,{Z:function(){return m}});var l=a(85893),s=a(67294),r=a(91444),n=a(90723),i=a(16053),c=a(67827);let d="bg-white text-slate-900 border border-slate-300 rounded-lg px-2 py-1 text-sm w-full",o=e=>null==e?"":String(e);function u(e,t){let a=(0,c.eZ)(t).trim();if("amount"===e.type){let t=a.replace(/[,Ù¬\s]/g,"");return/^\d+$/.test(t)?{value:Number(t)}:{error:"\xab".concat(e.label,"\xbb Ø¨Ø§ÛØ¯ عدد صØÛØ (تÙÙ
اÙ) باشد.")}}if("date"===e.type){let e=(0,c.yg)(a);return e?{value:e}:{error:"ØªØ§Ø±ÛØ® را ب٠شک٠۱۴۰۵/Û°Û·/Û°Û² ÙØ§Ø±Ø¯ Ú©ÙÛØ¯."}}return"percent"===e.type?/^\d{1,3}(\.\d{1,2})?$/.test(a)?{value:a}:{error:"\xab".concat(e.label,"\xbb درصد ÙØ§Ù
عتبر است.")}:"select"===e.type&&e.numeric?{value:Number(t)}:{value:t.trim()}}function x(e,t){let a=(0,c.eZ)(t).trim().replace(/[,Ù¬]/g,""),l=(0,c.eZ)(o(e.value)).trim().replace(/[,Ù¬]/g,"");return"percent"===e.type?Number(a)===Number(l):a===l}function m(e){var t,a;let{kind:c,id:m,displayNumber:p,fields:h,lines:b=[],onSaved:j,note:g,compact:v}=e,{isSuperuser:y}=(0,n.uu)(),[f,N]=(0,s.useState)(!1),[_,k]=(0,s.useState)({}),[w,C]=(0,s.useState)(""),[S,O]=(0,s.useState)(!1),[A,E]=(0,s.useState)("");if(!y)return null;let q=()=>{let e={};h.forEach(t=>{e[t.key]=o(t.value)}),b.forEach(t=>t.fields.forEach(a=>{e["".concat(t.id,".").concat(a.key)]=o(a.value)})),k(e),C(""),E(""),N(!0)},M=()=>{var e,t,a;let l={};for(let a of h){if(x(a,null!==(e=_[a.key])&&void 0!==e?e:""))continue;let s=u(a,null!==(t=_[a.key])&&void 0!==t?t:"");if(s.error)return{error:s.error};l[a.key]=s.value}let s=[];for(let e of b){let t={};for(let l of e.fields){let s=null!==(a=_["".concat(e.id,".").concat(l.key)])&&void 0!==a?a:"";if(x(l,s))continue;let r=u(l,s);if(r.error)return{error:"".concat(e.label,": ").concat(r.error)};t[l.key]=r.value}Object.keys(t).length&&s.push({id:e.id,...t})}return s.length&&(l.lines=s),{changes:l}},V=async()=>{let e=M();if(e.error){E(e.error);return}if(!e.changes||!Object.keys(e.changes).length){E("ÚÛØ²Û تغÛÛØ± Ùکرد٠است.");return}O(!0);let t=await (0,i.NR)(c,m,w,e.changes);O(!1),t.ok?(r.Am.success("".concat(p," ÙÛØ±Ø§ÛØ´ شد.")),N(!1),j()):E(t.error.detail)},P=(e,s)=>(0,l.jsxs)("label",{className:"text-xs text-slate-600 space-y-1 block",children:[(0,l.jsx)("span",{children:e.label}),"select"===e.type?(0,l.jsx)("select",{className:d,"aria-label":e.label,value:null!==(t=_[s])&&void 0!==t?t:"",onChange:e=>k({..._,[s]:e.target.value}),children:(e.options||[]).map(e=>{let[t,a]=e;return(0,l.jsx)("option",{value:t,children:a},t)})}):(0,l.jsx)("input",{className:d,"aria-label":e.label,value:null!==(a=_[s])&&void 0!==a?a:"",dir:"text"===e.type?void 0:"ltr",onChange:e=>k({..._,[s]:e.target.value})})]},s);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{type:"button",onClick:q,"aria-label":"ÙÛØ±Ø§ÛØ´ ".concat(p),className:v?"text-xs text-violet-800 ml-3":"px-4 py-2 rounded-xl border border-violet-300 text-violet-800 text-sm",children:"ÙÛØ±Ø§ÛØ´ (سÙپرادÙ
ÛÙ)"}),f&&(0,l.jsx)("div",{role:"dialog","aria-modal":"true","aria-label":"ÙÛØ±Ø§ÛØ´ ".concat(p),className:"fixed inset-0 bg-black/40 flex items-center justify-center z-50 p-4",children:(0,l.jsxs)("div",{className:"bg-white rounded-2xl p-6 w-full max-w-2xl max-h-[90vh] overflow-y-auto space-y-4",dir:"rtl",children:[(0,l.jsxs)("h2",{className:"font-bold text-lg",children:["ÙÛØ±Ø§ÛØ´ Ù
ستÙÛÙ
",(0,l.jsx)("span",{dir:"ltr",children:p})]}),(0,l.jsxs)("p",{className:"text-xs text-slate-600",children:["جÙ
عâÙØ§Ø Ø³ÙØ¯ Ù ØØ³Ø§Ø¨ طرÙâØØ³Ø§Ø¨ از رÙÛ ÙÙ
Û٠اعداد Ø¯ÙØ¨Ø§Ø±Ù ØØ³Ø§Ø¨ Ù
ÛâØ´ÙÙØ¯ Ù ÙØ³Ø®ÙÙ ÙØ¨Ù ٠بعد در گزارش Ù
Ù
ÛØ²Û Ù
ÛâÙ
Ø§ÙØ¯.",g?" ".concat(g):""]}),h.length>0&&(0,l.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:h.map(e=>P(e,e.key))}),b.map(e=>(0,l.jsxs)("fieldset",{className:"border border-slate-200 rounded-xl p-3",children:[(0,l.jsx)("legend",{className:"px-1 text-sm font-semibold",children:e.label}),(0,l.jsx)("div",{className:"grid gap-3 sm:grid-cols-4",children:e.fields.map(t=>P(t,"".concat(e.id,".").concat(t.key)))})]},e.id)),(0,l.jsx)("textarea",{className:d,rows:2,value:w,"aria-label":"دÙÛÙ ÙÛØ±Ø§ÛØ´",placeholder:"دÙÛÙ ÙÛØ±Ø§ÛØ´ (Ø§ÙØ²Ø§Ù
Û)",onChange:e=>C(e.target.value)}),A&&(0,l.jsx)("div",{className:"text-sm text-rose-700",role:"alert",children:A}),(0,l.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,l.jsx)("button",{className:"px-4 py-2 rounded-xl border border-slate-300 text-sm",disabled:S,onClick:()=>N(!1),children:"Ø§ÙØµØ±Ø§Ù"}),(0,l.jsx)("button",{className:"px-4 py-2 rounded-xl bg-violet-700 text-white text-sm disabled:opacity-50",disabled:S||!w.trim(),onClick:V,children:"Ø°Ø®ÛØ±ÙÙ ÙÛØ±Ø§ÛØ´"})]})]})})]})}},21168:function(e,t,a){"use strict";a.d(t,{Jg:function(){return s},Mz:function(){return x},NR:function(){return o},RI:function(){return i},Y0:function(){return u},Zq:function(){return n},ai:function(){return d},tV:function(){return r}});var l=a(67827);let s={cash:"ÙÙØ¯Û",bank:"Ø§ÙØªÙا٠باÙÚ©Û",card:"کارت ب٠کارت",cheque:"ÚÚ©",online:"پرداخت اÛÙØªØ±ÙتÛ",other:"Ø³Ø§ÛØ±"},r={paid:"پرداخت شدÙ",unpaid:"پرداخت ÙØ´Ø¯Ù"},n={arvin:"آرÙÛÙ",babaketab:"باباکتاب",tikbooks:"تÛÚ©âØ¨ÙÚ©",group:"گرÙÙ (Ù
شترک)"},i={day:"Ø±ÙØ²Ø§ÙÙ",week:"ÙÙØªÚ¯Û",month:"Ù
Ø§ÙØ§ÙÙ",year:"Ø³Ø§ÙØ§ÙÙ"},c=["image/jpeg","image/png","image/webp","application/pdf"];function d(e){return e?c.includes(e.type)?e.size?e.size>5242880?"ØØ¬Ù
ÙØ§ÛÙ Ø¨ÛØ´ØªØ± از Ûµ Ù
Ú¯Ø§Ø¨Ø§ÛØª است.":"":"ÙØ§Û٠خاÙÛ Ø§Ø³Øª.":"ÙÙØ· تصÙÛØ± (JPGØ PNGØ WEBP) ÛØ§ PDF Ù¾Ø°ÛØ±Ùت٠Ù
ÛâØ´ÙØ¯.":"ÙØ§ÛÙÛ Ø§ÙØªØ®Ø§Ø¨ ÙØ´Ø¯Ù است."}function o(e){var t,a,i,c,d,o;let u={},x=String(null!==(t=e.title)&&void 0!==t?t:"").trim();x||(u.title="عÙÙØ§Ù ÙØ²ÛÙ٠را ÙØ§Ø±Ø¯ Ú©ÙÛØ¯.");let m=String(null!==(a=e.payer)&&void 0!==a?a:"").trim();m||(u.payer="پرداختâÚ©ÙÙØ¯Ù را ÙØ§Ø±Ø¯ Ú©ÙÛØ¯.");let p=(0,l.VV)(String(null!==(i=e.category)&&void 0!==i?i:"").trim());p||(u.category="دستÙÙ ÙØ²ÛÙ٠را Ø§ÙØªØ®Ø§Ø¨ Ú©ÙÛØ¯.");let h=(0,l.VV)(String(null!==(c=e.amount)&&void 0!==c?c:"").trim());(null===h||h<=0)&&(u.amount="Ù
Ø¨ÙØº Ø¨Ø§ÛØ¯ عدد صØÛØ Ù
ثبت (تÙÙ
اÙ) باشد."),s[e.method]||(u.method="Ø±ÙØ´ پرداخت را Ø§ÙØªØ®Ø§Ø¨ Ú©ÙÛØ¯."),r[e.payment_status]||(u.payment_status="ÙØ¶Ø¹Ûت پرداخت را Ø§ÙØªØ®Ø§Ø¨ Ú©ÙÛØ¯."),n[e.company]||(u.company="شرکت Ù
رتبط را Ø§ÙØªØ®Ø§Ø¨ Ú©ÙÛØ¯.");let b=(0,l.yg)(String(null!==(d=e.doc_date)&&void 0!==d?d:"").trim());if(b||(u.doc_date="ØªØ§Ø±ÛØ® را ب٠شک٠۱۴۰۵/Û°Û¶/Û²Û³ ÙØ§Ø±Ø¯ Ú©ÙÛØ¯."),Object.keys(u).length)return{ok:!1,errors:u};let j={doc_date:b,title:x,category:p,amount:h,payer:m,method:e.method,company:e.company,payment_status:e.payment_status},g=String(null!==(o=e.description)&&void 0!==o?o:"").trim();return g&&(j.description=g),{ok:!0,body:j}}function u(e){var t,a,l;let n={},i=String(null!==(t=e.title)&&void 0!==t?t:"").trim();i||(n.title="عÙÙØ§Ù ÙØ²ÛÙ٠را ÙØ§Ø±Ø¯ Ú©ÙÛØ¯.");let c=String(null!==(a=e.payer)&&void 0!==a?a:"").trim();return(c||(n.payer="پرداختâÚ©ÙÙØ¯Ù را ÙØ§Ø±Ø¯ Ú©ÙÛØ¯."),s[e.method]||(n.method="Ø±ÙØ´ پرداخت را Ø§ÙØªØ®Ø§Ø¨ Ú©ÙÛØ¯."),r[e.payment_status]||(n.payment_status="ÙØ¶Ø¹Ûت پرداخت را Ø§ÙØªØ®Ø§Ø¨ Ú©ÙÛØ¯."),Object.keys(n).length)?{ok:!1,errors:n}:{ok:!0,body:{title:i,payer:c,description:String(null!==(l=e.description)&&void 0!==l?l:"").trim(),method:e.method,payment_status:e.payment_status}}}function x(e){var t,a,s;let r={};for(let a of["category","company","method","payment_status","status","q"]){let l=String(null!==(t=e[a])&&void 0!==t?t:"").trim();l&&(r[a]=l)}for(let t of["min_amount","max_amount"]){let s=String(null!==(a=e[t])&&void 0!==a?a:"").trim();if(!s)continue;let n=(0,l.VV)(s);if(null===n||n<0)return{ok:!1,error:"Ù
Ø¨ÙØº ÙÛÙØªØ± Ø¨Ø§ÛØ¯ عدد صØÛØ Ø¨Ø§Ø´Ø¯."};r[t]=String(n)}for(let t of["from","to"]){let a=String(null!==(s=e[t])&&void 0!==s?s:"").trim();if(!a)continue;let n=(0,l.yg)(a);if(!n)return{ok:!1,error:"ØªØ§Ø±ÛØ® را ب٠شک٠۱۴۰۵/Û°Û¶/Û²Û³ ÙØ§Ø±Ø¯ Ú©ÙÛØ¯."};r[t]=n}return{ok:!0,params:r}}}},function(e){e.O(0,[9774,2888,179],function(){return e(e.s=40327)}),_N_E=e.O()}]);
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.