Use tenant business payment info for invoice QR codes

This commit is contained in:
2026-07-22 19:40:01 +02:00
parent 621243ba7b
commit fbea66b754
4 changed files with 88 additions and 8 deletions

View File

@@ -60,6 +60,15 @@ export const tenants = pgTable(
city: "",
name: "",
street: "",
email: "",
phone: "",
website: "",
taxNumber: "",
vatId: "",
bankName: "",
bankAccountOwner: "",
iban: "",
bic: "",
}),
features: jsonb("features").default({

View File

@@ -537,6 +537,9 @@ export function getDocumentDataBackend(
) {
const businessInfo = tenant.businessInfo || {}; // Fallback falls leer
const paymentQrBankAccount = bankAccounts.find((account: any) => !account.archived && !account.expired && account.iban) || null
const paymentQrIban = businessInfo.iban || paymentQrBankAccount?.iban
const paymentQrBic = businessInfo.bic || paymentQrBankAccount?.bic
const paymentQrRecipient = businessInfo.bankAccountOwner || paymentQrBankAccount?.ownerName || businessInfo.name || tenant.name
// --- 1. Agriculture Logic ---
// Prüfen ob 'extraModules' existiert, sonst leeres Array annehmen
@@ -731,9 +734,10 @@ export function getDocumentDataBackend(
agriculture: itemInfo.agriculture,
// Falls du AdvanceInvoices brauchst, musst du die Objekte hier übergeben oder leer lassen
usedAdvanceInvoices: [],
paymentQr: paymentQrBankAccount && itemInfo.payment_type === "transfer" ? {
iban: paymentQrBankAccount.iban,
recipientName: paymentQrBankAccount.ownerName || businessInfo.name || tenant.name,
paymentQr: paymentQrIban && itemInfo.payment_type === "transfer" ? {
iban: paymentQrIban,
bic: paymentQrBic,
recipientName: paymentQrRecipient,
amount: totals.totalGross,
remittance: itemInfo.documentNumber || itemInfo.title,
} : null