Work on ordertest, splitting address lines, and shipping entry stuff

orders
Nisse Lommerde 6 days ago
parent 2c0fbfde5b
commit 487ea48c14

@ -31,8 +31,10 @@ class CustomerResource extends Resource
Section::make([
TextInput::make('company_name'),
TextInput::make('phone'),
TextInput::make('shipping_address'),
TextInput::make('billing_address'),
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),
]);
}
@ -41,8 +43,10 @@ class CustomerResource extends Resource
{
return $table
->columns([
TextColumn::make('company_name'),
TextColumn::make('shipping_address'),
TextColumn::make('company_name')
->searchable()
->sortable(),
// TextColumn::make('shipping_address'),
TextColumn::make('phone'),
])
->filters([

@ -32,8 +32,9 @@ class ShippingEntriesRelationManager extends RelationManager
->label('Username'),
Tables\Columns\TextColumn::make('account_password')
->label('Password'),
Tables\Columns\TextColumn::make('info_needed')
->extraHeaderAttributes(['class' => 'w-full']),
Tables\Columns\TextColumn::make('info_needed'),
// ->extraHeaderAttributes(['class' => 'w-full']),
Tables\Columns\TextColumn::make('notes'),
])
->filters([
//
@ -42,8 +43,8 @@ class ShippingEntriesRelationManager extends RelationManager
Tables\Actions\CreateAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
// Tables\Actions\EditAction::make(),
// Tables\Actions\DeleteAction::make(),
]);
}
}

@ -121,12 +121,6 @@ class InvoiceReportResource extends Resource
}),
], layout: Tables\Enums\FiltersLayout::AboveContent)
->hiddenFilterIndicators()
->actions([// Action::make('generateReport')
// ->label('Make Report')
// ->icon('lucide-sticky-note'),
]);
->hiddenFilterIndicators()
->actions([])

@ -89,6 +89,7 @@ class OrderResource extends Resource
->schema([
ToggleButtons::make('status')
->required()
->default(OrderStatus::DRAFT->value)
->options(OrderStatus::class)
->inline(),
@ -99,9 +100,11 @@ class OrderResource extends Resource
ToggleButtons::make('printed')
->boolean()
->default(false)
->inline(),
ToggleButtons::make('pre_production')
->label('Pre-production')
->default(false)
->boolean()
->inline()
->colors([

@ -9,6 +9,7 @@ use App\Models\OrderProduct;
use App\Models\ProductService;
use App\Models\ProductSize;
use App\Models\ServiceFile;
use App\Models\ServiceType;
use Filament\Resources\Pages\CreateRecord;
class CreateOrder extends CreateRecord
@ -64,9 +65,8 @@ class CreateOrder extends CreateRecord
'setup_number' => $service['serviceFileSetupNumber'] ?? null,
]);
//todo: change servce_type
ProductService::create([
// 'service_type' => strtoupper($service['service_type']) ?? null,
'service_type_id' => ServiceType::findOrFail($service['serviceType'])->id ?? null,
'placement' => strtoupper($service['placement']) ?? null,
'notes' => strtoupper($service['notes']) ?? null,
'amount' => $service['amount'] ?? null,
@ -77,8 +77,6 @@ class CreateOrder extends CreateRecord
]);
}
dd($data);
return $order;
}
}

