From 9592e2b0626c5113954bf1b2682325d1e13ed567 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Fri, 15 May 2026 18:13:29 +0200 Subject: [PATCH] =?UTF-8?q?SEPA-Mandate=20in=20Vertr=C3=A4ge=20und=20Ausga?= =?UTF-8?q?ngsrechnungen=20einbauen=20#183?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/pages/createDocument/edit/[[id]].vue | 119 ++++++++++++------ frontend/stores/data.js | 8 +- 2 files changed, 90 insertions(+), 37 deletions(-) diff --git a/frontend/pages/createDocument/edit/[[id]].vue b/frontend/pages/createDocument/edit/[[id]].vue index 4e0e7da..e91e09a 100644 --- a/frontend/pages/createDocument/edit/[[id]].vue +++ b/frontend/pages/createDocument/edit/[[id]].vue @@ -224,6 +224,33 @@ const availableSepaMandates = computed(() => { }) }) +const getSelectedSepaMandate = () => { + return availableSepaMandates.value.find((mandate) => mandate.id === itemInfo.value.outgoingsepamandate) || null +} + +const mapContractPaymentType = (paymentType) => { + if (paymentType === "Einzug") return "direct-debit" + if (paymentType === "Überweisung") return "transfer" + return null +} + +const applyContractPaymentData = () => { + const selectedContract = contracts.value.find((contract) => contract.id === itemInfo.value.contract) + if (!selectedContract) return + + const mappedPaymentType = mapContractPaymentType(selectedContract.paymentType) + if (mappedPaymentType) { + itemInfo.value.payment_type = mappedPaymentType + } + + const contractMandateId = selectedContract.outgoingsepamandate?.id || selectedContract.outgoingsepamandate + if (mappedPaymentType === "direct-debit" && contractMandateId) { + itemInfo.value.outgoingsepamandate = contractMandateId + } else if (mappedPaymentType === "transfer") { + itemInfo.value.outgoingsepamandate = null + } +} + const applyDefaultSepaMandate = () => { if (itemInfo.value.payment_type !== "direct-debit") { itemInfo.value.outgoingsepamandate = null @@ -246,6 +273,11 @@ const applyDefaultSepaMandate = () => { itemInfo.value.outgoingsepamandate = defaultMandate?.id || null } +watch( + () => itemInfo.value.contract, + () => applyContractPaymentData() +) + watch( () => [itemInfo.value.customer, itemInfo.value.contract, itemInfo.value.payment_type, outgoingsepamandates.value.length], () => applyDefaultSepaMandate() @@ -2268,6 +2300,24 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = { class="w-full" /> + + + + + + + - - - - - - - - - + + + + + + + + { inputType: "select", selectDataType: "outgoingsepamandates", selectOptionAttribute: "reference", - selectSearchAttributes: ["reference"], + selectSearchAttributes: ["reference", "status"], selectDataTypeFilter: function (i, item) { const mandateCustomer = i.customer?.id || i.customer - return !item.customer || mandateCustomer === item.customer + return !i.archived && i.status === "Aktiv" && (!item.customer || mandateCustomer === item.customer) + }, + entityModalButtonsType: "outgoingsepamandates", + entityModalCreateQueryFunction: function (item) { + return {customer: item.customer} }, showFunction: function (item) { return item.paymentType === "Einzug"