From 856d4d52a9ad3304024325ffcc9ab693e9f278a5 Mon Sep 17 00:00:00 2001 From: Daniel Stock Date: Wed, 19 Nov 2025 12:48:21 +0100 Subject: [PATCH] =?UTF-8?q?Fixed=20a=20regression=20where=20customer=20and?= =?UTF-8?q?=20contacts=20of=20an=20invoice=20haven=E2=80=99t=20been=20set?= =?UTF-8?q?=20when=20opening=20an=20invoice=20for=20editing=20as=20these?= =?UTF-8?q?=20fields=20aren't=20in=20the=20summary=20that=20now=20get?= =?UTF-8?q?=E2=80=99s=20loaded=20with=20inertia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/components/documents/InvoiceDialog.vue | 59 +++++++------------ resources/js/types/index.d.ts | 2 + 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/resources/js/components/documents/InvoiceDialog.vue b/resources/js/components/documents/InvoiceDialog.vue index 16180f6..ac11685 100644 --- a/resources/js/components/documents/InvoiceDialog.vue +++ b/resources/js/components/documents/InvoiceDialog.vue @@ -131,8 +131,8 @@ watch(invoice, (newValue, oldValue) => { if (newValue == oldValue) return - console.group('watch invoice') - console.log(`isDirty: ${isDirty.value}\tisLoading: ${isLoading.value}`) + // console.group('watch invoice') + // console.log(`isDirty: ${isDirty.value}\tisLoading: ${isLoading.value}`) if (isLoading.value) { if (!newValue) { @@ -160,19 +160,24 @@ watch(invoice, } } - if (newValue.customer?.id !== 0) { + if (newValue.customerId && newValue.customerId !== 0) { // if (importCustomer.value != newValue.customer) // console.warn('trigger importCustomer watcher') - importCustomer.value = newValue.customer as Customer - newValue.customer?.contacts.find(contact => { - if ( - contact.firstName === newValue?.billingData?.contactFirstName && - contact.lastName === newValue?.billingData?.contactLastName - ) { - // if (importContact.value != contact) - // console.warn('trigger importContact watcher') - importContact.value = contact - return true + console.log(newValue, newValue.customerId) + customers.value.find(customer => { + if (customer.id === newValue.customerId) { + if (invoice.value) invoice.value.customer = customer as Customer + importCustomer.value = customer as Customer + + customer.contacts.find(contact => { + if (contact.firstName === newValue?.billingData?.contactFirstName && + contact.lastName === newValue?.billingData?.contactLastName) { + // if (importContact.value != contact) + // console.warn('trigger importContact watcher') + importContact.value = contact + return true + } + }) } }) } @@ -183,8 +188,8 @@ watch(invoice, isDirty.value = true } - console.log(`isDirty: ${isDirty.value}\tisLoading: ${isLoading.value}`) - console.groupEnd() + // console.log(`isDirty: ${isDirty.value}\tisLoading: ${isLoading.value}`) + // console.groupEnd() }, { deep: true } ) @@ -624,7 +629,7 @@ const updateLineItems = (newItems: LineItem[]) => {
+ class="h-19 pb-12 sticky top-0 bg-background z-1 flex flex-col md:flex-row justify-between items-center">
@@ -634,26 +639,6 @@ const updateLineItems = (newItems: LineItem[]) => {
- - -
@@ -701,7 +686,7 @@ const updateLineItems = (newItems: LineItem[]) => { class="bg-transparent dark:bg-transparent hover:bg-background dark:hover:bg-background/40 p-1 shadow-none border-0 border-b-1 border-slate-300 dark:border-neutral-800 placeholder:text-muted-foreground/50 rounded-none hover:rounded-md" />