Work on ordertest, splitting address lines, and shipping entry stuff
This commit is contained in:
parent
2c0fbfde5b
commit
487ea48c14
@ -31,8 +31,10 @@ public static function form(Form $form): Form
|
||||
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 @@ public static function table(Table $table): Table
|
||||
{
|
||||
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 @@ public function table(Table $table): Table
|
||||
->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 @@ public function table(Table $table): Table
|
||||
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 @@ public static function table(Table $table): Table
|
||||
}),
|
||||
|
||||
], layout: Tables\Enums\FiltersLayout::AboveContent)
|
||||
->hiddenFilterIndicators()
|
||||
->actions([// Action::make('generateReport')
|
||||
// ->label('Make Report')
|
||||
// ->icon('lucide-sticky-note'),
|
||||
]);
|
||||
|
||||
->hiddenFilterIndicators()
|
||||
|
||||
->actions([])
|
||||
|
@ -89,6 +89,7 @@ public static function form(Form $form): Form
|
||||
->schema([
|
||||
ToggleButtons::make('status')
|
||||
->required()
|
||||
->default(OrderStatus::DRAFT->value)
|
||||
->options(OrderStatus::class)
|
||||
->inline(),
|
||||
|
||||
@ -99,9 +100,11 @@ public static function form(Form $form): Form
|
||||
|
||||
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\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 @@ protected function handleRecordCreation(array $data): Order
|
||||
'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 @@ protected function handleRecordCreation(array $data): Order
|
||||
]);
|
||||
}
|
||||
|
||||
dd($data);
|
||||
|
||||
return $order;
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
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 @@ protected function mutateFormDataBeforeFill(array $data): array
|
||||
'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 @@ public function handleRecordUpdate(Model $record, array $data): Model
|
||||
]);
|
||||
|
||||
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 @@ public static function table(Table $table): Table
|
||||
{
|
||||
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 @@ public static function table(Table $table): Table
|
||||
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
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 @@ public function definition()
|
||||
{
|
||||
$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 @@ public function up()
|
||||
|
||||
$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#'
|
||||
@ -15,4 +15,4 @@ parameters:
|
||||
# excludePaths:
|
||||
# - ./*/*/FileToBeExcluded.php
|
||||
#
|
||||
# checkMissingIterableValueType: false
|
||||
# checkMissingIterableValueType: false
|
||||
|
BIN
public/invoice-tn-in-24-0054.pdf
Normal file
BIN
public/invoice-tn-in-24-0054.pdf
Normal file
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);
|
||||
});
|
110
tests/Feature/OrdersTest.php
Normal file
110
tests/Feature/OrdersTest.php
Normal file
@ -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);
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user