Files
crater/public/build/assets/InvoiceCreate.4d51ed6b.js
Mohit Panjwani 7202fdcbf2 new build
2022-02-22 12:31:28 +05:30

2 lines
7.3 KiB
JavaScript

var K=Object.defineProperty,Q=Object.defineProperties;var W=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var X=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable;var q=(t,e,i)=>e in t?K(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,L=(t,e)=>{for(var i in e||(e={}))X.call(e,i)&&q(t,i,e[i]);if(j)for(var i of j(e))Z.call(e,i)&&q(t,i,e[i]);return t},T=(t,e)=>Q(t,W(e));import{r as l,o as u,e as x,f as o,u as n,w as c,J as ee,G as ne,aN as te,B as C,k as I,L as p,M as y,S as oe,O as ie,aP as ae,T as se,C as le,l as b,j as k,h as $,t as M,m as ce,i as re,U as de,F as ue}from"./vendor.d12b5734.js";import{i as P,b as me,m as ve,r as ge}from"./main.a7fcb8c6.js";import{_ as pe,a as fe,b as _e,c as Ie,d as be,e as we,f as ye}from"./SalesTax.c8248724.js";import{_ as $e}from"./ExchangeRateConverter.a78813f9.js";import{_ as Be}from"./CreateCustomFields.67b63220.js";import{_ as Se}from"./TaxTypeModal.49ec37b3.js";import"./DragIcon.2af1ef76.js";import"./SelectNotePopup.412d32f0.js";import"./NoteModal.5ed66306.js";import"./payment.07ad8f38.js";import"./exchange-rate.7e231fb0.js";const he={class:"grid grid-cols-12 gap-8 mt-6 mb-8"},Ce={props:{v:{type:Object,default:null},isLoading:{type:Boolean,default:!1},isEdit:{type:Boolean,default:!1}},setup(t){const e=P();return(i,r)=>{const B=l("BaseCustomerSelectPopup"),d=l("BaseDatePicker"),m=l("BaseInputGroup"),S=l("BaseInput"),f=l("BaseInputGrid");return u(),x("div",he,[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(d,{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(d,{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($e,{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})])}}},ke=["onSubmit"],Ve={class:"flex"},je={class:"block mt-10 invoice-foot lg:flex lg:justify-between lg:items-start"},qe={class:"relative w-full lg:w-1/2 lg:mr-4"},He={setup(t){const e=P(),i=me(),r=ve(),B=ge(),{t:d}=ee();let m=ne(),S=te();const f="newInvoice";let a=C(!1);const F=C(!1),E=C(["customer","company","customerCustom","invoice","invoiceCustom"]);let _=I(()=>e.isFetchingInvoice||e.isFetchingInitialSettings),N=I(()=>v.value?d("invoices.edit_invoice"):d("invoices.new_invoice"));const U=I(()=>i.selectedCompanySettings.sales_tax_us_enabled==="YES"&&B.salesTaxUSEnabled);let v=I(()=>m.name==="invoices.edit");const D={invoice_date:{required:p.withMessage(d("validation.required"),y)},reference_number:{maxLength:p.withMessage(d("validation.price_maxlength"),oe(255))},customer_id:{required:p.withMessage(d("validation.required"),y)},invoice_number:{required:p.withMessage(d("validation.required"),y)},exchange_rate:{required:ie(function(){return p.withMessage(d("validation.required"),y),e.showExchangeRate}),decimal:p.withMessage(d("validation.valid_exchange_rate"),ae)}},w=se(D,I(()=>e.newInvoice),{$scope:f});r.resetCustomFields(),w.value.$reset,e.resetCurrentInvoice(),e.fetchInvoiceInitialSettings(v.value),le(()=>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=T(L({},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"),R=l("BaseBreadcrumb"),V=l("BaseButton"),H=l("router-link"),O=l("BaseIcon"),z=l("BasePageHeader"),A=l("BaseScrollPane"),J=l("BasePage");return u(),x(ue,null,[o(pe),o(fe),o(Se),n(U)&&(!n(_)||n(m).query.customer)?(u(),b(_e,{key:0,store:n(e),"is-edit":n(v),"store-prop":"newInvoice",customer:n(e).newInvoice.customer},null,8,["store","is-edit","customer"])):k("",!0),o(J,{class:"relative invoice-create-page"},{default:c(()=>[$("form",{onSubmit:de(G,["prevent"])},[o(z,{title:n(N)},{actions:c(()=>[s.$route.name==="invoices.edit"?(u(),b(H,{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,M(s.$t("general.view_pdf")),1)]),_:1})]),_:1},8,["to"])):k("",!0),o(V,{loading:n(a),disabled:n(a),variant:"primary",type:"submit"},{left:c(Y=>[n(a)?k("",!0):(u(),b(O,{key:0,name:"SaveIcon",class:ce(Y.class)},null,8,["class"]))]),default:c(()=>[re(" "+M(s.$t("invoices.save_invoice")),1)]),_:1},8,["loading","disabled"])]),default:c(()=>[o(R,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"?(u(),b(g,{key:0,title:s.$t("invoices.edit_invoice"),to:"#",active:""},null,8,["title"])):(u(),b(g,{key:1,title:s.$t("invoices.new_invoice"),to:"#",active:""},null,8,["title"]))]),_:1})]),_:1},8,["title"]),o(Ce,{v:n(w),"is-loading":n(_),"is-edit":n(v)},null,8,["v","is-loading","is-edit"]),o(A,null,{default:c(()=>[o(Ie,{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",je,[$("div",qe,[o(be,{store:n(e),"store-prop":"newInvoice",fields:E.value,type:"Invoice"},null,8,["store","fields"]),o(Be,{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(we,{store:n(e),"store-prop":"newInvoice","component-name":"InvoiceTemplate","is-mark-as-default":F.value},null,8,["store","is-mark-as-default"])]),o(ye,{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,ke)]),_:1})],64)}}};export{He as default};