芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/invoicer.pulsehost.co.uk/public/build/assets/InvoiceCreate-BCnV08Iv.js
import{aq as L,r as s,o as v,c as E,a as n,l as t,w as a,E as H,ae as A,av as J,v as K,L as O,e as W,f as C,k as w,g as f,h as $,ai as Q,ag as X,W as Z,j as ee,z as te,m as y,K as k,b as B,t as V,J as ne,p as oe,q as ie,N as ae,P as se}from"./main-WS8l16KQ.js";import{_ as le,a as ce,b as re,c as ue,d as de,e as me,f as ve}from"./SalesTax-LST-awog.js";import{_ as pe}from"./ExchangeRateConverter-oor-rXm9.js";import{_ as ge}from"./CreateCustomFields-KP2lJheQ.js";import{_ as _e}from"./TaxTypeModal-BIJxDmkL.js";import"./DragIcon-Bhk7q250.js";import"./SelectNotePopup-C-3WYDWX.js";import"./NoteModal-CwF9gy7n.js";import"./payment-DKm7vv1R.js";import"./exchange-rate-MCtDo2g9.js";import"./dynamic-import-helper-BheWnx7M.js";const fe={class:"grid grid-cols-12 gap-8 mt-6 mb-8"},Ie={__name:"InvoiceCreateBasicFields",props:{v:{type:Object,default:null},isLoading:{type:Boolean,default:!1},isEdit:{type:Boolean,default:!1}},setup(i){const e=L();return(p,l)=>{const h=s("BaseCustomerSelectPopup"),c=s("BaseDatePicker"),g=s("BaseInputGroup"),S=s("BaseInput"),m=s("BaseInputGrid");return v(),E("div",fe,[n(h,{modelValue:t(e).newInvoice.customer,"onUpdate:modelValue":l[0]||(l[0]=r=>t(e).newInvoice.customer=r),valid:i.v.customer_id,"content-loading":i.isLoading,type:"invoice",class:"col-span-12 lg:col-span-5 pr-0"},null,8,["modelValue","valid","content-loading"]),n(m,{class:"col-span-12 lg:col-span-7"},{default:a(()=>[n(g,{label:p.$t("invoices.invoice_date"),"content-loading":i.isLoading,required:"",error:i.v.invoice_date.$error&&i.v.invoice_date.$errors[0].$message},{default:a(()=>[n(c,{modelValue:t(e).newInvoice.invoice_date,"onUpdate:modelValue":l[1]||(l[1]=r=>t(e).newInvoice.invoice_date=r),"content-loading":i.isLoading,"calendar-button":!0,"calendar-button-icon":"calendar"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),n(g,{label:p.$t("invoices.due_date"),"content-loading":i.isLoading},{default:a(()=>[n(c,{modelValue:t(e).newInvoice.due_date,"onUpdate:modelValue":l[2]||(l[2]=r=>t(e).newInvoice.due_date=r),"content-loading":i.isLoading,"calendar-button":!0,"calendar-button-icon":"calendar"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading"]),n(g,{label:p.$t("invoices.invoice_number"),"content-loading":i.isLoading,error:i.v.invoice_number.$error&&i.v.invoice_number.$errors[0].$message,required:""},{default:a(()=>[n(S,{modelValue:t(e).newInvoice.invoice_number,"onUpdate:modelValue":l[3]||(l[3]=r=>t(e).newInvoice.invoice_number=r),"content-loading":i.isLoading,onInput:l[4]||(l[4]=r=>i.v.invoice_number.$touch())},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading","error"]),n(pe,{store:t(e),"store-prop":"newInvoice",v:i.v,"is-loading":i.isLoading,"is-edit":i.isEdit,"customer-currency":t(e).newInvoice.currency_id},null,8,["store","v","is-loading","is-edit","customer-currency"])]),_:1})])}}},we={class:"flex"},ye={class:"block mt-10 invoice-foot lg:flex lg:justify-between lg:items-start"},be={class:"relative w-full lg:w-1/2 lg:mr-4"},q="newInvoice",Pe={__name:"InvoiceCreate",setup(i){const e=L(),p=H(),l=A(),h=J(),{t:c}=K.useI18n();let g=O(),S=W(),m=C(!1);const r=C(!1),P=C(["customer","company","customerCustom","invoice","invoiceCustom"]);let I=w(()=>e.isFetchingInvoice||e.isFetchingInitialSettings),F=w(()=>_.value?c("invoices.edit_invoice"):c("invoices.new_invoice"));const M=w(()=>p.selectedCompanySettings.sales_tax_us_enabled==="YES"&&h.salesTaxUSEnabled);let _=w(()=>g.name==="invoices.edit");const T={invoice_date:{required:f.withMessage(c("validation.required"),$)},reference_number:{maxLength:f.withMessage(c("validation.price_maxlength"),Q(255))},customer_id:{required:f.withMessage(c("validation.required"),$)},invoice_number:{required:f.withMessage(c("validation.required"),$)},exchange_rate:{required:X(function(){return f.withMessage(c("validation.required"),$),e.showExchangeRate}),decimal:f.withMessage(c("validation.valid_exchange_rate"),Z)}},b=ee(T,w(()=>e.newInvoice),{$scope:q});l.resetCustomFields(),b.value.$reset,e.resetCurrentInvoice(),e.fetchInvoiceInitialSettings(_.value),te(()=>e.newInvoice.customer,o=>{o&&o.currency?e.newInvoice.selectedCurrency=o.currency:e.newInvoice.selectedCurrency=p.selectedCompanyCurrency});async function N(){if(b.value.$touch(),b.value.$invalid)return!1;m.value=!0;let o=se.cloneDeep({...e.newInvoice,sub_total:e.getSubTotal,total:e.getTotal,tax:e.getTotalTax});o.discount_per_item==="YES"?o.items.forEach((u,d)=>{u.discount_type==="fixed"&&(o.items[d].discount=u.discount*100)}):o.discount_type==="fixed"&&(o.discount=o.discount*100),!e.newInvoice.tax_per_item==="YES"&&o.taxes.length&&(o.tax_type_ids=o.taxes.map(u=>u.tax_type_id));try{const d=await(_.value?e.updateInvoice:e.addInvoice)(o);S.push(`/admin/invoices/${d.data.data.id}/view`)}catch(u){console.error(u)}m.value=!1}return(o,u)=>{const d=s("BaseBreadcrumbItem"),D=s("BaseBreadcrumb"),x=s("BaseButton"),U=s("router-link"),j=s("BaseIcon"),G=s("BasePageHeader"),R=s("BaseScrollPane"),Y=s("BasePage");return v(),E(ae,null,[n(le),n(ce),n(_e),M.value&&(!t(I)||t(g).query.customer)?(v(),y(re,{key:0,store:t(e),"is-edit":t(_),"store-prop":"newInvoice",customer:t(e).newInvoice.customer},null,8,["store","is-edit","customer"])):k("",!0),n(Y,{class:"relative invoice-create-page"},{default:a(()=>[B("form",{onSubmit:ie(N,["prevent"])},[n(G,{title:t(F)},{actions:a(()=>[o.$route.name==="invoices.edit"?(v(),y(U,{key:0,to:`/invoices/pdf/${t(e).newInvoice.unique_hash}`,target:"_blank"},{default:a(()=>[n(x,{class:"mr-3",variant:"primary-outline",type:"button"},{default:a(()=>[B("span",we,V(o.$t("general.view_pdf")),1)]),_:1})]),_:1},8,["to"])):k("",!0),n(x,{loading:t(m),disabled:t(m),variant:"primary",type:"submit"},{left:a(z=>[t(m)?k("",!0):(v(),y(j,{key:0,name:"SaveIcon",class:ne(z.class)},null,8,["class"]))]),default:a(()=>[oe(" "+V(o.$t("invoices.save_invoice")),1)]),_:1},8,["loading","disabled"])]),default:a(()=>[n(D,null,{default:a(()=>[n(d,{title:o.$t("general.home"),to:"/admin/dashboard"},null,8,["title"]),n(d,{title:o.$t("invoices.invoice",2),to:"/admin/invoices"},null,8,["title"]),o.$route.name==="invoices.edit"?(v(),y(d,{key:0,title:o.$t("invoices.edit_invoice"),to:"#",active:""},null,8,["title"])):(v(),y(d,{key:1,title:o.$t("invoices.new_invoice"),to:"#",active:""},null,8,["title"]))]),_:1})]),_:1},8,["title"]),n(Ie,{v:t(b),"is-loading":t(I),"is-edit":t(_)},null,8,["v","is-loading","is-edit"]),n(R,null,{default:a(()=>[n(ue,{currency:t(e).newInvoice.selectedCurrency,"is-loading":t(I),"item-validation-scope":q,store:t(e),"store-prop":"newInvoice"},null,8,["currency","is-loading","store"]),B("div",ye,[B("div",be,[n(de,{store:t(e),"store-prop":"newInvoice",fields:P.value,type:"Invoice"},null,8,["store","fields"]),n(ge,{type:"Invoice","is-edit":t(_),"is-loading":t(I),store:t(e),"store-prop":"newInvoice","custom-field-scope":q,class:"mb-6"},null,8,["is-edit","is-loading","store"]),n(me,{store:t(e),"store-prop":"newInvoice","component-name":"InvoiceTemplate","is-mark-as-default":r.value},null,8,["store","is-mark-as-default"])]),n(ve,{currency:t(e).newInvoice.selectedCurrency,"is-loading":t(I),store:t(e),"store-prop":"newInvoice","tax-popup-type":"invoice"},null,8,["currency","is-loading","store"])])]),_:1})],32)]),_:1})],64)}}};export{Pe as default};