Files
crater/public/build/assets/InvoiceCreate.b760d6d6.js
Mohit Panjwani 7427f8a4ac new build
2022-02-15 11:44:39 +05:30

2 lines
7.2 KiB
JavaScript

var A=Object.defineProperty,K=Object.defineProperties;var Q=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var j=(t,e,i)=>e in t?A(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,q=(t,e)=>{for(var i in e||(e={}))W.call(e,i)&&j(t,i,e[i]);if(k)for(var i of k(e))X.call(e,i)&&j(t,i,e[i]);return t},L=(t,e)=>K(t,Q(e));import{r as l,o as d,e as T,f as o,u as n,w as c,J as Z,G as ee,aN as ne,B as x,k as b,L as p,M as y,S as te,O as oe,aP as ie,T as ae,C as se,l as I,j as C,h as $,t as P,m as le,i as ce,U as re,F as ue}from"./vendor.d12b5734.js";import{i as M,b as de,m as me,r as ve}from"./main.94931a0e.js";import{_ as ge,a as pe,b as fe,c as _e,d as be,e as Ie,f as we}from"./SalesTax.180f6f10.js";import{_ as ye}from"./ExchangeRateConverter.6b3bf01f.js";import{_ as $e}from"./CreateCustomFields.bf400434.js";import{_ as Be}from"./TaxTypeModal.7f1ffc59.js";import"./DragIcon.1895161b.js";import"./SelectNotePopup.391530ef.js";import"./NoteModal.faeb98ea.js";import"./payment.b31ac5a8.js";import"./exchange-rate.5f3eeb90.js";const Se={class:"grid grid-cols-12 gap-8 mt-6 mb-8"},he={props:{v:{type:Object,default:null},isLoading:{type:Boolean,default:!1},isEdit:{type:Boolean,default:!1}},setup(t){const e=M();return(i,r)=>{const B=l("BaseCustomerSelectPopup"),u=l("BaseDatePicker"),m=l("BaseInputGroup"),S=l("BaseInput"),f=l("BaseInputGrid");return d(),T("div",Se,[o(B,{modelValue:n(e).newInvoice.customer,"onUpdate:modelValue":r[0]||(r[0]=a=>n(e).newInvoice.customer=a),valid:t.v.customer_id,"content-loading":t.isLoading,type:"invoice",class:"col-span-12 lg:col-span-5 pr-0"},null,8,["modelValue","valid","content-loading"]),o(f,{class:"col-span-12 lg:col-span-7"},{default:c(()=>[o(m,{label:i.$t("invoices.invoice_date"),"content-loading":t.isLoading,required:"",error:t.v.invoice_date.$error&&t.v.invoice_date.$errors[0].$message},{default:c(()=>[o(u,{modelValue:n(e).newInvoice.invoice_date,"onUpdate:modelValue":r[1]||(r[1]=a=>n(e).newInvoice.invoice_date=a),"content-loading":t.isLoading,"calendar-button":!0,"calendar-button-icon":"calendar"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),o(m,{label:i.$t("invoices.due_date"),"content-loading":t.isLoading},{default:c(()=>[o(u,{modelValue:n(e).newInvoice.due_date,"onUpdate:modelValue":r[2]||(r[2]=a=>n(e).newInvoice.due_date=a),"content-loading":t.isLoading,"calendar-button":!0,"calendar-button-icon":"calendar"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading"]),o(m,{label:i.$t("invoices.invoice_number"),"content-loading":t.isLoading,error:t.v.invoice_number.$error&&t.v.invoice_number.$errors[0].$message,required:""},{default:c(()=>[o(S,{modelValue:n(e).newInvoice.invoice_number,"onUpdate:modelValue":r[3]||(r[3]=a=>n(e).newInvoice.invoice_number=a),"content-loading":t.isLoading,onInput:r[4]||(r[4]=a=>t.v.invoice_number.$touch())},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),o(ye,{store:n(e),"store-prop":"newInvoice",v:t.v,"is-loading":t.isLoading,"is-edit":t.isEdit,"customer-currency":n(e).newInvoice.currency_id},null,8,["store","v","is-loading","is-edit","customer-currency"])]),_:1})])}}},Ce=["onSubmit"],Ve={class:"flex"},ke={class:"block mt-10 invoice-foot lg:flex lg:justify-between lg:items-start"},je={class:"relative w-full lg:w-1/2 lg:mr-4"},Re={setup(t){const e=M(),i=de(),r=me(),B=ve(),{t:u}=Z();let m=ee(),S=ne();const f="newInvoice";let a=x(!1);const F=x(["customer","company","customerCustom","invoice","invoiceCustom"]);let _=b(()=>e.isFetchingInvoice||e.isFetchingInitialSettings),E=b(()=>v.value?u("invoices.edit_invoice"):u("invoices.new_invoice"));const N=b(()=>i.selectedCompanySettings.sales_tax_us_enabled==="YES"&&B.salesTaxUSEnabled);let v=b(()=>m.name==="invoices.edit");const U={invoice_date:{required:p.withMessage(u("validation.required"),y)},reference_number:{maxLength:p.withMessage(u("validation.price_maxlength"),te(255))},customer_id:{required:p.withMessage(u("validation.required"),y)},invoice_number:{required:p.withMessage(u("validation.required"),y)},exchange_rate:{required:oe(function(){return p.withMessage(u("validation.required"),y),e.showExchangeRate}),decimal:p.withMessage(u("validation.valid_exchange_rate"),ie)}},w=ae(U,b(()=>e.newInvoice),{$scope:f});r.resetCustomFields(),w.value.$reset,e.resetCurrentInvoice(),e.fetchInvoiceInitialSettings(v.value),se(()=>e.newInvoice.customer,s=>{s&&s.currency?e.newInvoice.selectedCurrency=s.currency:e.newInvoice.selectedCurrency=i.selectedCompanyCurrency});async function G(){if(w.value.$touch(),w.value.$invalid)return!1;a.value=!0;let s=L(q({},e.newInvoice),{sub_total:e.getSubTotal,total:e.getTotal,tax:e.getTotalTax});try{const g=await(v.value?e.updateInvoice:e.addInvoice)(s);S.push(`/admin/invoices/${g.data.data.id}/view`)}catch(h){console.error(h)}a.value=!1}return(s,h)=>{const g=l("BaseBreadcrumbItem"),D=l("BaseBreadcrumb"),V=l("BaseButton"),R=l("router-link"),H=l("BaseIcon"),O=l("BasePageHeader"),z=l("BaseScrollPane"),J=l("BasePage");return d(),T(ue,null,[o(ge),o(pe),o(Be),n(N)&&(!n(_)||n(m).query.customer)?(d(),I(fe,{key:0,store:n(e),"is-edit":n(v),"store-prop":"newInvoice",customer:n(e).newInvoice.customer},null,8,["store","is-edit","customer"])):C("",!0),o(J,{class:"relative invoice-create-page"},{default:c(()=>[$("form",{onSubmit:re(G,["prevent"])},[o(O,{title:n(E)},{actions:c(()=>[s.$route.name==="invoices.edit"?(d(),I(R,{key:0,to:`/invoices/pdf/${n(e).newInvoice.unique_hash}`,target:"_blank"},{default:c(()=>[o(V,{class:"mr-3",variant:"primary-outline",type:"button"},{default:c(()=>[$("span",Ve,P(s.$t("general.view_pdf")),1)]),_:1})]),_:1},8,["to"])):C("",!0),o(V,{loading:n(a),disabled:n(a),variant:"primary",type:"submit"},{left:c(Y=>[n(a)?C("",!0):(d(),I(H,{key:0,name:"SaveIcon",class:le(Y.class)},null,8,["class"]))]),default:c(()=>[ce(" "+P(s.$t("invoices.save_invoice")),1)]),_:1},8,["loading","disabled"])]),default:c(()=>[o(D,null,{default:c(()=>[o(g,{title:s.$t("general.home"),to:"/admin/dashboard"},null,8,["title"]),o(g,{title:s.$tc("invoices.invoice",2),to:"/admin/invoices"},null,8,["title"]),s.$route.name==="invoices.edit"?(d(),I(g,{key:0,title:s.$t("invoices.edit_invoice"),to:"#",active:""},null,8,["title"])):(d(),I(g,{key:1,title:s.$t("invoices.new_invoice"),to:"#",active:""},null,8,["title"]))]),_:1})]),_:1},8,["title"]),o(he,{v:n(w),"is-loading":n(_),"is-edit":n(v)},null,8,["v","is-loading","is-edit"]),o(z,null,{default:c(()=>[o(_e,{currency:n(e).newInvoice.selectedCurrency,"is-loading":n(_),"item-validation-scope":f,store:n(e),"store-prop":"newInvoice"},null,8,["currency","is-loading","store"]),$("div",ke,[$("div",je,[o(be,{store:n(e),"store-prop":"newInvoice",fields:F.value,type:"Invoice"},null,8,["store","fields"]),o($e,{type:"Invoice","is-edit":n(v),"is-loading":n(_),store:n(e),"store-prop":"newInvoice","custom-field-scope":f,class:"mb-6"},null,8,["is-edit","is-loading","store"]),o(Ie,{store:n(e),"store-prop":"newInvoice","component-name":"InvoiceTemplate"},null,8,["store"])]),o(we,{currency:n(e).newInvoice.selectedCurrency,"is-loading":n(_),store:n(e),"store-prop":"newInvoice","tax-popup-type":"invoice"},null,8,["currency","is-loading","store"])])]),_:1})],40,Ce)]),_:1})],64)}}};export{Re as default};