|
|
|
@ -9,6 +9,7 @@ use Filament\Forms\Components\DatePicker;
|
|
|
|
|
use Filament\Forms\Form;
|
|
|
|
|
use Filament\Resources\Resource;
|
|
|
|
|
use Filament\Tables;
|
|
|
|
|
use Filament\Tables\Grouping\Group;
|
|
|
|
|
use Filament\Tables\Table;
|
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
|
|
|
|
|
@ -36,21 +37,19 @@ class InvoiceReportResource extends Resource
|
|
|
|
|
{
|
|
|
|
|
return $table
|
|
|
|
|
->columns([
|
|
|
|
|
Tables\Columns\TextColumn::make('year')
|
|
|
|
|
->getStateUsing(fn (Order $record) => $record->invoice->date)
|
|
|
|
|
->date('Y'),
|
|
|
|
|
Tables\Columns\TextColumn::make('invoice.date')
|
|
|
|
|
->label('Date')
|
|
|
|
|
->date('Y-m-d'),
|
|
|
|
|
|
|
|
|
|
Tables\Columns\TextColumn::make('month')
|
|
|
|
|
->getStateUsing(fn (Order $record) => $record->invoice->date)
|
|
|
|
|
->date('m'),
|
|
|
|
|
Tables\Columns\TextColumn::make('invoice.internal_id')
|
|
|
|
|
->color('primary')
|
|
|
|
|
->fontFamily('mono'),
|
|
|
|
|
|
|
|
|
|
Tables\Columns\TextColumn::make('customer_po')
|
|
|
|
|
->color('code')
|
|
|
|
|
->weight('bold')
|
|
|
|
|
->extraHeaderAttributes(['class' => 'w-full']),
|
|
|
|
|
|
|
|
|
|
Tables\Columns\TextColumn::make('invoice.date')
|
|
|
|
|
->label('Date'),
|
|
|
|
|
Tables\Columns\TextColumn::make('total_service_price')
|
|
|
|
|
->label('Subtotal')
|
|
|
|
|
->alignRight()
|
|
|
|
@ -87,6 +86,7 @@ class InvoiceReportResource extends Resource
|
|
|
|
|
Tables\Columns\TextColumn::make('invoice.status')
|
|
|
|
|
->badge(InvoiceStatus::class),
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
->filters([
|
|
|
|
|
Tables\Filters\SelectFilter::make('customer')
|
|
|
|
|
->relationship('customer', 'company_name')
|
|
|
|
@ -95,7 +95,7 @@ class InvoiceReportResource extends Resource
|
|
|
|
|
->placeholder('Select a customer...')
|
|
|
|
|
->selectablePlaceholder(false)
|
|
|
|
|
->query(function (array $data, Builder $query): Builder {
|
|
|
|
|
return $query->where('customer_id', $data['value'] ?? '-1');
|
|
|
|
|
return $query->where('orders.customer_id', $data['value'] ?? '-1');
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
Tables\Filters\Filter::make('date_from')
|
|
|
|
@ -121,12 +121,21 @@ class InvoiceReportResource extends Resource
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
], layout: Tables\Enums\FiltersLayout::AboveContent)
|
|
|
|
|
|
|
|
|
|
->hiddenFilterIndicators()
|
|
|
|
|
->actions([// Action::make('generateReport')
|
|
|
|
|
// ->label('Make Report')
|
|
|
|
|
// ->icon('lucide-sticky-note'),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
->actions([])
|
|
|
|
|
->defaultGroup(
|
|
|
|
|
Group::make('date')
|
|
|
|
|
->getKeyFromRecordUsing(fn (Order $record): string => $record->invoice->date->format('Y-m-0'))
|
|
|
|
|
->getTitleFromRecordUsing(fn (Order $record): string => $record->invoice->date->format('F Y'))
|
|
|
|
|
->orderQueryUsing(function (Builder $query) {
|
|
|
|
|
|
|
|
|
|
return $query->join('invoices', 'orders.invoice_id', '=', 'invoices.id')
|
|
|
|
|
->orderBy('invoices.date', 'desc');
|
|
|
|
|
})
|
|
|
|
|
->titlePrefixedWithLabel(false),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getEloquentQuery(): \Illuminate\Database\Eloquent\Builder
|
|
|
|
|