74a38420d8
- Empezada nueva vista y modelo gastos.
91 lines
3.4 KiB
PHP
91 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use App\Models\Sale;
|
|
use App\Models\SaleDetail;
|
|
use App\Models\Expense;
|
|
use App\Models\Product;
|
|
use App\Models\Client;
|
|
use App\Models\Supplier;
|
|
|
|
class FakeDataSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
// Ensure there are some products, clients, and suppliers
|
|
$client = Client::first() ?? Client::create(['name' => 'Cliente Falso', 'phone' => '123456', 'email' => 'cliente@fake.com']);
|
|
$product = Product::first() ?? Product::create([
|
|
'name' => 'Bicicleta de Prueba',
|
|
'description' => 'Prueba',
|
|
'sale_price' => 50000,
|
|
'stock_quantity' => 10,
|
|
'type' => 'bike'
|
|
]);
|
|
$supplier = Supplier::first() ?? Supplier::create(['name' => 'Proveedor Falso', 'phone' => '123456', 'email' => 'prov@fake.com']);
|
|
|
|
// 1. Create 10 Sales
|
|
$paymentMethods = ['Efectivo', 'Tarjeta de Débito', 'Tarjeta de Crédito', 'Transferencia'];
|
|
for ($i = 1; $i <= 10; $i++) {
|
|
$sale = Sale::create([
|
|
'client_id' => $client->id,
|
|
'total' => 50000,
|
|
'payment_method' => $paymentMethods[array_rand($paymentMethods)],
|
|
'created_at' => now()->subDays(rand(1, 30)),
|
|
]);
|
|
|
|
SaleDetail::create([
|
|
'sale_id' => $sale->id,
|
|
'product_id' => $product->id,
|
|
'quantity' => 1,
|
|
'price' => 50000,
|
|
]);
|
|
}
|
|
|
|
// 2. Create 10 Expenses (Servicios/Impuestos)
|
|
$expenseCategories = ['Servicios', 'Impuestos', 'Otros'];
|
|
$services = ['Factura de Luz - Edesur', 'Internet - Fibertel', 'Agua - AySA', 'Gas - Metrogas', 'Alquiler Local', 'Impuesto Municipal', 'Monotributo', 'Papelería', 'Limpieza', 'Café y Mate'];
|
|
for ($i = 0; $i < 10; $i++) {
|
|
Expense::create([
|
|
'description' => $services[$i],
|
|
'expense_category' => $expenseCategories[array_rand($expenseCategories)],
|
|
'type' => 'Factura',
|
|
'status' => 'Pagado',
|
|
'total_amount' => rand(1500, 25000),
|
|
'expense_date' => now()->subDays(rand(1, 30)),
|
|
]);
|
|
}
|
|
|
|
// 3. Create 10 Orders (Pedidos a Proveedores)
|
|
for ($i = 1; $i <= 10; $i++) {
|
|
Expense::create([
|
|
'supplier_id' => $supplier->id,
|
|
'description' => 'Pedido de repuestos varios #' . $i,
|
|
'expense_category' => 'Mercadería',
|
|
'type' => 'Pedido',
|
|
'status' => 'Pendiente',
|
|
'total_amount' => 0, // Orders might not have amounts until they arrive
|
|
'expense_date' => now()->subDays(rand(1, 10)),
|
|
]);
|
|
}
|
|
|
|
// 4. Create 10 Bills (Facturas de Proveedores)
|
|
for ($i = 1; $i <= 10; $i++) {
|
|
Expense::create([
|
|
'supplier_id' => $supplier->id,
|
|
'description' => 'Compra de bicicletas y cascos',
|
|
'expense_category' => 'Mercadería',
|
|
'type' => 'Compra',
|
|
'status' => 'Pagado',
|
|
'total_amount' => rand(100000, 500000),
|
|
'document_number' => 'FAC-0001-0000' . rand(1000, 9999),
|
|
'expense_date' => now()->subDays(rand(1, 30)),
|
|
]);
|
|
}
|
|
}
|
|
}
|