Additional query filters for invoices

This commit is contained in:
David Bomba 2023-07-31 11:17:36 +10:00
parent 34f2b04e33
commit e13d867c7f
2 changed files with 45 additions and 0 deletions

View File

@ -183,6 +183,48 @@ class InvoiceFilters extends QueryFilters
->where('client_id', $this->decodePrimaryKey($client_id)); ->where('client_id', $this->decodePrimaryKey($client_id));
} }
/**
* @param string $date
* @return Builder
* @throws InvalidArgumentException
*/
public function date(string $date = ''): Builder
{
if (strlen($date) == 0) {
return $this->builder;
}
if (is_numeric($date)) {
$created_at = Carbon::createFromTimestamp((int)$date);
} else {
$created_at = Carbon::parse($date);
}
return $this->builder->where('date', '>=', $date);
}
/**
* @param string $date
* @return Builder
* @throws InvalidArgumentException
*/
public function due_date(string $date = ''): Builder
{
if (strlen($date) == 0) {
return $this->builder;
}
if (is_numeric($date)) {
$created_at = Carbon::createFromTimestamp((int)$date);
} else {
$created_at = Carbon::parse($date);
}
return $this->builder->where('due_date', '>=', $date);
}
/** /**
* Sorts the list based on $sort. * Sorts the list based on $sort.
* *

View File

@ -25,6 +25,7 @@ use App\Models\Subscription;
use App\Repositories\ClientContactRepository; use App\Repositories\ClientContactRepository;
use App\Repositories\ClientRepository; use App\Repositories\ClientRepository;
use App\Utils\Number; use App\Utils\Number;
use App\Utils\Traits\MakesHash;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -34,6 +35,7 @@ use Livewire\Component;
class BillingPortalPurchasev2 extends Component class BillingPortalPurchasev2 extends Component
{ {
use MakesHash;
/** /**
* Random hash generated by backend to handle the tracking of state. * Random hash generated by backend to handle the tracking of state.
* *
@ -422,6 +424,7 @@ class BillingPortalPurchasev2 extends Component
$client_repo = new ClientRepository(new ClientContactRepository()); $client_repo = new ClientRepository(new ClientContactRepository());
$data = [ $data = [
'name' => '', 'name' => '',
'group_id' => $this->encodePrimaryKey($this->subscription->group_id),
'contacts' => [ 'contacts' => [
['email' => $this->email], ['email' => $this->email],
], ],