Work on invoice report table (added date groups)

Nisse Lommerde 1 week ago
parent b47dd597e1
commit 5a54672aad

@ -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'),
];
}
}

@ -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();
}
}
}

30
todos

@ -1,4 +1,34 @@
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
- add to invoice button on order page

Loading…
Cancel
Save