ruạṛ
import{u as M,d as A,f as L,z as w,j as m,H as B,c as n,bf as F,h as T,ay as P,cn as E,m as k,T as O,cl as R,p as z,x as H,C as q,aA as G,bv as x,cs as V,I as J,cu as I,bA as K}from"./bundle.9abe88c8.js";import{u as Q,C as U}from"./usePaymentTypes-db32e981.js";import{P as W}from"./PaymentStatus-030854d8.js";import{I as X}from"./InfoCard-3b3f3798.js";import{C as Y}from"./ClientActionButtons-a4f20d96.js";import"./payment-status-51e1486d.js";function D(e,r,s){var i,t;if(s){const a=(i=e==null?void 0:e.credits)==null?void 0:i.find(h=>h.id==r.credit_id);return(a==null?void 0:a.number)||""}const o=(t=e==null?void 0:e.invoices)==null?void 0:t.find(a=>a.id==r.invoice_id);return(o==null?void 0:o.number)||""}function Z(e){var t,a,h,$,c,u,d,y,f,_,v,g;const[r]=M(),s=A(),{dateFormat:o}=L(),i=w();return m(B,{children:[e.paymentable.invoice_id&&m("div",{className:"grid grid-cols-1 gap-2 my-2 border border-x-5 py-4",children:[n("div",{className:"flex items-center justify-center",children:m("span",{className:"flex item-center gap-2",style:{color:i.$3,colorScheme:i.$0},children:[`${r("invoice")} `,n(F,{to:T("/invoices/:id/edit",{id:e.paymentable.invoice_id}),children:m("div",{className:"flex items-center gap-2",style:{color:i.$3,colorScheme:i.$0},children:[n("span",{children:D(e.payment,e.paymentable)}),n("div",{children:n(P,{element:E,style:{width:"1.1rem",height:"1.1rem",marginBottom:"0.27rem"}})})]})})]})}),m("div",{className:"flex items-center justify-center",children:[n("span",{style:{color:i.$3,colorScheme:i.$0},children:s(((t=e==null?void 0:e.paymentable)==null?void 0:t.amount)||0,(a=e.payment.client)==null?void 0:a.country_id,(h=e.payment)==null?void 0:h.currency_id)}),n("span",{className:"mx-5",style:{color:i.$3,colorScheme:i.$0},children:k(new Date(e.paymentable.created_at*1e3).toString(),o)}),e.paymentable.refunded>0&&m("span",{style:{color:"red",colorScheme:i.$0},children:["("," ",s((($=e==null?void 0:e.paymentable)==null?void 0:$.refunded)||0,(c=e.payment.client)==null?void 0:c.country_id,(u=e.payment)==null?void 0:u.currency_id)," ",r("refunded")," )"]})]})]}),e.paymentable.credit_id&&m("div",{className:"grid grid-cols-1 gap-2 my-2 border border-x-5 py-4",children:[n("div",{className:"flex items-center justify-center",children:m("span",{className:"flex item-center gap-2",style:{color:i.$3,colorScheme:i.$0},children:[`${r("credit")} `,n(F,{to:T("/credits/:id/edit",{id:e.paymentable.credit_id}),children:m("div",{className:"flex items-center gap-2",style:{color:i.$3,colorScheme:i.$0},children:[n("span",{children:D(e.payment,e.paymentable,!0)}),n("div",{children:n(P,{element:E,style:{width:"1.1rem",height:"1.1rem",marginBottom:"0.27rem"}})})]})})]})}),m("div",{className:"flex items-center justify-center",children:[n("span",{style:{color:i.$3,colorScheme:i.$0},children:s(((d=e==null?void 0:e.paymentable)==null?void 0:d.amount)||0,(y=e.payment.client)==null?void 0:y.country_id,(f=e.payment)==null?void 0:f.currency_id)}),n("span",{className:"mx-5",style:{color:i.$3,colorScheme:i.$0},children:k(new Date(e.paymentable.created_at*1e3).toString(),o)}),e.paymentable.refunded>0&&m("span",{style:{color:"red",colorScheme:i.$0},children:["("," ",s(((_=e==null?void 0:e.paymentable)==null?void 0:_.refunded)||0,(v=e.payment.client)==null?void 0:v.country_id,(g=e.payment)==null?void 0:g.currency_id)," ",r("refunded")," )"]})]})]})]})}function p(e){var i,t,a,h,$,c,u,d,y,f,_,v,g,S,C;const[r]=M(),s=A(),o=w();return m("div",{children:[m("div",{className:"grid grid-cols-2 gap-4 my-4",children:[n("div",{className:"flex items-center justify-center",children:n("span",{style:{color:o.$3,colorScheme:o.$0},children:`${r("amount")}: ${s(((i=e==null?void 0:e.payment)==null?void 0:i.amount)||0,(t=e.payment.client)==null?void 0:t.country_id,(a=e.payment)==null?void 0:a.currency_id)}`})}),n("div",{className:"flex items-center justify-center",children:n("span",{style:{color:o.$3,colorScheme:o.$0},children:`${r("applied")}: ${s(((h=e==null?void 0:e.payment)==null?void 0:h.applied)||0,($=e.payment.client)==null?void 0:$.country_id,(c=e.payment)==null?void 0:c.currency_id)}`})}),n("div",{className:"flex items-center justify-center",children:n(W,{entity:e.payment})}),n("div",{className:"flex items-center justify-center",children:n("span",{style:{color:o.$3,colorScheme:o.$0},children:`${r("refunded")}: ${s(((u=e==null?void 0:e.payment)==null?void 0:u.refunded)||0,(d=e.payment.client)==null?void 0:d.country_id,(y=e.payment)==null?void 0:y.currency_id)}`})}),((f=e==null?void 0:e.payment)==null?void 0:f.applied)<((_=e==null?void 0:e.payment)==null?void 0:_.amount)&&m(B,{children:[n("div",{className:"flex items-center justify-center"}),n("div",{className:"flex items-center justify-center",children:n("span",{style:{color:o.$3,colorScheme:o.$0},children:`${r("unapplied")}: ${s(((v=e==null?void 0:e.payment)==null?void 0:v.amount)-((g=e==null?void 0:e.payment)==null?void 0:g.applied)||0,(S=e.payment.client)==null?void 0:S.country_id,(C=e.payment)==null?void 0:C.currency_id)}`})})]})]}),n("div",{children:e.payment.paymentables.map(b=>n(Z,{payment:e.payment,paymentable:b},b.id))})]})}function ee(e){const[r]=M(),{client:s}=e;return n(B,{children:s&&n("div",{className:"col-span-12 lg:col-span-3",children:n(X,{title:r("client"),value:n(Y,{displayClientName:!0,client:s}),className:"h-full"})})})}function re(){var y,f,_,v,g,S,C,b;const{documentTitle:e}=O("edit_payment"),[r]=M(),s=Q(),o=R(),{setPayment:i,payment:t,errors:a}=o,[h,$]=z.useState(!!(t!=null&&t.exchange_currency_id)),c=H(),u=w(),d=(l,N)=>{i(j=>j&&{...j,[l]:N})};return m(q,{title:e,children:[(t==null?void 0:t.client)&&n(ee,{client:t.client}),t&&n(p,{payment:t}),n(G,{}),n(x,{leftSide:r("payment_number"),children:n(V,{style:{color:u.$3,colorScheme:u.$0},id:"number",value:t==null?void 0:t.number,onValueChange:l=>d("number",l),errorMessage:a==null?void 0:a.errors.number})}),n(x,{leftSide:r("payment_date"),children:n(V,{style:{color:u.$3,colorScheme:u.$0},id:"date",type:"date",value:t==null?void 0:t.date,onValueChange:l=>d("date",l),errorMessage:a==null?void 0:a.errors.date})}),n(x,{leftSide:r("payment_type"),children:n(J,{value:t==null?void 0:t.type_id,onValueChange:l=>d("type_id",l),errorMessage:a==null?void 0:a.errors.type_id,withBlank:!0,customSelector:!0,style:{color:u.$3,colorScheme:u.$0},children:s.map(([l,N],j)=>n("option",{value:l,children:N},j))})}),n(x,{leftSide:r("transaction_reference"),children:n(V,{style:{color:u.$3,colorScheme:u.$0},id:"transaction_reference",onValueChange:l=>d("transaction_reference",l),value:t==null?void 0:t.transaction_reference,errorMessage:a==null?void 0:a.errors.transaction_reference})}),n(x,{leftSide:r("private_notes"),children:n(V,{style:{color:u.$3,colorScheme:u.$0},element:"textarea",id:"private_notes",value:t==null?void 0:t.private_notes,onValueChange:l=>d("private_notes",l),errorMessage:a==null?void 0:a.errors.private_notes})}),((y=c==null?void 0:c.custom_fields)==null?void 0:y.payment1)&&n(I,{field:"custom_value1",defaultValue:t==null?void 0:t.custom_value1,value:(f=c==null?void 0:c.custom_fields)==null?void 0:f.payment1,onValueChange:l=>d("custom_value1",l.toString())}),((_=c==null?void 0:c.custom_fields)==null?void 0:_.payment2)&&n(I,{field:"custom_value2",defaultValue:t==null?void 0:t.custom_value2,value:(v=c==null?void 0:c.custom_fields)==null?void 0:v.payment2,onValueChange:l=>d("custom_value2",l.toString())}),((g=c==null?void 0:c.custom_fields)==null?void 0:g.payment3)&&n(I,{field:"custom_value3",defaultValue:t==null?void 0:t.custom_value3,value:(S=c==null?void 0:c.custom_fields)==null?void 0:S.payment3,onValueChange:l=>d("custom_value3",l.toString())}),((C=c==null?void 0:c.custom_fields)==null?void 0:C.payment4)&&n(I,{field:"custom_value4",defaultValue:t==null?void 0:t.custom_value4,value:(b=c==null?void 0:c.custom_fields)==null?void 0:b.payment4,onValueChange:l=>d("custom_value4",l.toString())}),n(x,{leftSide:r("convert_currency"),children:n(K,{style:{color:u.$3,colorScheme:u.$0},checked:!!(t!=null&&t.exchange_currency_id),onChange:l=>{$(l),l||(d("exchange_currency_id",""),d("exchange_rate",1))}})}),t&&(!!(t!=null&&t.exchange_currency_id)||h)&&n(U,{exchangeRate:t.exchange_rate.toString()||"1",exchangeCurrencyId:t.exchange_currency_id||"1",currencyId:t.currency_id||"1",amount:t==null?void 0:t.amount,onChange:(l,N)=>{d("exchange_rate",l),d("exchange_currency_id",N)},onExchangeRateChange:l=>d("exchange_rate",l)})]})}export{re as default};
cải xoăn