From 4620cd7640c061d51c54fcb559581c870d670040 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 4 Apr 2019 10:30:49 +1100 Subject: [PATCH] Invoice Factory and Quote Model --- app/Models/Invoice.php | 10 +++++- app/Models/Quote.php | 36 +++++++++++++++++++ database/factories/InvoiceFactory.php | 24 +++++++++++-- .../2014_10_13_000000_create_users_table.php | 2 ++ 4 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 app/Models/Quote.php diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index af2e4c449451..1950fa41952b 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -13,6 +13,14 @@ class Invoice extends BaseModel 'id', ]; + const STATUS_DRAFT = 1; + const STATUS_SENT = 2; + const STATUS_VIEWED = 3; + const STATUS_PARTIAL = 5; + const STATUS_PAID = 6; + const STATUS_OVERDUE = -1; + const STATUS_UNPAID = -2; + public function company() { return $this->belongsTo(Company::class); @@ -22,7 +30,7 @@ class Invoice extends BaseModel { return $this->belongsTo(User::class); } - + public function invitations() { $this->morphMany(Invitation::class, 'inviteable'); diff --git a/app/Models/Quote.php b/app/Models/Quote.php new file mode 100644 index 000000000000..e1285b32e89d --- /dev/null +++ b/app/Models/Quote.php @@ -0,0 +1,36 @@ +belongsTo(Company::class); + } + + public function user() + { + return $this->belongsTo(User::class); + } + + public function invitations() + { + $this->morphMany(Invitation::class, 'inviteable'); + } +} diff --git a/database/factories/InvoiceFactory.php b/database/factories/InvoiceFactory.php index 65e422147c56..20a0559e3c02 100644 --- a/database/factories/InvoiceFactory.php +++ b/database/factories/InvoiceFactory.php @@ -2,8 +2,26 @@ use Faker\Generator as Faker; -$factory->define(Model::class, function (Faker $faker) { +$factory->define(App\Models\Invoice::class, function (Faker $faker) { return [ - // + 'invoice_status_id' => App\Models\Invoice::STATUS_PAID, + 'invoice_number' => 'abc-123', + 'discount' => $faker->numberBetween(1,10), + 'is_amount_discount' => $faker->boolean(), + 'tax_name1' => 'GST', + 'tax_rate1' => 10, + 'tax_name2' => 'VAT', + 'tax_rate2' => 17.5, + 'custom_value1' => $faker->text(20), + 'custom_value2' => $faker->text(20), + 'custom_value3' => $faker->text(20), + 'custom_value4' => $faker->text(20), + 'is_deleted' => false, + 'po_number' => $faker->text(10), + 'invoice_date' => $faker->date(), + 'due_date' => $faker->date(), + 'line_items' => false, + 'options' => '', + 'backup' => '', ]; -}); +}); \ No newline at end of file diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index e632fb67d85b..ec73559b40b0 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -366,6 +366,8 @@ class CreateUsersTable extends Migration $t->string('custom_value1')->nullable(); $t->string('custom_value2')->nullable(); + $t->string('custom_value3')->nullable(); + $t->string('custom_value4')->nullable(); $t->decimal('amount', 13, 2); $t->decimal('balance', 13, 2);