2 lines
		
	
	
		
			7.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			2 lines
		
	
	
		
			7.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
import{u as F,d as B,f as D,z as I,j as m,H as O,c as n,be as P,h as T,dV as E,m as w,O as k,c0 as L,p as R,x as z,C as A,ax as H,bs as x,c6 as j,I as q,c7 as M,bx as G}from"./bundle.293347bb.js";import{u as J,C as K}from"./bundle.486d5ac1.js";import{P as Q}from"./bundle.ab119c46.js";import{I as U}from"./bundle.876f2b18.js";import{C as W}from"./bundle.fa74b961.js";import"./bundle.51e1486d.js";function X(e,d){var o;const u=(o=e==null?void 0:e.invoices)==null?void 0:o.find(l=>l.id==d.invoice_id);return(u==null?void 0:u.number)||""}function Y(e){var t,i,g,$,c,s,r,h,y,_,f,v;const[d]=F(),u=B(),{dateFormat:o}=D(),l=I();return m(O,{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:l.$3,colorScheme:l.$0},children:[`${d("invoice")} `,n(P,{to:T("/invoices/:id/edit",{id:e.paymentable.invoice_id}),children:m("span",{className:"flex items-center gap-2",style:{color:l.$3,colorScheme:l.$0},children:[X(e.payment,e.paymentable)," ",n(E,{})]})})]})}),m("div",{className:"flex items-center justify-center",children:[n("span",{style:{color:l.$3,colorScheme:l.$0},children:u(((t=e==null?void 0:e.paymentable)==null?void 0:t.amount)||0,(i=e.payment.client)==null?void 0:i.country_id,(g=e.payment)==null?void 0:g.currency_id)}),n("span",{className:"mx-5",style:{color:l.$3,colorScheme:l.$0},children:w(new Date(e.paymentable.created_at*1e3).toString(),o)}),e.paymentable.refunded>0&&m("span",{className:"",style:{color:"red",colorScheme:l.$0},children:["( ",u((($=e==null?void 0:e.paymentable)==null?void 0:$.refunded)||0,(c=e.payment.client)==null?void 0:c.country_id,(s=e.payment)==null?void 0:s.currency_id)," ",d("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:n("span",{style:{color:l.$3,colorScheme:l.$0},children:n(P,{to:T("/credits/:id/edit",{id:e.paymentable.credit_id}),children:`${d("credit")} `})})}),m("div",{className:"flex items-center justify-center",children:[n("span",{style:{color:l.$3,colorScheme:l.$0},children:u(((r=e==null?void 0:e.paymentable)==null?void 0:r.amount)||0,(h=e.payment.client)==null?void 0:h.country_id,(y=e.payment)==null?void 0:y.currency_id)}),n("span",{className:"mx-5",style:{color:l.$3,colorScheme:l.$0},children:w(new Date(e.paymentable.created_at*1e3).toString(),o)}),e.paymentable.refunded>0&&m("span",{className:"",style:{color:"red",colorScheme:l.$0},children:["( ",u(((_=e==null?void 0:e.paymentable)==null?void 0:_.refunded)||0,(f=e.payment.client)==null?void 0:f.country_id,(v=e.payment)==null?void 0:v.currency_id)," ",d("refunded")," )"]})]})]})]})}function Z(e){var l,t,i,g,$,c,s,r,h,y,_,f,v,S,C;const[d]=F(),u=B(),o=I();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:`${d("amount")}: ${u(((l=e==null?void 0:e.payment)==null?void 0:l.amount)||0,(t=e.payment.client)==null?void 0:t.country_id,(i=e.payment)==null?void 0:i.currency_id)}`})}),n("div",{className:"flex items-center justify-center",children:n("span",{style:{color:o.$3,colorScheme:o.$0},children:`${d("applied")}: ${u(((g=e==null?void 0:e.payment)==null?void 0:g.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(Q,{entity:e.payment})}),n("div",{className:"flex items-center justify-center",children:n("span",{style:{color:o.$3,colorScheme:o.$0},children:`${d("refunded")}: ${u(((s=e==null?void 0:e.payment)==null?void 0:s.refunded)||0,(r=e.payment.client)==null?void 0:r.country_id,(h=e.payment)==null?void 0:h.currency_id)}`})}),((y=e==null?void 0:e.payment)==null?void 0:y.applied)<((_=e==null?void 0:e.payment)==null?void 0:_.amount)&&m(O,{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:`${d("unapplied")}: ${u(((f=e==null?void 0:e.payment)==null?void 0:f.amount)-((v=e==null?void 0:e.payment)==null?void 0:v.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(Y,{payment:e.payment,paymentable:b},b.id))})]})}function p(e){const[d]=F(),{client:u}=e;return n(O,{children:u&&n("div",{className:"col-span-12 lg:col-span-3",children:n(U,{title:d("client"),value:n(W,{displayClientName:!0,client:u}),className:"h-full"})})})}function ie(){var h,y,_,f,v,S,C,b;const{documentTitle:e}=k("edit_payment"),[d]=F(),u=J(),o=L(),{setPayment:l,payment:t,errors:i}=o,[g,$]=R.useState(!!(t!=null&&t.exchange_currency_id)),c=z(),s=I(),r=(a,N)=>{l(V=>V&&{...V,[a]:N})};return m(A,{title:e,children:[(t==null?void 0:t.client)&&n(p,{client:t.client}),t&&n(Z,{payment:t}),n(H,{}),n(x,{leftSide:d("payment_number"),children:n(j,{style:{color:s.$3,colorScheme:s.$0},id:"number",value:t==null?void 0:t.number,onValueChange:a=>r("number",a),errorMessage:i==null?void 0:i.errors.number})}),n(x,{leftSide:d("payment_date"),children:n(j,{style:{color:s.$3,colorScheme:s.$0},id:"date",type:"date",value:t==null?void 0:t.date,onValueChange:a=>r("date",a),errorMessage:i==null?void 0:i.errors.date})}),n(x,{leftSide:d("payment_type"),children:n(q,{style:{color:s.$3,colorScheme:s.$0},id:"type_id",value:t==null?void 0:t.type_id,onValueChange:a=>r("type_id",a),errorMessage:i==null?void 0:i.errors.type_id,withBlank:!0,children:u.map(([a,N],V)=>n("option",{value:a,children:N},V))})}),n(x,{leftSide:d("transaction_reference"),children:n(j,{style:{color:s.$3,colorScheme:s.$0},id:"transaction_reference",onValueChange:a=>r("transaction_reference",a),value:t==null?void 0:t.transaction_reference,errorMessage:i==null?void 0:i.errors.transaction_reference})}),n(x,{leftSide:d("private_notes"),children:n(j,{style:{color:s.$3,colorScheme:s.$0},element:"textarea",id:"private_notes",value:t==null?void 0:t.private_notes,onValueChange:a=>r("private_notes",a),errorMessage:i==null?void 0:i.errors.private_notes})}),((h=c==null?void 0:c.custom_fields)==null?void 0:h.payment1)&&n(M,{field:"custom_value1",defaultValue:t==null?void 0:t.custom_value1,value:(y=c==null?void 0:c.custom_fields)==null?void 0:y.payment1,onValueChange:a=>r("custom_value1",a.toString())}),((_=c==null?void 0:c.custom_fields)==null?void 0:_.payment2)&&n(M,{field:"custom_value2",defaultValue:t==null?void 0:t.custom_value2,value:(f=c==null?void 0:c.custom_fields)==null?void 0:f.payment2,onValueChange:a=>r("custom_value2",a.toString())}),((v=c==null?void 0:c.custom_fields)==null?void 0:v.payment3)&&n(M,{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:a=>r("custom_value3",a.toString())}),((C=c==null?void 0:c.custom_fields)==null?void 0:C.payment4)&&n(M,{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:a=>r("custom_value4",a.toString())}),n(x,{leftSide:d("convert_currency"),children:n(G,{style:{color:s.$3,colorScheme:s.$0},checked:!!(t!=null&&t.exchange_currency_id),onChange:a=>{$(a),a||(r("exchange_currency_id",""),r("exchange_rate",1))}})}),t&&(!!(t!=null&&t.exchange_currency_id)||g)&&n(K,{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:(a,N)=>{r("exchange_rate",a),r("exchange_currency_id",N)},onExchangeRateChange:a=>r("exchange_rate",a)})]})}export{ie as default};
 |