1import{r as b,fr as h,k5 as C,a0 as l,a1 as n,j as e,a4 as j,a5 as I,a6 as E,ad as u,hh as _,f4 as g,I as M,la as S,l5 as v,eH as F,ah as N}from"./index-Q1iXNk99.js";import{b as c}from"./FICAutocomplete-C-NmwFv3.js";import{_ as D}from"./useCompanyRegistryActivationPermissions-l6SE_hl0.js";import{F as L}from"./FICModule-sJUKROR-.js";import{a as A}from"./FICModuleTitle-CG-_7DU3.js";import{F as f,b as B,a as x}from"./FICPageSection-BnLT3aGG.js";import{i as p}from"./objectUtils-CaUc5Oqv.js";import{F as T,a as w}from"./FICFormGenerator-JXGxSFjb.js";import"./FICTooltip-C8aKWVwm.js";import"./VaporIconBase-DKBiqbaD.js";import"./IssuedDocumentHelper-glpQaO12.js";import"./documents-Bj0mKn64.js";import"./ValidatedInput-bECwFuQ2.js";import"./mapRoutes-Bk_cS7Ze.js";import"./index-CBqSKsdP.js";import"./FICInputText-C9LNsxWR.js";import"./FICLabel-CM82NjUS.js";const r=[{campo:"es. IBAN, e-mail...",desc:"es. IT02L1234512345123456789012",label:"Parametri per il pagamento:",label2:" "},{campo:"es. Intestatario",desc:"es. Mario Rossi"},{campo:"(opzionale)",desc:""},{campo:"(opzionale)",desc:""},{campo:"(opzionale)",desc:""}];class z extends b.Component{constructor(t){super(t),this.state=h.clone(t.method)}getUsefulAccounts=t=>{const s=[];return t.map(a=>s.push({value:a.id,label:a.name})),s};handleChange=(t,s)=>{let a=h.clone(this.state);C(a,t,s),a=this.getNormalizedState(a),a.ibanError=void 0;const o=a.name?.trim()||"";if(o&&p(o)&&(a.ibanError="L'IBAN inserito non è valido"),!a.ibanError&&a.details&&Array.isArray(a.details))for(let i=0;i<a.details.length;i++){const d=a.details[i]?.title?.trim()||"",m=a.details[i]?.description?.trim()||"";if(d&&p(d)||m&&p(m)){a.ibanError="L'IBAN inserito non è valido";break}}this.setState(a)};getNormalizedState=t=>(t.type!=="riba"&&(t.default_payment_account=null),t);saveMethod=(t,s)=>{const a=t.id>0?l.put:l.post,o=t.id>0?"/"+t.id:"";if(t.type==="riba"&&(!t.default_payment_account||!t.default_payment_account.id)){n.error("Seleziona un conto da collegare");return}a({request:"settings/payment_methods"+o,postData:{data:t,_form_mapping:s.getMapping()},onSuccess:()=>{n.success(t.id>0?"Modalità di pagamento modificato.":"Modalità di pagamento creato."),this.props.onEdit(),this.props.hide()},onError:i=>{i?.error?.code==="USER_BANNED"&&this.props.hide()}})};render(){const t=this.getUsefulAccounts(this.props.accountsList),s=[{type:"text",name:"name",label:"Nome modalità :",placeholder:"Inserisci la modalità di pagamento",onBlur:()=>{this.state.ibanError&&n.warning(this.state.ibanError)},mapping:{name:"il nome",gender:"m"}},{type:"checkbox",name:"is_default",text:"Utilizza come modalità predefinita"},{type:"column-layout-lite",content:[{type:"select",name:"type",label:"Tipologia:",options:this.props.methodTypes,placeholder:"Seleziona la tipologia",mapping:{name:"la tipologia",gender:"f"}},{type:"select",name:"default_payment_account.id",label:"Conto collegato:",options:t,placeholder:"Seleziona il conto",mapping:{name:"il conto collegato",gender:"m"},props:{clearable:!0},hide:i=>i.type!=="riba"}]}];for(let i=0;i<5;i++)s.push({type:"column-layout-lite",content:[{type:"text",name:"details["+i+"].title",label:r[i].label,placeholder:r[i].campo,onBlur:()=>{this.state.ibanError&&n.warning(this.state.ibanError)},mapping:{name:"il titolo del "+i+"° parametro di pagamento",gender:"m"},props:{maxLength:32}},{type:"text",name:"details["+i+"].description",label:r[i].label2,placeholder:r[i].desc,onBlur:()=>{this.state.ibanError&&n.warning(this.state.ibanError)},mapping:{name:"il valore del "+i+"° parametro di pagamento",gender:"m"},props:{maxLength:64}}]});const a=T.create({type:"column",content:s}),o=[{text:"Chiudi",color:"white",onClick:this.props.hide},{text:"Salva",color:"green",isDisabled:!!this.state.ibanError,onClick:()=>{if(this.state.ibanError){n.warning(this.state.ibanError);return}this.saveMethod(this.state,a)}}];return e.jsxs("div",{children:[e.jsx(j,{html:this.state.id>0?"Modifica modalità di pagamento":"Aggiungi modalità di pagamento"}),e.jsx(I,{children:e.jsx(w,{config:a,data:this.state,onChange:this.handleChange})}),e.jsx(E,{buttons:o})]})}}class P extends b.Component{constructor(t){super(t),this.state={accountsList:[],methodsList:[]},this.loadAccountsData(),this.loadMethodsData(),this.accountTypes=[{value:"standard",label:"Conto standard (predefinito)"},{value:"bank",label:"Conto bancario"}],this.methodTypes=[{value:"standard",label:"Standard (predefinita)"},{value:"riba",label:"Ricevuta bancaria"}]}loadAccountsData=()=>{l.get({request:"settings/payment_accounts",queryData:{fieldset:"detailed"},onSuccess:t=>{this.setState({accountsList:t.data})}})};loadMethodsData=()=>{l.get({request:"settings/payment_methods",queryData:{fieldset:"detailed"},onSuccess:t=>{this.setState({methodsList:t.data})}})};deleteMethod=t=>{u.show({title:"Attenzione",body:"Vuoi eliminare questa modalità di pagamento?",actions:[{text:"Elimina",color:"red",onClick:()=>{l.delete({request:"settings/payment_methods/"+t.id,onSuccess:()=>{this.loadMethodsData(),n.show("Metodo di pagamento eliminato con successo",{type:_.SUCCESS})}})}},{text:"Annulla",color:"white"}]})};addMethod=()=>{const t={name:"",type:"standard",is_default:!1,details:[],default_payment_account:[]};this.handleEdit(t)}
1;setDefaultMethod=t=>{const s={...t,is_default:!t.is_default};l.put({request:"settings/payment_methods/"+s.id,postData:{data:s},onSuccess:()=>{this.loadMethodsData()}})};handleEdit=t=>{u.showCustom(e.jsx(z,{method:t,onEdit:()=>this.loadMethodsData(),accountsList:this.state.accountsList,methodTypes:this.methodTypes}))};render(){return e.jsxs(L,{scrollable:!0,align:"left",children:[e.jsx(f,{align:"left",children:e.jsx(A,{children:"Metodi di pagamento"})}),e.jsx(B,{children:e.jsxs(x,{align:"left",children:["In questa sezione puoi impostare i metodi di pagamento da mostrare nella stampa PDF dei documenti.",e.jsx("br",{}),"Si tratta dellâindicazione per il cliente su come deve essere saldata la fattura (es. Bonifico, contanti, assegno ecc..)."]})}),e.jsx(f,{className:"PageContent",align:"left",children:e.jsxs(x,{children:[this.state.methodsList.map((t,s)=>e.jsxs(D,{className:t.is_default?"methodItem defaultContainer":"methodItem",children:[e.jsxs("div",{className:"box",children:[e.jsx("div",{className:"title",children:t.name}),e.jsxs("div",{className:"type",children:[e.jsx("label",{children:"Tipologia:"}),this.methodTypes.map((a,o)=>e.jsx("span",{children:a.value===t.type&&a.label},o))]}),t.type==="riba"&&e.jsxs("div",{children:[e.jsx("label",{children:"Conto collegato:"}),t.default_payment_account?t.default_payment_account.name:"Nessuno"]}),t.details&&t.details.length>0&&e.jsxs("div",{className:"details",children:[e.jsx("div",{className:"title",children:"Dettagli di pagamento:"}),t.details.map((a,o)=>e.jsxs("div",{className:"singleDetail",children:[e.jsx("span",{children:a.title}),e.jsx("span",{children:a.description})]},o))]})]}),e.jsxs("div",{className:"box actions",children:[t.is_default?e.jsxs("span",{className:"default",children:[e.jsx(M,{icon:g}),"PREDEFINITO"]}):e.jsx(c,{onClick:()=>this.setDefaultMethod(t),icon:{icon:g},style:{marginLeft:8}}),e.jsx(c,{onClick:()=>this.handleEdit(t),icon:{icon:S},color:"primary",style:{marginLeft:8}}),e.jsx(c,{onClick:()=>this.deleteMethod(t),icon:{icon:v},style:{marginLeft:8}})]})]},s)),e.jsx(F,{text:"Aggiungi modalità di pagamento",iconLeft:N,onClick:this.addMethod})]})})]})}}const et=()=>e.jsx(P,{});export{et 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.