mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
2 lines
7.2 KiB
JavaScript
2 lines
7.2 KiB
JavaScript
var A=Object.defineProperty,K=Object.defineProperties;var Q=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var I=(a,e,n)=>e in a?A(a,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[e]=n,V=(a,e)=>{for(var n in e||(e={}))W.call(e,n)&&I(a,n,e[n]);if(x)for(var n of x(e))X.call(e,n)&&I(a,n,e[n]);return a},j=(a,e)=>K(a,Q(e));import{r as o,o as g,e as q,f as s,u as t,w as l,J as Z,B as L,G as ee,aN as te,k as v,L as b,M as E,S as ae,O as se,aP as ne,T as ie,C as oe,l as y,j as h,h as B,t as T,m as le,i as re,U as me,F as de}from"./vendor.01d0adc5.js";import{k as P,r as ue,b as ce,m as pe}from"./main.07a42384.js";import{_ as ge,a as _e,b as fe,c as be,d as ve,e as ye,f as we}from"./SalesTax.576f67ba.js";import{_ as Ee}from"./CreateCustomFields.e41d5130.js";import{_ as Be}from"./ExchangeRateConverter.5cb06f23.js";import{_ as $e}from"./TaxTypeModal.0d30c104.js";import"./DragIcon.e4721446.js";import"./SelectNotePopup.03e6a0bb.js";import"./NoteModal.c2797ba4.js";import"./payment.5b85ec0c.js";import"./exchange-rate.0f2c2a2b.js";const Se={class:"md:grid-cols-12 grid-cols-1 md:gap-x-6 mt-6 mb-8 grid gap-y-5"},he={props:{v:{type:Object,default:null},isLoading:{type:Boolean,default:!1},isEdit:{type:Boolean,default:!1}},setup(a){const e=P();return(n,r)=>{const $=o("BaseCustomerSelectPopup"),m=o("BaseDatePicker"),c=o("BaseInputGroup"),p=o("BaseInput"),S=o("BaseInputGrid");return g(),q("div",Se,[s($,{modelValue:t(e).newEstimate.customer,"onUpdate:modelValue":r[0]||(r[0]=d=>t(e).newEstimate.customer=d),valid:a.v.customer_id,"content-loading":a.isLoading,type:"estimate",class:"col-span-5 pr-0"},null,8,["modelValue","valid","content-loading"]),s(S,{class:"col-span-7"},{default:l(()=>[s(c,{label:n.$t("reports.estimates.estimate_date"),"content-loading":a.isLoading,required:"",error:a.v.estimate_date.$error&&a.v.estimate_date.$errors[0].$message},{default:l(()=>[s(m,{modelValue:t(e).newEstimate.estimate_date,"onUpdate:modelValue":r[1]||(r[1]=d=>t(e).newEstimate.estimate_date=d),"content-loading":a.isLoading,"calendar-button":!0,"calendar-button-icon":"calendar"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),s(c,{label:n.$t("estimates.expiry_date"),"content-loading":a.isLoading},{default:l(()=>[s(m,{modelValue:t(e).newEstimate.expiry_date,"onUpdate:modelValue":r[2]||(r[2]=d=>t(e).newEstimate.expiry_date=d),"content-loading":a.isLoading,"calendar-button":!0,"calendar-button-icon":"calendar"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading"]),s(c,{label:n.$t("estimates.estimate_number"),"content-loading":a.isLoading,required:"",error:a.v.estimate_number.$error&&a.v.estimate_number.$errors[0].$message},{default:l(()=>[s(p,{modelValue:t(e).newEstimate.estimate_number,"onUpdate:modelValue":r[3]||(r[3]=d=>t(e).newEstimate.estimate_number=d),"content-loading":a.isLoading},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),s(Be,{store:t(e),"store-prop":"newEstimate",v:a.v,"is-loading":a.isLoading,"is-edit":a.isEdit,"customer-currency":t(e).newEstimate.currency_id},null,8,["store","v","is-loading","is-edit","customer-currency"])]),_:1})])}}},Ce=["onSubmit"],ke={class:"flex"},xe={class:"block mt-10 estimate-foot lg:flex lg:justify-between lg:items-start"},Ie={class:"relative w-full lg:w-1/2"},Re={setup(a){const e=P(),n=ue(),r=ce(),$=pe(),{t:m}=Z(),c="newEstimate";let p=L(!1);const S=L(["customer","company","customerCustom","estimate","estimateCustom"]);let d=ee(),M=te(),_=v(()=>e.isFetchingInitialSettings),F=v(()=>f.value?m("estimates.edit_estimate"):m("estimates.new_estimate")),f=v(()=>d.name==="estimates.edit");const N=v(()=>r.selectedCompanySettings.sales_tax_us_enabled==="YES"&&n.salesTaxUSEnabled),U={estimate_date:{required:b.withMessage(m("validation.required"),E)},estimate_number:{required:b.withMessage(m("validation.required"),E)},reference_number:{maxLength:b.withMessage(m("validation.price_maxlength"),ae(255))},customer_id:{required:b.withMessage(m("validation.required"),E)},exchange_rate:{required:se(function(){return b.withMessage(m("validation.required"),E),e.showExchangeRate}),decimal:b.withMessage(m("validation.valid_exchange_rate"),ne)}},w=ie(U,v(()=>e.newEstimate),{$scope:c});oe(()=>e.newEstimate.customer,i=>{i&&i.currency?e.newEstimate.selectedCurrency=i.currency:e.newEstimate.selectedCurrency=r.selectedCompanyCurrency}),e.resetCurrentEstimate(),$.resetCustomFields(),w.value.$reset,e.fetchEstimateInitialSettings(f.value);async function G(){if(w.value.$touch(),w.value.$invalid)return!1;p.value=!0;let i=j(V({},e.newEstimate),{sub_total:e.getSubTotal,total:e.getTotal,tax:e.getTotalTax});const C=f.value?e.updateEstimate:e.addEstimate;try{let u=await C(i);u.data.data&&M.push(`/admin/estimates/${u.data.data.id}/view`)}catch(u){console.error(u)}p.value=!1}return(i,C)=>{const u=o("BaseBreadcrumbItem"),D=o("BaseBreadcrumb"),k=o("BaseButton"),R=o("router-link"),H=o("BaseIcon"),O=o("BasePageHeader"),z=o("BaseScrollPane"),J=o("BasePage");return g(),q(de,null,[s(ge),s(_e),s($e),t(N)&&(!t(_)||t(d).query.customer)?(g(),y(fe,{key:0,store:t(e),"store-prop":"newEstimate","is-edit":t(f),customer:t(e).newEstimate.customer},null,8,["store","is-edit","customer"])):h("",!0),s(J,{class:"relative estimate-create-page"},{default:l(()=>[B("form",{onSubmit:me(G,["prevent"])},[s(O,{title:t(F)},{actions:l(()=>[i.$route.name==="estimates.edit"?(g(),y(R,{key:0,to:`/estimates/pdf/${t(e).newEstimate.unique_hash}`,target:"_blank"},{default:l(()=>[s(k,{class:"mr-3",variant:"primary-outline",type:"button"},{default:l(()=>[B("span",ke,T(i.$t("general.view_pdf")),1)]),_:1})]),_:1},8,["to"])):h("",!0),s(k,{loading:t(p),disabled:t(p),"content-loading":t(_),variant:"primary",type:"submit"},{left:l(Y=>[t(p)?h("",!0):(g(),y(H,{key:0,class:le(Y.class),name:"SaveIcon"},null,8,["class"]))]),default:l(()=>[re(" "+T(i.$t("estimates.save_estimate")),1)]),_:1},8,["loading","disabled","content-loading"])]),default:l(()=>[s(D,null,{default:l(()=>[s(u,{title:i.$t("general.home"),to:"/admin/dashboard"},null,8,["title"]),s(u,{title:i.$tc("estimates.estimate",2),to:"/admin/estimates"},null,8,["title"]),i.$route.name==="estimates.edit"?(g(),y(u,{key:0,title:i.$t("estimates.edit_estimate"),to:"#",active:""},null,8,["title"])):(g(),y(u,{key:1,title:i.$t("estimates.new_estimate"),to:"#",active:""},null,8,["title"]))]),_:1})]),_:1},8,["title"]),s(he,{v:t(w),"is-loading":t(_),"is-edit":t(f)},null,8,["v","is-loading","is-edit"]),s(z,null,{default:l(()=>[s(be,{currency:t(e).newEstimate.selectedCurrency,"is-loading":t(_),"item-validation-scope":c,store:t(e),"store-prop":"newEstimate"},null,8,["currency","is-loading","store"]),B("div",xe,[B("div",Ie,[s(ve,{store:t(e),"store-prop":"newEstimate",fields:S.value,type:"Estimate"},null,8,["store","fields"]),s(Ee,{type:"Estimate","is-edit":t(f),"is-loading":t(_),store:t(e),"store-prop":"newEstimate","custom-field-scope":c,class:"mb-6"},null,8,["is-edit","is-loading","store"]),s(ye,{store:t(e),"component-name":"EstimateTemplate","store-prop":"newEstimate"},null,8,["store"])]),s(we,{currency:t(e).newEstimate.selectedCurrency,"is-loading":t(_),store:t(e),"store-prop":"newEstimate","tax-popup-type":"estimate"},null,8,["currency","is-loading","store"])])]),_:1})],40,Ce)]),_:1})],64)}}};export{Re as default};
|