Work on invoice report table (added date groups)

orders
Nisse Lommerde 1 week ago
parent b47dd597e1
commit fcb1cef6fd

@ -38,7 +38,8 @@ class CustomerReportResource extends Resource
Tables\Columns\TextColumn::make('company_name')
->label('Customer')
->sortable()
->searchable(),
->searchable()
->extraHeaderAttributes(['class' => 'w-full']),
Tables\Columns\TextColumn::make('subtotal')
->money('usd')

@ -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,15 @@ 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('month')
->getStateUsing(fn (Order $record) => $record->invoice->date)
->date('m'),
Tables\Columns\TextColumn::make('invoice.date')
->label('Date')
->date('Y-m-d'),
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 +82,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 +91,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,11 +117,22 @@ 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),
);
// ->defaultSort('date', 'desc');
}

@ -3,6 +3,7 @@
namespace App\Filament\Resources\InvoiceReportResource\Pages;
use App\Filament\Resources\InvoiceReportResource;
use Filament\Actions\Action;
use Filament\Resources\Pages\ListRecords;
class ListInvoiceReports extends ListRecords
@ -14,7 +15,9 @@ class ListInvoiceReports extends ListRecords
protected function getHeaderActions(): array
{
return [
// Actions\CreateAction::make(),
Action::make('generateReport')
->label('Make Report')
->icon('lucide-printer'),
];
}
}

@ -232,8 +232,7 @@ class OrderResource extends Resource
? 'lucide-calendar-clock' : ($record->rush
? OrderAttributes::rush->getIcon() : null);
})
->size(Tables\Columns\IconColumn\IconColumnSize::Small),
->size(Tables\Columns\IconColumn\IconColumnSize::Medium),
TextColumn::make('internal_po')
->label('Internal PO')

@ -24,9 +24,18 @@ class ListOrders extends ListRecords
public function getTabs(): array
{
return [
null => Tab::make('All')
->icon('lucide-layout-grid'),
'active' => Tab::make()
->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()
->query(function ($query) {
return $query->whereDate('due_date', '<=', today())
@ -61,25 +70,28 @@ class ListOrders extends ListRecords
})
->badgeColor('warning'),
'draft' => Tab::make()
->query(fn ($query) => $query->where('status', OrderStatus::DRAFT->value))
->icon(OrderStatus::DRAFT->getIcon()),
'approved' => Tab::make()
->query(fn ($query) => $query->where('status', OrderStatus::APPROVED->value))
->icon(OrderStatus::APPROVED->getIcon()),
'production' => Tab::make()
->query(fn ($query) => $query->where('status', OrderStatus::PRODUCTION->value))
->icon(OrderStatus::PRODUCTION->getIcon()),
'shipped' => Tab::make()
->query(fn ($query) => $query->where('status', OrderStatus::SHIPPED->value))
->icon(OrderStatus::SHIPPED->getIcon()),
null => Tab::make('All')
->icon('lucide-layout-grid'),
'invoiced' => Tab::make()
->query(fn ($query) => $query->where('status', OrderStatus::INVOICED->value))
->icon(OrderStatus::INVOICED->getIcon()),
// 'draft' => Tab::make()
// ->query(fn ($query) => $query->where('status', OrderStatus::DRAFT->value))
// ->icon(OrderStatus::DRAFT->getIcon()),
//
// 'approved' => Tab::make()
// ->query(fn ($query) => $query->where('status', OrderStatus::APPROVED->value))
// ->icon(OrderStatus::APPROVED->getIcon()),
//
// 'production' => Tab::make()
// ->query(fn ($query) => $query->where('status', OrderStatus::PRODUCTION->value))
// ->icon(OrderStatus::PRODUCTION->getIcon()),
//
// 'shipped' => Tab::make()
// ->query(fn ($query) => $query->where('status', OrderStatus::SHIPPED->value))
// ->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 = [
'date' => 'datetime',
'total' => 'decimal:2',
'subtotal' => 'decimal:2',
'status' => InvoiceStatus::class,

@ -20,6 +20,7 @@ class InvoiceFactory extends Factory
'created_at' => Carbon::now()->subDays(rand(1, 30)),
'gst' => true,
'pst' => $this->faker->boolean(40),
'date' => Carbon::now()->subDays(rand(1, 60)),
'status' => $this->faker->randomElement(InvoiceStatus::cases())->value,
'customer_id' => $customer->id,
'updated_at' => Carbon::now(),

@ -14,7 +14,7 @@ class OrderSeeder extends Seeder
public function run(): void
{
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

@ -1,4 +1,38 @@
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
- add to invoice button on order page
@ -8,6 +42,3 @@ renamings:
- order->total_service_price => subtotal
- amount > quantity
- amount_price > amount
orders: tabs for status or rush!! :D
Loading…
Cancel
Save