Make invoices and payments searchable. Extend payments overview.

This commit is contained in:
2025-05-13 11:32:21 +02:00
parent e4238bfda6
commit 5deef877ba
3 changed files with 81 additions and 20 deletions

View File

@@ -36,11 +36,23 @@
<h2 class="text-lg font-medium text-gray-900 dark:text-gray-100">
{{ __('invoice.Existing invoices') }}
</h2>
<div class="flex flex-row space-x-4 items-center mt-4">
<x-input-label for="from" :value="__('invoice.From')"/>
<x-text-input type="date" id="from" name="from" x-model="from" x-on:change="fetchInvoices()"/>
<x-input-label for="end" :value="__('invoice.End')"/>
<x-text-input type="date" id="end" name="end" x-model="end" x-on:change="fetchInvoices()"/>
<div class="grid grid-cols-2">
<div class="flex flex-row space-x-4 items-center mt-4">
<x-input-label for="from" :value="__('invoice.From')"/>
<x-text-input type="date" id="from" name="from" x-model="from" x-on:change="fetchInvoices()"/>
<x-input-label for="end" :value="__('invoice.End')"/>
<x-text-input type="date" id="end" name="end" x-model="end" x-on:change="fetchInvoices()"/>
</div>
<div class="flex flex-row items-center gap-8">
<x-input-label for="search_invoice" :value="__('common.Search')"/>
<x-text-input id="search_invoice" name="search_invoice" type="text"
class="mt-1 block w-full"
x-ref="search_invoice"
autofocus
placeholder="{{ __('incoming.Search invoice') }}"
x-on:keydown.window.prevent.slash="$refs.search_invoice.focus()"
x-model="search_invoice"/>
</div>
</div>
</header>
@@ -53,7 +65,7 @@
<div class="w-1/12 font-bold border-b-2 text-right">{{ __('common.Created at') }}</div>
</summary>
<template x-for="invoice in invoices">
<template x-for="invoice in getFilteredInvoices()">
<details class="even:bg-gray-100 odd:bg-white hover:bg-gray-400">
<summary class="cursor-pointer flex flex-row w-full" @click="window.location.href='/invoice/' + invoice.id;">
<div class="w-1/6" x-text="invoice.number"></div>
@@ -96,6 +108,7 @@
from: "{{ $first }}",
end: "{{ $last }}",
invoices: [],
search_invoice: '',
sum: 0,
tax: 0,
@@ -115,6 +128,22 @@
})
},
getFilteredInvoices() {
if (this.search_invoice === '') {
return this.invoices;
}
return this.invoices.filter((invoice) => {
return invoice.customer.name
.replace(/ /g, '')
.toLowerCase()
.includes(this.search_invoice.replace(/ /g, '').toLowerCase())
|| invoice.number
.replace(/ /g, '')
.toLowerCase()
.includes(this.search_invoice.replace(/ /g, '').toLowerCase())
});
},
calculateSum() {
this.sum = 0;
this.tax = 0;