Phase7: Void/Refund logic
This commit is contained in:
@@ -24,9 +24,8 @@ import {
|
||||
renderToBuffer,
|
||||
} from "@react-pdf/renderer";
|
||||
import type { CreditNote, Invoice } from "@/types";
|
||||
import { BRAND, Logo, ACCENT_CREDIT_NOTE } from "./pdf-brand";
|
||||
import { BRAND, Logo } from "./pdf-brand";
|
||||
|
||||
const ACCENT = ACCENT_CREDIT_NOTE;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Localized strings
|
||||
@@ -207,15 +206,15 @@ const styles = StyleSheet.create({
|
||||
logoBlock: { flexDirection: "row", alignItems: "center" },
|
||||
brandName: {
|
||||
fontSize: 16,
|
||||
color: ACCENT.primaryDark,
|
||||
color: BRAND.primaryDark,
|
||||
marginLeft: 8,
|
||||
fontFamily: "Helvetica-Bold",
|
||||
},
|
||||
issuerBlock: { textAlign: "right", fontSize: 8.5, color: BRAND.mutedColor },
|
||||
issuerName: { fontSize: 11, color: ACCENT.primaryDark, marginBottom: 2 },
|
||||
issuerName: { fontSize: 11, color: BRAND.primaryDark, marginBottom: 2 },
|
||||
docTitle: {
|
||||
fontSize: 22,
|
||||
color: ACCENT.primaryDark,
|
||||
color: BRAND.primaryDark,
|
||||
marginBottom: 8,
|
||||
fontFamily: "Helvetica-Bold",
|
||||
},
|
||||
@@ -230,9 +229,9 @@ const styles = StyleSheet.create({
|
||||
billTo: {
|
||||
marginBottom: 24,
|
||||
padding: 8,
|
||||
backgroundColor: "#fdf2f2",
|
||||
backgroundColor: "#f7f7f5",
|
||||
borderLeftWidth: 3,
|
||||
borderLeftColor: ACCENT.primary,
|
||||
borderLeftColor: BRAND.primary,
|
||||
},
|
||||
billToLabel: { fontSize: 8, color: BRAND.mutedColor, marginBottom: 4 },
|
||||
billToName: { fontSize: 11, marginBottom: 2 },
|
||||
@@ -245,7 +244,7 @@ const styles = StyleSheet.create({
|
||||
},
|
||||
amountHeader: {
|
||||
flexDirection: "row",
|
||||
backgroundColor: ACCENT.primaryDark,
|
||||
backgroundColor: BRAND.primaryDark,
|
||||
color: "#ffffff",
|
||||
paddingVertical: 5,
|
||||
paddingHorizontal: 6,
|
||||
@@ -273,17 +272,17 @@ const styles = StyleSheet.create({
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
borderTopWidth: 1,
|
||||
borderTopColor: ACCENT.primaryDark,
|
||||
borderTopColor: BRAND.primaryDark,
|
||||
paddingTop: 6,
|
||||
marginTop: 4,
|
||||
},
|
||||
totalsGrandLabel: {
|
||||
color: ACCENT.primaryDark,
|
||||
color: BRAND.primaryDark,
|
||||
fontSize: 11,
|
||||
fontFamily: "Helvetica-Bold",
|
||||
},
|
||||
totalsGrandValue: {
|
||||
color: ACCENT.primaryDark,
|
||||
color: BRAND.primaryDark,
|
||||
fontSize: 11,
|
||||
textAlign: "right",
|
||||
fontFamily: "Helvetica-Bold",
|
||||
@@ -353,7 +352,7 @@ function CreditNotePdfDocument({ creditNote, invoice }: CreditNotePdfProps) {
|
||||
Issuer block from BRAND.issuer (shared with invoice). */}
|
||||
<View style={styles.headerRow}>
|
||||
<View style={styles.logoBlock}>
|
||||
<Logo size={42} color={ACCENT.primary} />
|
||||
<Logo size={42} color={BRAND.primary} />
|
||||
<Text style={styles.brandName}>{BRAND.name}</Text>
|
||||
</View>
|
||||
<View style={styles.issuerBlock}>
|
||||
|
||||
@@ -1261,10 +1261,12 @@ export async function sendCreditNoteEmail(params: {
|
||||
const safeNumberINV = escapeHtml(params.invoiceNumber);
|
||||
const safeReason = params.reason ? escapeHtml(params.reason) : null;
|
||||
|
||||
// Red accent (#DC2626) for the credit-note emails, mirroring the
|
||||
// PDF accent so the document family reads visually consistent.
|
||||
// The invoice email uses emerald; the credit note uses red.
|
||||
const ACCENT = "#DC2626";
|
||||
// PieCed brand emerald — same accent the invoice email uses.
|
||||
// A credit note is still a PieCed IT document; the company
|
||||
// identity stays consistent across the document family. The
|
||||
// doc type is distinguished by the subject line and copy, not
|
||||
// by colour.
|
||||
const ACCENT = "#10B981";
|
||||
|
||||
try {
|
||||
await getTransporter().sendMail({
|
||||
|
||||
@@ -57,24 +57,16 @@ export const BRAND = {
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// 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.
|
||||
// Logo — PieCed's hexagon-pattern mark. Same shape used everywhere
|
||||
// and same brand colour. The credit note is still a PieCed IT
|
||||
// document and reads with the same company identity as an invoice.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
interface LogoProps {
|
||||
size?: number;
|
||||
/** Defaults to BRAND.primary (emerald). Pass ACCENT_CREDIT_NOTE.primary
|
||||
* on credit notes for the red variant. */
|
||||
/** Defaults to BRAND.primary. Override only for special cases
|
||||
* (e.g. an inverse variant on a dark background). Standard
|
||||
* documents — invoices, credit notes — all use BRAND.primary. */
|
||||
color?: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user