Files
InvoiceShelf/public/build/assets/EstimateCreate-NLa0dCKB.js
2024-01-28 18:15:55 -06:00

2 lines
6.9 KiB
JavaScript

import{as as L,r as o,o as c,c as x,a,l as t,w as n,av as A,E as J,ae as K,v as O,f as S,L as X,e as Y,k as v,g as _,h as w,ai as Q,ag as W,X as Z,j as ee,z as te,m as E,K as C,b,t as q,J as ae,p as se,q as ie,N as ne}from"./main-WMXHPsTs.js";import{_ as oe,a as le,b as re,c as me,d as de,e as ue,f as ce}from"./SalesTax-1bCXExhs.js";import{_ as ge}from"./CreateCustomFields--vFU38k2.js";import{_ as pe}from"./ExchangeRateConverter-G19_Li5d.js";import{_ as _e}from"./TaxTypeModal-E-PaOV8a.js";import"./DragIcon-5BDgiv1X.js";import"./SelectNotePopup-wzqC6aO8.js";import"./NoteModal-jScVrYU1.js";import"./payment-41Om6QZO.js";import"./dynamic-import-helper-0gtGTknh.js";import"./exchange-rate-dmwjabGR.js";const fe={class:"md:grid-cols-12 grid-cols-1 md:gap-x-6 mt-6 mb-8 grid gap-y-5"},ve={__name:"EstimateCreateBasicFields",props:{v:{type:Object,default:null},isLoading:{type:Boolean,default:!1},isEdit:{type:Boolean,default:!1}},setup(s){const e=L();return(f,l)=>{const B=o("BaseCustomerSelectPopup"),r=o("BaseDatePicker"),d=o("BaseInputGroup"),$=o("BaseInput"),h=o("BaseInputGrid");return c(),x("div",fe,[a(B,{modelValue:t(e).newEstimate.customer,"onUpdate:modelValue":l[0]||(l[0]=m=>t(e).newEstimate.customer=m),valid:s.v.customer_id,"content-loading":s.isLoading,type:"estimate",class:"col-span-5 pr-0"},null,8,["modelValue","valid","content-loading"]),a(h,{class:"col-span-7"},{default:n(()=>[a(d,{label:f.$t("reports.estimates.estimate_date"),"content-loading":s.isLoading,required:"",error:s.v.estimate_date.$error&&s.v.estimate_date.$errors[0].$message},{default:n(()=>[a(r,{modelValue:t(e).newEstimate.estimate_date,"onUpdate:modelValue":l[1]||(l[1]=m=>t(e).newEstimate.estimate_date=m),"content-loading":s.isLoading,"calendar-button":!0,"calendar-button-icon":"calendar"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),a(d,{label:f.$t("estimates.expiry_date"),"content-loading":s.isLoading},{default:n(()=>[a(r,{modelValue:t(e).newEstimate.expiry_date,"onUpdate:modelValue":l[2]||(l[2]=m=>t(e).newEstimate.expiry_date=m),"content-loading":s.isLoading,"calendar-button":!0,"calendar-button-icon":"calendar"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading"]),a(d,{label:f.$t("estimates.estimate_number"),"content-loading":s.isLoading,required:"",error:s.v.estimate_number.$error&&s.v.estimate_number.$errors[0].$message},{default:n(()=>[a($,{modelValue:t(e).newEstimate.estimate_number,"onUpdate:modelValue":l[3]||(l[3]=m=>t(e).newEstimate.estimate_number=m),"content-loading":s.isLoading},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),a(pe,{store:t(e),"store-prop":"newEstimate",v:s.v,"is-loading":s.isLoading,"is-edit":s.isEdit,"customer-currency":t(e).newEstimate.currency_id},null,8,["store","v","is-loading","is-edit","customer-currency"])]),_:1})])}}},Ee={class:"flex"},ye={class:"block mt-10 estimate-foot lg:flex lg:justify-between lg:items-start"},we={class:"relative w-full lg:w-1/2"},k="newEstimate",xe={__name:"EstimateCreate",setup(s){const e=L(),f=A(),l=J(),B=K(),{t:r}=O.useI18n();let d=S(!1);const $=S(!1),h=S(["customer","company","customerCustom","estimate","estimateCustom"]);let m=X(),P=Y(),g=v(()=>e.isFetchingInitialSettings),M=v(()=>p.value?r("estimates.edit_estimate"):r("estimates.new_estimate")),p=v(()=>m.name==="estimates.edit");const T=v(()=>l.selectedCompanySettings.sales_tax_us_enabled==="YES"&&f.salesTaxUSEnabled),F={estimate_date:{required:_.withMessage(r("validation.required"),w)},estimate_number:{required:_.withMessage(r("validation.required"),w)},reference_number:{maxLength:_.withMessage(r("validation.price_maxlength"),Q(255))},customer_id:{required:_.withMessage(r("validation.required"),w)},exchange_rate:{required:W(function(){return _.withMessage(r("validation.required"),w),e.showExchangeRate}),decimal:_.withMessage(r("validation.valid_exchange_rate"),Z)}},y=ee(F,v(()=>e.newEstimate),{$scope:k});te(()=>e.newEstimate.customer,i=>{i&&i.currency?e.newEstimate.selectedCurrency=i.currency:e.newEstimate.selectedCurrency=l.selectedCompanyCurrency}),e.resetCurrentEstimate(),B.resetCustomFields(),y.value.$reset,e.fetchEstimateInitialSettings(p.value);async function N(){if(y.value.$touch(),y.value.$invalid)return!1;d.value=!0;let i={...e.newEstimate,sub_total:e.getSubTotal,total:e.getTotal,tax:e.getTotalTax};const I=p.value?e.updateEstimate:e.addEstimate;try{let u=await I(i);u.data.data&&P.push(`/admin/estimates/${u.data.data.id}/view`)}catch(u){console.error(u)}d.value=!1}return(i,I)=>{const u=o("BaseBreadcrumbItem"),U=o("BaseBreadcrumb"),V=o("BaseButton"),j=o("router-link"),D=o("BaseIcon"),G=o("BasePageHeader"),R=o("BaseScrollPane"),z=o("BasePage");return c(),x(ne,null,[a(oe),a(le),a(_e),T.value&&(!t(g)||t(m).query.customer)?(c(),E(re,{key:0,store:t(e),"store-prop":"newEstimate","is-edit":t(p),customer:t(e).newEstimate.customer},null,8,["store","is-edit","customer"])):C("",!0),a(z,{class:"relative estimate-create-page"},{default:n(()=>[b("form",{onSubmit:ie(N,["prevent"])},[a(G,{title:t(M)},{actions:n(()=>[i.$route.name==="estimates.edit"?(c(),E(j,{key:0,to:`/estimates/pdf/${t(e).newEstimate.unique_hash}`,target:"_blank"},{default:n(()=>[a(V,{class:"mr-3",variant:"primary-outline",type:"button"},{default:n(()=>[b("span",Ee,q(i.$t("general.view_pdf")),1)]),_:1})]),_:1},8,["to"])):C("",!0),a(V,{loading:t(d),disabled:t(d),"content-loading":t(g),variant:"primary",type:"submit"},{left:n(H=>[t(d)?C("",!0):(c(),E(D,{key:0,class:ae(H.class),name:"SaveIcon"},null,8,["class"]))]),default:n(()=>[se(" "+q(i.$t("estimates.save_estimate")),1)]),_:1},8,["loading","disabled","content-loading"])]),default:n(()=>[a(U,null,{default:n(()=>[a(u,{title:i.$t("general.home"),to:"/admin/dashboard"},null,8,["title"]),a(u,{title:i.$t("estimates.estimate",2),to:"/admin/estimates"},null,8,["title"]),i.$route.name==="estimates.edit"?(c(),E(u,{key:0,title:i.$t("estimates.edit_estimate"),to:"#",active:""},null,8,["title"])):(c(),E(u,{key:1,title:i.$t("estimates.new_estimate"),to:"#",active:""},null,8,["title"]))]),_:1})]),_:1},8,["title"]),a(ve,{v:t(y),"is-loading":t(g),"is-edit":t(p)},null,8,["v","is-loading","is-edit"]),a(R,null,{default:n(()=>[a(me,{currency:t(e).newEstimate.selectedCurrency,"is-loading":t(g),"item-validation-scope":k,store:t(e),"store-prop":"newEstimate"},null,8,["currency","is-loading","store"]),b("div",ye,[b("div",we,[a(de,{store:t(e),"store-prop":"newEstimate",fields:h.value,type:"Estimate"},null,8,["store","fields"]),a(ge,{type:"Estimate","is-edit":t(p),"is-loading":t(g),store:t(e),"store-prop":"newEstimate","custom-field-scope":k,class:"mb-6"},null,8,["is-edit","is-loading","store"]),a(ue,{store:t(e),"component-name":"EstimateTemplate","store-prop":"newEstimate","is-mark-as-default":$.value},null,8,["store","is-mark-as-default"])]),a(ce,{currency:t(e).newEstimate.selectedCurrency,"is-loading":t(g),store:t(e),"store-prop":"newEstimate","tax-popup-type":"estimate"},null,8,["currency","is-loading","store"])])]),_:1})],32)]),_:1})],64)}}};export{xe as default};