From b5dd70004473b9c1c35392834d810377aa2cd998 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Mon, 10 Jul 2017 18:54:51 -0500 Subject: [PATCH] Adjust columns in migrations and give lens to strings and custom flight fields #48 --- .gitignore | 2 ++ app/Models/Pirep.php | 2 ++ app/Services/PIREPService.php | 9 +++++++++ config/phpvms.php | 11 ++++++++++- ...2017_06_08_191703_create_airlines_table.php | 6 +++--- ...017_06_09_010621_create_aircrafts_table.php | 8 ++++---- .../2017_06_10_040335_create_fares_table.php | 6 ++++-- ...2017_06_11_135707_create_airports_table.php | 6 +++--- .../2017_06_17_214650_create_flights_table.php | 18 +++++++++++++----- .../2017_06_21_165410_create_ranks_table.php | 2 +- ...017_06_23_011011_create_subfleets_table.php | 7 +++---- .../2017_06_28_195426_create_pireps_table.php | 17 ++++++++--------- tests/PIREPTest.php | 9 +++++++++ tests/data/base.yml | 2 ++ 14 files changed, 73 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 26ef46a5..421ea92a 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,5 @@ phpvms_next.iml .idea/**/gradle.xml .idea/**/libraries public/info.php + +local.conf.php diff --git a/app/Models/Pirep.php b/app/Models/Pirep.php index 771b1d5c..aeb2a5f0 100644 --- a/app/Models/Pirep.php +++ b/app/Models/Pirep.php @@ -30,6 +30,7 @@ class Pirep extends Model 'route_leg', 'dpt_airport_id', 'arr_airport_id', + 'fuel_used', 'source', 'level', 'route', @@ -47,6 +48,7 @@ class Pirep extends Model = [ 'flight_time' => 'integer', 'level' => 'integer', + 'fuel_used' => 'integer', 'source' => 'integer', 'status' => 'integer', ]; diff --git a/app/Services/PIREPService.php b/app/Services/PIREPService.php index ae4cfb5a..5a75c37d 100644 --- a/app/Services/PIREPService.php +++ b/app/Services/PIREPService.php @@ -152,4 +152,13 @@ class PIREPService extends BaseService return $pirep; } + + /** + * Calculate all of the finances for a PIREP + * @param Pirep $pirep + */ + public function calculateFinances(Pirep &$pirep) + { + + } } diff --git a/config/phpvms.php b/config/phpvms.php index c60efead..8bb7f39d 100644 --- a/config/phpvms.php +++ b/config/phpvms.php @@ -11,9 +11,18 @@ return [ + /** + * Start date. Set the date of when your VA has started + * Used as an anchor point for some financials and things + * + * YYYY-MM-DD format + */ + 'start_date' => '2017-07-07', + /** * Pick one of: - * dollar, euro, gbp, yen, jpy, rupee, ruble + * dollar, euro, gbp, yen, jpy, rupee, ruble */ 'currency' => 'dollar', + ]; diff --git a/database/migrations/2017_06_08_191703_create_airlines_table.php b/database/migrations/2017_06_08_191703_create_airlines_table.php index 73346112..d304ca44 100644 --- a/database/migrations/2017_06_08_191703_create_airlines_table.php +++ b/database/migrations/2017_06_08_191703_create_airlines_table.php @@ -15,9 +15,9 @@ class CreateAirlinesTable extends Migration { Schema::create('airlines', function (Blueprint $table) { $table->increments('id'); - $table->string('code'); - $table->string('name'); - $table->char('country', 2)->nullable(); + $table->string('code', 5); + $table->string('name', 50); + $table->string('country', 2)->nullable(); $table->boolean('active'); $table->timestamps(); diff --git a/database/migrations/2017_06_09_010621_create_aircrafts_table.php b/database/migrations/2017_06_09_010621_create_aircrafts_table.php index 6926e0d8..ca610cf4 100644 --- a/database/migrations/2017_06_09_010621_create_aircrafts_table.php +++ b/database/migrations/2017_06_09_010621_create_aircrafts_table.php @@ -11,10 +11,10 @@ class CreateAircraftsTable extends Migration $table->increments('id'); $table->integer('subfleet_id')->unsigned(); $table->integer('airport_id')->unsigned()->nullable(); - $table->string('hex_code')->nullable(); - $table->string('name'); - $table->string('registration')->nullable(); - $table->string('tail_number')->nullable(); + $table->string('hex_code', 10)->nullable(); + $table->string('name', 50); + $table->string('registration', 10)->nullable(); + $table->string('tail_number', 10)->nullable(); $table->boolean('active')->default(true); $table->timestamps(); diff --git a/database/migrations/2017_06_10_040335_create_fares_table.php b/database/migrations/2017_06_10_040335_create_fares_table.php index 68fc3a05..2cb6dbab 100644 --- a/database/migrations/2017_06_10_040335_create_fares_table.php +++ b/database/migrations/2017_06_10_040335_create_fares_table.php @@ -15,14 +15,16 @@ class CreateFaresTable extends Migration { Schema::create('fares', function (Blueprint $table) { $table->increments('id'); - $table->string('code'); - $table->string('name'); + $table->string('code', 50); + $table->string('name', 50); $table->decimal('price', 19, 2)->default(0.0); $table->decimal('cost', 19, 2)->default(0.0); $table->integer('capacity')->default(0)->unsigned(); $table->string('notes')->nullable(); $table->boolean('active')->default(true); $table->timestamps(); + + $table->primary('id'); }); } diff --git a/database/migrations/2017_06_11_135707_create_airports_table.php b/database/migrations/2017_06_11_135707_create_airports_table.php index a3e83c58..8038d92b 100644 --- a/database/migrations/2017_06_11_135707_create_airports_table.php +++ b/database/migrations/2017_06_11_135707_create_airports_table.php @@ -16,9 +16,9 @@ class CreateAirportsTable extends Migration Schema::create('airports', function (Blueprint $table) { $table->increments('id'); $table->string('icao', 5)->unique(); - $table->string('name'); - $table->string('location')->nullable(); - $table->string('country')->nullable(); + $table->string('name', 50); + $table->string('location', 50)->nullable(); + $table->string('country', 50)->nullable(); $table->double('fuel_100ll_cost', 19, 2)->default(0); $table->double('fuel_jeta_cost', 19, 2)->default(0); $table->double('fuel_mogas_cost', 19, 2)->default(0); diff --git a/database/migrations/2017_06_17_214650_create_flights_table.php b/database/migrations/2017_06_17_214650_create_flights_table.php index 59ff10f6..40b628b2 100644 --- a/database/migrations/2017_06_17_214650_create_flights_table.php +++ b/database/migrations/2017_06_17_214650_create_flights_table.php @@ -16,15 +16,16 @@ class CreateFlightsTable extends Migration Schema::create('flights', function (Blueprint $table) { $table->uuid('id'); $table->integer('airline_id')->unsigned(); - $table->text('flight_number'); - $table->text('route_code')->nullable(); - $table->text('route_leg')->nullable(); + $table->string('flight_number', 10); + $table->string('route_code', 5)->nullable(); + $table->string('route_leg', 5)->nullable(); $table->integer('dpt_airport_id')->unsigned(); $table->integer('arr_airport_id')->unsigned(); $table->integer('alt_airport_id')->unsigned()->nullable(); $table->text('route')->nullable(); - $table->text('dpt_time')->nullable(); - $table->text('arr_time')->nullable(); + $table->text('dpt_time', 10)->nullable(); + $table->text('arr_time', 10)->nullable(); + $table->double('flight_time', 19, 2)->unsigned(); $table->text('notes')->nullable(); $table->boolean('active')->default(true); $table->timestamps(); @@ -37,6 +38,13 @@ class CreateFlightsTable extends Migration $table->index('dpt_airport_id'); $table->index('arr_airport_id'); }); + + Schema::create('flight_fields', function (Blueprint $table) { + $table->increments('id'); + $table->uuid('flight_id'); + $table->string('name', 50); + $table->text('value'); + }); } /** diff --git a/database/migrations/2017_06_21_165410_create_ranks_table.php b/database/migrations/2017_06_21_165410_create_ranks_table.php index bdd63b52..734362f5 100644 --- a/database/migrations/2017_06_21_165410_create_ranks_table.php +++ b/database/migrations/2017_06_21_165410_create_ranks_table.php @@ -15,7 +15,7 @@ class CreateRanksTable extends Migration { Schema::create('ranks', function (Blueprint $table) { $table->increments('id'); - $table->string('name'); + $table->string('name', 50); $table->integer('hours')->default(0); $table->boolean('auto_approve_acars')->default(false); $table->boolean('auto_approve_manual')->default(false); diff --git a/database/migrations/2017_06_23_011011_create_subfleets_table.php b/database/migrations/2017_06_23_011011_create_subfleets_table.php index ff9331fa..b95fc62b 100644 --- a/database/migrations/2017_06_23_011011_create_subfleets_table.php +++ b/database/migrations/2017_06_23_011011_create_subfleets_table.php @@ -16,19 +16,18 @@ class CreateSubfleetsTable extends Migration Schema::create('subfleets', function (Blueprint $table) { $table->increments('id'); $table->integer('airline_id')->unsigned()->nullable(); - $table->string('name'); - $table->text('type'); + $table->string('name', 50); + $table->string('type', 7); $table->tinyInteger('fuel_type')->unsigned()->nullable(); $table->double('cargo_capacity', 19, 2)->nullable(); $table->double('fuel_capacity', 19, 2)->nullable(); $table->double('gross_weight', 19, 2)->nullable(); $table->timestamps(); - $table->softDeletes(); }); Schema::create('subfleet_expenses', function(Blueprint $table) { $table->integer('subfleet_id')->unsigned(); - $table->string('name'); + $table->string('name', 50); $table->decimal('cost', 19, 2)->unsigned(); $table->primary(['subfleet_id', 'name']); diff --git a/database/migrations/2017_06_28_195426_create_pireps_table.php b/database/migrations/2017_06_28_195426_create_pireps_table.php index 4d3d0efe..0515e021 100644 --- a/database/migrations/2017_06_28_195426_create_pireps_table.php +++ b/database/migrations/2017_06_28_195426_create_pireps_table.php @@ -16,16 +16,15 @@ class CreatePirepsTable extends Migration Schema::create('pireps', function (Blueprint $table) { $table->uuid('id'); $table->integer('user_id'); - $table->string('flight_id'); + $table->uuid('flight_id')->nullable(); $table->integer('aircraft_id'); - $table->text('route_code')->nullable(); - $table->text('route_leg')->nullable(); + $table->string('route_code', 5)->nullable(); + $table->string('route_leg', 5)->nullable(); $table->integer('dpt_airport_id')->unsigned(); $table->integer('arr_airport_id')->unsigned(); - $table->integer('flight_time')->unsigned(); + $table->double('flight_time', 19, 2)->unsigned(); $table->double('gross_weight', 19, 2)->nullable(); - $table->double('starting_fuel', 19, 2)->nullable(); - $table->double('landing_fuel', 19, 2)->nullable(); + $table->double('fuel_used', 19, 2)->nullable(); $table->integer('level')->unsigned(); $table->string('route')->nullable(); $table->string('notes')->nullable(); @@ -68,7 +67,7 @@ class CreatePirepsTable extends Migration */ Schema::create('pirep_fields', function (Blueprint $table) { $table->increments('id'); - $table->string('name'); + $table->string('name', 50); $table->integer('required'); $table->timestamps(); }); @@ -76,8 +75,8 @@ class CreatePirepsTable extends Migration Schema::create('pirep_field_values', function (Blueprint $table) { $table->increments('id'); $table->uuid('pirep_id'); - $table->string('name'); - $table->string('value'); + $table->string('name', 50); + $table->text('value'); $table->tinyInteger('source')->default(0); $table->timestamps(); diff --git a/tests/PIREPTest.php b/tests/PIREPTest.php index c224ec01..e9c05a3f 100644 --- a/tests/PIREPTest.php +++ b/tests/PIREPTest.php @@ -22,6 +22,7 @@ class PIREPTest extends TestCase 'flight_time' => 21600, # 6 hours 'level' => 320, 'source' => 0, # manual + 'fuel_used' => 100, 'notes' => 'just a pilot report', ]; @@ -52,6 +53,9 @@ class PIREPTest extends TestCase parent::setUp(); // TODO: Change the autogenerated stub $this->addData('base'); $this->pirepSvc = app('App\Services\PIREPService'); + + $conf = config('phpvms'); + print_r($conf); } /** @@ -121,4 +125,9 @@ class PIREPTest extends TestCase $latest_pirep->status ); } + + public function testPirepFinances() + { + + } } diff --git a/tests/data/base.yml b/tests/data/base.yml index 42435490..90b4c708 100644 --- a/tests/data/base.yml +++ b/tests/data/base.yml @@ -99,11 +99,13 @@ subfleets: name: 747-400 Winglets type: 744W fuel_type: 1 + fuel_capacity: 2000 - id: 2 airline_id: 1 name: 777-200 LR type: 772-LR fuel_type: 1 + fuel_capacity: 1000 # add a few mods to aircraft and fares subfleet_fare: