|
@@ -106,6 +106,8 @@ export function InvoiceView({
|
|
|
dateFormat,
|
|
dateFormat,
|
|
|
timezone,
|
|
timezone,
|
|
|
termsOfSaleUrl,
|
|
termsOfSaleUrl,
|
|
|
|
|
+ primaryColor = '#d97706',
|
|
|
|
|
+ headerStyle = 'standard',
|
|
|
}: {
|
|
}: {
|
|
|
record: InvoiceRecord
|
|
record: InvoiceRecord
|
|
|
workshop: { name: string; address: string; phone: string; email: string }
|
|
workshop: { name: string; address: string; phone: string; email: string }
|
|
@@ -121,6 +123,8 @@ export function InvoiceView({
|
|
|
dateFormat?: string
|
|
dateFormat?: string
|
|
|
timezone?: string
|
|
timezone?: string
|
|
|
termsOfSaleUrl?: string
|
|
termsOfSaleUrl?: string
|
|
|
|
|
+ primaryColor?: string
|
|
|
|
|
+ headerStyle?: string
|
|
|
}) {
|
|
}) {
|
|
|
const [carouselIndex, setCarouselIndex] = useState<number | null>(null)
|
|
const [carouselIndex, setCarouselIndex] = useState<number | null>(null)
|
|
|
const [paymentAmount, setPaymentAmount] = useState('')
|
|
const [paymentAmount, setPaymentAmount] = useState('')
|
|
@@ -294,7 +298,8 @@ export function InvoiceView({
|
|
|
<h1 className="text-2xl font-bold">Invoice</h1>
|
|
<h1 className="text-2xl font-bold">Invoice</h1>
|
|
|
<button
|
|
<button
|
|
|
onClick={handleDownloadPDF}
|
|
onClick={handleDownloadPDF}
|
|
|
- className="inline-flex items-center gap-2 rounded-lg bg-amber-600 px-4 py-2 text-sm font-medium text-white hover:bg-amber-700"
|
|
|
|
|
|
|
+ className="inline-flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium text-white"
|
|
|
|
|
+ style={{ backgroundColor: primaryColor }}
|
|
|
>
|
|
>
|
|
|
<Download className="h-4 w-4" />
|
|
<Download className="h-4 w-4" />
|
|
|
Download PDF
|
|
Download PDF
|
|
@@ -454,40 +459,93 @@ export function InvoiceView({
|
|
|
|
|
|
|
|
<div className="rounded-xl border bg-white p-6 shadow-sm sm:p-8 dark:bg-gray-900">
|
|
<div className="rounded-xl border bg-white p-6 shadow-sm sm:p-8 dark:bg-gray-900">
|
|
|
{/* Header */}
|
|
{/* Header */}
|
|
|
- <div className="flex flex-col gap-4 border-b-2 border-amber-500 pb-6 sm:flex-row sm:items-start sm:justify-between">
|
|
|
|
|
- <div>
|
|
|
|
|
- {showLogo && logoUrl && (
|
|
|
|
|
- <img
|
|
|
|
|
- src={logoUrl}
|
|
|
|
|
- alt={shopName}
|
|
|
|
|
- className="mb-2 max-h-16 max-w-[180px] object-contain object-left"
|
|
|
|
|
- />
|
|
|
|
|
- )}
|
|
|
|
|
- {showCompanyName && (
|
|
|
|
|
- <h2 className="text-xl font-bold text-amber-600 sm:text-2xl">{shopName}</h2>
|
|
|
|
|
- )}
|
|
|
|
|
- {workshop.address && <p className="mt-1 text-sm text-gray-500">{workshop.address}</p>}
|
|
|
|
|
- {workshop.phone && <p className="text-sm text-gray-500">Tel: {workshop.phone}</p>}
|
|
|
|
|
- {workshop.email && <p className="text-sm text-gray-500">{workshop.email}</p>}
|
|
|
|
|
- </div>
|
|
|
|
|
- <div className="sm:text-right">
|
|
|
|
|
- {showTorqvoiceBranding && (
|
|
|
|
|
- <div className="mb-2 inline-flex items-center gap-1.5 rounded-full bg-gray-100 px-2.5 py-1 dark:bg-gray-800">
|
|
|
|
|
- <img src="/torqvoice_app_logo.png" alt="Torqvoice" className="h-4 w-4" />
|
|
|
|
|
- <span className="text-xs font-semibold text-gray-500 dark:text-gray-400">Torqvoice</span>
|
|
|
|
|
|
|
+ {headerStyle === 'modern' ? (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <div className="rounded-lg p-6 text-center text-white" style={{ backgroundColor: primaryColor }}>
|
|
|
|
|
+ {showLogo && logoUrl && (
|
|
|
|
|
+ <img
|
|
|
|
|
+ src={logoUrl}
|
|
|
|
|
+ alt={shopName}
|
|
|
|
|
+ className="mx-auto mb-2 max-h-16 max-w-[180px] object-contain"
|
|
|
|
|
+ />
|
|
|
|
|
+ )}
|
|
|
|
|
+ {showCompanyName && (
|
|
|
|
|
+ <h2 className="text-xl font-bold sm:text-2xl">{shopName}</h2>
|
|
|
|
|
+ )}
|
|
|
|
|
+ {workshop.address && <p className="mt-1 text-sm opacity-80">{workshop.address}</p>}
|
|
|
|
|
+ <div className="mt-1 flex flex-wrap justify-center gap-3 text-sm opacity-70">
|
|
|
|
|
+ {workshop.phone && <span>Tel: {workshop.phone}</span>}
|
|
|
|
|
+ {workshop.email && <span>{workshop.email}</span>}
|
|
|
</div>
|
|
</div>
|
|
|
- )}
|
|
|
|
|
- <h3 className="text-xl font-bold">INVOICE</h3>
|
|
|
|
|
- <p className="mt-1 text-sm text-gray-500">{invoiceNum}</p>
|
|
|
|
|
- <p className="text-sm text-gray-500">{serviceDate}</p>
|
|
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="mt-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
|
|
|
|
+ <h3 className="text-xl font-bold">INVOICE</h3>
|
|
|
|
|
+ <div className="flex gap-3 text-sm text-gray-500">
|
|
|
|
|
+ <span>{invoiceNum}</span>
|
|
|
|
|
+ <span>{serviceDate}</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </>
|
|
|
|
|
+ ) : headerStyle === 'compact' ? (
|
|
|
|
|
+ <div className="flex flex-col gap-4 border-b pb-6 sm:flex-row sm:items-center sm:justify-between" style={{ borderColor: '#e5e7eb' }}>
|
|
|
|
|
+ <div className="flex items-center gap-3">
|
|
|
|
|
+ {showLogo && logoUrl && (
|
|
|
|
|
+ <img
|
|
|
|
|
+ src={logoUrl}
|
|
|
|
|
+ alt={shopName}
|
|
|
|
|
+ className="h-12 w-12 rounded object-contain"
|
|
|
|
|
+ />
|
|
|
|
|
+ )}
|
|
|
|
|
+ <div>
|
|
|
|
|
+ {showCompanyName && (
|
|
|
|
|
+ <h2 className="text-lg font-bold" style={{ color: primaryColor }}>{shopName}</h2>
|
|
|
|
|
+ )}
|
|
|
|
|
+ {workshop.address && <p className="text-sm text-gray-500">{workshop.address}</p>}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="sm:text-right">
|
|
|
|
|
+ <h3 className="text-lg font-bold">INVOICE</h3>
|
|
|
|
|
+ <p className="text-sm text-gray-500">{invoiceNum}</p>
|
|
|
|
|
+ <p className="text-sm text-gray-500">{serviceDate}</p>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ /* Standard */
|
|
|
|
|
+ <div className="flex flex-col gap-4 border-b-2 pb-6 sm:flex-row sm:items-start sm:justify-between" style={{ borderColor: primaryColor }}>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ {showLogo && logoUrl && (
|
|
|
|
|
+ <img
|
|
|
|
|
+ src={logoUrl}
|
|
|
|
|
+ alt={shopName}
|
|
|
|
|
+ className="mb-2 max-h-16 max-w-[180px] object-contain object-left"
|
|
|
|
|
+ />
|
|
|
|
|
+ )}
|
|
|
|
|
+ {showCompanyName && (
|
|
|
|
|
+ <h2 className="text-xl font-bold sm:text-2xl" style={{ color: primaryColor }}>{shopName}</h2>
|
|
|
|
|
+ )}
|
|
|
|
|
+ {workshop.address && <p className="mt-1 text-sm text-gray-500">{workshop.address}</p>}
|
|
|
|
|
+ {workshop.phone && <p className="text-sm text-gray-500">Tel: {workshop.phone}</p>}
|
|
|
|
|
+ {workshop.email && <p className="text-sm text-gray-500">{workshop.email}</p>}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="sm:text-right">
|
|
|
|
|
+ {showTorqvoiceBranding && (
|
|
|
|
|
+ <div className="mb-2 inline-flex items-center gap-1.5 rounded-full bg-gray-100 px-2.5 py-1 dark:bg-gray-800">
|
|
|
|
|
+ <img src="/torqvoice_app_logo.png" alt="Torqvoice" className="h-4 w-4" />
|
|
|
|
|
+ <span className="text-xs font-semibold text-gray-500 dark:text-gray-400">Torqvoice</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
+ <h3 className="text-xl font-bold" style={{ color: primaryColor }}>INVOICE</h3>
|
|
|
|
|
+ <p className="mt-1 text-sm text-gray-500">{invoiceNum}</p>
|
|
|
|
|
+ <p className="text-sm text-gray-500">{serviceDate}</p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
|
|
|
{/* Info Boxes */}
|
|
{/* Info Boxes */}
|
|
|
<div className="mt-6 grid grid-cols-1 gap-4 sm:grid-cols-3">
|
|
<div className="mt-6 grid grid-cols-1 gap-4 sm:grid-cols-3">
|
|
|
{record.vehicle.customer && (
|
|
{record.vehicle.customer && (
|
|
|
<div className="rounded-lg bg-gray-50 p-4 dark:bg-gray-800">
|
|
<div className="rounded-lg bg-gray-50 p-4 dark:bg-gray-800">
|
|
|
- <p className="mb-1 text-xs font-bold uppercase text-amber-600">Bill To</p>
|
|
|
|
|
|
|
+ <p className="mb-1 text-xs font-bold uppercase" style={{ color: primaryColor }}>Bill To</p>
|
|
|
<p className="font-semibold">{record.vehicle.customer.name}</p>
|
|
<p className="font-semibold">{record.vehicle.customer.name}</p>
|
|
|
{record.vehicle.customer.company && (
|
|
{record.vehicle.customer.company && (
|
|
|
<p className="text-sm">{record.vehicle.customer.company}</p>
|
|
<p className="text-sm">{record.vehicle.customer.company}</p>
|
|
@@ -504,7 +562,7 @@ export function InvoiceView({
|
|
|
</div>
|
|
</div>
|
|
|
)}
|
|
)}
|
|
|
<div className="rounded-lg bg-gray-50 p-4 dark:bg-gray-800">
|
|
<div className="rounded-lg bg-gray-50 p-4 dark:bg-gray-800">
|
|
|
- <p className="mb-1 text-xs font-bold uppercase text-amber-600">Vehicle</p>
|
|
|
|
|
|
|
+ <p className="mb-1 text-xs font-bold uppercase" style={{ color: primaryColor }}>Vehicle</p>
|
|
|
<p className="font-semibold">{vehicleName}</p>
|
|
<p className="font-semibold">{vehicleName}</p>
|
|
|
{record.vehicle.vin && (
|
|
{record.vehicle.vin && (
|
|
|
<p className="text-sm text-gray-500">VIN: {record.vehicle.vin}</p>
|
|
<p className="text-sm text-gray-500">VIN: {record.vehicle.vin}</p>
|
|
@@ -514,7 +572,7 @@ export function InvoiceView({
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|
|
|
<div className="rounded-lg bg-gray-50 p-4 dark:bg-gray-800">
|
|
<div className="rounded-lg bg-gray-50 p-4 dark:bg-gray-800">
|
|
|
- <p className="mb-1 text-xs font-bold uppercase text-amber-600">Service</p>
|
|
|
|
|
|
|
+ <p className="mb-1 text-xs font-bold uppercase" style={{ color: primaryColor }}>Service</p>
|
|
|
<p className="font-semibold">{record.title}</p>
|
|
<p className="font-semibold">{record.title}</p>
|
|
|
<p className="text-sm text-gray-500">Type: {record.type}</p>
|
|
<p className="text-sm text-gray-500">Type: {record.type}</p>
|
|
|
{record.techName && <p className="text-sm text-gray-500">Tech: {record.techName}</p>}
|
|
{record.techName && <p className="text-sm text-gray-500">Tech: {record.techName}</p>}
|
|
@@ -528,7 +586,7 @@ export function InvoiceView({
|
|
|
<div className="-mx-6 overflow-x-auto px-6 sm:mx-0 sm:px-0">
|
|
<div className="-mx-6 overflow-x-auto px-6 sm:mx-0 sm:px-0">
|
|
|
<table className="w-full min-w-125 text-sm">
|
|
<table className="w-full min-w-125 text-sm">
|
|
|
<thead>
|
|
<thead>
|
|
|
- <tr className="border-b bg-amber-50 text-left dark:bg-amber-900/20">
|
|
|
|
|
|
|
+ <tr className="border-b text-left" style={{ backgroundColor: `${primaryColor}15` }}>
|
|
|
<th className="p-2 font-medium">Part #</th>
|
|
<th className="p-2 font-medium">Part #</th>
|
|
|
<th className="p-2 font-medium">Description</th>
|
|
<th className="p-2 font-medium">Description</th>
|
|
|
<th className="p-2 text-right font-medium">Qty</th>
|
|
<th className="p-2 text-right font-medium">Qty</th>
|
|
@@ -563,7 +621,7 @@ export function InvoiceView({
|
|
|
<div className="-mx-6 overflow-x-auto px-6 sm:mx-0 sm:px-0">
|
|
<div className="-mx-6 overflow-x-auto px-6 sm:mx-0 sm:px-0">
|
|
|
<table className="w-full min-w-112.5 text-sm">
|
|
<table className="w-full min-w-112.5 text-sm">
|
|
|
<thead>
|
|
<thead>
|
|
|
- <tr className="border-b bg-amber-50 text-left dark:bg-amber-900/20">
|
|
|
|
|
|
|
+ <tr className="border-b text-left" style={{ backgroundColor: `${primaryColor}15` }}>
|
|
|
<th className="p-2 font-medium">Description</th>
|
|
<th className="p-2 font-medium">Description</th>
|
|
|
<th className="p-2 text-right font-medium">Hours</th>
|
|
<th className="p-2 text-right font-medium">Hours</th>
|
|
|
<th className="p-2 text-right font-medium">Rate</th>
|
|
<th className="p-2 text-right font-medium">Rate</th>
|
|
@@ -612,13 +670,14 @@ export function InvoiceView({
|
|
|
</div>
|
|
</div>
|
|
|
)}
|
|
)}
|
|
|
<div
|
|
<div
|
|
|
- className={`border-t pt-2 ${totalPaid > 0 ? 'border-gray-200' : 'border-amber-500'}`}
|
|
|
|
|
|
|
+ className={`border-t pt-2 ${totalPaid > 0 ? 'border-gray-200' : ''}`}
|
|
|
|
|
+ style={totalPaid > 0 ? undefined : { borderColor: primaryColor }}
|
|
|
>
|
|
>
|
|
|
<div
|
|
<div
|
|
|
className={`flex justify-between ${totalPaid > 0 ? 'text-sm text-gray-500' : 'text-lg font-bold'}`}
|
|
className={`flex justify-between ${totalPaid > 0 ? 'text-sm text-gray-500' : 'text-lg font-bold'}`}
|
|
|
>
|
|
>
|
|
|
<span>Total</span>
|
|
<span>Total</span>
|
|
|
- <span className={totalPaid > 0 ? '' : 'text-amber-600'}>
|
|
|
|
|
|
|
+ <span style={totalPaid > 0 ? undefined : { color: primaryColor }}>
|
|
|
{formatCurrency(displayTotal, currencyCode)}
|
|
{formatCurrency(displayTotal, currencyCode)}
|
|
|
</span>
|
|
</span>
|
|
|
</div>
|
|
</div>
|
|
@@ -664,8 +723,8 @@ export function InvoiceView({
|
|
|
(invoiceSettings.bankAccount ||
|
|
(invoiceSettings.bankAccount ||
|
|
|
invoiceSettings.orgNumber ||
|
|
invoiceSettings.orgNumber ||
|
|
|
invoiceSettings.paymentTerms) && (
|
|
invoiceSettings.paymentTerms) && (
|
|
|
- <div className="mt-6 rounded-lg border border-amber-200 bg-amber-50/50 p-4 dark:border-amber-800 dark:bg-amber-900/10">
|
|
|
|
|
- <p className="mb-2 text-xs font-bold uppercase text-amber-600">Payment Information</p>
|
|
|
|
|
|
|
+ <div className="mt-6 rounded-lg border p-4" style={{ borderColor: `${primaryColor}40`, backgroundColor: `${primaryColor}08` }}>
|
|
|
|
|
+ <p className="mb-2 text-xs font-bold uppercase" style={{ color: primaryColor }}>Payment Information</p>
|
|
|
<div className="grid grid-cols-1 gap-3 text-sm sm:grid-cols-2">
|
|
<div className="grid grid-cols-1 gap-3 text-sm sm:grid-cols-2">
|
|
|
{invoiceSettings.showBankAccount && invoiceSettings.bankAccount && (
|
|
{invoiceSettings.showBankAccount && invoiceSettings.bankAccount && (
|
|
|
<div>
|
|
<div>
|
|
@@ -810,7 +869,7 @@ export function InvoiceView({
|
|
|
{/* Notes */}
|
|
{/* Notes */}
|
|
|
{record.invoiceNotes && (
|
|
{record.invoiceNotes && (
|
|
|
<div className="mt-6 rounded-lg bg-gray-50 p-4 dark:bg-gray-800">
|
|
<div className="mt-6 rounded-lg bg-gray-50 p-4 dark:bg-gray-800">
|
|
|
- <p className="mb-1 text-xs font-bold uppercase text-amber-600">Notes</p>
|
|
|
|
|
|
|
+ <p className="mb-1 text-xs font-bold uppercase" style={{ color: primaryColor }}>Notes</p>
|
|
|
<div
|
|
<div
|
|
|
className="notes-content text-sm text-gray-600 dark:text-gray-400"
|
|
className="notes-content text-sm text-gray-600 dark:text-gray-400"
|
|
|
dangerouslySetInnerHTML={{ __html: sanitizeHtml(record.invoiceNotes) }}
|
|
dangerouslySetInnerHTML={{ __html: sanitizeHtml(record.invoiceNotes) }}
|
|
@@ -819,7 +878,7 @@ export function InvoiceView({
|
|
|
)}
|
|
)}
|
|
|
{record.diagnosticNotes && (
|
|
{record.diagnosticNotes && (
|
|
|
<div className="mt-4 rounded-lg bg-gray-50 p-4 dark:bg-gray-800">
|
|
<div className="mt-4 rounded-lg bg-gray-50 p-4 dark:bg-gray-800">
|
|
|
- <p className="mb-1 text-xs font-bold uppercase text-amber-600">Diagnostic Notes</p>
|
|
|
|
|
|
|
+ <p className="mb-1 text-xs font-bold uppercase" style={{ color: primaryColor }}>Diagnostic Notes</p>
|
|
|
<div
|
|
<div
|
|
|
className="notes-content text-sm text-gray-600 dark:text-gray-400"
|
|
className="notes-content text-sm text-gray-600 dark:text-gray-400"
|
|
|
dangerouslySetInnerHTML={{ __html: sanitizeHtml(record.diagnosticNotes) }}
|
|
dangerouslySetInnerHTML={{ __html: sanitizeHtml(record.diagnosticNotes) }}
|