@ -9,6 +9,7 @@ use App\Models\OrderProduct;
use App\Models\ProductService;
use App\Models\ProductSize;
use App\Models\ServiceFile;
use App\Models\ServiceType;
use Filament\Actions;
use Filament\Actions\Action;
use Filament\Resources\Pages\EditRecord;
@ -46,15 +47,13 @@ class EditOrder extends EditRecord
'amount' => $service->amount ?? '',
'amount_price' => $service->amount_price ?? '',
'notes' => $service->notes ?? '',
'serviceType' => $service->serviceType->id ?? '',
'serviceFileName' => $service->serviceFile->name ?? '',
'serviceFileWidth' => $service->serviceFile->width ?? '',
'serviceFileHeight' => $service->serviceFile->height ?? '',
'serviceFileCode' => $service->serviceFile->code ?? '',
'serviceFileSetupNumber' => $service->serviceFile->setup_number ?? '',
];
//todo ServiceType
// $service->serviceType()->associate(ServiceType::)
}
foreach (OrderAttributes::cases() as $case) {
@ -128,7 +127,7 @@ class EditOrder extends EditRecord
]);
ProductService::create([
'service_type' => strtoupper($service['service_type']) ?? null,
'service_type_id' => ServiceType::findOrFail($service['serviceType'])->id ?? null,
'placement' => strtoupper($service['placement']) ?? null,
'notes' => strtoupper($service['notes']) ?? null,
'amount' => $service['amount'] ?? null,

@ -31,7 +31,19 @@ class ShippingEntryResource extends Resource
{
return $table
->columns([
//
Tables\Columns\TextColumn::make('customer.company_name')
->searchable(),
Tables\Columns\TextColumn::make('shipping_type')
->label('Type')
->sortable(),
Tables\Columns\TextColumn::make('courier'),
// Tables\Columns\TextColumn::make('contact'),
Tables\Columns\TextColumn::make('account_title'),
// Tables\Columns\TextColumn::make('account_username'),
// Tables\Columns\TextColumn::make('account_password'),
Tables\Columns\TextColumn::make('info_needed'),
Tables\Columns\TextColumn::make('notify'),
])
->filters([
//
@ -40,10 +52,14 @@ class ShippingEntryResource extends Resource
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
// Tables\Actions\BulkActionGroup::make([
// Tables\Actions\DeleteBulkAction::make(),
// ]),
]);
// ->defaultGroup(
// Group::make('customer.company_name')
// ->titlePrefixedWithLabel(false)
// );
}
public static function getRelations(): array

@ -16,8 +16,10 @@ class Customer extends Model
protected $fillable = [
'company_name',
'internal_name',
'shipping_address',
'billing_address',
'shipping_address_line_1',
'shipping_address_line_2',
'billing_address_line_1',
'billing_address_line_2',
'phone',
];

@ -16,6 +16,7 @@ class ProductService extends Model
protected $fillable = [
'order_id',
'service_file_id',
'service_type_id',
'placement',
'setup_amount',
'amount',

4
composer.lock generated

@ -11355,12 +11355,12 @@
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {},
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^8.2"
},
"platform-dev": [],
"platform-dev": {},
"plugin-api-version": "2.6.0"
}

@ -14,16 +14,19 @@ class CustomerFactory extends Factory
{
$company_name = $this->faker->company();
$internal_name = explode(',', $company_name);
$address = $this->faker->address();
$address = $this->faker->streetAddress();
$city = 'Vancouver, Canada';
return [
'company_name' => $company_name,
'internal_name' => strtolower($internal_name[0]),
'shipping_address' => $address,
'billing_address' => $address,
'phone' => $this->faker->phoneNumber(),
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
'company_name' => $company_name,
'internal_name' => strtolower($internal_name[0]),
'shipping_address_line_1' => $address,
'shipping_address_line_2' => $city,
'billing_address_line_1' => $address,
'billing_address_line_2' => $city,
'phone' => $this->faker->phoneNumber(),
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
];
}
}

@ -13,8 +13,10 @@ return new class extends Migration
$table->string('company_name');
$table->string('internal_name');
$table->string('shipping_address');
$table->string('billing_address');
$table->string('shipping_address_line_1');
$table->string('shipping_address_line_2');
$table->string('billing_address_line_1');
$table->string('billing_address_line_2');
$table->string('phone');
$table->softDeletes();

@ -7,7 +7,7 @@ parameters:
- app/
# Level 9 is the highest level
level: 9
level: 1
# ignoreErrors:
# - '#PHPDoc tag @var#'

Binary file not shown.

@ -29,7 +29,8 @@
</div>
<div>
{{$invoice->customer->company_name}} <br>
{{$invoice->customer->billing_address}} <br>
{{$invoice->customer->billing_address_line_1}} <br>
{{$invoice->customer->billing_address_line_2}} <br>
</div>
</div>

@ -1,38 +0,0 @@
<?php
namespace Tests\Feature;
use App\Filament\Resources\OrderResource\Pages\ListOrders;
use App\Models\Customer;
use App\Models\Order;
use App\Models\OrderProduct;
use App\Models\ProductService;
use App\Models\ServiceFile;
use function Pest\Livewire\livewire;
it('can list posts', function () {
$customer = Customer::factory()->create();
$orders = Order::factory()->for($customer)->count(2)->create();
livewire(ListOrders::class)
->assertCanSeeTableRecords($orders);
});
it('can create a post', function () {
$customer = Customer::factory()->create();
$formData = Order::factory()->for($customer)->create();
$formData['order_products'] = OrderProduct::factory()->count(2)->create();
$formData['order_products'][0]['xs'] = 4;
$formData['order_products'][1]['s'] = 3;
$serviceFile1 = ServiceFile::factory()->create();
$serviceFile2 = ServiceFile::factory()->create();
$formData['services'][0] = ProductService::factory()->for($serviceFile1)->create();
$formData['services'][1] = ProductService::factory()->for($serviceFile2)->create();
dd($formData);
});

