Remove subfleet_expenses and combine into main expenses table; select expense type on subfleet #130 #136
This commit is contained in:
@@ -13,6 +13,8 @@ $factory->define(App\Models\Expense::class, function (Faker $faker) {
|
||||
'amount' => $faker->randomFloat(2, 100, 1000),
|
||||
'type' => ExpenseType::FLIGHT,
|
||||
'multiplier' => false,
|
||||
'ref_class' => \App\Models\Expense::class,
|
||||
'ref_class_id' => null,
|
||||
'active' => true,
|
||||
];
|
||||
});
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(App\Models\SubfleetExpense::class, function (Faker $faker) {
|
||||
return [
|
||||
'subfleet_id' => null,
|
||||
'name' => $faker->text(20),
|
||||
'amount' => $faker->randomFloat(2, 100, 1000),
|
||||
];
|
||||
});
|
||||
@@ -3,14 +3,11 @@
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class CreateSubfleetTables
|
||||
*/
|
||||
class CreateSubfleetTables extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('subfleets', function (Blueprint $table) {
|
||||
@@ -26,17 +23,6 @@ class CreateSubfleetTables extends Migration
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('subfleet_expenses', function(Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedBigInteger('subfleet_id');
|
||||
$table->string('name', 50);
|
||||
$table->unsignedTinyInteger('type'); # ExpenseType
|
||||
$table->unsignedDecimal('amount');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('subfleet_id');
|
||||
});
|
||||
|
||||
Schema::create('subfleet_fare', function (Blueprint $table) {
|
||||
$table->unsignedInteger('subfleet_id');
|
||||
$table->unsignedInteger('fare_id');
|
||||
@@ -76,7 +62,6 @@ class CreateSubfleetTables extends Migration
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('subfleets');
|
||||
Schema::dropIfExists('subfleet_expenses');
|
||||
Schema::dropIfExists('subfleet_fare');
|
||||
Schema::dropIfExists('subfleet_flight');
|
||||
Schema::dropIfExists('subfleet_rank');
|
||||
|
||||
@@ -16,15 +16,19 @@ class CreateExpensesTable extends Migration
|
||||
Schema::create('expenses', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('airline_id')->nullable();
|
||||
|
||||
$table->string('name');
|
||||
$table->unsignedInteger('amount');
|
||||
$table->unsignedTinyInteger('type');
|
||||
$table->boolean('multiplier')->nullable()->default(0);
|
||||
$table->boolean('active')->nullable()->default(true);
|
||||
|
||||
# Internal fields are expenses tied to some system object
|
||||
# ref fields are expenses tied to some model object
|
||||
# EG, the airports has an internal expense for gate costs
|
||||
$table->nullableMorphs('expensable');
|
||||
$table->string('ref_class')->nullable();
|
||||
$table->string('ref_class_id', 36)->nullable();
|
||||
$table->index(['ref_class', 'ref_class_id']);
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -184,25 +184,38 @@ expenses:
|
||||
amount: 100
|
||||
type: 0
|
||||
active: 1
|
||||
ref_class: App\Models\Expense
|
||||
- name: Per-Flight (multiplier)
|
||||
amount: 100
|
||||
type: 0
|
||||
multiplier: 1
|
||||
active: 1
|
||||
ref_class: App\Models\Expense
|
||||
- name: Per-Flight (multiplier, on airline)
|
||||
airline_id: 1
|
||||
amount: 200
|
||||
type: 0
|
||||
multiplier: 1
|
||||
active: 1
|
||||
ref_class: App\Models\Expense
|
||||
- name: A daily fee
|
||||
amount: 800
|
||||
type: 1
|
||||
active: 1
|
||||
ref_class: App\Models\Expense
|
||||
- name: A monthly fee
|
||||
amount: 5000
|
||||
type: 2
|
||||
active: 1
|
||||
ref_class: App\Models\Expense
|
||||
- name: Catering
|
||||
amount: 1000
|
||||
type: 0
|
||||
active: 1
|
||||
ref_class: App\Models\Subfleet
|
||||
ref_class_id: 1
|
||||
created_at: now
|
||||
updated_at: now
|
||||
|
||||
fares:
|
||||
- id: 1
|
||||
@@ -238,13 +251,14 @@ subfleets:
|
||||
type: 772-36ER-GE90-115B
|
||||
ground_handling_multiplier: 150
|
||||
|
||||
subfleet_expenses:
|
||||
- id: 1
|
||||
subfleet_id: 1
|
||||
name: Catering
|
||||
amount: 1000
|
||||
created_at: now
|
||||
updated_at: now
|
||||
#subfleet_expenses:
|
||||
# - id: 1
|
||||
# subfleet_id: 1
|
||||
# name: Catering
|
||||
# amount: 1000
|
||||
# type: 0
|
||||
# created_at: now
|
||||
# updated_at: now
|
||||
|
||||
# add a few mods to aircraft and fares
|
||||
subfleet_fare:
|
||||
|
||||
Reference in New Issue
Block a user