PageSourceSearch

https://evisas.io/assets/SupplierStatementPage-DMHTX3kv.js

js evisas.io collected 2026-10-04 02:55:41 UTC 24,916 bytes, 2 lines download raw bytes

1import{r as u,j as e}from"./vendor-react-CuUun9aL.js";import{a as Ie,u as je}from"./vendor-query-Ch735aT_.js";import{G as Re,s as Z,a as U}from"./GeneralTransferDialog-CqEDjXaD.js";import{B as T,s as ee,J as N}from"./index-CffYHF1C.js";import{C as G,a as se,e as ae,c as te}from"./card-khC1k9a2.js";import{B as A}from"./badge-tBo3c1at.js";import{C as ge}from"./checkbox-Dps3iZul.js";import{I as Ce}from"./input-Ccd_OHYE.js";import{T as Ue,a as Ve,b as re,c as C,d as $e,e as w}from"./table-Bf8kae7D.js";import{D as qe,a as He,b as Oe,c as B}from"./dropdown-menu-LhELHrUX.js";import{S as ye,a as be,b as ve,c as Ne,d as _}from"./select-BaOXAfxm.js";import{f as b}from"./currency-CifnWf-V.js";import{T as Qe}from"./TransferDetailsDialog-6g6kUvGv.js";import{D as ne,a as le,b as oe,c as ce,d as de,e as ue}from"./dialog-C-hTN1bv.js";import{T as _e}from"./textarea-CHbjQrep.js";import{L as ie}from"./label-BaKeqYGc.js";import{A as Te,a as De}from"./alert-DWegkEzP.js";import{m as Fe,F as Ke,aP as Ge,L as Xe,o as Ye,g as Je,b as Ze,aO as we,aX as es,bG as ss,a1 as Se,bM as as,aL as ts}from"./vendor-icons-9tdgZqZ8.js";import{f as V}from"./vendor-date-BqJAPjTW.js";import{E as rs}from"./jspdf.es.min-CKI9zLA2.js";import{autoTable as is}from"./jspdf.plugin.autotable-bUJAAMeG.js";import{b as ns,u as ls}from"./vendor-router-CIKCSSKp.js";import"./bankStatementService-DlSTJenR.js";import"./vendor-supabase-V01cKGWO.js";import"./index-vW79U7ye.js";import"./supabaseProxy-B-2nsjjj.js";import"./bankAccountService-B97rjGFZ.js";import"./command-zr3jZ_P8.js";import"./vendor-radix-DHc79Ej6.js";import"./popover-Bf6khzEE.js";const os=({open:n,onOpenChange:m,onConfirm:j,applicationNumber:p})=>{const[h,a]=u.useState(""),[l,d]=u.useState(!1),o=async()=>{if(h.trim()){d(!0);try{await j(h),a(""),m(!1)}finally{d(!1)}}};return e.jsx(ne,{open:n,onOpenChange:m,children:e.jsxs(le,{className:"max-w-md",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Reverse Payment"}),e.jsxs(de,{children:["This will mark the statement as unpaid and clear the payment reference.",p&&` Application: ${p}`]})]}),e.jsxs(Te,{variant:"destructive",children:[e.jsx(Fe,{className:"h-4 w-4"}),e.jsx(De,{children:"This action will reverse the payment status but will NOT reverse the actual bank transfer. You must handle the financial reversal separately."})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(ie,{htmlFor:"reason",children:"Reason for Reversal *"}),e.jsx(_e,{id:"reason",placeholder:"Explain why this payment is being reversed...",value:h,onChange:f=>a(f.target.value),rows:4,className:"mt-2"})]})}),e.jsxs(ue,{children:[e.jsx(T,{variant:"outline",onClick:()=>m(!1),disabled:l,children:"Cancel"}),e.jsx(T,{variant:"destructive",onClick:o,disabled:!h.trim()||l,children:l?"Reversing...":"Reverse Payment"})]})]})})},cs=({open:n,onOpenChange:m,onConfirm:j,transferAmount:p,transferDate:h,transferDescription:a})=>{const[l,d]=u.useState(!1),o=async()=>{d(!0);try{await j(),m(!1)}finally{d(!1)}};return e.jsx(ne,{open:n,onOpenChange:m,children:e.jsxs(le,{className:"max-w-md",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Delete Transfer Entry"}),e.jsx(de,{children:"This action cannot be undone. The transfer entry will be permanently removed."})]}),e.jsxs(Te,{variant:"destructive",children:[e.jsx(Fe,{className:"h-4 w-4"}),e.jsx(De,{children:"Warning: This will remove the transfer record from the statement. Use only for erroneous entries that were recorded by mistake."})]}),p!==void 0&&e.jsxs("div",{className:"space-y-2 text-sm bg-muted p-4 rounded-md",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Amount:"}),e.jsx("span",{className:"font-medium",children:b(p)})]}),h&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Date:"}),e.jsx("span",{className:"font-medium",children:V(new Date(h),"PPp")})]}),a&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Description:"}),e.jsx("span",{className:"font-medium truncate ml-2",children:a})]})]}),e.jsxs(ue,{children:[e.jsx(T,{variant:"outline",onClick:()=>m(!1),disabled:l,children:"Cancel"}),e.jsx(T,{variant:"destructive",onClick:o,disabled:l,children:l?"Deleting...":"Delete Entry"})]})]})})},ds=({open:n,onOpenChange:m,onConfirm:j,currentDescription:p,currentAmount:h})=>{const[a,l]=u.useState(p),[d,o]=u.useState(h.toString()),[f,D]=u.useState(!1);u.useEffect(()=>{l(p),o(h.toString())},[p,h]);const E=async()=>
1{if(!a.trim()||!d)return;const x=parseFloat(d);if(!(isNaN(x)||x<=0)){D(!0);try{await j(a,x),m(!1)}finally{D(!1)}}};return e.jsx(ne,{open:n,onOpenChange:m,children:e.jsxs(le,{className:"max-w-md",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Edit Transfer Description"}),e.jsx(de,{children:"Update the description/remarks for this transfer entry."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ie,{htmlFor:"amount",children:"Amount (AED)"}),e.jsx(Ce,{id:"amount",type:"number",step:"0.01",placeholder:"Enter amount...",value:d,onChange:x=>o(x.target.value),className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(ie,{htmlFor:"description",children:"Description"}),e.jsx(_e,{id:"description",placeholder:"Enter transfer description...",value:a,onChange:x=>l(x.target.value),rows:4,className:"mt-2"})]})]}),e.jsxs(ue,{children:[e.jsx(T,{variant:"outline",onClick:()=>m(!1),disabled:f,children:"Cancel"}),e.jsx(T,{onClick:E,disabled:!a.trim()||!d||parseFloat(d)<=0||f,children:f?"Saving...":"Save Changes"})]})]})})},us=({statements:n,supplierName:m,loading:j=!1})=>{const p=()=>{const a=["Date","App # / Transfer #","Applicant / Description","Passport","Nationality","Destination","Visa Type","User / Performed By","Status","Debit (AED)","Credit (AED)","Balance (AED)"],l=n.map(i=>[V(new Date(i.created_at),"MMM dd, yyyy"),i.application_id?i.application_number||"N/A":i.transfer_number||"N/A",i.application_id?i.applicant_name||"N/A":i.transfer_description||"Payment Entry",i.application_id?i.passport_number||"N/A":"-",i.application_id?i.nationality||"N/A":"-",i.application_id?i.destination_country||"N/A":"-",i.application_id?i.visa_type||"N/A":"-",i.application_id?i.user_name||"N/A":i.performed_by_name||i.user_name||"Admin",i.status,i.debit>0?i.debit.toFixed(2):"-",i.credit>0?i.credit.toFixed(2):"-",i.running_balance.toFixed(2)]),d=n.filter(i=>i.status==="unpaid").reduce((i,k)=>i+k.amount,0),o=n.filter(i=>i.status==="paid").reduce((i,k)=>i+k.amount,0),f=n.length>0?n[0].running_balance:0;l.push([""]),l.push(["Summary","","","","","","","","","",""]),l.push(["Total Unpaid","","","","","","",d.toFixed(2),"","",""]),l.push(["Total Paid","","","","","","",o.toFixed(2),"","",""]),l.push(["Current Balance","","","","","","","","","",f.toFixed(2)]);const D=[a.join(","),...l.map(i=>i.map(k=>`"${k}"`).join(","))].join(`
2`),E=new Blob([D],{type:"text/csv;charset=utf-8;"}),x=document.createElement("a"),I=URL.createObjectURL(E);x.setAttribute("href",I),x.setAttribute("download",`supplier_statement_${m.replace(/\s+/g,"_")}_${new Date().toISOString().split("T")[0]}.csv`),x.style.visibility="hidden",document.body.appendChild(x),x.click(),document.body.removeChild(x)},h=()=>{const a=new rs("landscape","mm","a4"),l=a.internal.pageSize.getWidth(),d=a.internal.pageSize.getHeight(),o=10,f=[15,82,186],D=[34,197,94],E=[245,158,11],x=[59,130,246];a.setFillColor(...f),a.rect(0,0,l,28,"F"),a.setFontSize(22),a.setTextColor(255,255,255),a.setFont("helvetica","bold"),a.text("eVisas",o,14),a.setFontSize(14),a.setFont("helvetica","normal"),a.text("Supplier Statement",o,22),a.setFontSize(16),a.setFont("helvetica","bold");const I=a.getTextWidth(m);a.text(m,l-o-I,14),a.setFontSize(9),a.setFont("helvetica","normal");const i=`Generated: ${V(new Date,"dd MMM yyyy, HH:mm")}`,k=a.getTextWidth(i);a.text(i,l-o-k,22);const $=n.filter(t=>t.status==="unpaid").reduce((t,v)=>t+v.amount,0),X=n.filter(t=>t.status==="paid").reduce((t,v)=>t+v.amount,0),q=n.length>0?n[0].running_balance:0,Y=n.filter(t=>t.status==="unpaid").length,H=n.filter(t=>t.status==="paid").length;a.setFillColor(248,250,252),a.rect(0,28,l,16,"F"),a.setDrawColor(226,232,240),a.setLineWidth(.5),a.line(0,44,l,44);const c=38,M=(l-o*2)/3;a.setFontSize(8),a.setTextColor(100,116,139),a.setFont("helvetica","normal"),a.text("TOTAL UNPAID",o,c-3),a.setFontSize(12),a.setTextColor(...E),a.setFont("helvetica","bold"),a.text(`${b($)} (${Y})`,o,c+3);const S=o+M;a.setFontSize(8),a.setTextColor(100,116,139),a.setFont("helvetica","normal"),a.text("TOTAL PAID",S,c-3),a.setFontSize(12),a.setTextColor(...D),a.setFont("helvetica","bold"),a.text(`${b(X)} (${H})`,S,c+3);const O=o+M*2;a.setFontSize(8),a.setTextColor(100,116,139),a.setFont("helvetica","normal"),a.text("CURRENT BALANCE",O,c-3),a.setFontSize(14),a.setTextColor(...x),a.setFont("helvetica","bold"),a.text(b(q),O,c+4);const F=n.map(t=>[V(new Date(t.created_at),"dd/MM/yy"),t.application_id?t.application_number||"-":t.transfer_number||"-",t.application_id?t.applicant_name||"-":t.transfer_description||"Payment",t.application_id&&t.passport_number||"-",t.application_id&&t.nationality||"-",t.application_id&&t.destination_country||"-",t.application_id&&t.visa_type||"-",t.application_id?t.user_name||"-":t.performed_by_name||"Admin",t.status.toUpperCase(),t.debit>0?b(t.debit):"-",t.credit>0?b(t.credit):"-",b(t.running_balance)]),g=l-o*2;is(a,{head:[["Date","Ref #","Applicant/Description","Passport","Nat.","Dest.","Visa Type","User","Status","Debit","Credit","Balance"]],body:F,startY:48,margin:{left:o,right:o},tableWidth:g,styles:{fontSize:7,cellPadding:2,lineColor:[226,232,240],lineWidth:.1,overflow:"linebreak",minCellHeight:8},headStyles:{fillColor:[107,114,128],textColor:[255,255,255],fontStyle:"bold",fontSize:7,cellPadding:3},alternateRowStyles:{fillColor:[248,250,252]},columnStyles:{0:{cellWidth:16},1:{cellWidth:26},2:{cellWidth:30},3:{cellWidth:18},4:{cellWidth:22},5:{cellWidth:18},6:{cellWidth:30},7:{cellWidth:26},8:{cellWidth:18,halign:"center"},9:{cellWidth:20,halign:"right"},10:{cellWidth:20,halign:"right"},11:{cellWidth:21,halign:"right",fontStyle:"bold"}},didParseCell:function(t){if(t.column.index===8&&t.section==="body"){const v=t.cell.text[0];v==="PAID"?(t.cell.styles.textColor=D,t.cell.styles.fontStyle="bold"):v==="UNPAID"&&(t.cell.styles.textColor=E,t.cell.styles.fontStyle="bold")}t.column.index===11&&t.section==="body"&&(t.cell.styles.textColor=f),t.column.index===10&&t.section==="body"&&t.cell.text[0]!=="-"&&(t.cell.styles.textColor=D),t.column.index===9&&t.section==="body"&&t.cell.text[0]!=="-"&&(t.cell.styles.textColor=[220,38,38])},didDrawPage:function(t){const v=a.getNumberOfPages(),R=t.pageNumber;a.setDrawColor(226,232,240),a.setLineWidth(.5),a.line(o,d-12,l-o,d-12),a.setFontSize(8),a.setTextColor(148,163,184),a.setFont("helvetica","normal"),a.text("eVisas - Supplier Statement Report",o,d-7);const W=`Page ${R} of ${v}`,Q=a.getTextWidth(W);a.text(W,l-o-Q,d-7),a.setFontSize(7);const K="CONFIDENTIAL - For internal use only",J=a.getTextWidth(K);a.text(K,(l-J)/2,d-7)}}),a.save(`supplier_statement_${m.replace(/\s+/g,"_")}_${new Date().toISOString().split("T")[0]}.pdf`)};return e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(T,{variant:"outline",size:"sm",onClick:p,disabled:j||n.length===0,children:[e.jsx(Ke,{className:"h-4 w-4 mr-2"}),"Export CSV"]}),e.jsxs(T,{variant:"outline",size:"sm",onClick:h,disabled:j||n.length===0,children:[e.jsx(Ge,{className:"h-4 w-4 mr-2"}),"Export PDF"]})]})},Vs=()=>{const{supplierId:n}=ns(),m=ls(),j=Ie(),[p,h]=u.useState(new Set),[a,l]=u.useState(""),[d,o]=u.useState("all"),[f,D]=u.useState("all"),[E,x]=u.useState(!1),[I,i]=u.useState(!1),[k,$]=u.useState(!1),[X,q]=u.useState(!1),[Y,H]=u.useState(!1),[c,M]=u.useState(null),[S,O]=u.useState(null),{data:F}=je({queryKey:["supplier",n],queryFn:async()=>{const{data:s,error:r}=await ee.from("suppliers").select("*").eq("id",n).single();if(r)throw r;return s},enabled:!!n}),{data:g,isLoading:t,refetch:v}=je({queryKey:["supplier-statement",n],queryFn:()=>Z.getStatementWithBalance(n),enabled:!!n,staleTime:0,gcTime:2*60*1e3,refetchOnMount:"always"});u.useEffect(()=>{n&&j.invalidateQueries({queryKey:["supplier-statement",n]})},[n,j]),u.useEffect(()=>{if(!n)return;const s=ee.channel(`supplier-statement-sync-${n}`).on("postgres_changes",{event:"UPDATE",schema:"public",table:"applications",filter:`supplier_id=eq.${n}`},()=>{console.log("Supplier assignment changed, refreshing statements..."),j.invalidateQueries({queryKey:["supplier-statement",n]})}).on("postgres_changes",{event:"*",schema:"public",table:"supplier_statements",filter:`supplier_id=eq.${n}`},()=>{console.log("Supplier statement changed, refreshing..."),j.invalidateQueries({queryKey:["supplier-statement",n]})}).subscribe();return()=>{ee.removeChannel(s)}},[n,j]);const R=u.useMemo(()=>
2{if(!g)return{totalUnpaid:0,totalPaid:0,currentBalance:0};const s=g.filter(P=>P.status==="unpaid").reduce((P,z)=>P+z.amount,0),r=g.filter(P=>P.status==="paid").reduce((P,z)=>P+z.amount,0),y=g.length>0?g[0].running_balance:0;return{totalUnpaid:s,totalPaid:r,currentBalance:y}},[g]),W=u.useMemo(()=>g?g.filter(s=>{var r,y,P,z,xe,he,me,fe;if(d!=="all"&&s.status!==d||f!=="all"&&(!s.application_status||s.application_status!==f))return!1;if(a){const L=a.toLowerCase();return((r=s.application_number)==null?void 0:r.toLowerCase().includes(L))||((y=s.applicant_name)==null?void 0:y.toLowerCase().includes(L))||((P=s.passport_number)==null?void 0:P.toLowerCase().includes(L))||((z=s.nationality)==null?void 0:z.toLowerCase().includes(L))||((xe=s.destination_country)==null?void 0:xe.toLowerCase().includes(L))||((he=s.visa_type)==null?void 0:he.toLowerCase().includes(L))||((me=s.user_name)==null?void 0:me.toLowerCase().includes(L))||((fe=s.user_email)==null?void 0:fe.toLowerCase().includes(L))}return!0}):[],[g,a,d,f]),Q=u.useMemo(()=>g?g.filter(s=>p.has(s.id)&&s.status==="unpaid").reduce((s,r)=>s+r.amount,0):0,[g,p]),K=s=>{if(s){const r=W.filter(y=>y.status==="unpaid").map(y=>y.id);h(new Set(r))}else h(new Set)},J=(s,r)=>{const y=new Set(p);r?y.add(s):y.delete(s),h(y)},Pe=()=>{if(p.size===0){N.error("Please select statements to pay");return}x(!0)},Ae=s=>{h(new Set([s])),x(!0)},Ee=async s=>{try{const r=Array.from(p);await Z.markMultipleAsPaid(r,s),N.success(`Successfully paid ${r.length} statement(s)`),h(new Set),x(!1),v()}catch(r){console.error("Error updating statements:",r),N.error("Payment recorded but failed to update statement status")}},pe=async s=>{try{const r=await U.getTransferById(s);r&&(M(r),i(!0))}catch(r){console.error("Error fetching transfer details:",r),N.error("Failed to load transfer details")}},ke=s=>{O(s),$(!0)},We=async s=>{if(S)try{await Z.reversePayment(S.id,s),N.success("Payment reversed successfully"),v()}catch(r){console.error("Error reversing payment:",r),N.error("Failed to reverse payment")}},Le=async s=>{try{const r=await U.getTransferById(s);r&&(M(r),H(!0))}catch(r){console.error("Error fetching transfer:",r),N.error("Failed to load transfer details")}},Me=async(s,r)=>{if(c)try{await U.updateTransfer(c.id,{description:s,amount:r}),N.success("Transfer updated successfully"),v()}catch(y){console.error("Error updating transfer:",y),N.error("Failed to update transfer")}},ze=async s=>{try{const r=await U.getTransferById(s);r&&(M(r),q(!0))}catch(r){console.error("Error fetching transfer:",r),N.error("Failed to load transfer details")}},Be=async()=>{if(c)try{await U.deleteTransfer(c.id),N.success("Transfer entry deleted"),v()}catch(s){console.error("Error deleting transfer:",s),N.error("Failed to delete transfer")}};return t?e.jsx("div",{className:"flex items-center justify-center h-screen",children:e.jsx(Xe,{className:"h-8 w-8 animate-spin text-primary"})}):e.jsxs("div",{className:"max-w-[1600px] w-full mx-auto px-4 py-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(T,{variant:"ghost",size:"icon",onClick:()=>m("/admin",{state:{activeTab:"suppliers"}}),children:e.jsx(Ye,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Admin / Suppliers"}),e.jsxs("h1",{className:"text-2xl font-bold",children:[F==null?void 0:F.name," - Statement"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(G,{children:[e.jsxs(se,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(ae,{className:"text-sm font-medium",children:"Total Unpaid"}),e.jsx(Je,{className:"h-4 w-4 text-amber-500"})]}),e.jsx(te,{children:e.jsx("div",{className:"text-2xl font-bold text-amber-600",children:b(R.totalUnpaid)})})]}),e.jsxs(G,{children:[e.jsxs(se,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(ae,{className:"text-sm font-medium",children:"Total Paid"}),e.jsx(Ze,{className:"h-4 w-4 text-green-500"})]}),e.jsx(te,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:b(R.totalPaid)})})]}),e.jsxs(G,{children:[e.jsxs(se,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(ae,{className:"text-sm font-medium",children:"Current Balance"}),e.jsx(we,{className:"h-4 w-4 text-blue-500"})]}),e.jsx(te,{children:e.jsx("div",{className:"text-2xl font-bold text-blue-600",children:b(R.currentBalance)})})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(Ce,{placeholder:"Search by application, name, passport, destination, visa type, user...",value:a,onChange:s=>l(s.target.value),className:"max-w-md"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(es,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(ye,{value:d,onValueChange:o,children:[e.jsx(be,{className:"w-[140px]",children:e.jsx(ve,{placeholder:"Payment Status"})}),e.jsxs(Ne,{children:[e.jsx(_,{value:"all",children:"All Payments"}),e.jsx(_,{value:"unpaid",children:"Unpaid"}),e.jsx(_,{value:"paid",children:"Paid"})]})]}),e.jsxs(ye,{value:f,onValueChange:D,children:[e.jsx(be,{className:"w-[160px]",children:e.jsx(ve,{placeholder:"Visa Status"})}),e.jsxs(Ne,{children:[e.jsx(_,{value:"all",children:"All Visa Status"}),e.jsx(_,{value:"approved",children:"Approved"}),e.jsx(_,{value:"rejected",children:"Rejected"}),e.jsx(_,{value:"submitted",children:"Submitted"}),e.jsx(_,{value:"in_process",children:"In Process"}),e.jsx(_,{value:"cancelled",children:"Cancelled"}),e.jsx(_,{value:"waiting_for_appointment",children:"Waiting"}),e.jsx(_,{value:"imm_sent",children:"IMM Sent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(us,{statements:W,supplierName:(F==null?void 0:F.name)||"Unknown",loading:t}),p.size>0&&e.jsxs("div",{className:"flex items-center gap-4 bg-blue-50 dark:bg-blue-950 px-4 py-2 rounded-lg",children:[e.jsxs("span",{className:"text-sm font-medium",children:[p.size," selected | Total: ",b(Q)]}),e.jsx(T,{onClick:Pe,size:"sm",children:"Pay Selected"})]})]})]}),e.jsx(G,{children:e.jsxs(Ue,{children:[e.jsx(Ve,{children:e.jsxs(re,{children:[e.jsx(C,{className:"w-12",children:e.jsx(ge,{checked:W.filter(s=>s.status==="unpaid").length>0&&W.filter(s=>s.status==="unpaid").every(s=>p.has(s.id)),onCheckedChange:K})}),e.jsx(C,{children:"App #"}),e.jsx(C,{children:"Created"}),e.jsx(C,{className:"min-w-[320px]",children:"Particulars"}),e.jsx(C,{className:"min-w-[200px]",children:"User"}),e.jsx(C,{children:"Payment Status"}),e.jsx(C,{children:"Visa Status"}),e.jsx(C,{className:"text-right",children:"Debit"}),e.jsx(C,{className:"text-right",children:"Credit"}),e.jsx(C,{className:"text-right",children:"Balance"}),e.jsx(C,{children:"Actions"})]})}),e.jsx($e,{children:W.length===0?e.jsx(re,{children:e.jsx(w,{colSpan:11,className:"text-center text-muted-foreground py-8",children:"No statements found"})}):W.map(s=>e.jsxs(re,{children:[e.jsx(w,{children:s.status==="unpaid"&&e.jsx(ge,{checked:p.has(s.id),onCheckedChange:r=>J(s.id,r)})}),e.jsx(w,{className:"font-medium",children:s.application_id?s.application_number:e.jsx("span",{className:"text-green-600 font-mono text-xs",children:s.transfer_number||"N/A"})}),e.jsx(w,{className:"text-sm text-muted-foreground",children:V(new Date(s.created_at),"MMM dd, yyyy")}),e.jsx(w,{children:s.application_id?e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"font-medium text-sm",children:s.applicant_name}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:[s.passport_number&&e.jsxs("span",{className:"font-mono bg-muted px-2 py-0.5 rounded",children:["📄 ",s.passport_number]}),s.nationality&&e.jsxs("span",{className:"bg-blue-50 dark:bg-blue-950 px-2 py-0.5 rounded",children:["🌍 ",s.nationality]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs text-muted-foreground",children:[s.destination_country&&e.jsxs("span",{children:["📍 ",s.destination_country]}
2),s.visa_type&&e.jsxs("span",{className:"text-purple-600 dark:text-purple-400",children:["• ",s.visa_type]})]})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"font-medium text-green-700 dark:text-green-400",children:["💳 Payment from ",s.bank_name||"Bank"]}),s.transfer_description&&e.jsx("div",{className:"text-sm text-muted-foreground",children:s.transfer_description})]})}),e.jsx(w,{children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"font-medium text-sm",children:s.application_id?s.user_name:s.performed_by_name||s.user_name||"Admin"}),s.user_email&&s.user_email!=="N/A"&&e.jsx("div",{className:"text-xs text-muted-foreground",children:s.user_email})]})}),e.jsx(w,{children:s.status==="paid"?e.jsx(A,{variant:"default",className:"bg-green-100 text-green-800",children:"Paid"}):e.jsx(A,{variant:"secondary",className:"bg-amber-100 text-amber-800",children:"Unpaid"})}),e.jsx(w,{children:s.application_id?(()=>{const r=s.application_status;switch(r){case"approved":return e.jsx(A,{className:"bg-green-100 text-green-800",children:"Approved"});case"rejected":return e.jsx(A,{className:"bg-red-100 text-red-800",children:"Rejected"});case"submitted":return e.jsx(A,{className:"bg-blue-100 text-blue-800",children:"Submitted"});case"in_process":return e.jsx(A,{className:"bg-yellow-100 text-yellow-800",children:"In Process"});case"cancelled":return e.jsx(A,{className:"bg-gray-100 text-gray-800",children:"Cancelled"});case"waiting_for_appointment":return e.jsx(A,{className:"bg-purple-100 text-purple-800",children:"Waiting"});case"imm_sent":return e.jsx(A,{className:"bg-cyan-100 text-cyan-800",children:"IMM Sent"});default:return e.jsx(A,{className:"bg-gray-100 text-gray-600",children:r||"N/A"})}})():e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(w,{className:"text-right text-red-600 font-medium",children:s.debit>0?b(s.debit):"-"}),e.jsx(w,{className:"text-right text-green-600 font-medium",children:s.credit>0?b(s.credit):"-"}),e.jsx(w,{className:"text-right font-bold",children:b(s.running_balance)}),e.jsx(w,{children:e.jsxs(qe,{children:[e.jsx(He,{asChild:!0,children:e.jsx(T,{variant:"ghost",size:"sm",children:e.jsx(ss,{className:"h-4 w-4"})})}),e.jsxs(Oe,{align:"end",children:[s.application_id&&s.status==="paid"&&e.jsxs(e.Fragment,{children:[s.transfer_id&&e.jsxs(B,{onClick:()=>pe(s.transfer_id),children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"View Transfer"]}),e.jsxs(B,{onClick:()=>ke(s),className:"text-orange-600",children:[e.jsx(as,{className:"h-4 w-4 mr-2"}),"Reverse Payment"]})]}),s.application_id&&s.status==="unpaid"&&e.jsxs(B,{onClick:()=>Ae(s.id),children:[e.jsx(we,{className:"h-4 w-4 mr-2"}),"Pay Now"]}),!s.application_id&&s.credit>0&&s.transfer_id&&e.jsxs(e.Fragment,{children:[e.jsxs(B,{onClick:()=>pe(s.transfer_id),children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"View Details"]}),e.jsxs(B,{onClick:()=>Le(s.transfer_id),children:[e.jsx(ts,{className:"h-4 w-4 mr-2"}),"Edit Description"]}),e.jsxs(B,{onClick:()=>ze(s.transfer_id),className:"text-destructive",children:[e.jsx("span",{className:"mr-2",children:"🗑️"}),"Delete Entry"]})]})]})]})})]},s.id))})]})}),E&&F&&e.jsx(Re,{open:E,onOpenChange:x,preFilledFrom:{type:"bank",id:""},preFilledTo:{type:"supplier",id:F.id},preFilledAmount:Q,statementIds:Array.from(p),onTransferSuccess:Ee}),e.jsx(Qe,{transfer:c,open:I,onOpenChange:i}),e.jsx(os,{open:k,onOpenChange:$,onConfirm:We,statementId:(S==null?void 0:S.id)||"",applicationNumber:S==null?void 0:S.application_number}),e.jsx(cs,{open:X,onOpenChange:q,onConfirm:Be,transferAmount:c==null?void 0:c.amount,transferDate:c==null?void 0:c.performed_at,transferDescription:c==null?void 0:c.description}),e.jsx(ds,{open:Y,onOpenChange:H,onConfirm:Me,currentDescription:(c==null?void 0:c.description)||"",currentAmount:(c==null?void 0:c.amount)||0})]})};export{Vs as default};

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