Fixed a regression where customer and contacts of an invoice haven’t been set when opening an invoice for editing as these fields aren't in the summary that now get’s loaded with inertia

This commit is contained in:
2025-11-19 12:48:21 +01:00
parent f264459435
commit d6e58a762c
2 changed files with 24 additions and 37 deletions
@@ -131,8 +131,8 @@ watch(invoice,
(newValue, oldValue) => { (newValue, oldValue) => {
if (newValue == oldValue) return if (newValue == oldValue) return
console.group('watch invoice') // console.group('watch invoice')
console.log(`isDirty: ${isDirty.value}\tisLoading: ${isLoading.value}`) // console.log(`isDirty: ${isDirty.value}\tisLoading: ${isLoading.value}`)
if (isLoading.value) { if (isLoading.value) {
if (!newValue) { if (!newValue) {
@@ -160,15 +160,18 @@ watch(invoice,
} }
} }
if (newValue.customer?.id !== 0) { if (newValue.customerId && newValue.customerId !== 0) {
// if (importCustomer.value != newValue.customer) // if (importCustomer.value != newValue.customer)
// console.warn('trigger importCustomer watcher') // console.warn('trigger importCustomer watcher')
importCustomer.value = newValue.customer as Customer console.log(newValue, newValue.customerId)
newValue.customer?.contacts.find(contact => { customers.value.find(customer => {
if ( if (customer.id === newValue.customerId) {
contact.firstName === newValue?.billingData?.contactFirstName && if (invoice.value) invoice.value.customer = customer as Customer
contact.lastName === newValue?.billingData?.contactLastName importCustomer.value = customer as Customer
) {
customer.contacts.find(contact => {
if (contact.firstName === newValue?.billingData?.contactFirstName &&
contact.lastName === newValue?.billingData?.contactLastName) {
// if (importContact.value != contact) // if (importContact.value != contact)
// console.warn('trigger importContact watcher') // console.warn('trigger importContact watcher')
importContact.value = contact importContact.value = contact
@@ -176,6 +179,8 @@ watch(invoice,
} }
}) })
} }
})
}
value.value = fromDate(new Date(newValue.invoiceDate), getLocalTimeZone()) value.value = fromDate(new Date(newValue.invoiceDate), getLocalTimeZone())
} }
@@ -183,8 +188,8 @@ watch(invoice,
isDirty.value = true isDirty.value = true
} }
console.log(`isDirty: ${isDirty.value}\tisLoading: ${isLoading.value}`) // console.log(`isDirty: ${isDirty.value}\tisLoading: ${isLoading.value}`)
console.groupEnd() // console.groupEnd()
}, },
{ deep: true } { deep: true }
) )
@@ -624,7 +629,7 @@ const updateLineItems = (newItems: LineItem[]) => {
<div id="document"> <div id="document">
<div id="document-header" <div id="document-header"
class="h-7 mb-12 sticky top-0 bg-background z-1 flex flex-col md:flex-row justify-between items-center"> class="h-19 pb-12 sticky top-0 bg-background z-1 flex flex-col md:flex-row justify-between items-center">
<!-- Status --> <!-- Status -->
<div> <div>
@@ -634,26 +639,6 @@ const updateLineItems = (newItems: LineItem[]) => {
</div> </div>
<!-- <div class="flex gap-4 mr-6 w-33" v-if="invoice && invoice.paymentStatus == 'draft'">
</div>
<Select v-model="invoice.paymentStatus" v-else>
<SelectTrigger class="bg-transparent! shadow-none! outline-0 border-0 pr-8 w-41 pl-0">
<StatusBadge size="lg" :variant="invoice.paymentStatus">{{
statusBadgeLabels[invoice.paymentStatus] }}
</StatusBadge>
<!-- <SelectValue placeholder="Status" />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem v-for="(label, value) in statusBadgeLabels" :value="value">
<SelectLabel>{{ label }}</SelectLabel>
</SelectItem>
</SelectGroup>
</SelectContent>
</Select> -->
<!-- Betrag --> <!-- Betrag -->
<div class="grid grid-cols-[auto_auto_auto_auto] items-end gap-x-6 gap-y-0"> <div class="grid grid-cols-[auto_auto_auto_auto] items-end gap-x-6 gap-y-0">
<label class="text-muted-foreground text-xs pb-[0.4rem]">Netto</label> <label class="text-muted-foreground text-xs pb-[0.4rem]">Netto</label>
@@ -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" /> 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" />
<Select v-model="importContact" by="id"> <Select v-model="importContact" by="id">
<SelectTrigger v-bind:disabled="!importCustomer || invoice.customer.id === 0" <SelectTrigger v-bind:disabled="!importCustomer || invoice.customerId === 0"
class="bg-transparent dark:bg-transparent hover:bg-background dark:hover:bg-background/40 border-none"> class="bg-transparent dark:bg-transparent hover:bg-background dark:hover:bg-background/40 border-none">
<SelectValue> <SelectValue>
<User /> <User />
+2
View File
@@ -149,6 +149,7 @@ export interface Invoice {
serviceEndDate: Date | null; serviceEndDate: Date | null;
isRecurring: boolean; isRecurring: boolean;
isPartialService: boolean; isPartialService: boolean;
customerId?: number | null;
customer?: Customer | null; customer?: Customer | null;
paymentStatus: PaymentStatus; paymentStatus: PaymentStatus;
totalAmount: number; totalAmount: number;
@@ -180,6 +181,7 @@ export function newInvoice(): Invoice {
serviceEndDate: date, serviceEndDate: date,
isRecurring: false, isRecurring: false,
isPartialService: false, isPartialService: false,
customerId: 0,
customer: newCustomer(), customer: newCustomer(),
paymentStatus: "draft", paymentStatus: "draft",
totalAmount: 0, totalAmount: 0,