Work on post-oplevering issues
This commit is contained in:
parent
056462f511
commit
306afd630b
@ -3,12 +3,15 @@
|
||||
namespace App\Filament\Admin\Resources;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\Invoice;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Columns\Summarizers\Summarizer;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
|
||||
class CustomerReportResource extends Resource
|
||||
{
|
||||
@ -42,6 +45,15 @@ public static function table(Table $table): Table
|
||||
|
||||
Tables\Columns\TextColumn::make('subtotal')
|
||||
->money()
|
||||
->summarize(Summarizer::make()->using(function (Builder $query, Table $table) {
|
||||
return '$'.
|
||||
number_format(
|
||||
round(Invoice::whereBetween('date', [
|
||||
$table->getFilter('created_at')->getState()['created_at'] ?? '1900-01-01',
|
||||
$table->getFilter('created_until')->getState()['created_until'] ?? '2100-01-01',
|
||||
])->sum('subtotal'), 2), 2, '.', ',');
|
||||
|
||||
}))
|
||||
->alignRight()
|
||||
->getStateUsing(function (Table $table, Model $record) {
|
||||
return $record->getSubtotalAttribute(
|
||||
@ -74,6 +86,15 @@ public static function table(Table $table): Table
|
||||
|
||||
Tables\Columns\TextColumn::make('total')
|
||||
->money()
|
||||
->summarize(Summarizer::make()->using(function (Builder $query, Table $table) {
|
||||
return '$'.
|
||||
number_format(
|
||||
round(Invoice::whereBetween('date', [
|
||||
$table->getFilter('created_at')->getState()['created_at'] ?? '1900-01-01',
|
||||
$table->getFilter('created_until')->getState()['created_until'] ?? '2100-01-01',
|
||||
])->sum('total'), 2), 2, '.', ',');
|
||||
|
||||
}))
|
||||
->weight('bold')
|
||||
->alignRight()
|
||||
->getStateUsing(function (Table $table, Model $record) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
@ -65,11 +66,6 @@ public static function form(Form $form): Form
|
||||
->inline()
|
||||
->default(InvoiceStatus::UNPAID)
|
||||
->columnSpan(2),
|
||||
// Select::make('status')
|
||||
// ->options(InvoiceStatus::class)
|
||||
// ->searchable()
|
||||
// ->required()
|
||||
// ->default(InvoiceStatus::UNPAID),
|
||||
])->columnSpan(2),
|
||||
|
||||
Grid::make(1)
|
||||
@ -120,7 +116,7 @@ public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('internal_id')
|
||||
TextColumn::make('internal_id')
|
||||
->label('ID')
|
||||
->fontFamily('mono')
|
||||
->color('primary')
|
||||
@ -133,37 +129,39 @@ public static function table(Table $table): Table
|
||||
});
|
||||
}),
|
||||
|
||||
Tables\Columns\TextColumn::make('customer.company_name')
|
||||
TextColumn::make('customer.company_name')
|
||||
->sortable()
|
||||
->extraHeaderAttributes(['class' => 'w-full'])
|
||||
->searchable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
TextColumn::make('created_at')
|
||||
->label('Created')
|
||||
->date()
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('subtotal')
|
||||
TextColumn::make('subtotal')
|
||||
->money()
|
||||
->alignRight(),
|
||||
|
||||
Tables\Columns\TextColumn::make('gst_amount')
|
||||
TextColumn::make('gst_amount')
|
||||
->label('GST')
|
||||
->money()
|
||||
->alignRight(),
|
||||
|
||||
Tables\Columns\TextColumn::make('pst_amount')
|
||||
->label('PST')
|
||||
->formatStateUsing(function ($state) {
|
||||
return $state == 0.00 ? '-' : '$'.$state;
|
||||
return $state == 0 ? '-' : '$'.number_format($state, 2);
|
||||
})
|
||||
->alignRight(),
|
||||
Tables\Columns\TextColumn::make('total')
|
||||
->label('Balance')
|
||||
|
||||
TextColumn::make('pst_amount')
|
||||
->label('PST')
|
||||
->formatStateUsing(function ($state) {
|
||||
return $state == 0 ? '-' : '$'.number_format($state, 2);
|
||||
})
|
||||
->alignRight(),
|
||||
TextColumn::make('total')
|
||||
->label('Total')
|
||||
->money()
|
||||
->weight('bold')
|
||||
->alignRight(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
TextColumn::make('status')
|
||||
->badge(InvoiceStatus::class)
|
||||
->sortable(),
|
||||
])
|
||||
|
@ -23,15 +23,4 @@ protected function getHeaderActions(): array
|
||||
->icon('lucide-trash-2'),
|
||||
];
|
||||
}
|
||||
|
||||
// protected function after(array $data): array
|
||||
// {
|
||||
// $invoice = Invoice::findOrFail($data['id']);
|
||||
//
|
||||
// if ($invoice->invoiceReports()->count() > 0) {
|
||||
// foreach ($invoice->invoiceReports as $report) {
|
||||
// $report->updateTotalBalance();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
@ -150,7 +150,15 @@ protected function getHeaderActions(): array
|
||||
->icon('lucide-save'),
|
||||
Actions\ReplicateAction::make()
|
||||
->icon('lucide-copy')
|
||||
->color('info'),
|
||||
->color('info')
|
||||
->mutateRecordDataUsing(function (array $data): array {
|
||||
$po = 'Duplicate of '.$data['customer_po'];
|
||||
$data['customer_po'] = $po;
|
||||
|
||||
return $data;
|
||||
})
|
||||
->beforeReplicaSaved(function (Model $replica): void {})
|
||||
->successRedirectUrl(fn (Model $replica): string => OrderResource::getUrl('edit', [$replica])),
|
||||
Action::make('print')
|
||||
->icon('lucide-printer')
|
||||
->url(fn (Order $record) => route('orders.pdf', $record))
|
||||
|
71
app/Filament/Admin/Resources/TaxResource.php
Normal file
71
app/Filament/Admin/Resources/TaxResource.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources;
|
||||
|
||||
use App\Filament\Admin\Resources\TaxResource\Pages;
|
||||
use App\Models\Tax;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TaxResource extends Resource
|
||||
{
|
||||
// protected static ?string $model = Tax::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'Service Tax';
|
||||
|
||||
protected static ?string $navigationIcon = 'lucide-circle-dollar-sign';
|
||||
|
||||
protected static ?string $navigationGroup = 'Settings';
|
||||
|
||||
protected static ?int $navigationSort = 11;
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
//
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
//
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()->is_admin;
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListTaxes::route('/'),
|
||||
'create' => Pages\CreateTax::route('/create'),
|
||||
'edit' => Pages\EditTax::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
11
app/Filament/Admin/Resources/TaxResource/Pages/CreateTax.php
Normal file
11
app/Filament/Admin/Resources/TaxResource/Pages/CreateTax.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\TaxResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\TaxResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTax extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TaxResource::class;
|
||||
}
|
19
app/Filament/Admin/Resources/TaxResource/Pages/EditTax.php
Normal file
19
app/Filament/Admin/Resources/TaxResource/Pages/EditTax.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\TaxResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\TaxResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTax extends EditRecord
|
||||
{
|
||||
protected static string $resource = TaxResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
19
app/Filament/Admin/Resources/TaxResource/Pages/ListTaxes.php
Normal file
19
app/Filament/Admin/Resources/TaxResource/Pages/ListTaxes.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\TaxResource\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\TaxResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTaxes extends ListRecords
|
||||
{
|
||||
protected static string $resource = TaxResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Customer\Resources\OrderResource\Pages;
|
||||
|
||||
use App\Filament\Customer\Resources\OrderResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListOrders extends ListRecords
|
||||
@ -13,7 +12,6 @@ class ListOrders extends ListRecords
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@ -34,6 +35,8 @@ class Invoice extends Model
|
||||
'date' => 'datetime',
|
||||
'total' => 'decimal:2',
|
||||
'subtotal' => 'decimal:2',
|
||||
'gst' => 'bool',
|
||||
'pst' => 'bool',
|
||||
'status' => InvoiceStatus::class,
|
||||
];
|
||||
|
||||
@ -47,6 +50,24 @@ public static function boot(): void
|
||||
});
|
||||
}
|
||||
|
||||
public function setPstAttribute(int $value): void
|
||||
{
|
||||
$this->attributes['pst'] = $value;
|
||||
$this->save();
|
||||
|
||||
$this->calculateTotals();
|
||||
}
|
||||
|
||||
public function setGstAttribute(int $value): void
|
||||
{
|
||||
$this->attributes['gst'] = $value;
|
||||
$this->save();
|
||||
|
||||
$this->calculateTotals();
|
||||
|
||||
// dd('value: '.$value.', model: '.$this->gst);
|
||||
}
|
||||
|
||||
public function setStatus(InvoiceStatus $status)
|
||||
{
|
||||
if ($this->status !== $status) {
|
||||
@ -55,14 +76,6 @@ public function setStatus(InvoiceStatus $status)
|
||||
}
|
||||
}
|
||||
|
||||
// public function generateInternalId(int $id): string
|
||||
// {
|
||||
// $po = str_pad(strval($id), 4, '0', STR_PAD_LEFT);
|
||||
// $year = date('y');
|
||||
//
|
||||
// return 'TN-IN-'.$year.'-'.$po;
|
||||
// }
|
||||
|
||||
public function calculateTotals(): void
|
||||
{
|
||||
$subtotal = 0;
|
||||
|
@ -45,7 +45,7 @@ public static function boot(): void
|
||||
$invoices = Invoice::whereBetween('date', [$model->date_start, $model->date_end])
|
||||
->where('customer_id', $model->customer_id)
|
||||
->when($model->filter_paid, function ($query) {
|
||||
$query->whereNot('status', InvoiceStatus::PAID);
|
||||
$query->where('status', InvoiceStatus::UNPAID);
|
||||
});
|
||||
$model->invoices()->sync($invoices->pluck('id')->toArray());
|
||||
|
||||
|
@ -32,9 +32,9 @@ public function panel(Panel $panel): Panel
|
||||
])
|
||||
->discoverResources(in: app_path('Filament/Customer/Resources'), for: 'App\\Filament\\Customer\\Resources')
|
||||
->discoverPages(in: app_path('Filament/Customer/Pages'), for: 'App\\Filament\\Customer\\Pages')
|
||||
->pages([
|
||||
Pages\Dashboard::class,
|
||||
])
|
||||
// ->pages([
|
||||
// Pages\Dashboard::class,
|
||||
// ])
|
||||
->discoverWidgets(in: app_path('Filament/Customer/Widgets'), for: 'App\\Filament\\Customer\\Widgets')
|
||||
->widgets([
|
||||
Widgets\AccountWidget::class,
|
||||
@ -53,6 +53,7 @@ public function panel(Panel $panel): Panel
|
||||
])
|
||||
->authMiddleware([
|
||||
Authenticate::class,
|
||||
]);
|
||||
])
|
||||
->sidebarWidth('13rem');
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ public function up(): void
|
||||
|
||||
$table->string('status')->default('UNPAID');
|
||||
|
||||
$table->float('subtotal', 2)->default(0.00);
|
||||
$table->float('total', 2)->default(0.00);
|
||||
$table->decimal('subtotal', 8, 2)->default(0.00);
|
||||
$table->decimal('total', 8, 2)->default(0.00);
|
||||
|
||||
$table->boolean('gst')->default(0);
|
||||
$table->boolean('pst')->default(0);
|
||||
$table->boolean('gst')->default(false);
|
||||
$table->boolean('pst')->default(false);
|
||||
|
||||
$table->date('date')->default(today());
|
||||
$table->date('due_date')->nullable();
|
||||
|
@ -11,10 +11,10 @@ public function up(): void
|
||||
Schema::create('packing_slips', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->string('order_id')->nullable(); //todo: replace this once orders are actually in da system
|
||||
$table->foreignId('order_id')->nullable()->constrained(); //todo: replace this once orders are actually in da system
|
||||
$table->foreignId('customer_id')->nullable()->constrained();
|
||||
$table->date('date_received');
|
||||
$table->string('amount');
|
||||
$table->string('amount')->nullable();
|
||||
$table->string('contents');
|
||||
|
||||
$table->softDeletes();
|
47
todos
47
todos
@ -1,18 +1,9 @@
|
||||
todo
|
||||
|
||||
Customer panel
|
||||
-----------
|
||||
Make login stuff
|
||||
Set query to use logged in customer
|
||||
Disable edit
|
||||
Make view page
|
||||
|
||||
Orders
|
||||
-------
|
||||
- Validation
|
||||
- Tabs for quotes, invoices, packingSlips?
|
||||
- Duplicate in order?
|
||||
|
||||
|
||||
Quotes
|
||||
------
|
||||
@ -22,18 +13,10 @@ Customer report
|
||||
----------------
|
||||
- Save to PDF
|
||||
|
||||
Invoices
|
||||
--------
|
||||
Due date doesn't update?
|
||||
Total doesn't update after dis/enabling pst or gst
|
||||
|
||||
Others
|
||||
-------
|
||||
- Change price calculations to round to two
|
||||
- customer name to invoice title / filename
|
||||
- ability to change PST / GST amounts
|
||||
- ability to change office address (see below)
|
||||
- dynamically get office address in invoice / invoice reports (add top notch as customer?)
|
||||
|
||||
Potentials
|
||||
-----------
|
||||
@ -41,34 +24,20 @@ Potentials
|
||||
- add to invoice button on order page?
|
||||
- Save and close buttons at header (orders)
|
||||
|
||||
|
||||
renamings:
|
||||
- order->total_service_price => subtotal
|
||||
- amount > quantity
|
||||
- amount_price > amount
|
||||
|
||||
|
||||
Discuss w/ James
|
||||
-----------------
|
||||
- Customer address system improvement (multiple addresses per customer instead of customer entry per address?)
|
||||
- Global search?
|
||||
- GST / PST edits? > yes, set global amount
|
||||
- Advanced shipping match system
|
||||
- Automatic BeUltimate orders
|
||||
|
||||
|
||||
Oplevering
|
||||
-----------
|
||||
User management
|
||||
|
||||
orders:
|
||||
- Remove customer name from print form
|
||||
- Go to new order when click replicate
|
||||
- Add order to invoice
|
||||
|
||||
Invoices:
|
||||
- Admin permissions
|
||||
|
||||
Invoice
|
||||
- Enter payment amount & link to invoice(s)
|
||||
- Calculate total of all selected invoices
|
||||
@ -78,22 +47,6 @@ Invoice
|
||||
- Partially paid invoice = not paid, registered in balance instead
|
||||
- Filter paid should only show "not paid"
|
||||
|
||||
Customer Reports
|
||||
-----------------
|
||||
Subtotal/totals for all customers combined
|
||||
|
||||
Quote
|
||||
-----
|
||||
- Logo, quantity, run charge, emb / digitizing, screen printing
|
||||
|
||||
Packing slips
|
||||
--------------
|
||||
Amount default value
|
||||
|
||||
|
||||
Customer Site
|
||||
--------------
|
||||
Get rid of New order button
|
||||
|
||||
Public site
|
||||
-----------
|
||||
|
Loading…
x
Reference in New Issue
Block a user