From 0385f614d61027d5fd2da042a9f6d62ade3ff831 Mon Sep 17 00:00:00 2001 From: Nisse Lommerde Date: Tue, 11 Mar 2025 11:41:29 -0400 Subject: [PATCH 1/4] #116: 'Ready for invoice'-badge shows 0 instead of hiding --- README.md | 73 +------------------ .../OrderResource/Pages/ListOrders.php | 2 +- config/app.php | 2 +- 3 files changed, 4 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index e89b870..189b6ba 100644 --- a/README.md +++ b/README.md @@ -1,73 +1,4 @@ # Changelog -- Release -https://github.com/spatie/laravel-pdf/discussions/90 - -for spatie/pdf stuff - -

Laravel Logo

- -

-Build Status -Total Downloads -Latest Stable Version -License -

- -## About Laravel - -Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: - -- [Simple, fast routing engine](https://laravel.com/docs/routing). -- [Powerful dependency injection container](https://laravel.com/docs/container). -- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. -- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). -- Database agnostic [schema migrations](https://laravel.com/docs/migrations). -- [Robust background job processing](https://laravel.com/docs/queues). -- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). - -Laravel is accessible, powerful, and provides tools required for large, robust applications. - -## Learning Laravel - -Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. - -You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch. - -If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. - -## Laravel Sponsors - -We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com). - -### Premium Partners - -- **[Vehikl](https://vehikl.com/)** -- **[Tighten Co.](https://tighten.co)** -- **[WebReinvent](https://webreinvent.com/)** -- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** -- **[64 Robots](https://64robots.com)** -- **[Curotec](https://www.curotec.com/services/technologies/laravel/)** -- **[Cyber-Duck](https://cyber-duck.co.uk)** -- **[DevSquad](https://devsquad.com/hire-laravel-developers)** -- **[Jump24](https://jump24.co.uk)** -- **[Redberry](https://redberry.international/laravel/)** -- **[Active Logic](https://activelogic.com)** -- **[byte5](https://byte5.de)** -- **[OP.GG](https://op.gg)** - -## Contributing - -Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). - -## Code of Conduct - -In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). - -## Security Vulnerabilities - -If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. - -## License - -The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). +**2025-03-11** +- Fixed #116 - 'Ready for invoice'-badge shows 0 instead of hiding diff --git a/app/Filament/Admin/Resources/OrderResource/Pages/ListOrders.php b/app/Filament/Admin/Resources/OrderResource/Pages/ListOrders.php index 71d66c8..24abd3e 100644 --- a/app/Filament/Admin/Resources/OrderResource/Pages/ListOrders.php +++ b/app/Filament/Admin/Resources/OrderResource/Pages/ListOrders.php @@ -74,7 +74,7 @@ public function getTabs(): array 'ready_for_invoice' => Tab::make() ->query(fn ($query) => $query->where('status', OrderStatus::READY_FOR_INVOICE)) ->icon(OrderStatus::READY_FOR_INVOICE->getIcon()) - ->badge(fn () => Order::query()->where('status', OrderStatus::READY_FOR_INVOICE)->count()) + ->badge(fn () => ($count = Order::query()->where('status', OrderStatus::READY_FOR_INVOICE)->count()) > 0 ? $count : null) ->badgeColor(OrderStatus::READY_FOR_INVOICE->getColor()), ]; } diff --git a/config/app.php b/config/app.php index 3fc3ae6..48fb06c 100644 --- a/config/app.php +++ b/config/app.php @@ -25,7 +25,7 @@ | or any other location as required by the application or its packages. */ - 'version' => '1.0.0', + 'version' => '20250310', /* |-------------------------------------------------------------------------- From 47669851ffdf2e68d6d344ab8eb72a60de3c128d Mon Sep 17 00:00:00 2001 From: Nisse Lommerde Date: Tue, 11 Mar 2025 11:44:51 -0400 Subject: [PATCH 2/4] #117: Draft orders should not show up in order tabs --- README.md | 1 + app/Filament/Admin/Resources/OrderResource/Pages/ListOrders.php | 2 ++ config/app.php | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 189b6ba..9f78890 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Changelog **2025-03-11** +- Fixed #117 - Draft orders should not show up in order tabs - Fixed #116 - 'Ready for invoice'-badge shows 0 instead of hiding diff --git a/app/Filament/Admin/Resources/OrderResource/Pages/ListOrders.php b/app/Filament/Admin/Resources/OrderResource/Pages/ListOrders.php index 24abd3e..99225c9 100644 --- a/app/Filament/Admin/Resources/OrderResource/Pages/ListOrders.php +++ b/app/Filament/Admin/Resources/OrderResource/Pages/ListOrders.php @@ -18,6 +18,7 @@ class ListOrders extends ListRecords private function excludeStatuses($query): mixed { return $query + ->whereNot('status', OrderStatus::DRAFT) ->whereNot('status', OrderStatus::READY_FOR_INVOICE) ->whereNot('status', OrderStatus::INVOICED) ->whereNot('status', OrderStatus::SHIPPED); @@ -26,6 +27,7 @@ private function excludeStatuses($query): mixed private function getBadgeCount(callable $queryCallback): ?int { $count = Order::query()->when(true, $queryCallback) + ->whereNot('status', OrderStatus::DRAFT) ->whereNot('status', OrderStatus::READY_FOR_INVOICE) ->whereNot('status', OrderStatus::INVOICED) ->whereNot('status', OrderStatus::SHIPPED) diff --git a/config/app.php b/config/app.php index 48fb06c..2a6b4b4 100644 --- a/config/app.php +++ b/config/app.php @@ -25,7 +25,7 @@ | or any other location as required by the application or its packages. */ - 'version' => '20250310', + 'version' => '20250311', /* |-------------------------------------------------------------------------- From 68148211004845f0de0ba7daf6e68c44d844152f Mon Sep 17 00:00:00 2001 From: Nisse Lommerde Date: Tue, 11 Mar 2025 12:17:53 -0400 Subject: [PATCH 3/4] #118: Improve customer form Also re-added creating a new customer from the order form --- .../Admin/Resources/CustomerResource.php | 45 +++++++++++++++---- .../CustomerResource/Pages/ListCustomers.php | 1 + .../Admin/Resources/OrderResource.php | 7 +-- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/app/Filament/Admin/Resources/CustomerResource.php b/app/Filament/Admin/Resources/CustomerResource.php index f1b62f3..c31b046 100644 --- a/app/Filament/Admin/Resources/CustomerResource.php +++ b/app/Filament/Admin/Resources/CustomerResource.php @@ -8,6 +8,7 @@ use App\Filament\Admin\Resources\CustomerResource\RelationManagers\PaymentsRelationManager; use App\Filament\Admin\Resources\CustomerResource\RelationManagers\ShippingEntriesRelationManager; use App\Models\Customer; +use Filament\Forms\Components\Fieldset; use Filament\Forms\Components\Section; use Filament\Forms\Components\TextInput; use Filament\Forms\Form; @@ -29,16 +30,44 @@ class CustomerResource extends Resource public static function form(Form $form): Form { return $form + ->columns(1) ->schema([ Section::make([ - TextInput::make('company_name') - ->required(), - TextInput::make('phone'), - TextInput::make('shipping_address_line_1'), - TextInput::make('shipping_address_line_2'), - TextInput::make('billing_address_line_1'), - TextInput::make('billing_address_line_2'), - ])->columns(2), + Fieldset::make('Primary Information') + ->columns(1) + ->columnSpan(fn (?Customer $record) => $record ? 1 : 3) + ->schema([ + TextInput::make('company_name') + ->required(), + TextInput::make('phone'), + ]), + + Fieldset::make('Shipping Address') + ->columns(1) + ->columnSpan(fn (?Customer $record) => $record ? 1 : 3) + ->schema([ + TextInput::make('shipping_address_line_1') + ->label('Line 1') + ->placeholder('618 East Kent Ave S #108'), + TextInput::make('shipping_address_line_2') + ->label('Line 2') + ->placeholder('Vancouver, BC V5X 0B2, Canada'), + ]), + + Fieldset::make('Billing Address') + ->columns(1) + ->columnSpan(fn (?Customer $record) => $record ? 1 : 3) + ->schema([ + TextInput::make('billing_address_line_1') + ->label('Line 1') + ->placeholder('618 East Kent Ave S #108'), + TextInput::make('billing_address_line_2') + ->label('Line 2') + ->placeholder('Vancouver, BC V5X 0B2, Canada'), + ]), + ]) + ->columns(3) + ->columnSpan(fn (?Customer $record) => $record ? 1 : 3), ]); } diff --git a/app/Filament/Admin/Resources/CustomerResource/Pages/ListCustomers.php b/app/Filament/Admin/Resources/CustomerResource/Pages/ListCustomers.php index e3ed324..a7bc1a6 100644 --- a/app/Filament/Admin/Resources/CustomerResource/Pages/ListCustomers.php +++ b/app/Filament/Admin/Resources/CustomerResource/Pages/ListCustomers.php @@ -16,6 +16,7 @@ protected function getHeaderActions(): array return [ Actions\CreateAction::make() ->modal() + ->modalWidth('lg') ->icon(IconEnum::NEW->value) ->successRedirectUrl(fn ($record) => CustomerResource::getUrl('edit', ['record' => $record->id])), ]; diff --git a/app/Filament/Admin/Resources/OrderResource.php b/app/Filament/Admin/Resources/OrderResource.php index c93530f..aa42251 100644 --- a/app/Filament/Admin/Resources/OrderResource.php +++ b/app/Filament/Admin/Resources/OrderResource.php @@ -7,7 +7,6 @@ use App\Enums\OrderAttributes; use App\Enums\OrderStatus; use App\Enums\OrderType; -use App\Models\Customer; use App\Models\Invoice; use App\Models\Order; use App\Models\OrderProduct; @@ -61,11 +60,13 @@ public static function form(Form $form): Form ->options(OrderType::class) ->searchable(), - // Split::make([ Select::make('customer_id') ->required() ->label('Customer') - ->options(Customer::all()->pluck('company_name', 'id')) + ->relationship(name: 'customer', titleAttribute: 'company_name') + ->preload() + ->createOptionForm(fn ($form) => CustomerResource::form($form)) + ->createOptionAction(fn ($action) => $action->modalWidth('lg')) ->searchable(), TextInput::make('customer_po') From 77b9c558afe445859fffe41b6c1acad048d2274d Mon Sep 17 00:00:00 2001 From: Nisse Lommerde Date: Tue, 11 Mar 2025 12:31:12 -0400 Subject: [PATCH 4/4] #107: Fix Dashboard --- README.md | 2 ++ .../Admin/Widgets/ActiveOrdersTable.php | 36 ------------------- app/Filament/Admin/Widgets/OrderStats.php | 6 ++++ .../Admin/Widgets/RushOrdersTable.php | 35 ------------------ 4 files changed, 8 insertions(+), 71 deletions(-) delete mode 100644 app/Filament/Admin/Widgets/ActiveOrdersTable.php delete mode 100644 app/Filament/Admin/Widgets/RushOrdersTable.php diff --git a/README.md b/README.md index 9f78890..05f00c5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Changelog **2025-03-11** +- Fixed #107 - Fix dashboard +- Fixed #118 - Improved customer form and re-add 'create customer' to order form - Fixed #117 - Draft orders should not show up in order tabs - Fixed #116 - 'Ready for invoice'-badge shows 0 instead of hiding diff --git a/app/Filament/Admin/Widgets/ActiveOrdersTable.php b/app/Filament/Admin/Widgets/ActiveOrdersTable.php deleted file mode 100644 index eb86c61..0000000 --- a/app/Filament/Admin/Widgets/ActiveOrdersTable.php +++ /dev/null @@ -1,36 +0,0 @@ -query( - Order::query() - ->where('status', '!=', OrderStatus::SHIPPED) - ->where('status', '!=', OrderStatus::INVOICED) - ) - ->columns([ - TextColumn::make('customer.company_name'), - TextColumn::make('customer_po') - ->color('code') - ->weight('bold'), - TextColumn::make('status') -// ->color(OrderStatus::class) - ->badge(), - ]) - ->defaultPaginationPageOption(5); - } -} diff --git a/app/Filament/Admin/Widgets/OrderStats.php b/app/Filament/Admin/Widgets/OrderStats.php index 83d183f..f97f429 100644 --- a/app/Filament/Admin/Widgets/OrderStats.php +++ b/app/Filament/Admin/Widgets/OrderStats.php @@ -35,7 +35,9 @@ protected function getStats(): array private function getActiveOrders(): string { return Order::all() + ->where('order_status', '!=', OrderStatus::DRAFT) ->where('order_status', '!=', OrderStatus::SHIPPED) + ->where('order_status', '!=', OrderStatus::READY_FOR_INVOICE) ->where('order_status', '!=', OrderStatus::INVOICED) ->count(); } @@ -43,6 +45,8 @@ private function getActiveOrders(): string private function getOrdersPast30Days(): string { return Order::all() + ->where('order_status', '!=', OrderStatus::DRAFT) + ->where('order_status', '!=', OrderStatus::READY_FOR_INVOICE) ->where('order_status', '!=', OrderStatus::SHIPPED) ->where('order_status', '!=', OrderStatus::INVOICED) ->whereBetween('created_at', [now()->startOfMonth(), now()->endOfMonth()]) @@ -65,6 +69,8 @@ private function getOrdersInPast30DaysChart(): array private function getDueOrders(): string { return Order::all() + ->where('order_status', '!=', OrderStatus::DRAFT) + ->where('order_status', '!=', OrderStatus::READY_FOR_INVOICE) ->where('order_status', '!=', OrderStatus::SHIPPED) ->where('order_status', '!=', OrderStatus::INVOICED) ->where('due_date', '<=', now()) diff --git a/app/Filament/Admin/Widgets/RushOrdersTable.php b/app/Filament/Admin/Widgets/RushOrdersTable.php deleted file mode 100644 index c0b0ad3..0000000 --- a/app/Filament/Admin/Widgets/RushOrdersTable.php +++ /dev/null @@ -1,35 +0,0 @@ -query( - Order::query() - ->where('status', '!=', OrderStatus::SHIPPED) - ->where('status', '!=', OrderStatus::INVOICED) - ->where('rush', true) - ->orderByDesc('due_date') - ) - ->columns([ - TextColumn::make('customer.company_name'), - TextColumn::make('customer_po') - ->color('code') - ->weight('bold'), - TextColumn::make('status') - ->badge(), - ]) - ->defaultPaginationPageOption(5); - } -}