whoami7 - Manager
:
/
home
/
qbizpnmr
/
arif.umairtax.com
/
public
/
Upload File:
files >> /home/qbizpnmr/arif.umairtax.com/public/Create-DUbET5n7.js
import{bu as W,r as w,e as g,bk as p,er as re,a9 as oe,bf as E,i as de,$ as ue,L as he,u as _e,bO as me,a as ve,t as ge,d as fe,Z as pe,p as C,j as t,Q as xe,e1 as be,C as Ce,by as _,cu as je,cy as V,aA as k,c5 as $,z as j,bb as q,c6 as f,cx as B,E as ye,cz as S,bC as G}from"./bundle.OlIVtvc7.js";import{u as $e}from"./payments-BhlrdSKU.js";import{u as Se,C as Ne}from"./usePaymentTypes-BHeQ2Qab.js";import{p as Ie}from"./atoms-BIyl7r8z.js";import{B as Fe}from"./Banner-D9Q__Gmd.js";/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */function Ee(){const h=W();return{find:o=>h.fetchQuery(["/api/v1/credits",o],()=>w("GET",g("/api/v1/credits/:id?include=client&sort=id|asc",{id:o})).then(r=>r.data.data),{staleTime:1/0})}}/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */function Ve(){const h=W();return{find:o=>h.fetchQuery(["/api/v1/invoices",o],()=>w("GET",g("/api/v1/invoices/:id?include=client.group_settings&sort=id|asc",{id:o})).then(r=>r.data.data),{staleTime:1/0})}}/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */function ke(h){const{payment:l,setPayment:o}=h;return{handleCreditChange:r=>{o(c=>c&&{...c,credits:[...c.credits,{_id:p(),amount:r.balance>0?r.balance:r.amount,credit_id:r.id}]})},handleExistingCreditChange:(r,c)=>{const a={...l};a.credits[c]={_id:p(),amount:r.balance>0?r.balance:r.amount,credit_id:r.id},o({...a})},handleCreditInputChange:(r,c)=>{const a={...l};a.credits[r].amount=c,o({...a})},handleDeletingCredit:r=>{o(c=>c&&{...c,credits:c.credits.filter(a=>a._id!==r)})}}}/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */function Be(h){const{payment:l,setPayment:o}=h;return{handleInvoiceChange:r=>{o(c=>c&&{...c,invoices:[...c.invoices,{_id:p(),amount:r.balance>0?r.balance:r.amount,invoice_id:r.id}]})},handleExistingInvoiceChange:(r,c)=>{const a={...l};a.invoices[c]={_id:p(),amount:r.balance>0?r.balance:r.amount,invoice_id:r.id},o({...a})},handleInvoiceInputChange:(r,c)=>{const a={...l};a.invoices[r].amount=c,o({...a})},handleDeletingInvoice:r=>{o(c=>c&&{...c,invoices:c.invoices.filter(a=>a._id!==r)})}}}/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */function we(){const h=re.sha256.create();return h.update(`${Date.now().toString()}${Math.random().toString()}`),h.hex()}/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */function Me(h){const{setErrors:l,setIsFormBusy:o,isFormBusy:r}=h,c=oe();return(a,N)=>{if(!r){E.processing(),l(void 0),o(!0);const I=we();w("POST",g("/api/v1/payments?email_receipt=:email",{email:N}),{...a,idempotency_key:I}).then(m=>{E.success("created_payment"),c(de("/payments/:id/edit",{id:m.data.data.id}))}).catch(m=>{var y;((y=m.response)==null?void 0:y.status)===422&&(E.dismiss(),l(m.response.data))}).finally(()=>{o(!1),ue(["payments","credits","invoices","clients"])})}}}function De(){var T,A,P,L,D,R,Q,z,H;const{documentTitle:h}=he("create_payment"),[l]=_e(),[o]=me(),r=[{name:l("payments"),href:"/payments"},{name:l("new_payment"),href:"/payments/create"}],c=ve(),a=ge(),N=Ee(),I=Ve(),m=fe(),y=Se(),[e,v]=pe(Ie),[i,K]=C.useState(),[M,X]=C.useState(!1),[O,Z]=C.useState((T=a==null?void 0:a.settings)==null?void 0:T.client_manual_payment_notification),[J,U]=C.useState(!1),{data:F}=$e();C.useEffect(()=>{v(n=>{var s;let d=n;return o.get("action")!=="enter"&&o.get("action")!=="apply"&&(d=void 0),typeof F<"u"&&typeof d>"u"&&(d={...F.data.data,invoices:[],credits:[],client_id:"",type_id:((s=a==null?void 0:a.settings)==null?void 0:s.payment_type_id)??""}),d}),o.has("client")&&v(n=>n&&{...n,client_id:o.get("client")}),o.has("client")&&o.has("invoice")&&I.find(o.get("invoice")).then(n=>v(d=>d&&{...d,invoices:[{_id:p(),invoice_id:n.id,amount:n.balance>0?n.balance:n.amount}]})),o.has("client")&&o.has("credit")&&N.find(o.get("credit")).then(n=>v(d=>d&&{...d,credits:[{_id:p(),credit_id:n.id,amount:n.balance>0?n.balance:n.amount}]})),o.has("type")&&v(n=>n&&{...n,type_id:o.get("type")??""})},[F]);const{handleInvoiceChange:Y,handleExistingInvoiceChange:ee,handleInvoiceInputChange:ne,handleDeletingInvoice:te}=Be({payment:e,setPayment:v}),{handleCreditChange:ae,handleExistingCreditChange:ie,handleCreditInputChange:se,handleDeletingCredit:le}=ke({payment:e,setPayment:v}),u=(n,d)=>{v(s=>s&&{...s,[n]:d})},ce=Me({setErrors:K,setIsFormBusy:X,isFormBusy:M});return t.jsx(xe,{title:h,breadcrumbs:r,onSaveClick:()=>ce(e,O),disableSaveButton:!e||M,aboveMainContainer:!!(e&&e.amount<0)&&t.jsx(Fe,{variant:"orange",style:{borderColor:c.$5},children:l("negative_payment_warning")}),children:t.jsx(be,{breadcrumbs:[],children:t.jsxs(Ce,{title:l("enter_payment"),className:"shadow-sm",style:{borderColor:c.$24},headerStyle:{borderColor:c.$20},children:[t.jsx(_,{leftSide:l("client"),children:t.jsx(je,{onChange:n=>{u("client_id",n==null?void 0:n.id),u("currency_id",(n==null?void 0:n.settings.currency_id)||"1"),u("invoices",[]),u("credits",[])},onClearButtonClick:()=>{u("client_id",""),u("currency_id",""),u("invoices",[]),u("credits",[])},errorMessage:i==null?void 0:i.errors.client_id,defaultValue:e==null?void 0:e.client_id,value:e==null?void 0:e.client_id,readonly:o.has("invoice")||o.get("action")==="enter"||o.get("action")==="apply",initiallyVisible:!(e!=null&&e.client_id)})}),t.jsx(_,{leftSide:l("amount_received"),leftSideHelp:l("amount_received_help"),children:t.jsx(V,{value:(e==null?void 0:e.amount)||"",onValueChange:n=>u("amount",isNaN(parseFloat(n))?0:parseFloat(n)),errorMessage:i==null?void 0:i.errors.amount,changeOverride:!0})}),(e==null?void 0:e.client_id)&&t.jsx(k,{}),e&&e.invoices.length>0&&e.invoices.map((n,d)=>t.jsx(_,{children:t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("div",{className:"flex items-end space-x-2",children:[t.jsx($,{inputOptions:{value:n.invoice_id,label:l("invoice")??""},endpoint:g(`/api/v1/invoices?payable=${e.client_id}&per_page=100`),entryOptions:{label:"number",id:"id",value:"id",searchable:"number",dropdownLabelFn:s=>{var x,b;return`${l("invoice_number_short")}${s.number} - ${l("balance")} ${m(s.balance,(x=e.client)==null?void 0:x.country_id,(b=e.client)==null?void 0:b.settings.currency_id)}`},inputLabelFn:s=>s?`${l("invoice_number_short")}${s==null?void 0:s.number}`:""},onChange:s=>s.resource?ee(s.resource,d):null,exclude:j(e.invoices.filter(({invoice_id:s})=>s!==n.invoice_id)).pluck("invoice_id").toArray()}),t.jsx(V,{label:l("amount_received"),value:n.amount||"",onValueChange:s=>ne(d,isNaN(parseFloat(s))?0:parseFloat(s)),className:"w-full",withoutLabelWrapping:!0}),t.jsx("div",{className:"cursor-pointer self-center mt-6 focus:outline-none focus:ring-0",onClick:()=>te(n._id),children:t.jsx(q,{color:c.$16,hoverColor:c.$3,borderColor:c.$5,hoverBorderColor:c.$17,size:"1.6rem"})})]}),t.jsx(f,{className:"mt-2",children:i==null?void 0:i.errors[`invoices.${d}.amount`]}),t.jsx(f,{className:"mt-2",children:i==null?void 0:i.errors[`invoices.${d}.invoice_id`]})]})},d)),(e==null?void 0:e.client_id)&&t.jsx(_,{leftSide:l("invoices"),children:t.jsx($,{endpoint:g(`/api/v1/invoices?payable=${e==null?void 0:e.client_id}&per_page=100`),inputOptions:{value:"id"},entryOptions:{id:"id",value:"id",label:"number",searchable:"number",dropdownLabelFn:n=>{var d,s;return`${l("invoice_number_short")}${n.number} - ${l("balance")} ${m(n.balance,(d=e.client)==null?void 0:d.country_id,(s=e.client)==null?void 0:s.settings.currency_id)}`}},onChange:({resource:n})=>n?Y(n):null,exclude:j(e.invoices).pluck("invoice_id").toArray(),clearInputAfterSelection:!0})}),(i==null?void 0:i.errors.invoices)&&t.jsx("div",{className:"px-6",children:t.jsx(f,{className:"mt-2",children:i==null?void 0:i.errors.invoices})}),(e==null?void 0:e.client_id)&&t.jsx(k,{}),e&&e.credits.length>0&&e.credits.map((n,d)=>t.jsx(_,{children:t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("div",{className:"flex items-end space-x-2",children:[t.jsx($,{inputOptions:{value:n.credit_id,label:l("credit")??""},endpoint:g(`/api/v1/credits?client_id=${e.client_id}&per_page=100&applicable=true`),entryOptions:{id:"id",value:"id",label:"number",searchable:"number",dropdownLabelFn:s=>{var x,b;return`${l("credit")} #${s.number} - ${l("balance")} ${m(s.balance,(x=e.client)==null?void 0:x.country_id,(b=e.client)==null?void 0:b.settings.currency_id)}`}},onChange:s=>s.resource?ie(s.resource,d):null,exclude:j(e.credits.filter(({credit_id:s})=>s!==n.credit_id)).pluck("credit_id").toArray()}),t.jsx(V,{label:l("amount"),onValueChange:s=>se(d,isNaN(parseFloat(s))?0:parseFloat(s)),className:"w-full",value:n.amount||"",withoutLabelWrapping:!0}),t.jsx("div",{className:"cursor-pointer self-center mt-6 focus:outline-none focus:ring-0",onClick:()=>le(n._id),children:t.jsx(q,{color:c.$16,hoverColor:c.$3,borderColor:c.$5,hoverBorderColor:c.$17,size:"1.6rem"})})]}),t.jsx(f,{className:"mt-2",children:i==null?void 0:i.errors[`credits.${d}.amount`]}),t.jsx(f,{className:"mt-2",children:i==null?void 0:i.errors[`credits.${d}.credit_id`]})]})},d)),(e==null?void 0:e.client_id)&&t.jsx(_,{leftSide:l("credits"),children:t.jsx($,{endpoint:g(`/api/v1/credits?client_id=${e.client_id}&applicable=true`),inputOptions:{value:null},entryOptions:{id:"id",label:"number",value:"id",searchable:"number",dropdownLabelFn:n=>{var d,s;return`${l("credit")} #${n.number} - ${l("balance")} ${m(n.balance,(d=e.client)==null?void 0:d.country_id,(s=e.client)==null?void 0:s.settings.currency_id)}`}},onChange:n=>n.resource?ae(n.resource):null,exclude:j(e.credits).pluck("credit_id").toArray(),clearInputAfterSelection:!0})}),(i==null?void 0:i.errors.credits)&&t.jsx("div",{className:"px-6",children:t.jsx(f,{className:"mt-2",children:i==null?void 0:i.errors.credits})}),(e==null?void 0:e.client_id)&&t.jsx(k,{}),t.jsx(_,{leftSide:l("payment_date"),children:t.jsx(B,{type:"date",id:"date",value:e==null?void 0:e.date,onValueChange:n=>u("date",n),errorMessage:i==null?void 0:i.errors.date})}),t.jsx(_,{leftSide:l("payment_type"),children:t.jsx(ye,{value:e==null?void 0:e.type_id,onValueChange:n=>u("type_id",n),errorMessage:i==null?void 0:i.errors.type_id,withBlank:!0,customSelector:!0,children:y.map(([n,d],s)=>t.jsx("option",{value:n,children:d},s))})}),t.jsx(_,{leftSide:l("transaction_reference"),children:t.jsx(B,{id:"transaction_reference",onValueChange:n=>u("transaction_reference",n),errorMessage:i==null?void 0:i.errors.transaction_reference})}),t.jsx(_,{leftSide:l("private_notes"),children:t.jsx(B,{element:"textarea",id:"private_notes",onValueChange:n=>u("private_notes",n),errorMessage:i==null?void 0:i.errors.private_notes})}),((A=a==null?void 0:a.custom_fields)==null?void 0:A.payment1)&&t.jsx(S,{field:"payment1",defaultValue:e==null?void 0:e.custom_value1,value:(P=a==null?void 0:a.custom_fields)==null?void 0:P.payment1,onValueChange:n=>u("custom_value1",n.toString())}),((L=a==null?void 0:a.custom_fields)==null?void 0:L.payment2)&&t.jsx(S,{field:"payment2",defaultValue:e==null?void 0:e.custom_value2,value:(D=a==null?void 0:a.custom_fields)==null?void 0:D.payment2,onValueChange:n=>u("custom_value2",n.toString())}),((R=a==null?void 0:a.custom_fields)==null?void 0:R.payment3)&&t.jsx(S,{field:"payment3",defaultValue:e==null?void 0:e.custom_value3,value:(Q=a==null?void 0:a.custom_fields)==null?void 0:Q.payment3,onValueChange:n=>u("custom_value3",n.toString())}),((z=a==null?void 0:a.custom_fields)==null?void 0:z.payment4)&&t.jsx(S,{field:"payment4",defaultValue:e==null?void 0:e.custom_value4,value:(H=a==null?void 0:a.custom_fields)==null?void 0:H.payment4,onValueChange:n=>u("custom_value4",n.toString())}),t.jsx(_,{leftSide:l("send_email"),children:t.jsx(G,{checked:O,onChange:Z})}),t.jsx(_,{leftSide:l("convert_currency"),children:t.jsx(G,{checked:!!(e!=null&&e.exchange_currency_id),onChange:n=>{U(n),n?u("exchange_currency_id","1"):u("exchange_currency_id",""),u("exchange_rate",1)}})}),J&&e&&t.jsx(Ne,{exchangeRate:e.exchange_rate.toString()||"1",exchangeCurrencyId:e.exchange_currency_id,currencyId:e.currency_id||"1",amount:j(e==null?void 0:e.invoices).sum("amount")+((e==null?void 0:e.amount)??0),onChange:(n,d)=>{u("exchange_rate",n),u("exchange_currency_id",d)},onExchangeRateChange:n=>u("exchange_rate",n)})]})})})}export{De as default};
Copyright ©2021 || Defacer Indonesia