From 6fc753fc19afb7acb1d3735ca5df39543ef16c38 Mon Sep 17 00:00:00 2001 From: Nisse Lommerde Date: Wed, 12 Feb 2025 13:32:39 -0500 Subject: [PATCH] #92 Implement qoutes feedback --- .../Admin/Resources/QuoteResource.php | 70 +++++++++++-------- app/Models/HeatTransferEntry.php | 1 + app/Models/Quote.php | 8 +-- app/Models/ScreenPrintEntry.php | 8 ++- .../factories/HeatTransferEntryFactory.php | 11 +-- .../factories/ScreenPrintEntryFactory.php | 16 +++-- .../021_create_screen_print_entries_table.php | 14 ++-- ...022_create_heat_transfer_entries_table.php | 1 + resources/views/pdf/quote.blade.php | 5 +- 9 files changed, 76 insertions(+), 58 deletions(-) diff --git a/app/Filament/Admin/Resources/QuoteResource.php b/app/Filament/Admin/Resources/QuoteResource.php index 96a1f28..fab5b6e 100644 --- a/app/Filament/Admin/Resources/QuoteResource.php +++ b/app/Filament/Admin/Resources/QuoteResource.php @@ -53,7 +53,8 @@ public static function form(Form $form): Form ->columnSpan(2), ]) ->columns(2) - ->columnSpan(fn (?Quote $record) => $record === null ? 3 : 2), + ->columnSpan(fn (?Quote $record) => $record === null ? 3 : 2) + ->extraAttributes(['class' => 'h-full']), Section::make() ->schema([ @@ -69,7 +70,8 @@ public static function form(Form $form): Form ]) ->columnSpan(1) - ->hidden(fn (?Quote $record) => $record === null), + ->hidden(fn (?Quote $record) => $record === null) + ->extraAttributes(['class' => 'h-full']), ]), TableRepeater::make('embroideryEntries') @@ -115,30 +117,24 @@ public static function form(Form $form): Form TextInput::make('logo') ->label('Logo name') ->columnSpan(2), + TextInput::make('placement'), TextInput::make('quantity') - ->rules(['numeric']), + ->rules(['numeric']) + ->label('Qty'), TextInput::make('width') ->rules('numeric'), TextInput::make('height') ->rules('numeric'), TextInput::make('setup_amount') + ->label('Setup qty') ->rules('numeric'), TextInput::make('color_amount') + ->label('Color qty') + ->rules('numeric'), + TextInput::make('color_match') + ->rules('numeric'), + TextInput::make('color_change') ->rules('numeric'), - Select::make('color_match') - ->required() - ->options([ - true => 'Yes', - false => 'No', - ]) - ->default(false), - Select::make('color_change') - ->required() - ->options([ - true => 'Yes', - false => 'No', - ]) - ->default(false), TextInput::make('flash') ->rules(['numeric']), TextInput::make('fleece') @@ -147,19 +143,33 @@ public static function form(Form $form): Form ->rules('numeric'), TextInput::make('run_charge') ->rules('numeric'), - TextInput::make('other_charges') + TextInput::make('artwork_fee') + ->label('Artwork fee') + ->rules('numeric'), + TextInput::make('repacking_fee') + ->label('Repack. fee') ->rules('numeric'), ]) ->addActionLabel('Add Screen Print Entry') ->defaultItems(0) ->reorderable() ->colStyles([ - 'logo' => 'width: 15%', - 'quantity' => 'width: 5%', - 'width' => 'width: 6%', - 'height' => 'width: 6%', - 'setup_amount' => 'width: 5%', - 'color_amount' => 'width: 5%', + 'logo' => 'width: 11%', + 'placement' => 'width: 11%', + 'quantity' => 'width: 5%', + 'width' => 'width: 6%', + 'height' => 'width: 6%', + 'setup_amount' => 'width: 5%', + 'color_amount' => 'width: 5%', + 'color_match' => 'width: 6%', + 'color_change' => 'width: 5%', + 'flash' => 'width: 6%', + 'fleece' => 'width: 6%', + 'poly_ink' => 'width: 6%', + 'run_charge' => 'width: 6%', + 'artwork_fee' => 'width: 6%', + 'repacking_fee' => 'width: 6%', + ]), TableRepeater::make('heatTransferEntries') @@ -167,6 +177,7 @@ public static function form(Form $form): Form ->schema([ TextInput::make('logo') ->label('Logo name'), + TextInput::make('placement'), TextInput::make('quantity') ->prefix('#') ->rules('numeric'), @@ -184,11 +195,12 @@ public static function form(Form $form): Form ->defaultItems(0) ->reorderable() ->colStyles([ - 'logo' => 'width: 20%', - 'quantity' => 'width: 10%', - 'width' => 'width: 11%', - 'height' => 'width: 11%', - 'price' => 'width: 15%', + 'logo' => 'width: 25%', + 'placement' => 'width: 25%', + 'quantity' => 'width: 10%', + 'width' => 'width: 11%', + 'height' => 'width: 11%', + 'price' => 'width: 15%', ]), ])->columns(1); diff --git a/app/Models/HeatTransferEntry.php b/app/Models/HeatTransferEntry.php index 268708c..a1a32ea 100644 --- a/app/Models/HeatTransferEntry.php +++ b/app/Models/HeatTransferEntry.php @@ -12,6 +12,7 @@ class HeatTransferEntry extends Model protected $fillable = [ 'quote_id', + 'placement', 'quantity', 'logo', 'width', diff --git a/app/Models/Quote.php b/app/Models/Quote.php index 1e3b425..76f00a9 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -30,15 +30,11 @@ public function getTotalAttribute(): float $embDigitizingTotal = $this->embroideryEntries()->sum('digitizing_cost'); $embRunChargeTotal = $this->embroideryEntries()->sum('run_charge'); - $scpRunChargeTotal = $this->screenPrintEntries()->sum('run_charge'); - $scpOtherChargeTotal = $this->screenPrintEntries()->sum('other_charges'); - $scpFleeceTotal = $this->screenPrintEntries()->sum('fleece'); - $scpFlashTotal = $this->screenPrintEntries()->sum('flash'); - $scpPolyInkTotal = $this->screenPrintEntries()->sum('poly_ink'); + $scpTotal = $this->screenPrintEntries->sum(fn (ScreenPrintEntry $record) => $record->total_price); $heatTransferTotal = $this->heatTransferEntries()->sum('price'); - return $embDigitizingTotal + $embRunChargeTotal + $scpRunChargeTotal + $scpOtherChargeTotal + $scpFleeceTotal + $scpFlashTotal + $scpPolyInkTotal + $heatTransferTotal; + return $embDigitizingTotal + $embRunChargeTotal + $scpTotal + $heatTransferTotal; } public function customer(): BelongsTo diff --git a/app/Models/ScreenPrintEntry.php b/app/Models/ScreenPrintEntry.php index 5fbc300..0da6b46 100644 --- a/app/Models/ScreenPrintEntry.php +++ b/app/Models/ScreenPrintEntry.php @@ -14,6 +14,7 @@ class ScreenPrintEntry extends Model 'quote_id', 'quantity', 'logo', + 'placement', 'width', 'height', 'color_amount', @@ -24,7 +25,8 @@ class ScreenPrintEntry extends Model 'flash', 'fleece', 'poly_ink', - 'other_charges', + 'artwork_fee', + 'repacking_fee', 'notes', ]; @@ -34,7 +36,9 @@ class ScreenPrintEntry extends Model protected function getTotalPriceAttribute(): float { - return $this->flash + $this->fleece + $this->poly_ink + $this->run_charge + $this->other_charges; + $perUnitTotals = ($this->flash + $this->fleece + $this->poly_ink + $this->run_charge + $this->repacking_fee) * $this->quantity ?? 0; + + return $perUnitTotals + $this->artwork_fee + $this->color_change + $this->color_match; } public function quote(): BelongsTo diff --git a/database/factories/HeatTransferEntryFactory.php b/database/factories/HeatTransferEntryFactory.php index 48ba381..610b5fb 100644 --- a/database/factories/HeatTransferEntryFactory.php +++ b/database/factories/HeatTransferEntryFactory.php @@ -17,11 +17,12 @@ class HeatTransferEntryFactory extends Factory public function definition(): array { return [ - 'quantity' => $this->faker->numberBetween(1, 10), - 'logo' => $this->faker->words(2, true), - 'width' => $this->faker->randomFloat(2, 1, 5), - 'height' => $this->faker->randomFloat(2, 1, 5), - 'price' => $this->faker->randomFloat(2, 1, 10), + 'quantity' => $this->faker->numberBetween(1, 10), + 'placement' => $this->faker->words(2, true), + 'logo' => $this->faker->words(2, true), + 'width' => $this->faker->randomFloat(2, 1, 5), + 'height' => $this->faker->randomFloat(2, 1, 5), + 'price' => $this->faker->randomFloat(2, 1, 10), ]; } } diff --git a/database/factories/ScreenPrintEntryFactory.php b/database/factories/ScreenPrintEntryFactory.php index 451fb06..2bb22d5 100644 --- a/database/factories/ScreenPrintEntryFactory.php +++ b/database/factories/ScreenPrintEntryFactory.php @@ -19,17 +19,19 @@ public function definition(): array return [ 'quantity' => random_int(1, 10), 'logo' => $this->faker->words(2, true), + 'placement' => $this->faker->words(2, true), 'width' => $this->faker->randomFloat(2, 1, 5), 'height' => $this->faker->randomFloat(2, 1, 5), 'color_amount' => random_int(1, 5), 'setup_amount' => random_int(1, 5), - 'run_charge' => $this->faker->randomFloat(2, 1, 10), - 'color_change' => $this->faker->boolean(), - 'color_match' => $this->faker->boolean(), - 'flash' => $this->faker->randomFloat(2, 1, 10), - 'fleece' => $this->faker->randomFloat(2, 1, 10), - 'poly_ink' => $this->faker->randomFloat(2, 1, 10), - 'other_charges' => $this->faker->randomFloat(2, 1, 10), + 'artwork_fee' => $this->faker->randomFloat(2, 1, 10), + 'color_change' => $this->faker->randomFLoat(2, 1, 10), + 'color_match' => $this->faker->randomFLoat(2, 1, 10), + 'flash' => $this->faker->randomFloat(2, 0, 2), + 'fleece' => $this->faker->randomFloat(2, 0, 2), + 'poly_ink' => $this->faker->randomFloat(2, 0, 2), + 'run_charge' => $this->faker->randomFloat(2, 0, 2), + 'repacking_fee' => $this->faker->randomFloat(2, 0, 2), ]; } } diff --git a/database/migrations/021_create_screen_print_entries_table.php b/database/migrations/021_create_screen_print_entries_table.php index f48b8eb..bb71eee 100644 --- a/database/migrations/021_create_screen_print_entries_table.php +++ b/database/migrations/021_create_screen_print_entries_table.php @@ -18,17 +18,19 @@ public function up(): void $table->integer('quantity')->nullable(); $table->string('logo')->nullable(); + $table->string('placement')->nullable(); $table->decimal('width', 6, 2)->nullable(); $table->decimal('height', 6, 2)->nullable(); $table->integer('color_amount')->nullable(); $table->integer('setup_amount')->nullable(); $table->decimal('run_charge', 8, 2)->nullable(); - $table->boolean('color_change')->default(false); - $table->boolean('color_match')->default(false); - $table->decimal('flash', 8, 2)->default(false); - $table->decimal('fleece', 8, 2)->default(false); - $table->decimal('poly_ink', 8, 2)->default(false); - $table->decimal('other_charges', 8, 2)->default(false); + $table->decimal('color_change', 8, 2)->nullable(); + $table->decimal('color_match', 8, 2)->nullable(); + $table->decimal('flash', 8, 2)->nullable(); + $table->decimal('fleece', 8, 2)->nullable(); + $table->decimal('poly_ink', 8, 2)->nullable(); + $table->decimal('artwork_fee', 8, 2)->nullable(); + $table->decimal('repacking_fee', 8, 2)->nullable(); $table->text('notes')->nullable(); $table->timestamps(); diff --git a/database/migrations/022_create_heat_transfer_entries_table.php b/database/migrations/022_create_heat_transfer_entries_table.php index 6bbb115..59214b6 100644 --- a/database/migrations/022_create_heat_transfer_entries_table.php +++ b/database/migrations/022_create_heat_transfer_entries_table.php @@ -17,6 +17,7 @@ public function up(): void $table->foreignId('quote_id')->constrained()->cascadeOnDelete(); $table->integer('quantity')->nullable(); + $table->string('placement')->nullable(); $table->string('logo')->nullable(); $table->decimal('width', 6, 2)->nullable(); $table->decimal('height', 6, 2)->nullable(); diff --git a/resources/views/pdf/quote.blade.php b/resources/views/pdf/quote.blade.php index eff8a2e..930ad77 100644 --- a/resources/views/pdf/quote.blade.php +++ b/resources/views/pdf/quote.blade.php @@ -79,7 +79,7 @@ Screen Printing {{$entry->logo}} - + {{$entry->placement}} {{$entry->quantity}} ${{number_format($entry->total_price, 2)}} @@ -89,7 +89,7 @@ Heat Transfer {{$entry->logo}} - + {{$entry->placement}} {{$entry->quantity}} ${{number_format($entry->price, 2)}} @@ -109,4 +109,3 @@ -