Work on invoice report table (added date groups)
This commit is contained in:
parent
b47dd597e1
commit
f945ad2f71
@ -38,7 +38,8 @@ public static function table(Table $table): Table
|
|||||||
Tables\Columns\TextColumn::make('company_name')
|
Tables\Columns\TextColumn::make('company_name')
|
||||||
->label('Customer')
|
->label('Customer')
|
||||||
->sortable()
|
->sortable()
|
||||||
->searchable(),
|
->searchable()
|
||||||
|
->extraHeaderAttributes(['class' => 'w-full']),
|
||||||
|
|
||||||
Tables\Columns\TextColumn::make('subtotal')
|
Tables\Columns\TextColumn::make('subtotal')
|
||||||
->money('usd')
|
->money('usd')
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Grouping\Group;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
|
||||||
@ -36,21 +37,19 @@ public static function table(Table $table): Table
|
|||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->columns([
|
->columns([
|
||||||
Tables\Columns\TextColumn::make('year')
|
Tables\Columns\TextColumn::make('invoice.date')
|
||||||
->getStateUsing(fn (Order $record) => $record->invoice->date)
|
->label('Date')
|
||||||
->date('Y'),
|
->date('Y-m-d'),
|
||||||
|
|
||||||
Tables\Columns\TextColumn::make('month')
|
Tables\Columns\TextColumn::make('invoice.internal_id')
|
||||||
->getStateUsing(fn (Order $record) => $record->invoice->date)
|
->color('primary')
|
||||||
->date('m'),
|
->fontFamily('mono'),
|
||||||
|
|
||||||
Tables\Columns\TextColumn::make('customer_po')
|
Tables\Columns\TextColumn::make('customer_po')
|
||||||
->color('code')
|
->color('code')
|
||||||
->weight('bold')
|
->weight('bold')
|
||||||
->extraHeaderAttributes(['class' => 'w-full']),
|
->extraHeaderAttributes(['class' => 'w-full']),
|
||||||
|
|
||||||
Tables\Columns\TextColumn::make('invoice.date')
|
|
||||||
->label('Date'),
|
|
||||||
Tables\Columns\TextColumn::make('total_service_price')
|
Tables\Columns\TextColumn::make('total_service_price')
|
||||||
->label('Subtotal')
|
->label('Subtotal')
|
||||||
->alignRight()
|
->alignRight()
|
||||||
@ -87,6 +86,7 @@ public static function table(Table $table): Table
|
|||||||
Tables\Columns\TextColumn::make('invoice.status')
|
Tables\Columns\TextColumn::make('invoice.status')
|
||||||
->badge(InvoiceStatus::class),
|
->badge(InvoiceStatus::class),
|
||||||
])
|
])
|
||||||
|
|
||||||
->filters([
|
->filters([
|
||||||
Tables\Filters\SelectFilter::make('customer')
|
Tables\Filters\SelectFilter::make('customer')
|
||||||
->relationship('customer', 'company_name')
|
->relationship('customer', 'company_name')
|
||||||
@ -95,7 +95,7 @@ public static function table(Table $table): Table
|
|||||||
->placeholder('Select a customer...')
|
->placeholder('Select a customer...')
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->query(function (array $data, Builder $query): Builder {
|
->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')
|
Tables\Filters\Filter::make('date_from')
|
||||||
@ -121,12 +121,21 @@ public static function table(Table $table): Table
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
], layout: Tables\Enums\FiltersLayout::AboveContent)
|
], layout: Tables\Enums\FiltersLayout::AboveContent)
|
||||||
->hiddenFilterIndicators()
|
|
||||||
->actions([// Action::make('generateReport')
|
|
||||||
// ->label('Make Report')
|
|
||||||
// ->icon('lucide-sticky-note'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
->hiddenFilterIndicators()
|
||||||
|
|
||||||
|
->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
|
public static function getEloquentQuery(): \Illuminate\Database\Eloquent\Builder
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Resources\InvoiceReportResource\Pages;
|
namespace App\Filament\Resources\InvoiceReportResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\InvoiceReportResource;
|
use App\Filament\Resources\InvoiceReportResource;
|
||||||
|
use Filament\Actions\Action;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
class ListInvoiceReports extends ListRecords
|
class ListInvoiceReports extends ListRecords
|
||||||
@ -14,7 +15,9 @@ class ListInvoiceReports extends ListRecords
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// Actions\CreateAction::make(),
|
Action::make('generateReport')
|
||||||
|
->label('Make Report')
|
||||||
|
->icon('lucide-printer'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ class Invoice extends Model
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
'date' => 'datetime',
|
||||||
'total' => 'decimal:2',
|
'total' => 'decimal:2',
|
||||||
'subtotal' => 'decimal:2',
|
'subtotal' => 'decimal:2',
|
||||||
'status' => InvoiceStatus::class,
|
'status' => InvoiceStatus::class,
|
||||||
|
@ -20,6 +20,7 @@ public function definition(): array
|
|||||||
'created_at' => Carbon::now()->subDays(rand(1, 30)),
|
'created_at' => Carbon::now()->subDays(rand(1, 30)),
|
||||||
'gst' => true,
|
'gst' => true,
|
||||||
'pst' => $this->faker->boolean(40),
|
'pst' => $this->faker->boolean(40),
|
||||||
|
'date' => Carbon::now()->subDays(rand(1, 60)),
|
||||||
'status' => $this->faker->randomElement(InvoiceStatus::cases())->value,
|
'status' => $this->faker->randomElement(InvoiceStatus::cases())->value,
|
||||||
'customer_id' => $customer->id,
|
'customer_id' => $customer->id,
|
||||||
'updated_at' => Carbon::now(),
|
'updated_at' => Carbon::now(),
|
||||||
|
@ -14,7 +14,7 @@ class OrderSeeder extends Seeder
|
|||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
foreach (Customer::all() as $customer) {
|
foreach (Customer::all() as $customer) {
|
||||||
Order::factory(rand(10, 50), ['customer_id' => $customer])->create();
|
Order::factory(rand(50, 150), ['customer_id' => $customer])->create();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
30
todos
30
todos
@ -1,4 +1,34 @@
|
|||||||
todo
|
todo
|
||||||
|
Invoice Report
|
||||||
|
--------------
|
||||||
|
Model ?customer > table
|
||||||
|
|
||||||
|
Quotes
|
||||||
|
------
|
||||||
|
- Add date?
|
||||||
|
|
||||||
|
Orders
|
||||||
|
-------
|
||||||
|
- Fix service type
|
||||||
|
- PDF pre-pro property
|
||||||
|
- Change order status from table > do thru checkboxes?
|
||||||
|
- Tabs for quotes, invoices, packingSlips?
|
||||||
|
- Fix total order price
|
||||||
|
- Duplicate to new order
|
||||||
|
|
||||||
|
Shipping Entries
|
||||||
|
-----------------
|
||||||
|
- Clickable URL in title
|
||||||
|
|
||||||
|
Others
|
||||||
|
-------
|
||||||
|
- ServiceFile findOrCreate
|
||||||
|
- Way to set GST and PST
|
||||||
|
- Remove service_type from ProductService?
|
||||||
|
- order pdfs checkboxes don't tick no more
|
||||||
|
- duplicate order button (edit page header)
|
||||||
|
- badge for invoices
|
||||||
|
|
||||||
|
|
||||||
- finish invoice styling
|
- finish invoice styling
|
||||||
- add to invoice button on order page
|
- add to invoice button on order page
|
||||||
|
Loading…
x
Reference in New Issue
Block a user