@ -0,0 +1,110 @@
<?php
namespace Tests\Feature;
use App\Enums\OrderAttributes;
use App\Enums\OrderStatus;
use App\Enums\OrderType;
use App\Filament\Resources\OrderResource\Pages\CreateOrder;
use App\Models\Contact;
use App\Models\Customer;
use App\Models\Order;
use App\Models\ServiceType;
use App\Models\User;
use function Pest\Livewire\livewire;
it('can create an order and save it to the database', function () {
$type = fake()->randomElement(OrderType::cases());
$status = fake()->randomElement(OrderStatus::cases());
$customer = Customer::factory()->create();
$contact = Contact::factory()->for($customer)->create();
$attributes = array_map(fn ($case) => $case->value, OrderAttributes::cases());
$serviceTypes = ServiceType::factory()->count(2)->create();
$user = User::factory()->create();
$this->actingAs($user);
$formData = [
'order_type' => $type->value,
'customer_id' => $customer->id,
'contact_id' => $contact->id,
'customer_po' => 'Customer PO name here',
'order_date' => today(),
'due_date' => today()->addDays(10),
'notes' => 'Notes go here! Here\'s the notes!',
'pre_production' => '1',
'printed' => '1',
'status' => $status->value,
'order_attributes' => $attributes,
'order_products' => [
[
'sku' => 'sku 1',
'product_name' => 'test',
'color' => 'black',
'xs' => '1',
's' => '2',
'm' => '3',
'l' => '4',
'xl' => '5',
'2xl' => '6',
'3xl' => '7',
'osfa' => '8',
],
[
'sku' => 'sku 2',
'product_name' => 'alsotest',
'color' => 'white',
'xs' => '9',
's' => '10',
'm' => '11',
'l' => '12',
'xl' => '13',
'2xl' => '14',
'3xl' => '15',
'osfa' => '16',
],
],
'services' => [
[
'serviceType' => $serviceTypes[0]->id,
'placement' => 'c/f',
'serviceFileName' => 'logo name 1',
'serviceFileSetupNumber' => '1',
'serviceFileWidth' => '1',
'serviceFileHeight' => '2',
'amount' => '3',
'amount_price' => '4',
'serviceFileCode' => 'A1234',
'notes' => 'Here\'s some notes, all handwritten by me.',
],
[
'serviceType' => $serviceTypes[1]->id,
'placement' => 'f/b',
'serviceFileName' => 'logo name 2',
'serviceFileSetupNumber' => '5',
'serviceFileWidth' => '6',
'serviceFileHeight' => '7',
'amount' => '8',
'amount_price' => '9',
'serviceFileCode' => 'B5678',
'notes' => 'Here\'s even more notes, still handwritten by me.',
],
],
];
livewire(CreateOrder::class)
->set('data.order_products', [])
->set('data.services', [])
->fillForm($formData)
->call('create')
->assertHasNoErrors();
$order = Order::first();
$this->assertNotNull($order);
$this->assertSame($order->customer_id, $formData['customer_id']);
});

@ -1,38 +0,0 @@
<?php
namespace Tests\Feature;
use App\Filament\Resources\OrderResource\Pages\ListOrders;
use App\Models\Customer;
use App\Models\Order;
use App\Models\OrderProduct;
use App\Models\ProductService;
use App\Models\ServiceFile;
use function Pest\Livewire\livewire;
it('can list posts', function () {
$customer = Customer::factory()->create();
$orders = Order::factory()->for($customer)->count(2)->create();
livewire(ListOrders::class)
->assertCanSeeTableRecords($orders);
});
it('can create a post', function () {
$customer = Customer::factory()->create();
$formData = Order::factory()->for($customer)->create();
$formData['order_products'] = OrderProduct::factory()->count(2)->create();
$formData['order_products'][0]['xs'] = 4;
$formData['order_products'][1]['s'] = 3;
$serviceFile1 = ServiceFile::factory()->create();
$serviceFile2 = ServiceFile::factory()->create();
$formData['services'][0] = ProductService::factory()->for($serviceFile1)->create();
$formData['services'][1] = ProductService::factory()->for($serviceFile2)->create();
dd($formData);
});

Binary file not shown.
Loading…
Cancel
Save