Use tenant business payment info for invoice QR codes
This commit is contained in:
@@ -60,6 +60,15 @@ export const tenants = pgTable(
|
||||
city: "",
|
||||
name: "",
|
||||
street: "",
|
||||
email: "",
|
||||
phone: "",
|
||||
website: "",
|
||||
taxNumber: "",
|
||||
vatId: "",
|
||||
bankName: "",
|
||||
bankAccountOwner: "",
|
||||
iban: "",
|
||||
bic: "",
|
||||
}),
|
||||
|
||||
features: jsonb("features").default({
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1411,8 +1411,11 @@ const getDocumentData = async () => {
|
||||
|
||||
let customerData = customers.value.find(i => i.id === itemInfo.value.customer)
|
||||
let contactData = contacts.value.find(i => i.id === itemInfo.value.contact)
|
||||
let businessInfo = auth.activeTenantData.businessInfo
|
||||
let businessInfo = auth.activeTenantData.businessInfo || {}
|
||||
const paymentQrBankAccount = bankaccounts.value.find(account => !account.archived && !account.expired && account.iban)
|
||||
const paymentQrIban = businessInfo.iban || paymentQrBankAccount?.iban
|
||||
const paymentQrBic = businessInfo.bic || paymentQrBankAccount?.bic
|
||||
const paymentQrRecipient = businessInfo.bankAccountOwner || paymentQrBankAccount?.ownerName || businessInfo.name || auth.activeTenantData.name
|
||||
|
||||
if (auth.activeTenantData.extraModules.includes("agriculture")) {
|
||||
itemInfo.value.rows.forEach(row => {
|
||||
@@ -1629,9 +1632,10 @@ const getDocumentData = async () => {
|
||||
usedAdvanceInvoices: itemInfo.value.usedAdvanceInvoices.map(i => {
|
||||
return createddocuments.value.find(x => x.id === i)
|
||||
}),
|
||||
paymentQr: paymentQrBankAccount && itemInfo.value.payment_type === "transfer" ? {
|
||||
iban: paymentQrBankAccount.iban,
|
||||
recipientName: paymentQrBankAccount.ownerName || businessInfo.name || auth.activeTenantData.name,
|
||||
paymentQr: paymentQrIban && itemInfo.value.payment_type === "transfer" ? {
|
||||
iban: paymentQrIban,
|
||||
bic: paymentQrBic,
|
||||
recipientName: paymentQrRecipient,
|
||||
amount: documentTotal.value.totalSumToPay,
|
||||
remittance: itemInfo.value.documentNumber || itemInfo.value.title,
|
||||
} : null
|
||||
|
||||
@@ -214,17 +214,34 @@ const activeTelephonyTargetOptions = computed(() => {
|
||||
if (telephonyExtensionForm.targetType === "branch") return telephonyExtensionOptions.value.branches || []
|
||||
return telephonyExtensionOptions.value.users || []
|
||||
})
|
||||
const defaultBusinessInfo = {
|
||||
name: "",
|
||||
street: "",
|
||||
zip: "",
|
||||
city: "",
|
||||
email: "",
|
||||
phone: "",
|
||||
website: "",
|
||||
taxNumber: "",
|
||||
vatId: "",
|
||||
bankName: "",
|
||||
bankAccountOwner: "",
|
||||
iban: "",
|
||||
bic: "",
|
||||
}
|
||||
const normalizeBusinessInfo = (value) => ({ ...defaultBusinessInfo, ...(value || {}) })
|
||||
|
||||
const setupPage = async () => {
|
||||
itemInfo.value = auth.activeTenantData
|
||||
console.log(itemInfo.value)
|
||||
businessInfo.value = normalizeBusinessInfo(auth.activeTenantData?.businessInfo)
|
||||
planningBoardConfig.startTime = auth.activeTenantData?.calendarConfig?.planningBoard?.startTime || "06:00"
|
||||
planningBoardConfig.endTime = auth.activeTenantData?.calendarConfig?.planningBoard?.endTime || "21:00"
|
||||
planningBoardConfig.slotMinutes = auth.activeTenantData?.calendarConfig?.planningBoard?.slotMinutes || 180
|
||||
}
|
||||
|
||||
const features = ref({ ...defaultFeatures, ...(auth.activeTenantData?.features || {}) })
|
||||
const businessInfo = ref(auth.activeTenantData.businessInfo)
|
||||
const businessInfo = ref(normalizeBusinessInfo(auth.activeTenantData?.businessInfo))
|
||||
const accountChart = ref(auth.activeTenantData.accountChart || "skr03")
|
||||
const taxEvaluationPeriod = ref(normalizeTaxEvaluationPeriod(auth.activeTenantData.taxEvaluationPeriod))
|
||||
const accountChartOptions = [
|
||||
@@ -245,6 +262,7 @@ const updateTenant = async (newData) => {
|
||||
itemInfo.value = res
|
||||
auth.activeTenantData = res
|
||||
features.value = { ...defaultFeatures, ...(res?.features || {}) }
|
||||
businessInfo.value = normalizeBusinessInfo(res?.businessInfo)
|
||||
taxEvaluationPeriod.value = normalizeTaxEvaluationPeriod(res?.taxEvaluationPeriod)
|
||||
}
|
||||
}
|
||||
@@ -628,6 +646,51 @@ onMounted(() => {
|
||||
<UInput v-model="businessInfo.city" class="flex-auto"/>
|
||||
</InputGroup>
|
||||
</UFormField>
|
||||
<UFormField
|
||||
label="E-Mail:"
|
||||
>
|
||||
<UInput v-model="businessInfo.email"/>
|
||||
</UFormField>
|
||||
<UFormField
|
||||
label="Telefon:"
|
||||
>
|
||||
<UInput v-model="businessInfo.phone"/>
|
||||
</UFormField>
|
||||
<UFormField
|
||||
label="Website:"
|
||||
>
|
||||
<UInput v-model="businessInfo.website"/>
|
||||
</UFormField>
|
||||
<UFormField
|
||||
label="Steuernummer:"
|
||||
>
|
||||
<UInput v-model="businessInfo.taxNumber"/>
|
||||
</UFormField>
|
||||
<UFormField
|
||||
label="USt-IdNr.:"
|
||||
>
|
||||
<UInput v-model="businessInfo.vatId"/>
|
||||
</UFormField>
|
||||
<UFormField
|
||||
label="Bank:"
|
||||
>
|
||||
<UInput v-model="businessInfo.bankName"/>
|
||||
</UFormField>
|
||||
<UFormField
|
||||
label="Kontoinhaber:"
|
||||
>
|
||||
<UInput v-model="businessInfo.bankAccountOwner"/>
|
||||
</UFormField>
|
||||
<UFormField
|
||||
label="IBAN:"
|
||||
>
|
||||
<UInput v-model="businessInfo.iban"/>
|
||||
</UFormField>
|
||||
<UFormField
|
||||
label="BIC:"
|
||||
>
|
||||
<UInput v-model="businessInfo.bic"/>
|
||||
</UFormField>
|
||||
<UButton
|
||||
class="mt-3"
|
||||
@click="updateTenant({businessInfo: businessInfo})"
|
||||
|
||||
Reference in New Issue
Block a user