mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
feat: invoice generator
This commit is contained in:
71
app/(app)/apps/invoices/default-templates.ts
Normal file
71
app/(app)/apps/invoices/default-templates.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { SettingsMap } from "@/models/settings"
|
||||
import { User } from "@/prisma/client"
|
||||
import { addDays, format } from "date-fns"
|
||||
import { InvoiceFormData } from "./components/invoice-page"
|
||||
|
||||
export interface InvoiceTemplate {
|
||||
id?: string
|
||||
name: string
|
||||
formData: InvoiceFormData
|
||||
}
|
||||
|
||||
export default function defaultTemplates(user: User, settings: SettingsMap): InvoiceTemplate[] {
|
||||
const defaultTemplate: InvoiceFormData = {
|
||||
title: "INVOICE",
|
||||
businessLogo: user.businessLogo,
|
||||
invoiceNumber: "",
|
||||
date: format(new Date(), "yyyy-MM-dd"),
|
||||
dueDate: format(addDays(new Date(), 30), "yyyy-MM-dd"),
|
||||
currency: settings.default_currency || "EUR",
|
||||
companyDetails: `${user.businessName}\n${user.businessAddress || ""}`,
|
||||
companyDetailsLabel: "Bill From",
|
||||
billTo: "",
|
||||
billToLabel: "Bill To",
|
||||
items: [{ description: "", quantity: 1, unitPrice: 0, subtotal: 0 }],
|
||||
taxIncluded: true,
|
||||
additionalTaxes: [{ name: "VAT", rate: 0, amount: 0 }],
|
||||
additionalFees: [],
|
||||
notes: "",
|
||||
bankDetails: user.businessBankDetails || "",
|
||||
issueDateLabel: "Issue Date",
|
||||
dueDateLabel: "Due Date",
|
||||
itemLabel: "Item",
|
||||
quantityLabel: "Quantity",
|
||||
unitPriceLabel: "Unit Price",
|
||||
subtotalLabel: "Subtotal",
|
||||
summarySubtotalLabel: "Subtotal:",
|
||||
summaryTotalLabel: "Total:",
|
||||
}
|
||||
|
||||
const germanTemplate: InvoiceFormData = {
|
||||
title: "RECHNUNG",
|
||||
businessLogo: user.businessLogo,
|
||||
invoiceNumber: "",
|
||||
date: format(new Date(), "yyyy-MM-dd"),
|
||||
dueDate: format(addDays(new Date(), 30), "yyyy-MM-dd"),
|
||||
currency: "EUR",
|
||||
companyDetails: `${user.businessName}\n${user.businessAddress || ""}`,
|
||||
companyDetailsLabel: "Rechnungssteller",
|
||||
billTo: "",
|
||||
billToLabel: "Rechnungsempfänger",
|
||||
items: [{ description: "", quantity: 1, unitPrice: 0, subtotal: 0 }],
|
||||
taxIncluded: true,
|
||||
additionalTaxes: [{ name: "MwSt", rate: 19, amount: 0 }],
|
||||
additionalFees: [],
|
||||
notes: "",
|
||||
bankDetails: user.businessBankDetails || "",
|
||||
issueDateLabel: "Rechnungsdatum",
|
||||
dueDateLabel: "Fälligkeitsdatum",
|
||||
itemLabel: "Position",
|
||||
quantityLabel: "Menge",
|
||||
unitPriceLabel: "Einzelpreis",
|
||||
subtotalLabel: "Zwischensumme",
|
||||
summarySubtotalLabel: "Zwischensumme:",
|
||||
summaryTotalLabel: "Gesamtbetrag:",
|
||||
}
|
||||
|
||||
return [
|
||||
{ name: "Default", formData: defaultTemplate },
|
||||
{ name: "DE", formData: germanTemplate },
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user