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 327e82a4a6
commit 856d4d52a9
2 changed files with 24 additions and 37 deletions
@@ -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,15 +160,18 @@ 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
) {
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
@@ -176,6 +179,8 @@ watch(invoice,
}
})
}
})
}
value.value = fromDate(new Date(newValue.invoiceDate), getLocalTimeZone())
}
@@ -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[]) => {
<div id="document">
<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 -->
<div>
@@ -634,26 +639,6 @@ const updateLineItems = (newItems: LineItem[]) => {
</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 -->
<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>
@@ -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" />
<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">
<SelectValue>
<User />
+2
View File
@@ -149,6 +149,7 @@ export interface Invoice {
serviceEndDate: Date | null;
isRecurring: boolean;
isPartialService: boolean;
customerId?: number | null;
customer?: Customer | null;
paymentStatus: PaymentStatus;
totalAmount: number;
@@ -180,6 +181,7 @@ export function newInvoice(): Invoice {
serviceEndDate: date,
isRecurring: false,
isPartialService: false,
customerId: 0,
customer: newCustomer(),
paymentStatus: "draft",
totalAmount: 0,