1/*! For license information please see 1737.0a6719dd.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkgarage_management_frontend=self.webpackChunkgarage_management_frontend||[]).push([[1737],{17276:(e,a,t)=>{t.d(a,{A:()=>c,q:()=>i});var n=t(80903),o=t(55030),s=t(79618),r=t(9332),l=t(44414);const i=e=>{let{onClick:a,label:t="Methodology",tone:o="default",className:s=""}=e;const r={default:"border border-slate-200 bg-slate-100 text-slate-700 hover:bg-slate-200 hover:text-slate-900",slate:"border border-slate-200 bg-slate-100 text-slate-700 hover:bg-slate-200 hover:text-slate-900",blue:"border border-blue-200 bg-blue-50 text-blue-700 hover:bg-blue-100 hover:text-blue-900"};return(0,l.jsxs)("button",{onClick:a,className:`inline-flex items-center gap-1.5 text-sm font-medium transition-colors rounded-full px-3 py-1.5 ${r[o]||r.default} ${s}`.trim(),children:[(0,l.jsx)(n.A,{className:"h-4 w-4"}),t]})},c=e=>{let{open:a,onOpenChange:t,title:n="Report Methodology",meta:i,pinned:c,children:d,disclaimerContent:u,dialogClassName:p="",bodyClassName:m=""}=e;const{t:g}=(0,o.Bd)("common"),h=g("close","Close");return(0,l.jsxs)(s.A,{open:a,onOpenChange:t,title:n,description:i,size:"wide",contentClassName:p,bodyClassName:(0,r.cn)("space-y-0",m),summary:u,cancelAction:{label:h},children:[c?(0,l.jsx)("div",{className:"sticky top-0 z-10 bg-white dark:bg-gray-900",children:c}):null,(0,l.jsx)("div",{className:"text-[14px] leading-relaxed text-slate-700 [&>ul>li]:pl-1 [&>ul>li+li]:border-t [&>ul>li+li]:border-slate-100 [&>ul>li+li]:pt-3",children:d})]})}},50684:(e,a,t)=>{t.d(a,{A:()=>r});t(9950);var n=t(69256),o=t(9332),s=t(44414);const r=e=>{let{options:a=[],value:t,onChange:r,tone:l="blue",name:i,className:c,testId:d}=e;const u=(0,n.TE)(l);return(0,s.jsx)("div",{role:"radiogroup","aria-label":i,"data-testid":d,className:(0,o.cn)("flex flex-col",c),children:a.map(((e,n)=>{const l=e.value===t;return(0,s.jsxs)("button",{type:"button",role:"radio","aria-checked":l,disabled:e.disabled,"data-testid":e.testId,onClick:()=>null===r||void 0===r?void 0:r(e.value),className:(0,o.cn)("flex items-center justify-between gap-3 border border-solid border-slate-200 px-3 py-2.5 text-start transition-colors disabled:opacity-50 dark:border-slate-700",0===n&&"rounded-t-xl",n===a.length-1&&"rounded-b-xl",n>0&&"-mt-px",l?u.optionSelected:"bg-white hover:bg-slate-50 dark:bg-transparent"),children:[(0,s.jsxs)("span",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"block truncate text-[14px] font-medium text-slate-900 dark:text-slate-100",children:e.label}),e.description?(0,s.jsx)("span",{className:"block truncate text-[13px] text-slate-500 dark:text-slate-400",children:e.description}):null]}),(0,s.jsx)("span",{"aria-hidden":"true",className:(0,o.cn)("h-4 w-4 shrink-0 rounded-full border border-solid",l?u.optionDot:"border-slate-300 dark:border-slate-600")})]},e.value)}))})}},22998:(e,a,t)=>{t.d(a,{A:()=>x});var n=t(9950),o=t(42074),s=t(28429),r=t(7901),l=t(77801),i=t(81946),c=t(45530),d=t(99938),u=t(79618),p=t(77060),m=t(50684),g=t(69256),h=t(63815),y=t(44414);const b=e=>{var a,t,o,r,l,b,v,f,x,C,A,w;let{feature:D,organization:j,garageId:k,children:R}=e;const E=(0,s.Zp)(),[F,N]=(0,n.useState)(!1),[O,P]=(0,n.useState)("monthly"),[B,T]=(0,n.use
2State)(null),M=(null===j||void 0===j||null===(a=j.address)||void 0===a?void 0:a.country)||(null===j||void 0===j?void 0:j.country),S=(0,n.useMemo)((()=>(0,d.Rz)(M)),[M]),$=(0,n.useMemo)((()=>(0,d.kw)(M)),[M]);if((null===j||void 0===j||null===(t=j.features)||void 0===t||null===(o=t[D])||void 0===o?void 0:o.enabled)||(null===j||void 0===j||null===(r=j.subscription)||void 0===r||null===(l=r.addons)||void 0===l?void 0:l.some((e=>e.feature===D&&"active"===e.status))))return R;const I={financialReports:{title:"Unlock Financial Reports",description:"Get deep insights into your business performance with advanced financial reporting",monthlyPrice:(null===$||void 0===$||null===(b=$.monthly)||void 0===b?void 0:b.amount)||0,monthlyPriceFormatted:(null===$||void 0===$||null===(v=$.monthly)||void 0===v?void 0:v.price)||"$0",yearlyPrice:(null===$||void 0===$||null===(f=$.yearly)||void 0===f?void 0:f.amount)||(null!==$&&void 0!==$&&null!==(x=$.monthly)&&void 0!==x&&x.amount?10*$.monthly.amount:0),yearlyPriceFormatted:(null===$||void 0===$||null===(C=$.yearly)||void 0===C?void 0:C.price)||(null!==$&&void 0!==$&&null!==(A=$.monthly)&&void 0!==A&&A.price?`${$.symbol||"$"}${(10*$.monthly.amount).toFixed(2)}`:"$0"),savings:null!==$&&void 0!==$&&null!==(w=$.yearly)&&void 0!==w&&w.originalPrice?Math.round((parseFloat($.yearly.originalPrice.replace(/[^\d.]/g,""))-$.yearly.amount)/parseFloat($.yearly.originalPrice.replace(/[^\d.]/g,""))*100):17,currency:(null===$||void 0===$?void 0:$.currency)||"USD",symbol:(null===$||void 0===$?void 0:$.symbol)||"$",features:["Profit & Loss Statement","Balance Sheet","Cash Flow Statement","Transaction Ledger","Account Balances","Aged Receivables","Aged Payables","Tax Reports (VAT/Sales Tax)","Export to Excel/PDF","Monthly Usage Limits"]}}[D];if(!I)return(0,y.jsx)(u.A,{open:!0,onOpenChange:()=>{},title:`Feature configuration not found: ${D}`,size:"standard",hideCloseButton:!0,primaryAction:{label:"Go to Dashboard",onClick:()=>E("/dashboard")}});return(0,y.jsxs)(u.A,{open:!0,onOpenChange:()=>{}
2,title:I.title,description:I.description,tone:"blue",size:"standard",summary:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("span",{children:"yearly"===O?"Billed yearly":"Billed monthly"}),(0,y.jsx)("b",{children:"yearly"===O?`${I.yearlyPriceFormatted}/year`:`${I.monthlyPriceFormatted}/month`})]}),primaryAction:{label:F?"Processing...":"Subscribe",onClick:()=>async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"monthly";N(!0),T(null);try{const a=await c.default.post(`/api/subscriptions/addons/${D}/purchase`,{billingInterval:e,region:S,garageId:k});if(!a.data.checkoutUrl)throw new Error("No checkout URL received");window.location.href=a.data.checkoutUrl}catch(n){var a,t;console.error("Error purchasing add-on:",n),T((null===(a=n.response)||void 0===a||null===(t=a.data)||void 0===t?void 0:t.error)||"Failed to start purchase. Please try again."),N(!1)}}(O),loading:F},cancelAction:{label:"Go Back",onClick:()=>E(-1),disabled:F},children:[B&&(0,y.jsx)("p",{className:g.d$.red,children:B}),(0,y.jsx)(m.A,{name:"Billing period",value:O,onChange:P,options:[{value:"monthly",label:"Monthly",description:`${I.monthlyPriceFormatted} per month`},{value:"yearly",label:"Yearly",description:`${I.yearlyPriceFormatted} per year \xb7 save ${I.savings}%`}]}),(0,y.jsxs)("div",{className:"space-y-1.5",children:[(0,y.jsx)("p",{className:h.Ho,children:"Included Features:"}),(0,y.jsx)(p.A,{items:I.features.map((e=>({label:e})))})]}),(0,y.jsxs)("div",{className:"space-y-1 text-[13px] leading-5 text-slate-500",children:[(0,y.jsxs)("p",{className:"flex items-center gap-1.5",children:[(0,y.jsx)(i.A,{className:"h-3.5 w-3.5 shrink-0"}),"Secure checkout powered by Stripe"]}),(0,y.jsx)("p",{children:"Cancel anytime. Billed separately from your main subscription."})]})]})},v=e=>{let{isOpen:a,onClose:t,addonName:n="Financial Reports",features:o=["Profit & Loss Statement","Balance Sheet","Cash Flow Statement","Transaction Ledger","Account Balances","Aged Receivables","Aged Payables","Tax Reports"],showCloseButton:s=!0,isDismissible:r=!0}=e;if(!a)return null;return(0,y.jsxs)(u.A,{open:a,onOpenChange:e=>{!e&&r&&t()},hideCloseButton:!s,tone:"green",size:"standard",title:`Welcome to ${n}!`,description:"Your add-on is now active and ready to use",primaryAction:{label:"Get Started",onClick:()=>{t()}},children:[(0,y.jsxs)("div",{className:"space-y-1.5",children:[(0,y.jsx)("p",{className:h.Ho,children:"You now have access to:"}),(0,y.jsx)(p.A,{items:o.map((e=>({label:e})))})]}),(0,y.jsxs)("p",{className:g.d$.blue,children:[(0,y.jsx)("span",{className:"font-semibold",children:"Billing:"})," This add-on will be billed separately and included in your next invoice."]})]})};var f=t(74452);const x=e=>{const a=a=>{var t,i,d,u,p,m,g;const[h,x]=(0,o.ok)(),{garageId:C}=(0,s.g)(),{organizationId:A,isFeatureEnabled:w,loading:D,refreshFeatures:j}=(0,l.e)(),[k,R]=(0,n.useState)(!1),E="true"===h.get("addon_success"),{data:F,isLoading:N}=(0,r.I)({queryKey:["organization",A],queryFn:async()=>{const e=await c.default.get(`/api/organizations/${A}`);return e.data.success?e.data.data:null},enabled:!!A,staleTime:18e5,gcTime:36e5,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1});if((0,n.useEffect)((()=>{E&&A&&(console.log("[Addon Activation] Purchase successful, refreshing features and showing success modal"),j(),(0,f.bu)(A),R(!0),h.delete("addon_success"),x(h,{replace:!0}))}),[E,A,j,h,x]),D||N)return(0,y.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,y.jsxs)("div",{className:"text-center",children:[(0,y.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),(0,y.jsx)("p",{className:"text-gray-600",children:"Loading..."})]})});const O=w("financialReports")||(null===F||void 0===F||null===(t=F.features)||void 0===t||null===(i=t.financialReports)||void 0===i?void 0:i.enabled)||(null===F||void 0===F||null===(d=F.subscription)||void 0===d||null===(u=d.addons)||void 0===u?void 0:u.some((e=>"financialReports"===e.feature&&"active"===e.status)));return console.log("[withFinancialReportsAccess] Access Check:",{hasFinancialReports:O,fromHook:w("financialReports"),fromOrgFeatures:null===F||void 0===F||null===(p=F.features)||void 0===p||null===(m=p.financialReports)||void 0===m?void 0:m.enabled,orgFeatures:null===F||void 0===F?void 0:F.features,orgAddons:null===F||void 0===F||null===(g=F.subscription)||void 0===g?void 0:g.addons,organizationId:A}),O?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(v,{isOpen:k,onClose:()=>R(!1),addonName:"Financial Reports"}),(0,y.jsx)(e,{...a}
2)]}):(0,y.jsx)(b,{feature:"financialReports",organization:F,garageId:C,children:(0,y.jsx)("div",{})})};return a.displayName=`withFinancialReportsAccess(${function(e){return e.displayName||e.name||"Component"}(e)})`,a}},93651:(e,a,t)=>{t.d(a,{Fq:()=>w,HQ:()=>f,LY:()=>A,We:()=>C,b8:()=>k,cE:()=>x,gn:()=>j,h1:()=>b,ll:()=>u,py:()=>D,rG:()=>y,sp:()=>v});var n=t(7901),o=t(9950),s=t(45530),r=t(25137);const l={"profit-loss":0,"financial-actuals":0,"general-ledger":36e5,"cash-flow":36e5,"aged-receivables":72e5,"aged-payables":72e5,"balance-sheet":72e5,"account-balances":72e5,tax:72e5,"financial-summary":0},i=new Set(["profit-loss","financial-actuals"]),c=new Set(["aged-receivables","aged-payables","balance-sheet"]),d=(e,a)=>{if(!a)return"";try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:a,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(e)),n=Object.fromEntries(t.map((e=>[e.type,e.value])));return`${n.year}-${n.month}-${n.day}`}catch{return""}},u=function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();const t=d(a,e);if(!t)return!1;let n=a,o=a+1296e5;if(d(o,e)===t)return!1;for(;o-n>1e3;){const a=Math.floor((n+o)/2);d(a,e)===t?n=a:o=a}return Math.max(1e3,o-a+1e3)},p={"profit-loss":{currency:{code:"AED",symbol:"AED"},period:{start:null,end:null,label:""},data:{current:{revenue:{service:0,parts:0,labour:0,other:0,total:0,jobCount:0,invoiceCount:0,issuedInvoices:[],linkedJobCogs:[],notYetInvoicedCompletedJobs:[]},cogs:{parts:0,labour:0,other:0,jobLinkedTotal:0,unallocatedCogs:0,recordedCogsExpensesTotal:0,total:0,cogsBasis:"job_linked",includesRecordedCogsExpenses:!1,recordedExpenses:[]},grossProfit:0,grossProfitMargin:0,operatingExpenses:{total:0,byCategory:[]},netProfit:0,netProfitMargin:0,profitMargin:0},previous:null,comparison:null}},"financial-actuals":{currency:{code:"AED",symbol:"AED"},period:{start:null,end:null,label:""},summaryCards:[],months:[],rows:[],meta:{basis:"completed_jobs_and_recorded_expenses",profitView:"accounting",cogsBasis:"job_linked",includesRecordedCogsExpenses:!1,generatedAt:null,reportMode:"actual_and_forecast",actualsThrough:null,forecastBasis:"recurring_indirect_expenses_only",includeUpcomingRecurringThisMonth:!1,hasCurrentMonthUpcomingRecurring:!1,dataQuality:{},limitations:[]}},tax:{currency:{code:"AED",symbol:"AED"},period:{start:null,end:null,label:""},data:{taxLabel:"VAT",summary:{totalNet:0,totalTax:0,totalGross:0,totalRecoverable:0,netVatDue:0,transactionCount:0,effectiveRate:0},byRate:[],byCode:[],byCategory:[],recoverable:{recoverable:{amount:0,taxAmount:0,count:0,percentage:0},nonRecoverable:{amount:0,count:0,percentage:0}},transactions:[]}},"aged-receivables":{currency:{code:"AED",symbol:"AED"},asOfDate:null,asOfLabel:"",data:{summary:{totalOutstanding:0,current:0,days1to30:0,days31to60:0,days61to90:0,over90Days:0,invoiceCount:0,customerCount:0},agingBuckets:[],byCustomer:[],invoices:[]}},"aged-payables":{currency:{code:"AED",symbol:"AED"},asOfDate:null,asOfLabel:"",data:{summary:{totalOutstanding:0,current:0,days1to30:0,days31to60:0,days61to90:0,over90Days:0,billCount:0,vendorCount:0,averageBillAge:0},totalOutstanding:0,agingBuckets:[],byVendor:[],expenses:[]}},"general-ledger":{currency:{code:"AED",symbol:"AED"},period:{start:null,end:null,label:""},data:{entries:[],summary:{openingBalance:0,closingBalance:0,totalRevenue:0,totalExpenses:0,entryCount:0}},pagination:{limit:50,offset:0,total:0,hasMore:!1}},"cash-flow":{currency:{code:"AED",symbol:"AED"},data:{period:{label:"",startDate:null,endDate:null},summary:{netCashFlow:0,netOperatingCash:0,netInvestingCash:0,netFinancingCash:0},operating:{cashReceived:0,customerRefunds:0,cashPaidToSuppliers:0,cashPaidForExpenses:0,cashPaidForTax:0},investing:{equipmentPurchases:0,assetSales:0},financing:{ownerContributions:0,ownerDrawings:0,loanRepayments:0}}},"balance-sheet":{currency:{code:"AED",symbol:"AED"},asOfDate:null,data:{current:{assets:{current:{accountsReceivable:0,inventory:0,total:0},fixed:{total:0},total:0},liabilities:{current:{accountsPayable:0,total:0},longTerm:{total:0},total:0},equity:{total:0}},previous:null}},"account-balances":{currency:{code:"AED",symbol:"AED"},data:{accounts:[],summary:{totalRevenue:0,totalExpenses:0,netBalance:0},comparison:null}},"financial-summary":{currency:{code:"AED",symbol:"AED"}
2,period:{start:null,end:null,label:""},data:{current:{revenue:0,completedRevenue:0,invoicedRevenue:0,expenseTotal:0,grossProfit:0,grossMargin:0,operatingExpenses:0,netProfit:0,netMargin:0,netCashFlow:0,accountsReceivable:0,accountsPayable:0,netVatDue:0},previous:{},deltas:{},questions:[],needsAttention:[],history:[]}}},m=r.CT,g=(e,a)=>{const t={},n=(0,r.yT)(a);switch(e){case"profit-loss":case"financial-actuals":case"tax":case"cash-flow":case"financial-summary":(a.preset||a.startDate&&a.endDate)&&Object.assign(t,n),"financial-summary"===e&&(t.view="matrix-v5"),a.includeComparison&&(t.includeComparison=!0),"profit-loss"===e&&a.cogsBasis&&(t.cogsBasis=a.cogsBasis),"financial-actuals"===e&&void 0!==a.includeUpcomingRecurringThisMonth&&(t.includeUpcomingRecurringThisMonth=Boolean(a.includeUpcomingRecurringThisMonth)),"financial-actuals"===e&&a.cogsBasis&&(t.cogsBasis=a.cogsBasis),"financial-actuals"===e&&a.profitView&&(t.profitView=a.profitView);break;case"aged-receivables":case"aged-payables":(0,r.C)(a.preset)?t.preset=(0,r.C)(a.preset):a.asOfDate&&(t.asOfDate=m(a.asOfDate)),a.includeComparison&&(t.compare=!0);break;case"balance-sheet":(0,r.C)(a.preset)?t.preset=(0,r.C)(a.preset):a.asOfDate&&(t.asOfDate=m(a.asOfDate)),"balance-sheet"===e&&a.includeComparison&&(t.includeComparison=!0);break;case"general-ledger":(a.preset||a.startDate&&a.endDate)&&Object.assign(t,n),a.page&&(t.page=a.page),a.limit&&(t.limit=a.limit),a.search&&(t.search=a.search),a.category&&(t.category=a.category),a.vendor&&(t.vendor=a.vendor),a.customer&&(t.customer=a.customer),a.type&&(t.type=a.type),a.paymentSource&&(t.paymentSource=a.paymentSource),a.invoiceStatus&&(t.invoiceStatus=a.invoiceStatus);break;case"account-balances":(a.preset||a.startDate&&a.endDate)&&Object.assign(t,n),a.compare&&(t.compare=!0)}return t},h=function(e,a){var t;let d=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{enabled:m=!0,...h}=d,y="financial-summary"===e,b=c.has(e)&&"today"===(0,r.C)(h.preset),v=y||i.has(e)||b,f=g(e,h),x=y?"gross-expenses-utc-date-boundaries-v1":"profit-loss"===e?"cogs-basis-v1":"general-ledger"===e?"invoice-state-column-v1":null,C=x?["financial-report",e,x,a,f]:["financial-report",e,a,f],{data:A,isLoading:w,isFetching:D,isError:j,error:k,refetch:R}=(0,n.I)({queryKey:C,queryFn:async()=>{const t=y?{...f,_t:Date.now()}:f;return(await s.default.get(`/api/financial/${a}/${e}`,{params:t,headers:y?{"Cache-Control":"no-cache",Pragma:"no-cache"}:void 0})).data},enabled:m&&!!a&&!!e,staleTime:b?0:null!==(t=l[e])&&void 0!==t?t:36e5,gcTime:v?0:72e5,refetchOnWindowFocus:y||b,refetchOnMount:!!v&&"always",refetchOnReconnect:y||b,refetchInterval:!!b&&(e=>u(null===e||void 0===e?void 0:e.timezone)),refetchIntervalInBackground:!1,placeholderData:y?void 0:e=>e,retry:2,retryDelay:e=>Math.min(1e3*2**e,1e4)}),E=(0,o.useCallback)((()=>{R()}),[R]);return{data:A||p[e]||{},isLoading:w&&!A,isFetching:D,isError:j,error:k,refresh:E}},y=()=>({exportReport:(0,o.useCallback)((async function(e,a){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=g(e,t);n.format=t.format||"excel";return(await s.default.get(`/api/financial/${a}/${e}/export`,{params:n,responseType:"blob"})).data}),[])}),b=function(e){return h("profit-loss",e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})},v=function(e){return h("financial-actuals",e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})},f=function(e){return h("tax",e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})},x=function(e){return h("aged-receivables",e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})},C=function(e){return h("aged-payables",e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})},A=function(e){return h("general-ledger",e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})},w=function(e){return h("cash-flow",e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})},D=function(e){return h("balance-sheet",e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})},j=function(e){return h("account-balances",e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})},k=function(e){return h("financial-summary",e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}},80903:(e,a,t)=>{t.d(a,{A:()=>n});const n=(0,t(44489).A)("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]])},81946:(e,a,t)=>{t.d(a,{A:()=>n});const n=(0,t(44489).A)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
2y:"oel41y"}]])}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.