Compare commits
No commits in common. "0528506dfaa52988bb87a7488d52d6acd1a0547e" and "9e8eb05e8814153ee3890569ef9e481df7c5a9f1" have entirely different histories.
0528506dfa
...
9e8eb05e88
@ -116,6 +116,12 @@ public static function table(Table $table): Table
|
|||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// TextColumn::make('Account Details')
|
||||||
|
// ->getStateUsing(function ($record) {
|
||||||
|
// return $record->account_username.'<br>'.$record->account_password;
|
||||||
|
// })
|
||||||
|
// ->html(),
|
||||||
|
|
||||||
TextColumn::make('account_title'),
|
TextColumn::make('account_title'),
|
||||||
TextColumn::make('info_needed'),
|
TextColumn::make('info_needed'),
|
||||||
TextColumn::make('notify'),
|
TextColumn::make('notify'),
|
||||||
|
@ -9,23 +9,17 @@
|
|||||||
use App\Models\Contact;
|
use App\Models\Contact;
|
||||||
use App\Models\Customer;
|
use App\Models\Customer;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use App\Models\OrderProduct;
|
|
||||||
use App\Models\ProductService;
|
|
||||||
use App\Models\ProductSize;
|
|
||||||
use App\Models\ServiceFile;
|
|
||||||
use App\Models\ServiceType;
|
use App\Models\ServiceType;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
use function Pest\Livewire\livewire;
|
use function Pest\Livewire\livewire;
|
||||||
|
|
||||||
it('can create an order and all associated models and save it to the database', function () {
|
it('can create an order and save it to the database', function () {
|
||||||
$type = fake()->randomElement(OrderType::cases());
|
$type = fake()->randomElement(OrderType::cases());
|
||||||
$status = fake()->randomElement(OrderStatus::cases());
|
$status = fake()->randomElement(OrderStatus::cases());
|
||||||
$customer = Customer::factory()->create();
|
$customer = Customer::factory()->create();
|
||||||
$contact = Contact::factory()->for($customer)->create();
|
$contact = Contact::factory()->for($customer)->create();
|
||||||
$attributes = array_map(fn ($case) => $case->value, OrderAttributes::cases());
|
$attributes = array_map(fn ($case) => $case->value, OrderAttributes::cases());
|
||||||
$orderDate = today();
|
|
||||||
$dueDate = today()->addDays(10);
|
|
||||||
|
|
||||||
$serviceTypes = ServiceType::factory()->count(2)->create();
|
$serviceTypes = ServiceType::factory()->count(2)->create();
|
||||||
|
|
||||||
@ -37,8 +31,8 @@
|
|||||||
'customer_id' => $customer->id,
|
'customer_id' => $customer->id,
|
||||||
'contact_id' => $contact->id,
|
'contact_id' => $contact->id,
|
||||||
'customer_po' => 'Customer PO name here',
|
'customer_po' => 'Customer PO name here',
|
||||||
'order_date' => $orderDate,
|
'order_date' => today(),
|
||||||
'due_date' => $dueDate,
|
'due_date' => today()->addDays(10),
|
||||||
'notes' => 'Notes go here! Here\'s the notes!',
|
'notes' => 'Notes go here! Here\'s the notes!',
|
||||||
'pre_production' => '1',
|
'pre_production' => '1',
|
||||||
'printed' => '1',
|
'printed' => '1',
|
||||||
@ -60,7 +54,7 @@
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'sku' => 'sku 2',
|
'sku' => 'sku 2',
|
||||||
'product_name' => 'also test',
|
'product_name' => 'alsotest',
|
||||||
'color' => 'white',
|
'color' => 'white',
|
||||||
'xs' => '9',
|
'xs' => '9',
|
||||||
's' => '10',
|
's' => '10',
|
||||||
@ -108,180 +102,9 @@
|
|||||||
->assertHasNoErrors();
|
->assertHasNoErrors();
|
||||||
|
|
||||||
$order = Order::first();
|
$order = Order::first();
|
||||||
|
|
||||||
$this->assertNotNull($order);
|
$this->assertNotNull($order);
|
||||||
$this->assertSame(
|
|
||||||
[
|
|
||||||
$order->id,
|
|
||||||
$order->customer_id,
|
|
||||||
$order->contact_id,
|
|
||||||
$order->internal_po,
|
|
||||||
$order->customer_po,
|
|
||||||
$order->invoice_id,
|
|
||||||
$order->order_date,
|
|
||||||
$order->order_type,
|
|
||||||
$order->status,
|
|
||||||
$order->due_date,
|
|
||||||
$order->notes,
|
|
||||||
$order->rush,
|
|
||||||
$order->repeat,
|
|
||||||
$order->new_art,
|
|
||||||
$order->event,
|
|
||||||
$order->digitizing,
|
|
||||||
$order->garments,
|
|
||||||
$order->supplied_file,
|
|
||||||
$order->printed,
|
|
||||||
$order->pre_production,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
1,
|
|
||||||
$customer->id,
|
|
||||||
$contact->id,
|
|
||||||
'TN24-0001',
|
|
||||||
'Customer PO name here',
|
|
||||||
null,
|
|
||||||
$orderDate->format('Y-m-d'),
|
|
||||||
$type,
|
|
||||||
$status,
|
|
||||||
$dueDate->format('Y-m-d'),
|
|
||||||
'Notes go here! Here\'s the notes!',
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Order Products
|
$this->assertSame($order->customer_id, $formData['customer_id']);
|
||||||
$orderProducts = OrderProduct::all();
|
|
||||||
$this->assertNotNull($orderProducts);
|
|
||||||
$this->assertEquals(2, $orderProducts->count());
|
|
||||||
$this->assertEquals(
|
|
||||||
[
|
|
||||||
$orderProducts[0]->id,
|
|
||||||
$orderProducts[0]->sku,
|
|
||||||
$orderProducts[0]->product_name,
|
|
||||||
$orderProducts[0]->color,
|
|
||||||
$orderProducts[0]->order_id,
|
|
||||||
|
|
||||||
$orderProducts[1]->id,
|
|
||||||
$orderProducts[1]->sku,
|
|
||||||
$orderProducts[1]->product_name,
|
|
||||||
$orderProducts[1]->color,
|
|
||||||
$orderProducts[1]->order_id,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
1,
|
|
||||||
'sku 1',
|
|
||||||
'test',
|
|
||||||
'black',
|
|
||||||
'1',
|
|
||||||
|
|
||||||
2,
|
|
||||||
'sku 2',
|
|
||||||
'also test',
|
|
||||||
'white',
|
|
||||||
'1',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Product Services
|
|
||||||
$productServices = ProductService::all();
|
|
||||||
$this->assertNotNull($productServices);
|
|
||||||
$this->assertEquals(2, $productServices->count());
|
|
||||||
$this->assertEquals(
|
|
||||||
[
|
|
||||||
$productServices[0]->id,
|
|
||||||
$productServices[0]->order_id,
|
|
||||||
$productServices[0]->service_file_id,
|
|
||||||
$productServices[0]->service_type_id,
|
|
||||||
$productServices[0]->placement,
|
|
||||||
$productServices[0]->amount,
|
|
||||||
$productServices[0]->amount_price,
|
|
||||||
$productServices[0]->notes,
|
|
||||||
|
|
||||||
$productServices[1]->id,
|
|
||||||
$productServices[1]->order_id,
|
|
||||||
$productServices[1]->service_file_id,
|
|
||||||
$productServices[1]->service_type_id,
|
|
||||||
$productServices[1]->placement,
|
|
||||||
$productServices[1]->amount,
|
|
||||||
$productServices[1]->amount_price,
|
|
||||||
$productServices[1]->notes,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
$serviceTypes[0]->id,
|
|
||||||
'C/F',
|
|
||||||
'3',
|
|
||||||
'4',
|
|
||||||
'HERE\'S SOME NOTES, ALL HANDWRITTEN BY ME.',
|
|
||||||
|
|
||||||
2,
|
|
||||||
1,
|
|
||||||
2,
|
|
||||||
$serviceTypes[1]->id,
|
|
||||||
'F/B',
|
|
||||||
'8',
|
|
||||||
'9',
|
|
||||||
'HERE\'S EVEN MORE NOTES, STILL HANDWRITTEN BY ME.',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Service Files
|
|
||||||
$serviceFiles = ServiceFile::all();
|
|
||||||
$this->assertNotNull($serviceFiles);
|
|
||||||
$this->assertEquals(2, $serviceFiles->count());
|
|
||||||
$this->assertEquals(
|
|
||||||
[
|
|
||||||
$serviceFiles[0]->id,
|
|
||||||
$serviceFiles[0]->code,
|
|
||||||
$serviceFiles[0]->name,
|
|
||||||
$serviceFiles[0]->width,
|
|
||||||
$serviceFiles[0]->height,
|
|
||||||
$serviceFiles[0]->setup_number,
|
|
||||||
|
|
||||||
$serviceFiles[1]->id,
|
|
||||||
$serviceFiles[1]->code,
|
|
||||||
$serviceFiles[1]->name,
|
|
||||||
$serviceFiles[1]->width,
|
|
||||||
$serviceFiles[1]->height,
|
|
||||||
$serviceFiles[1]->setup_number,
|
|
||||||
],
|
|
||||||
[
|
|
||||||
1,
|
|
||||||
'A1234',
|
|
||||||
'LOGO NAME 1',
|
|
||||||
'1.00',
|
|
||||||
'2.00',
|
|
||||||
1,
|
|
||||||
|
|
||||||
2,
|
|
||||||
'B5678',
|
|
||||||
'LOGO NAME 2',
|
|
||||||
'6.00',
|
|
||||||
'7.00',
|
|
||||||
5,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Product Sizes
|
|
||||||
$productSizes = ProductSize::all();
|
|
||||||
$this->assertNotNull($productSizes);
|
|
||||||
$this->assertEquals(16, $productSizes->count());
|
|
||||||
|
|
||||||
$sizes = ['xs', 's', 'm', 'l', 'xl', '2xl', '3xl', 'osfa', 'xs', 's', 'm', 'l', 'xl', '2xl', '3xl', 'osfa'];
|
|
||||||
|
|
||||||
for ($i = 0; $i < $productSizes->count(); $i++) {
|
|
||||||
$this->assertSame($productSizes[$i]->id, $i + 1);
|
|
||||||
$this->assertEquals($productSizes[$i]->order_product_id, $i > 7 ? '2' : '1');
|
|
||||||
$this->assertEquals($productSizes[$i]->amount, $i + 1);
|
|
||||||
$this->assertEquals($productSizes[$i]->size, $sizes[$i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user