#97 Search and sort invoices by prices
This commit is contained in:
parent
5bec1fc3d8
commit
2b377f72aa
@ -159,34 +159,51 @@ public static function table(Table $table): Table
|
||||
|
||||
TextColumn::make('created_at')
|
||||
->label('Created')
|
||||
->date()
|
||||
->date('Y-m-d')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('subtotal')
|
||||
->money()
|
||||
->alignRight(),
|
||||
->alignRight()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('has_gst')
|
||||
// FIXME: sortable doesn't sort correctly
|
||||
TextColumn::make('gst_amount')
|
||||
->label('GST/HST')
|
||||
->money()
|
||||
->formatStateUsing(function (Invoice $record) {
|
||||
->getStateUsing(function (Invoice $record) {
|
||||
return $record->has_gst
|
||||
? '$'.number_format($record->gst_amount, 2)
|
||||
: ($record->has_hst ? '$'.number_format($record->hst_amount, 2) : '-');
|
||||
})
|
||||
->alignRight(),
|
||||
->alignRight()
|
||||
->searchable(query: function (Builder $query, string $search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->where('hst_amount', 'like', "%{$search}%")
|
||||
->orWhere('gst_amount', 'like', "%{$search}%");
|
||||
});
|
||||
}),
|
||||
// ->sortable(query: function (Builder $query, string $direction) {
|
||||
// $query->orderByRaw("COALESCE(hst_amount, gst_amount, 0) $direction");
|
||||
// }),
|
||||
|
||||
TextColumn::make('has_pst')
|
||||
TextColumn::make('pst_amount')
|
||||
->label('PST')
|
||||
->formatStateUsing(function (Invoice $record) {
|
||||
->getStateUsing(function (Invoice $record) {
|
||||
return $record->has_pst ? '$'.number_format($record->pst_amount, 2) : '-';
|
||||
})
|
||||
->alignRight(),
|
||||
->alignRight()
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('total')
|
||||
->money()
|
||||
->alignRight()
|
||||
->weight(FontWeight::Medium),
|
||||
->weight(FontWeight::Medium)
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('balance')
|
||||
->getStateUsing(fn (Invoice $record) => $record->remainingBalance())
|
||||
|
Loading…
x
Reference in New Issue
Block a user