1 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="414be5d8-2b70-5880-8c2e-f241b19d76f5")}catch(e){}}(); 3import{bN as F,aJ as q,V as f,Q as $,W as P,R as e,bJ as N,b5 as V,b6 as k,ao as U,dO as W,b7 as _,c3 as j,c2 as K,aS as z,c1 as B,b9 as Q,ba as J,bV as h,bY as D,bi as m,bk as O,ee as Y,bj as G,ac as X,aD as Z,aU as ee,aj as ae,bs as te}from"./index-Cs-In7Vx.js";import{b as ne,u as T,a as re,d as oe,g as se,P as ie}from"./PaymentMethodsDialog-Uf28_Bj_.js";import{u as le}from"./useFinancialAccountsLite-LZoNKcV7.js";import{A as ce}from"./AutocompleteField-CYdBf8gZ.js";import{A as C}from"./index-Dpr9l0yn.js";import"./CreationAndUpdateInfo-CcB-rkli.js";import"./SearchTextInput-Gprlx1Wp.js";const g=F(a=>({open:!1,selectedPaymentMethod:null,defaultValues:{},openDialog:t=>a({open:!0,selectedPaymentMethod:t,defaultValues:{}}),closeDialog:()=>a({open:!1})})),de=a=>$.get(a).then(t=>t.data),x="/api/v2/financial/payment_methods/order_payment_methods";function me(a){const t=f.queryParamsObjectToString(a);return t?`${x}?${t}`:x}function fe(){return a=>typeof a=="string"&&a.startsWith(x)}function ue(a){const{data:t,error:i,mutate:r,isLoading:c}=q(me(a),de,{dedupingInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,keepPreviousData:!0});return{data:t,isLoading:c,isError:i,mutate:r}}function pe(a){return f.currencyStringToFloat(a)>=0}const _e=Q().shape({fin_account_id:h().required("Informe a conta"),fin_days_to_receive:h().transform((a,t)=>t===""?null:a).typeError("Dias para recebimento deve ser um número").nullable().optional(),fin_fee_rate:h().transform((a,t)=>t===""?null:a).typeError("Taxa percentual deve ser um número").nullable().optional(),fin_fee_fixed:J().trim().test("value","Valor inválido",pe).nullable().optional()}),ge={fin_account_id:"",fin_days_to_receive:"",fin_fee_rate:"",fin_fee_fixed:""};function be(){const a=P(),[t,i]=e.useState(!1),{mutate:r}=N(),c=g(o=>o.open),{data:n,isLoading:b,isError:y}=le(),l=g(o=>o.selectedPaymentMethod),s=g(o=>o.closeDialog),u=V({mode:"onSubmit",resolver:k(_e)}),{handleSubmit:E,reset:M,setValue:I,formState:w,control:p}=u;e.useEffect(()=>{c&&M({...l||ge})},[l,c,M]);const H=e.useCallback(async o=>{i(!0);const v={fin_account_id:o.fin_account_id,fin_days_to_receive:o.fin_days_to_receive||null,fin_fee_rate:o.fin_fee_rate||null,fin_fee_fixed:o.fin_fee_fixed?f.currencyStringToFloat(o.fin_fee_fixed):null};try{await ne(l?.id,v),await r(fe()),s()}catch(R){a.error(R.response?.data?.message||"Não foi possÃvel editar a forma de pagamento")}i(!1)},[r,s,l?.id,a]),L=e.useMemo(()=>l?.fin_account_id?n?.find(v=>v.id===l?.fin_account_id)?n||[]:[...n||[],l.fin_account]:n||[],[n,l]),{errors:d}=w;return e.createElement(U,{open:c,title:`Editar forma de pagamento ${l?.name}`,loading:t,onClose:s,onSubmit:E(H)},e.createElement(W,{...u},e.createElement("div",{className:"space-y-24"},e.createElement(_,{name:"fin_account_id",control:p,defaultValue:"",render:({field:o})=>e.createElement(ce,{...o,id:"fin_account_id",label:"Conta",options:L,error:!!d.fin_account_id||y,errorText:d?.fin_account_id?.message||"Erro ao carregar as contas",setValue:I,loading:b,noOptionsText:"Nenhuma conta encontrada",placeholder:"Selecione uma conta"})}),e.createElement(_,{name:"fin_days_to_receive",control:p,render:({field:o})=>e.createElement(j,{...o,id:"fin_days_to_receive",label:"Dias para recebimento",placeholder:"0 (Na hora)",error:!!d.fin_days_to_receive,helperText:d?.fin_days_to_receive?.message,size:"medium"})}),e.createElement(_,{name:"fin_fee_rate",control:p,render:({field:o})=>e.createElement(K,{...o,id:"fin_fee_rate",label:"Taxa percentual",placeholder:"0,00",error:!!d.fin_fee_rate,helperText:d?.fin_fee_rate?.message,InputProps:{endAdornment:e.createElement(z,{position:"end"},"%")},size:"medium"})}),e.createElement(_,{name:"fin_fee_fixed",control:p,render:({field:o})=>e.createElement(B,{...o,id:"fin_fee_fixed",label:"Taxa fixa",error:!!d.fin_fee_fixed,helperText:d?.fin_fee_fixed?.message,size:"medium",variant:"outlined",fullWidth:!0})}))))}const S=F(a=>({filters:{q:{}},updateFilter:(t,i)=>a(r=>({...r,filters:{...r.filters,[t]:i}}))})),ye=[{field:"active",label:"Status",type:"list_eq_required",valueOptions:[{id:"true",label:"Ativa"},{id:"false",label:"Inativa"}],valueOptionKey:"id",valueOptionLabel:"label"},{field:"fin_days_to_receive",label:"Dias para recebimento",type:"number"},{field:"fin_fee_rate",label:"Taxa percentual",type:"number"},{field:"fin_fee_fixed",label:"Taxa fixa",type:"number"}],Ee=[{field:"name",label:"Forma de pagamento",operation:"i_cont",type:"string",valueInputProps:{placeholder:"Pesquise pelo nome"}}
3];function ve(){const a=S(t=>t.updateFilter);return e.createElement(C,{fields:ye,fixedFields:Ee,onFilterChange:t=>a("q",t),wrapperClassName:null})}const he={active:e.createElement(m,{color:"green"},"Ativa"),inactive:e.createElement(m,{color:"red"},"Inativa")};function xe(a){return a?a>=1?`D + ${a}`:e.createElement(m,{color:"grey"},"Não informado"):"Na hora"}function Fe(){const a=g(n=>n.openDialog),t=S(n=>n.filters),{data:i,isLoading:r,isError:c}=ue(t);return e.createElement(D,{data:i,stickyHeader:!0,loadingRowsQuantity:5,loading:r,showError:c,defaultOrder:"active",defaultOrderBy:"desc",columns:[{Header:"Nome",accessor:"name",sortable:!1,className:"font-bold"},{Header:"Conta de recebimento",accessor:"fin_account",sortable:!1,formatDataFunction:n=>n?.name||e.createElement(m,{color:"red"},"Não informada")},{Header:"Dias para recebimento",accessor:"fin_days_to_receive",sortable:!1,formatDataFunction:n=>xe(n)},{Header:"Taxa percentual",accessor:"fin_fee_rate",formatDataFunction:n=>n?`${f.formatNumber(n)} %`:"-",sortable:!1},{Header:"Taxa fixa",accessor:"fin_fee_fixed",formatDataFunction:n=>n?f.formatMonetaryValue(n):"-",sortable:!1},{Header:"Status",accessor:"active",sortable:!1,formatDataFunction:n=>he[n?"active":"inactive"]},{Header:"",sortable:!1,align:"right",Cell:({row:n})=>e.createElement("div",{className:"flex w-full justify-end space-x-12"},e.createElement(O,{tooltip:"Editar",onClick:()=>a(n),disabled:n.kind===Y.money.id},e.createElement(G,{color:"inherit"})))}]})}const A=F(a=>({filters:{q:{}},updateFilter:(t,i)=>a(r=>({...r,filters:{...r.filters,[t]:i}}))})),Me=[{field:"active",label:"Status",type:"list_eq_required",valueOptions:[{id:"true",label:"Ativa"},{id:"false",label:"Inativa"}],valueOptionKey:"id",valueOptionLabel:"label"}],Pe=[{field:"name",label:"Forma de pagamento",operation:"i_cont",type:"string",valueInputProps:{placeholder:"Pesquise pelo nome"}}
3];function Ne(){const a=A(r=>r.updateFilter),t=T(r=>r.openDialogOnCreate),{hasUserPermissions:i}=X();return e.createElement(C,{fields:Me,fixedFields:Pe,onFilterChange:r=>a("q",r),wrapperClassName:null,actions:i(Z.FINANCIAL_CREATE_PAYMENT_METHOD)&&e.createElement("button",{className:"my-6 inline-flex cursor-pointer items-center space-x-12 whitespace-nowrap rounded-6 border border-solid border-gray-200 bg-gray-50 py-8 pl-12 pr-16 text-16 font-bold text-gray-600 hover:bg-gray-100",onClick:()=>t()},e.createElement(ee,null)," ",e.createElement("span",null,"Nova forma de pagamento"))})}const De={active:e.createElement(m,{color:"green"},"Ativa"),inactive:e.createElement(m,{color:"red"},"Inativa")};function Oe(){const a=P(),t=ae(),{mutate:i}=N(),r=T(s=>s.openDialogOnEdit),c=A(s=>s.filters),{data:n,isLoading:b,isError:y}=re(c),l=s=>async()=>{try{await t({title:"Confirmar exclusão da forma de pagamento?",cancellationText:"Voltar ",confirmationText:"Excluir"});try{await oe(s),await i(se()),a.success("Forma de pagamento excluÃda com sucesso!")}catch(u){const E=u.response?.data?.message;a.error(E||"Não foi possÃvel excluir a forma de pagamento")}}catch{}};return e.createElement(D,{data:n,stickyHeader:!0,onRowClick:s=>r(s),loadingRowsQuantity:5,loading:b,showError:y,defaultOrder:"active",defaultOrderBy:"desc",columns:[{Header:"Nome",accessor:"name",sortable:!1,className:"font-bold"},{Header:"Status",accessor:"active",sortable:!1,formatDataFunction:s=>De[s?"active":"inactive"]},{Header:"",sortable:!1,align:"right",Cell:({row:s})=>e.createElement("div",{className:"flex w-full justify-end space-x-12"},e.createElement(O,{tooltip:"Excluir",onClick:l(s.id),disabled:s.is_default},e.createElement(te,{color:"inherit"})))}]})}function Re(){return e.createElement("div",{className:"flex w-full flex-1 flex-col space-y-60 pb-16 sm:pb-24"},e.createElement("div",{className:"space-y-12 sm:space-y-16"},e.createElement("div",{className:"space-y-1"},e.createElement("div",{className:"text-20 font-bold text-gray-600"},"Formas de pagamento do financeiro"),e.createElement("div",{className:"text-16 font-light text-gray-600"},"Essas formas de pagamento são usadas para registrar as entradas e saÃdas financeiras.")),e.createElement(Ne,null),e.createElement("div",null,e.createElement(Oe,null))),e.createElement("div",{className:"space-y-12 sm:space-y-16"},e.createElement("div",{className:"space-y-1"},e.createElement("div",{className:"text-20 font-bold text-gray-600"},"Configurar formas de pagamentos dos pedidos"),e.createElement("div",{className:"text-16 font-light text-gray-600"},"Essas são as formas de pagamento usadas nos pedidos. Algumas configurações especÃficas devem ser modificadas em"," ",e.createElement("strong",{className:"font-bold"},"Minha empresa -",">"," Formas de pagamento"),".")),e.createElement(ve,null),e.createElement("div",null,e.createElement(Fe,null))),e.createElement(ie,null),e.createElement(be,null))}export{Re as default}; 4 5//# debugId=414be5d8-2b70-5880-8c2e-f241b19d76f5
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.