Invoice Factory and Quote Model

This commit is contained in:
David Bomba 2019-04-04 10:30:49 +11:00
parent 931ea9634c
commit 4620cd7640
4 changed files with 68 additions and 4 deletions

View File

@ -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);

36
app/Models/Quote.php Normal file
View File

@ -0,0 +1,36 @@
<?php
namespace App\Models;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
class Quote extends BaseModel
{
use MakesHash;
protected $guarded = [
'id',
];
const STATUS_DRAFT = 1;
const STATUS_SENT = 2;
const STATUS_VIEWED = 3;
const STATUS_APPROVED = 4;
const STATUS_OVERDUE = -1;
public function company()
{
return $this->belongsTo(Company::class);
}
public function user()
{
return $this->belongsTo(User::class);
}
public function invitations()
{
$this->morphMany(Invitation::class, 'inviteable');
}
}

View File

@ -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' => '',
];
});

View File

@ -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);