1import{A as e,I as t,J as n,P as r,et as i,i as a}from"./chunk-62JRHF6Z-CZLhzQUZ.js";import{t as o}from"./jsx-runtime-CI99cYnF.js";import{t as s}from"./PaymentKindIcon-Ds4SRTJf.js";import{t as c}from"./TrashIcon-DdTp1LLe.js";import{t as l}from"./XMarkIcon-Dc3DVNFU.js";import{a as u,n as d,o as f,t as p}from"./formatters-DQ2wEdHQ.js";import{t as m}from"./ConfirmPopover-CwqS0LNp.js";import{l as h,s as g}from"./useOverlayStack-BTopnEzT.js";import{t as _}from"./SlideOverlay-DJRXc9-d.js";import{t as v}from"./Notes-CnG5AGrD.js";import{t as y}from"./Attribute-DTpcTjwn.js";import{n as b}from"./paymentLabels-C47NYT4M.js";var x=i(n());function S({title:e,titleId:t,...n},r){return x.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?x.createElement(`title`,{id:t},e):null,x.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M18.364 18.364A9 9 0 0 0 5.636 5.636m12.728 12.728A9 9 0 0 1 5.636 5.636m12.728 12.728L5.636 5.636`}))}var C=x.forwardRef(S);function w({title:e,titleId:t,...n},r){return x.createElement(`svg`,Object.assign({xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,"aria-hidden":`true`,"data-slot":`icon`,ref:r,"aria-labelledby":t},n),e?x.createElement(`title`,{id:t},e):null,x.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125`}))}var T=x.forwardRef(w),E=o();function D({payment:t}){let n=r(),i=e(),{depth:a}=g(),o=t.invoices??[],s=!t.voidedAt&&o.length>1,c=i.formData?.get(`invoiceId`)?.toString(),u=e=>{i.submit({intent:`release_invoice`,invoiceId:String(e.id),returnSearch:h(n.search)},{method:`post`,action:`/payments/${t.id}${a>0?`?stacked=1`:``}`})};return o.length===0?null:(0,E.jsxs)(`section`,{children:[(0,E.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900`,children:`Covered invoices`}),(0,E.jsxs)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:[`Invoices paid by this payment.`,s&&` Removing one releases it for a future payment run and lowers this payment's amount.`]}),(0,E.jsx)(`ul`,{className:`mt-3 divide-y divide-gray-200 rounded-md border border-gray-200`,children:o.map(e=>{let t=c===String(e.id);return(0,E.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-3 py-2.5`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsxs)(`div`,{className:`truncate text-sm font-medium text-gray-900`,children:[e.shipment?.shipmentCode??`â`,e.number?(0,E.jsxs)(`span`,{className:`ml-2 font-normal text-gray-500`,children:[`Invoice #`,e.number]}):null]}),(0,E.jsx)(`div`,{className:`truncate text-xs text-gray-500`,children:e.shipment?.company?.legalName??``})]}),(0,E.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-3`,children:[(0,E.jsx)(`span`,{className:`text-sm tabular-nums text-gray-900`,children:p(e.amount)}),s&&(0,E.jsx)(m,{content:`Remove this invoice from the payment? It will be released for a future payment run and this payment's amount will be reduced accordingly.`,confirmText:`Remove`,theme:`destructive`,onConfirm:()=>u(e),children:(0,E.jsx)(`button`,{type:`button`,className:`rounded p-1 text-gray-400 hover:bg-gray-100 hover:text-red-600 disabled:opacity-50`,disabled:t,"aria-label":`Remove invoice from payment`,title:`Remove invoice from payment`,children:(0,E.jsx)(l,{className:`h-4 w-4`})})})]})]},e.id)})})]})}function O({payment:e}){let t=h(r().search),n=e.factoringCompany?.name??e.company?.legalName??void 0;return(0,E.jsxs)(`dl`,{className:`grid grid-cols-3 gap-x-2 gap-y-4 sm:gap-x-4`,children:[(0,E.jsx)(y,{label:`Amount`,value:(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,E.jsx)(s,{kind:e.kind}),p(e.amount),` `,d(e.paymentRun.currency)]})}),(0,E.jsx)(y,{label:`Payee`,value:n}),(0,E.jsx)(y,{label:`Payment Run`,value:(0,E.jsxs)(`span`,{children:[(0,E.jsxs)(a,{to:{pathname:`/payments/paymentRuns/${e.paymentRun.id}`,search:t},preventScrollReset:!0,className:`link`,children:[`#`,e.paymentRun.id]}),e.paymentRun.description&&(0,E.jsx)(`span`,{className:`ml-2 italic text-muted-foreground`,children:e.paymentRun.description})]})}),(0,E.jsx)(y,{label:`Paid`,value:u(e.paymentRun.createdAt,!1)}),(0,E.jsx)(y,{label:`Pay On`,value:f(e.paymentRun.payOn)}),(0,E.jsx)(y,{label:`Run By`,value:e.runByName})]})}function k({payment:n,closeLocation:i}
1){let o=r(),s=t(),l=e(),d=e(),{depth:f}=g(),p=f>0,y=`/payments/${n.id}${p?`?stacked=1`:``}`,S=!!n.voidedAt,w=l.state!==`idle`,k=d.state!==`idle`,A=()=>{l.submit({intent:`void`,returnSearch:h(o.search)},{method:`post`,action:y})},j=()=>{d.submit({intent:`delete`,returnSearch:h(o.search)},{method:`post`,action:y})},M=d.data?.deleted;(0,x.useEffect)(()=>{M&&s(i)},[M]);let N=(0,E.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,E.jsx)(T,{className:`hidden h-4 w-4 sm:block`}),(0,E.jsx)(`div`,{children:`Edit`})]});return(0,E.jsx)(_,{recordKey:n.id,documentTitle:`Payment #${n.id}`,title:b(n),description:(0,E.jsxs)(`div`,{className:`flex h-full items-center gap-2 sm:gap-4`,children:[!S&&(0,E.jsx)(a,{className:`link text-sm`,to:`/payments/${n.id}/edit`,preventScrollReset:!0,children:N}),!S&&(0,E.jsx)(m,{content:`Void preserves the audit record. Voided payments stay on the list (struck through) and their invoices are released for a future payment run. Continue?`,confirmText:`Void`,onConfirm:A,children:(0,E.jsx)(`button`,{type:`button`,className:`link text-sm disabled:opacity-50`,disabled:w,children:(0,E.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,E.jsx)(C,{className:`hidden h-4 w-4 sm:block`}),(0,E.jsx)(`div`,{children:w?`Voidingâ¦`:`Void`})]})})}),(0,E.jsx)(m,{content:`Delete removes the payment entirely (use only for accidental-create errors). Invoices will be released. Continue?`,confirmText:`Delete`,theme:`destructive`,onConfirm:j,children:(0,E.jsx)(`button`,{type:`button`,className:`link text-sm disabled:opacity-50`,disabled:k,children:(0,E.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,E.jsx)(c,{className:`hidden h-4 w-4 sm:block`}),(0,E.jsx)(`div`,{children:k?`Deletingâ¦`:`Delete`})]})})})]}),preventScrollResetOnClose:!0,closeLocation:i,children:(0,E.jsxs)(`div`,{className:`space-y-8 px-4 py-6 sm:px-6`,children:[S&&(0,E.jsxs)(`div`,{className:`rounded-md border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-900`,children:[`This payment was voided on`,` `,u(n.voidedAt,!0),`. Its invoices have been released for a future payment run.`]}),(0,E.jsx)(O,{payment:n}),(0,E.jsx)(D,{payment:n}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-gray-900`,children:`Notes`}),(0,E.jsx)(v,{notableId:n.id,notableType:`Payment`})]})]})})}export{k as t};
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.