Phase7: Void/Refund logic
All checks were successful
Build and Push / build (push) Successful in 1m42s
All checks were successful
Build and Push / build (push) Successful in 1m42s
This commit is contained in:
126
src/lib/pdf-brand.tsx
Normal file
126
src/lib/pdf-brand.tsx
Normal file
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* Shared brand constants and Logo component for all PDF documents
|
||||
* (invoices, credit notes, future quotes / reminders).
|
||||
*
|
||||
* Phase 7 fix: previously each PDF generator carried its own copy
|
||||
* of BRAND and its own Logo. When Cedric customized the invoice
|
||||
* issuer block in his deployment (real Strasse Nr., PLZ, etc.),
|
||||
* the credit note PDF kept the original placeholders because it
|
||||
* had its own duplicate. Hoisting both here means every PDF reads
|
||||
* the same source of truth.
|
||||
*
|
||||
* To change the brand: edit BRAND below. To change the logo:
|
||||
* edit Logo below. To change the issuer info Cedric ships: edit
|
||||
* BRAND.issuer — both billing-pdf.tsx and credit-note-pdf.tsx pick
|
||||
* it up automatically.
|
||||
*
|
||||
* The Logo component accepts a `color` prop so the credit-note
|
||||
* variant can render the SAME shape tinted red (the document
|
||||
* family is visually consistent; only the accent colour signals
|
||||
* "this is a credit, not an invoice").
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { Svg, Polygon, Polyline } from "@react-pdf/renderer";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Brand constants
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const BRAND = {
|
||||
name: "PieCed IT",
|
||||
// Primary emerald — matches the logo SVG fill (#10B981).
|
||||
primary: "#10B981",
|
||||
// Slightly darker emerald for headings.
|
||||
primaryDark: "#0a8060",
|
||||
textColor: "#1a1a1a",
|
||||
mutedColor: "#666",
|
||||
borderColor: "#d4d4d4",
|
||||
// Issuer block — change these to your real legal info.
|
||||
// Both billing-pdf.tsx and credit-note-pdf.tsx read from here.
|
||||
issuer: {
|
||||
legalName: "PieCed IT",
|
||||
addressLine1: "Cedric Mosimann",
|
||||
addressLine2: "[Strasse Nr.]",
|
||||
postalCity: "[PLZ] Basel",
|
||||
country: "Switzerland",
|
||||
email: "billing@pieced.ch",
|
||||
web: "pieced.ch",
|
||||
// Show "MWST-Nr. ..." on PDF when set.
|
||||
vatNumber: null as string | null,
|
||||
// Bank instructions — used by invoice PDF, ignored on credit
|
||||
// notes (refunds flow back via the original payment method).
|
||||
bankName: "[Bank name]",
|
||||
bankIban: "[CHxx xxxx xxxx xxxx xxxx x]",
|
||||
bankBic: "[BIC]",
|
||||
},
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Accent colours for document variants — credit notes are red so
|
||||
// customers can tell them apart from invoices at a glance.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export const ACCENT_CREDIT_NOTE = {
|
||||
primary: "#DC2626",
|
||||
primaryDark: "#991B1B",
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Logo — PieCed's hexagon-pattern mark. Same shape used everywhere;
|
||||
// only the colour changes per document type.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
interface LogoProps {
|
||||
size?: number;
|
||||
/** Defaults to BRAND.primary (emerald). Pass ACCENT_CREDIT_NOTE.primary
|
||||
* on credit notes for the red variant. */
|
||||
color?: string;
|
||||
}
|
||||
|
||||
export const Logo = ({ size = 60, color = BRAND.primary }: LogoProps) => (
|
||||
<Svg width={size} height={size * (106 / 70)} viewBox="0 0 70 106">
|
||||
{/* H1 solid */}
|
||||
<Polygon
|
||||
points="38.5,22.69 31.5,10.566 17.5,10.566 10.5,22.69 17.5,34.814 31.5,34.814"
|
||||
fill={color}
|
||||
stroke={color}
|
||||
strokeWidth={1.6}
|
||||
/>
|
||||
{/* H2 outline */}
|
||||
<Polygon
|
||||
points="59.5,34.814 52.5,22.69 38.5,22.69 31.5,34.814 38.5,46.938 52.5,46.938"
|
||||
fill="none"
|
||||
stroke={color}
|
||||
strokeWidth={1.8}
|
||||
/>
|
||||
{/* H3 outline */}
|
||||
<Polygon
|
||||
points="38.5,46.938 31.5,34.814 17.5,34.814 10.5,46.938 17.5,59.062 31.5,59.062"
|
||||
fill="none"
|
||||
stroke={color}
|
||||
strokeWidth={1.8}
|
||||
/>
|
||||
{/* H4 solid */}
|
||||
<Polygon
|
||||
points="59.5,59.062 52.5,46.938 38.5,46.938 31.5,59.062 38.5,71.186 52.5,71.186"
|
||||
fill={color}
|
||||
stroke={color}
|
||||
strokeWidth={1.6}
|
||||
/>
|
||||
{/* H5 partial */}
|
||||
<Polyline
|
||||
points="31.5,83.31 38.5,71.186 31.5,59.062 17.5,59.062 10.5,71.186"
|
||||
fill="none"
|
||||
stroke={color}
|
||||
strokeWidth={1.8}
|
||||
/>
|
||||
{/* H6 partial */}
|
||||
<Polyline
|
||||
points="59.5,83.31 52.5,71.186 38.5,71.186 31.5,83.31 38.5,95.434"
|
||||
fill="none"
|
||||
stroke={color}
|
||||
strokeWidth={1.8}
|
||||
/>
|
||||
</Svg>
|
||||
);
|
||||
Reference in New Issue
Block a user