Work on invoice report table (added date groups)
This commit is contained in:
parent
b47dd597e1
commit
fcb1cef6fd
@ -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,15 @@ 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')
|
|
||||||
->getStateUsing(fn (Order $record) => $record->invoice->date)
|
|
||||||
->date('m'),
|
|
||||||
|
|
||||||
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 +82,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 +91,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,11 +117,22 @@ public static function table(Table $table): Table
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
], layout: Tables\Enums\FiltersLayout::AboveContent)
|
], layout: Tables\Enums\FiltersLayout::AboveContent)
|
||||||
|
|
||||||
->hiddenFilterIndicators()
|
->hiddenFilterIndicators()
|
||||||
->actions([// Action::make('generateReport')
|
|
||||||
// ->label('Make Report')
|
->actions([])
|
||||||
// ->icon('lucide-sticky-note'),
|
->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),
|
||||||
|
);
|
||||||
|
// ->defaultSort('date', 'desc');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,8 +232,7 @@ public static function table(Table $table): Table
|
|||||||
? 'lucide-calendar-clock' : ($record->rush
|
? 'lucide-calendar-clock' : ($record->rush
|
||||||
? OrderAttributes::rush->getIcon() : null);
|
? OrderAttributes::rush->getIcon() : null);
|
||||||
})
|
})
|
||||||
|
->size(Tables\Columns\IconColumn\IconColumnSize::Medium),
|
||||||
->size(Tables\Columns\IconColumn\IconColumnSize::Small),
|
|
||||||
|
|
||||||
TextColumn::make('internal_po')
|
TextColumn::make('internal_po')
|
||||||
->label('Internal PO')
|
->label('Internal PO')
|
||||||
|
@ -24,9 +24,18 @@ protected function getHeaderActions(): array
|
|||||||
public function getTabs(): array
|
public function getTabs(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
null => Tab::make('All')
|
'active' => Tab::make()
|
||||||
->icon('lucide-layout-grid'),
|
->query(function ($query) {
|
||||||
|
return $query
|
||||||
|
->whereNot('status', OrderStatus::INVOICED)
|
||||||
|
->whereNot('status', ORderStatus::SHIPPED);
|
||||||
|
})
|
||||||
|
->icon(OrderStatus::PRODUCTION->getIcon())
|
||||||
|
->badge(function () {
|
||||||
|
return Order::whereNot('status', OrderStatus::SHIPPED)
|
||||||
|
->whereNot('status', OrderStatus::INVOICED)
|
||||||
|
->count();
|
||||||
|
}),
|
||||||
'overdue' => Tab::make()
|
'overdue' => Tab::make()
|
||||||
->query(function ($query) {
|
->query(function ($query) {
|
||||||
return $query->whereDate('due_date', '<=', today())
|
return $query->whereDate('due_date', '<=', today())
|
||||||
@ -61,25 +70,28 @@ public function getTabs(): array
|
|||||||
})
|
})
|
||||||
->badgeColor('warning'),
|
->badgeColor('warning'),
|
||||||
|
|
||||||
'draft' => Tab::make()
|
null => Tab::make('All')
|
||||||
->query(fn ($query) => $query->where('status', OrderStatus::DRAFT->value))
|
->icon('lucide-layout-grid'),
|
||||||
->icon(OrderStatus::DRAFT->getIcon()),
|
|
||||||
|
|
||||||
'approved' => Tab::make()
|
// 'draft' => Tab::make()
|
||||||
->query(fn ($query) => $query->where('status', OrderStatus::APPROVED->value))
|
// ->query(fn ($query) => $query->where('status', OrderStatus::DRAFT->value))
|
||||||
->icon(OrderStatus::APPROVED->getIcon()),
|
// ->icon(OrderStatus::DRAFT->getIcon()),
|
||||||
|
//
|
||||||
'production' => Tab::make()
|
// 'approved' => Tab::make()
|
||||||
->query(fn ($query) => $query->where('status', OrderStatus::PRODUCTION->value))
|
// ->query(fn ($query) => $query->where('status', OrderStatus::APPROVED->value))
|
||||||
->icon(OrderStatus::PRODUCTION->getIcon()),
|
// ->icon(OrderStatus::APPROVED->getIcon()),
|
||||||
|
//
|
||||||
'shipped' => Tab::make()
|
// 'production' => Tab::make()
|
||||||
->query(fn ($query) => $query->where('status', OrderStatus::SHIPPED->value))
|
// ->query(fn ($query) => $query->where('status', OrderStatus::PRODUCTION->value))
|
||||||
->icon(OrderStatus::SHIPPED->getIcon()),
|
// ->icon(OrderStatus::PRODUCTION->getIcon()),
|
||||||
|
//
|
||||||
'invoiced' => Tab::make()
|
// 'shipped' => Tab::make()
|
||||||
->query(fn ($query) => $query->where('status', OrderStatus::INVOICED->value))
|
// ->query(fn ($query) => $query->where('status', OrderStatus::SHIPPED->value))
|
||||||
->icon(OrderStatus::INVOICED->getIcon()),
|
// ->icon(OrderStatus::SHIPPED->getIcon()),
|
||||||
|
//
|
||||||
|
// 'invoiced' => Tab::make()
|
||||||
|
// ->query(fn ($query) => $query->where('status', OrderStatus::INVOICED->value))
|
||||||
|
// ->icon(OrderStatus::INVOICED->getIcon()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
37
todos
37
todos
@ -1,4 +1,38 @@
|
|||||||
todo
|
todo
|
||||||
|
Invoice Report
|
||||||
|
--------------
|
||||||
|
Model ?customer > table
|
||||||
|
|
||||||
|
Quotes
|
||||||
|
------
|
||||||
|
- Add date?
|
||||||
|
|
||||||
|
Orders
|
||||||
|
-------
|
||||||
|
- Move all to last
|
||||||
|
- Default tab 'active orders'
|
||||||
|
- sort by status:
|
||||||
|
|
||||||
|
- 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
|
||||||
@ -8,6 +42,3 @@ renamings:
|
|||||||
- order->total_service_price => subtotal
|
- order->total_service_price => subtotal
|
||||||
- amount > quantity
|
- amount > quantity
|
||||||
- amount_price > amount
|
- amount_price > amount
|
||||||
|
|
||||||
|
|
||||||
orders: tabs for status or rush!! :D
|
|
Loading…
x
Reference in New Issue
Block a user