mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
init crater
This commit is contained in:
21
database/factories/AddressFactory.php
Normal file
21
database/factories/AddressFactory.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\Address;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(Address::class, function (Faker $faker) {
|
||||
return [
|
||||
'name' => $faker->name,
|
||||
'address_street_1' => $faker->streetAddress,
|
||||
'address_street_2' => $faker->streetAddress,
|
||||
'city_id' => 5909,
|
||||
'state_id' => 42,
|
||||
'country_id' => 1,
|
||||
'zip' => $faker->postcode,
|
||||
'phone' => $faker->phoneNumber,
|
||||
'fax' => $faker->phoneNumber,
|
||||
'type' => Address::BILLING_TYPE
|
||||
];
|
||||
});
|
||||
45
database/factories/EstimateFactory.php
Normal file
45
database/factories/EstimateFactory.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\Estimate;
|
||||
use Laraspace\User;
|
||||
use Laraspace\Tax;
|
||||
use Faker\Generator as Faker;
|
||||
use Laraspace\EstimateItem;
|
||||
use Laraspace\EstimateTemplate;
|
||||
|
||||
$factory->define(Estimate::class, function (Faker $faker) {
|
||||
return [
|
||||
'estimate_date' => $faker->date($format = 'd/m/Y', $max = 'now'),
|
||||
'expiry_date' => $faker->date($format = 'd/m/Y', $max = 'now'),
|
||||
'estimate_number' => 'EST-'.Estimate::getNextEstimateNumber(),
|
||||
'reference_number' => Estimate::getNextEstimateNumber(),
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'user_id' => function () {
|
||||
return factory(User::class)->create(['role' => 'customer'])->id;
|
||||
},
|
||||
'status' => Estimate::STATUS_DRAFT,
|
||||
'estimate_template_id' => 1,
|
||||
'sub_total' => $faker->randomDigitNotNull,
|
||||
'discount' => 0,
|
||||
'discount_type' => 'fixed',
|
||||
'discount_val' => 0,
|
||||
'tax_per_item' => 'YES',
|
||||
'discount_per_item' => 'No',
|
||||
'total' => $faker->randomDigitNotNull,
|
||||
'tax' => $faker->randomDigitNotNull,
|
||||
'notes' => $faker->text(80),
|
||||
'unique_hash' => str_random(60)
|
||||
];
|
||||
});
|
||||
|
||||
$factory->afterCreating(Estimate::class, function ($estimate, $faker) {
|
||||
$estimate->items()->save(factory(EstimateItem::class)->make());
|
||||
$estimate->items()->save(factory(EstimateItem::class)->make());
|
||||
});
|
||||
|
||||
$factory->afterCreating(Estimate::class, function ($estimate, $faker) {
|
||||
$estimate->taxes()->save(factory(Tax::class)->make());
|
||||
$estimate->items()->save(factory(Tax::class)->make());
|
||||
});
|
||||
34
database/factories/EstimateItemFactory.php
Normal file
34
database/factories/EstimateItemFactory.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\EstimateItem;
|
||||
use Laraspace\Item;
|
||||
use Faker\Generator as Faker;
|
||||
use Laraspace\User;
|
||||
|
||||
$factory->define(EstimateItem::class, function (Faker $faker) {
|
||||
return [
|
||||
'item_id' => function () {
|
||||
return factory(Item::class)->create()->id;
|
||||
},
|
||||
'name' => function (array $item) {
|
||||
return Item::find($item['item_id'])->name;
|
||||
},
|
||||
'description' => function (array $item) {
|
||||
return Item::find($item['item_id'])->description;
|
||||
},
|
||||
'price' => function (array $item) {
|
||||
return Item::find($item['item_id'])->price;
|
||||
},
|
||||
'quantity' => $faker->randomDigitNotNull,
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'discount_type' => 'fixed',
|
||||
'tax' => $faker->randomDigitNotNull,
|
||||
'discount_val' => 0,
|
||||
'total' => function (array $item) {
|
||||
return ($item['price'] * $item['quantity']);
|
||||
},
|
||||
'discount' => 0
|
||||
];
|
||||
});
|
||||
14
database/factories/EstimateTemplateFactory.php
Normal file
14
database/factories/EstimateTemplateFactory.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\EstimateTemplate;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(EstimateTemplate::class, function (Faker $faker) {
|
||||
return [
|
||||
'path' => $faker->word,
|
||||
'view' => $faker->word,
|
||||
'name' => $faker->word,
|
||||
];
|
||||
});
|
||||
15
database/factories/ExpenseCategoryFactory.php
Normal file
15
database/factories/ExpenseCategoryFactory.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\ExpenseCategory;
|
||||
use Faker\Generator as Faker;
|
||||
use Laraspace\User;
|
||||
|
||||
$factory->define(ExpenseCategory::class, function (Faker $faker) {
|
||||
return [
|
||||
'name' => $faker->word,
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'description' => $faker->text
|
||||
];
|
||||
});
|
||||
21
database/factories/ExpenseFactory.php
Normal file
21
database/factories/ExpenseFactory.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\Expense;
|
||||
use Laraspace\ExpenseCategory;
|
||||
use Faker\Generator as Faker;
|
||||
use Laraspace\User;
|
||||
|
||||
$factory->define(Expense::class, function (Faker $faker) {
|
||||
return [
|
||||
'expense_date' => $faker->date($format = 'd/m/Y', $max = 'now'),
|
||||
'expense_category_id' => function () {
|
||||
return factory(ExpenseCategory::class)->create()->id;
|
||||
},
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'amount' => $faker->randomDigitNotNull,
|
||||
'notes' => $faker->text,
|
||||
'attachment_receipt' => null
|
||||
];
|
||||
});
|
||||
49
database/factories/InvoiceFactory.php
Normal file
49
database/factories/InvoiceFactory.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\Invoice;
|
||||
use Laraspace\User;
|
||||
use Laraspace\Tax;
|
||||
use Laraspace\InvoiceItem;
|
||||
use Laraspace\InvoiceTemplate;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(Invoice::class, function (Faker $faker) {
|
||||
return [
|
||||
'invoice_date' => $faker->date($format = 'd/m/Y', $max = 'now'),
|
||||
'due_date' => $faker->date($format = 'd/m/Y', $max = 'now'),
|
||||
'invoice_number' => 'INV-'.Invoice::getNextInvoiceNumber(),
|
||||
'reference_number' => Invoice::getNextInvoiceNumber(),
|
||||
'user_id' => function () {
|
||||
return factory(User::class)->create(['role' => 'customer'])->id;
|
||||
},
|
||||
'invoice_template_id' => 1,
|
||||
'status' => Invoice::STATUS_DRAFT,
|
||||
'tax_per_item' => 'NO',
|
||||
'discount_per_item' => 'NO',
|
||||
'paid_status' => Invoice::STATUS_UNPAID,
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'sub_total' => $faker->randomDigitNotNull,
|
||||
'discount' => 0,
|
||||
'discount_type' => 'fixed',
|
||||
'discount_val' => 0,
|
||||
'total' => $faker->randomDigitNotNull,
|
||||
'tax' => $faker->randomDigitNotNull,
|
||||
'due_amount' => function (array $invoice) {
|
||||
return $invoice['total'];
|
||||
},
|
||||
'notes' => $faker->text(80),
|
||||
'unique_hash' => str_random(60)
|
||||
];
|
||||
});
|
||||
|
||||
$factory->afterCreating(Invoice::class, function ($invoice, $faker) {
|
||||
$invoice->items()->save(factory(InvoiceItem::class)->make());
|
||||
$invoice->items()->save(factory(InvoiceItem::class)->make());
|
||||
});
|
||||
|
||||
$factory->afterCreating(Invoice::class, function ($invoice, $faker) {
|
||||
$invoice->taxes()->save(factory(Tax::class)->make());
|
||||
$invoice->items()->save(factory(Tax::class)->make());
|
||||
});
|
||||
34
database/factories/InvoiceItemFactory.php
Normal file
34
database/factories/InvoiceItemFactory.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\InvoiceItem;
|
||||
use Laraspace\Item;
|
||||
use Faker\Generator as Faker;
|
||||
use Laraspace\User;
|
||||
|
||||
$factory->define(InvoiceItem::class, function (Faker $faker) {
|
||||
return [
|
||||
'item_id' => function () {
|
||||
return factory(Item::class)->create()->id;
|
||||
},
|
||||
'name' => function (array $item) {
|
||||
return Item::find($item['item_id'])->name;
|
||||
},
|
||||
'description' => function (array $item) {
|
||||
return Item::find($item['item_id'])->description;
|
||||
},
|
||||
'price' => function (array $item) {
|
||||
return Item::find($item['item_id'])->price;
|
||||
},
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'quantity' => $faker->randomDigitNotNull,
|
||||
'discount_type' => 'fixed',
|
||||
'discount_val' => 0,
|
||||
'tax' => $faker->randomDigitNotNull,
|
||||
'total' => function (array $item) {
|
||||
return ($item['price'] * $item['quantity']);
|
||||
},
|
||||
'discount' => 0
|
||||
];
|
||||
});
|
||||
14
database/factories/InvoiceTemplateFactory.php
Normal file
14
database/factories/InvoiceTemplateFactory.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\InvoiceTemplate;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(InvoiceTemplate::class, function (Faker $faker) {
|
||||
return [
|
||||
'path' => $faker->word,
|
||||
'view' => $faker->word,
|
||||
'name' => $faker->word,
|
||||
];
|
||||
});
|
||||
23
database/factories/ItemFactory.php
Normal file
23
database/factories/ItemFactory.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\Item;
|
||||
use Laraspace\Tax;
|
||||
use Faker\Generator as Faker;
|
||||
use Laraspace\User;
|
||||
|
||||
$factory->define(Item::class, function (Faker $faker) {
|
||||
return [
|
||||
'name' => $faker->name,
|
||||
'description' => $faker->text,
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'price' => $faker->randomDigitNotNull,
|
||||
'unit' => 'kg'
|
||||
];
|
||||
});
|
||||
|
||||
$factory->afterCreating(Item::class, function ($item, $faker) {
|
||||
$item->taxes()->save(factory(Tax::class)->make());
|
||||
$item->taxes()->save(factory(Tax::class)->make());
|
||||
});
|
||||
40
database/factories/ModelFactory.php
Normal file
40
database/factories/ModelFactory.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Laraspace\Address;
|
||||
use Laraspace\User;
|
||||
use Laraspace\Currency;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of your model factories. Model factories give
|
||||
| you a convenient way to create models for testing and seeding your
|
||||
| database. Just tell the factory how a default model should look.
|
||||
|
|
||||
*/
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
$factory->define(User::class, function (Faker\Generator $faker) {
|
||||
static $password;
|
||||
|
||||
return [
|
||||
'name' => $faker->name,
|
||||
'company_name' => $faker->company,
|
||||
'contact_name' => $faker->name,
|
||||
'website' => $faker->url,
|
||||
'enable_portal' => true,
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'phone' => $faker->phoneNumber,
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'role' => 'admin',
|
||||
'password' => $password ?: $password = Hash::make('secret'),
|
||||
'remember_token' => str_random(10),
|
||||
'currency_id' => Currency::first()->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->afterCreating(User::class, function ($user, $faker) {
|
||||
$user->addresses()->save(factory(Address::class)->make());
|
||||
$user->addresses()->save(factory(Address::class)->make(['type' => Address::SHIPPING_TYPE]));
|
||||
});
|
||||
21
database/factories/PaymentFactory.php
Normal file
21
database/factories/PaymentFactory.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\Payment;
|
||||
use Laraspace\User;
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(Payment::class, function (Faker $faker) {
|
||||
return [
|
||||
'user_id' => function () {
|
||||
return factory(User::class)->create(['role' => 'customer'])->id;
|
||||
},
|
||||
'payment_date' => $faker->date($format = 'd/m/Y', $max = 'now'),
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'notes' => $faker->text(80),
|
||||
'amount' => $faker->randomDigitNotNull,
|
||||
'payment_number' => 'PAY-'.Payment::getNextPaymentNumber(),
|
||||
'payment_mode' => 'OTHER'
|
||||
];
|
||||
});
|
||||
24
database/factories/TaxFactory.php
Normal file
24
database/factories/TaxFactory.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\Tax;
|
||||
use Laraspace\TaxType;
|
||||
use Faker\Generator as Faker;
|
||||
use Laraspace\User;
|
||||
|
||||
$factory->define(Tax::class, function (Faker $faker) {
|
||||
return [
|
||||
'tax_type_id' => function () {
|
||||
return factory(TaxType::class)->create()->id;
|
||||
},
|
||||
'percent' => function (array $item) {
|
||||
return TaxType::find($item['tax_type_id'])->percent;
|
||||
},
|
||||
'name' => function (array $item) {
|
||||
return TaxType::find($item['tax_type_id'])->name;
|
||||
},
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'amount' => $faker->randomDigitNotNull
|
||||
];
|
||||
});
|
||||
18
database/factories/TaxTypeFactory.php
Normal file
18
database/factories/TaxTypeFactory.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use Laraspace\TaxType;
|
||||
use Faker\Generator as Faker;
|
||||
use Laraspace\User;
|
||||
|
||||
$factory->define(TaxType::class, function (Faker $faker) {
|
||||
return [
|
||||
'name' => $faker->word,
|
||||
'company_id' => User::find(1)->company_id,
|
||||
'percent' => $faker->randomDigitNotNull,
|
||||
'description' => $faker->text,
|
||||
'compound_tax' => 0,
|
||||
'collective_tax' => 0
|
||||
];
|
||||
});
|
||||
Reference in New Issue
Block a user