PageSourceSearch

https://goneat.co.uk/assets/vat-settings-7DUWJwwW.js

js goneat.co.uk collected 2026-09-24 15:14:40 UTC 5,841 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-query-D1Mshrk-.js";import{r as j}from"./vendor-react-BfQMi0FG.js";import{P as E}from"./page-header-C7x1KRLA.js";import{C as g,a as v,b as f,d as N}from"./card-C6DfUXn8.js";import{Y as k,a0 as F,Z as L,L as o,B as x,j as O,I as b,t as n}from"./index-D3kn74s7.js";import{S as C}from"./switch-vuioQ0-X.js";import{S as Z,a as P,b as B,c as I,d as T}from"./select-Da-jnnzS.js";import"./vendor-ui-nQy3bJlE.js";import"./check-CXo9hMCb.js";const A={0:{name:"Zero Rated",rate:0},1:{name:"Standard",rate:20},2:{name:"Reduced",rate:5}};function J(){const{data:i,isLoading:S}=k(),{data:m}=F(),d=L(),[c,l]=j.useState({});j.useEffect(()=>{if(i?.vatRates){const s={...i.vatRates};s[0]||(s[0]={name:"Zero Rated",rate:0}),l(s)}},[i?.vatRates]);const h=(s,t)=>{const r={[s]:t};s==="vatEnabled"&&t&&!i?.vatRates&&(r.vatType="inclusive",r.vatRates=A,l(A)),d.mutate(r,{onSuccess:()=>n.success("Setting updated"),onError:()=>n.error("Failed to update setting")})},V=(s,t)=>{d.mutate({[s]:t},{onSuccess:()=>n.success("Setting updated"),onError:()=>n.error("Failed to update setting")})},p=(s,t,r)=>{const a={...c};a[s]||(a[s]={name:"",rate:0}),t==="rate"?a[s]={...a[s],rate:parseFloat(r)||0}:a[s]={...a[s],name:r},l(a)},y=()=>{const s={...c};s[0]||(s[0]={name:"Zero Rated",rate:0}),d.mutate({vatRates:s},{onSuccess:()=>n.success("VAT rates updated"),onError:()=>n.error("Failed to update VAT rates")})},R=()=>{const s=Object.keys(c).map(Number);if(s.filter(a=>a>0).length>=4){n.error("Maximum 4 custom VAT rates allowed");return}const r=Math.max(0,...s)+1;l({...c,[String(r)]:{name:"",rate:0}})},w=s=>{if(s==="0")return;const t={...c};delete t[s],l(t),d.mutate({vatRates:t},{onSuccess:()=>n.success("VAT rate removed"),onError:()=>n.error("Failed to remove VAT rate")})};if(S)return e.jsx("div",{className:"p-6",children:"Loading..."});const u=i?.vatEnabled??!1;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{title:"VAT Settings",description:"Configure VAT calculation for orders"}),e.jsxs(g,{children:[e.jsx(v,{children:e.jsx(f,{children:"VAT Configuration"})}),e.jsxs(N,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(o,{children:"Enable VAT"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Calculate VAT on orders based on product/category settings"})]}),e.jsx(C,{checked:u,onCheckedChange:s=>h("vatEnabled",s)})]}),u&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"VAT Mode"}),e.jsxs(Z,{value:i?.vatType||"inclusive",onValueChange:s=>V("vatType",s),children:[e.jsx(P,{className:"w-full",children:e.jsx(B,{})}),e.jsxs(I,{children:[e.jsx(T,{value:"inclusive",children:"Inclusive (prices include VAT)"}),e.jsx(T,{value:"exclusive",children:"Exclusive (VAT added on top)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i?.vatType==="exclusive"?"VAT will be added on top of the product prices at checkout.":"Product prices already include VAT. The VAT amount will be shown as informational."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(o,{children:"VAT on Service Charge"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Apply the default VAT rate to service charges"})]}),e.jsx(C,{checked:i?.vatOnServiceCharge??!1,onCheckedChange:s=>h("vatOnServiceCharge",s)})]}),m?.taxNumber&&e.jsxs("div",{className:"rounded-lg border p-3 bg-muted/50",children:[e.jsxs("p",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"VAT Registration Number:"})," ",e.jsx("span",{className:"font-medium",children:m.taxNumber})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Edit in Basic Details settings"})]}),!m?.taxNumber&&e.jsx("p",{className:"text-xs text-amber-600",children:"No VAT registration number set. Add it in Basic Details settings to show it on receipts and emails."})]})]})]}),u&&e.jsxs(g,{children:[e.jsxs(v,{className:"flex flex-row items-center justify-between",children:[e.jsx(f,{children:"VAT Rates"}),e.jsx(x,{variant:"outline",size:"sm",onClick:R,disabled:Object.keys(c).filter(s=>s!=="0").length>=4,children:"Add Rate"})]}),e.jsxs(N,{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Code 0 (Zero Rated) is always present. Add up to 4 custom rates. Assign codes to categories/products. Leave a category/product unset to make it not VATable. Code 1 is used as the default rate for service charge VAT."}),Object.entries(c).sort(([s],[t])=>Number(s)-Number(t)).map(([s,t])=>{const r=s==="0";return e.jsxs("div",{className:"rounded-lg border p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-8 items-center rounded-md border bg-muted px-3 text-sm font-medium",children:s}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Code"})]}),!r&&e.jsx(x,{variant:"ghost",size:"icon",className:"text-destructive h-8 w-8",onClick:()=>w(s),children:e.jsx(O,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(o,{className:"text-xs",children:"Name"}),e.jsx(b,{value:t.name,onChange:a=>p(s,"name",a.target.value),placeholder:"e.g. Standard",disabled:r})]}),e.jsxs("div",{className:"w-24 space-y-1",children:[e.jsx(o,{className:"text-xs",children:"Rate %"}),e.jsx(b,{type:"number",step:"0.01",value:t.rate,onChange:a=>p(s,"rate",a.target.value),disabled:r})]})]})]},s)}),Object.keys(c).length>0&&e.jsx(x,{onClick:y,disabled:d.isPending,children:"Save Rates"})]})]})]})}export{J as VatSettingsPage};

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.