PageSourceSearch

https://pulsecars.co.uk/assets/admin.receipt._id-C7pUFxLK.js

js pulsecars.co.uk collected 2026-10-08 06:12:41 UTC 11,700 bytes, 53 lines download raw bytes

1import{r as c,j as e,E as N,k as A,l as T,s as v,t as h,L as _,B as u,e as E,M as z}from"./main-BGPPHxHM.js";import{A as C}from"./arrow-left-CFvWDBUx.js";import{P as B}from"./printer-Dw0VV2dF.js";import{D}from"./download-C6W6ED4X.js";const n={name:"PULSE CARS LIMITED",addressLines:["181-187 HUNTERS ROAD","BIRMINGHAM, B19 1ES"],phone:"07450 918041",email:"[email protected]",website:"pulsecars.co.uk",bankName:"PULSE CARS LIMITED",accountNumber:"24774493",sortCode:"04-03-33"},d=t=>typeof t=="number"?new Intl.NumberFormat("en-GB",{style:"currency",currency:"GBP",minimumFractionDigits:2}).format(t):"—";function S(t){return t.stock_number?t.stock_number:`INV-${t.id.slice(0,6).toUpperCase()}`}function R({r:t}){const r=new Date(t.sold_at),a=c.useMemo(()=>{const s=new Date(r);return s.setDate(s.getDate()+7),s},[t.sold_at]),l=s=>s.toLocaleDateString("en-GB",{day:"2-digit",month:"2-digit",year:"2-digit"}),p=[t.year,t.make,t.model,t.variant,t.body_type,t.color?`(${t.color})`:null,t.registration?t.registration.toUpperCase():null].filter(Boolean).join(" "),o=t.sold_price??0,i=t.part_ex_taken&&t.part_ex_value?t.part_ex_value:0,f=Math.max(0,o-i);return e.jsxs("div",{className:"receipt-sheet bg-white text-black mx-auto",children:[e.jsxs("div",{className:"receipt-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"2px solid #000",paddingBottom:12,gap:12},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:28,margin:0,letterSpacing:1},children:"INVOICE"}),e.jsx("div",{style:{marginTop:6,fontSize:11,color:"#333"},children:n.website})]}),e.jsxs("div",{style:{textAlign:"right",fontSize:11},children:[e.jsx("div",{style:{fontWeight:700,fontSize:14},children:n.name}),n.addressLines.map(s=>e.jsx("div",{children:s},s)),e.jsx("div",{children:n.phone}),e.jsx("div",{children:n.email})]})]}),e.jsxs("div",{className:"receipt-grid-2",style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:24,marginTop:18},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#666",letterSpacing:1},children:"BILL TO"}),e.jsxs("div",{style:{marginTop:4},children:[e.jsx("div",{style:{fontWeight:600},children:t.customer_name??"—"}),t.customer_postcode&&e.jsx("div",{children:t.customer_postcode}),t.customer_phone&&e.jsx("div",{children:t.customer_phone}),t.customer_email&&e.jsx("div",{children:t.customer_email})]})]}),e.jsxs("div",{className:"receipt-meta",style:{textAlign:"right"},children:[e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("span",{style:{fontSize:10,fontWeight:700,color:"#666",letterSpacing:1},children:"INVOICE # "}),e.jsx("span",{style:{fontWeight:700},children:S(t)})]}),e.jsxs("div",{style:{marginBottom:4},children:[e.jsx("span",{style:{fontSize:10,fontWeight:700,color:"#666",letterSpacing:1},children:"CREATION DATE "}),e.jsx("span",{children:l(r)})]}),e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:10,fontWeight:700,color:"#666",letterSpacing:1},children:"DUE DATE "}),e.jsx("span",{children:l(a)})]})]})]}),e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",marginTop:22},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f1f1f1"},children:[e.jsx("th",{style:{textAlign:"left",padding:"8px 10px",fontSize:10,letterSpacing:1,borderBottom:"1px solid #000"},children:"DESCRIPTION"}),e.jsx("th",{className:"receipt-qty",style:{textAlign:"right",padding:"8px 10px",fontSize:10,letterSpacing:1,borderBottom:"1px solid #000",width:60},children:"QTY"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 10px",fontSize:10,letterSpacing:1,borderBottom:"1px solid #000",width:100},children:"PRICE"}),e.jsx("th",{style:{textAlign:"right",padding:"8px 10px",fontSize:10,letterSpacing:1,borderBottom:"1px solid #000",width:110},children:"AMOUNT"})]})}),e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsxs("td",{style:{padding:"10px",verticalAlign:"top",borderBottom:"1px solid #ddd"},children:[e.jsx("div",{style:{fontWeight:600},children:p}),e.jsx("div",{style:{marginTop:6,fontSize:11,color:"#444"},children:"THE CAR IS SOLD WITH 30 DAYS WARRANTY COVERING ENGINE AND GEARBOX ONLY. EXTENDED WARRANTY OFFERED."}),t.payment_method&&e.jsxs("div",{style:{marginTop:6,fontSize:11,color:"#444"},children:["CUSTOMER PAID BY ",t.payment_method.toUpperCase()]}),t.notes&&e.jsx("div",{style:{marginTop:6,fontSize:11,color:"#444",whiteSpace:"pre-wrap"},children:t.notes})]}),e.jsx("td",{className:"receipt-qty",style:{padding:"10px",verticalAlign:"top",textAlign:"right",borderBottom:"1px solid #ddd"},children:"1.00"}),e.jsx("td",{style:{padding:"10px",verticalAlign:"top",textAlign:"right",borderBottom:"1px solid #ddd"},children:d(o)}),e.jsx("td",{style:{padding:"10px",verticalAlign:"top",textAlign:"right",borderBottom:"1px solid #ddd"},children:d(o)})]}),t.part_ex_taken&&t.part_ex_value?e.jsxs("tr",{children:[e.jsxs("td",{style:{padding:"10px",borderBottom:"1px solid #ddd"},children:["Part-exchange allowance",t.part_ex_registration?` (${t.part_ex_registration.toUpperCase()})`:""]}),e.jsx("td",{className:"receipt-qty",style:{padding:"10px",textAlign:"right",borderBottom:"1px solid #ddd"},children:"1.00"}),e.jsxs("td",{style:{padding:"10px",textAlign:"right",borderBottom:"1px solid #ddd"},children:["-",d(t.part_ex_value)]}),e.jsxs("td",{style:{padding:"10px",textAlign:"right",borderBottom:"1px solid #ddd"},children:["-",d(t.part_ex_value)]})]}):null]})]}),e.jsxs("div",{className:"receipt-grid-2",style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:24,marginTop:18},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#666",letterSpacing:1},children:"PAYMENT METHOD"}),e.jsxs("div",{style:{marginTop:4},children:[e.jsx("div",{children:n.bankName}),e.jsxs("div",{children:["Account: ",n.accountNumber]}),e.jsxs("div",{children:["Sort code: ",n.sortCode]}),t.salesperson&&e.jsxs("div",{style:{marginTop:8,fontSize:11},children:["Handled by: ",t.salesperson]})]})]}),e.jsx("div",{children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[i?e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"6px 10px",textAlign:"right"},children:"Subtotal"}),e.jsx("td",{style:{padding:"6px 10px",textAlign:"right",width:120},children:d(o)})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"6px 10px",textAlign:"right"},children:"Part-exchange"}),e.jsxs("td",{style:{padding:"6px 10px",textAlign:"right"},children:["-",d(i)]})]})]}):null,e.jsxs("tr",{style:{background:"#000",color:"#fff"},children:[e.jsx("td",{style:{padding:"10px",textAlign:"right",fontSize:12,letterSpacing:1},children:"TOTAL"}),e.jsx("td",{style:{padding:"10px",textAlign:"right",fontSize:14,fontWeight:700},children:d(f)})]})]})})]}),e.jsxs("div",{style:{marginTop:28,borderTop:"1px solid #000",paddingTop:10,fontSize:10,
1color:"#444"},children:[e.jsx("div",{style:{fontWeight:700,letterSpacing:1,color:"#000"},children:"TERMS & CONDITIONS"}),e.jsxs("div",{style:{marginTop:4},children:["Full terms and conditions can be read at ",n.website,"."]}),e.jsx("div",{style:{marginTop:4},children:"All prices include VAT where applicable."})]})]})}const I=`
2.receipt-sheet {
3  font-family: Arial, Helvetica, sans-serif;
4  width: 100%;
5  max-width: 210mm;
6  padding: 14px;
7  font-size: 12px;
8  line-height: 1.5;
9  box-sizing: border-box;
10  color: #000;
11}
12.receipt-sheet h1 { font-size: 20px !important; }
13.receipt-sheet table { table-layout: fixed; width: 100%; }
14.receipt-sheet td, .receipt-sheet th { word-wrap: break-word; overflow-wrap: anywhere; }
15@media (max-width: 640px) {
16  .receipt-sheet { padding: 12px; font-size: 12px; }
17  .receipt-sheet h1 { font-size: 18px !important; letter-spacing: 0 !important; }
18  .receipt-sheet .receipt-grid-2 {
19    display: grid !important;
20    grid-template-columns: 1fr !important;
21    gap: 14px !important;
22  }
23  .receipt-sheet .receipt-header {
24    flex-direction: column !important;
25    gap: 10px !important;
26    align-items: flex-start !important;
27  }
28  .receipt-sheet .receipt-header > div:last-child { text-align: left !important; }
29  .receipt-sheet .receipt-meta { text-align: left !important; }
30  .receipt-sheet .receipt-qty { display: none !important; }
31  .receipt-sheet th, .receipt-sheet td { padding: 6px !important; font-size: 11px !important; }
32}
33@media (min-width: 768px) {
34  .receipt-sheet { padding: 18mm 16mm; font-size: 12px; min-height: 297mm; }
35  .receipt-sheet h1 { font-size: 28px !important; }
36}
37@media print {
38  @page { size: A4; margin: 0; }
39  html, body { background: #fff !important; }
40  .no-print { display: none !important; }
41  .receipt-sheet {
42    box-shadow: none !important;
43    margin: 0 !important;
44    width: 210mm !important;
45    max-width: none !important;
46    min-height: 297mm !important;
47    padding: 18mm 16mm !important;
48    font-size: 12px !important;
49  }
50  .receipt-sheet h1 { font-size: 28px !important; }
51  .receipt-sheet .receipt-qty { display: table-cell !important; }
52}
53`;function M(){const{id:t}=N.useParams(),{user:r,isAdmin:a,loading:l,roleChecked:p}=A(),o=T(),[i,f]=c.useState(null),[s,j]=c.useState(!0),[y,b]=c.useState(!1);c.useEffect(()=>{l||!p||(!r||!a)&&o({to:"/admin/login"})},[l,p,r,a,o]),c.useEffect(()=>{!r||!a||(async()=>{j(!0);const{data:m,error:x}=await v.from("sold_cars").select("*").eq("id",t).maybeSingle();x&&h.error(x.message),f(m??null),j(!1)})()},[r,a,t]);async function w(){if(i){if(!i.customer_email){h.error("No customer email on record");return}b(!0);try{const{data:{session:m}}=await v.auth.getSession(),x=await fetch("/lovable/email/transactional/send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${m?.access_token??""}`},body:JSON.stringify({templateName:"sales-receipt",recipientEmail:i.customer_email,idempotencyKey:`sales-receipt-${i.id}`,templateData:{receipt:i}})}),g=await x.json().catch(()=>({}));if(!x.ok||g.error)throw new Error(g.error??"Send failed");g.success===!1?h.warning(`Not sent: ${g.reason??"unknown"}`):h.success(`Receipt emailed to ${i.customer_email}`)}catch(m){h.error(m?.message??"Failed to send")}finally{b(!1)}}}return l||!p||!r||!a||s?e.jsx("div",{className:"flex min-h-screen items-center justify-center text-muted-foreground",children:"Loading…"}):i?e.jsxs("div",{className:"min-h-screen bg-muted/30",children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:I}}),e.jsx("header",{className:"no-print sticky top-0 z-10 border-b border-border bg-card",children:e.jsxs("div",{className:"mx-auto flex h-16 max-w-5xl items-center justify-between gap-3 px-4",children:[e.jsxs(_,{to:"/admin/sold",className:"inline-flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground",children:[e.jsx(C,{className:"h-4 w-4"})," Back to sold"]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Receipt ",S(i)]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>window.print(),children:[e.jsx(B,{className:"mr-2 h-4 w-4"})," Print"]}),e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>window.print(),title:"Use your browser's 'Save as PDF' in the print dialog",children:[e.jsx(D,{className:"mr-2 h-4 w-4"})," Download PDF"]}),e.jsxs(u,{size:"sm",onClick:w,disabled:y||!i.customer_email,className:"bg-gradient-hero",children:[y?e.jsx(E,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(z,{className:"mr-2 h-4 w-4"})," Email customer"]})]})]})}),e.jsx("main",{className:"mx-auto max-w-5xl px-2 py-6 sm:px-4",children:e.jsx("div",{className:"shadow-card",children:e.jsx(R,{r:i})})})]}):e.jsx("div",{className:"flex min-h-screen items-center justify-center text-muted-foreground",children:"Receipt not found."})}export{M as component};

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.