Add/implement subfleet cost_block_hour and block_time for PIREP API
This commit is contained in:
@@ -4,14 +4,20 @@
|
||||
|
||||
- Finances! The finance portions have been implemented, you can [read about them here](http://docs.phpvms.net/concepts/finances)
|
||||
- Awards! Added the award plugin system. [see docs](http://docs.phpvms.net/customizing/awards)
|
||||
- Import/Export in admin panel for aircraft, airports, expenses, fares, flights and subfleets
|
||||
- Changed theme system to using [laravel-theme](https://github.com/igaster/laravel-theme), there are changes to making theming much simpler with much more flexibility.
|
||||
- Added cron task for background tasks
|
||||
- Expanded on flight types to match IATA SIMM format
|
||||
- Added subfleet `cost_block_hour`
|
||||
- Fixed several security vulnerabilities (thanks magicflyer!)
|
||||
- Fuel units changed to lbs/kgs [#193](https://github.com/nabeelio/phpvms/issues/193)
|
||||
- Airports can be restricted to only hubs on registration/user profile
|
||||
- Cleaned up a lot unused icons and files [#195](https://github.com/nabeelio/phpvms/issues/195)
|
||||
- Rank restrictions for PIREPs are respected [#170](https://github.com/nabeelio/phpvms/issues/170)
|
||||
- API: Added the ability to get/update/delete user bids [#172](https://github.com/nabeelio/phpvms/issues/172)
|
||||
- Artisan: Added a `phpvms:export [tables]` to export tables to YAML files which can be re-imported using `phpvms:import`
|
||||
- API: Added `block_time` parameter for PIREP prefile/update/file calls
|
||||
- Artisan: Added a `phpvms:csv-import [table] [file]` to import from CSV
|
||||
- Artisan: Added a `phpvms:yaml-export [tables]` to export tables to YAML files which can be re-imported using `phpvms:yaml-import`
|
||||
- Numerous bug fixes
|
||||
|
||||
## Alpha 2 (2018-02-23, v7.0.0-alpha2)
|
||||
|
||||
@@ -15,6 +15,8 @@ class CreateSubfleetTables extends Migration
|
||||
$table->unsignedInteger('airline_id')->nullable();
|
||||
$table->string('type', 50)->unique();
|
||||
$table->string('name', 50);
|
||||
$table->unsignedDecimal('cost_block_hour');
|
||||
$table->unsignedDecimal('cost_delay_minute');
|
||||
$table->unsignedTinyInteger('fuel_type')->nullable();
|
||||
$table->unsignedDecimal('ground_handling_multiplier')->nullable()->default(100);
|
||||
$table->unsignedDecimal('cargo_capacity')->nullable();
|
||||
|
||||
@@ -28,6 +28,7 @@ class CreatePirepTables extends Migration
|
||||
$table->unsignedInteger('level')->nullable();
|
||||
$table->unsignedDecimal('distance')->nullable();
|
||||
$table->unsignedDecimal('planned_distance')->nullable();
|
||||
$table->unsignedInteger('block_time')->nullable();
|
||||
$table->unsignedInteger('flight_time')->nullable();
|
||||
$table->unsignedInteger('planned_flight_time')->nullable();
|
||||
$table->unsignedDecimal('zfw')->nullable();
|
||||
|
||||
@@ -265,16 +265,19 @@ subfleets:
|
||||
airline_id: 1
|
||||
name: 747-43X RB211-524G
|
||||
type: 744-3X-RB211
|
||||
cost_block_hour: 1000
|
||||
ground_handling_multiplier: 200
|
||||
- id: 2
|
||||
airline_id: 1
|
||||
name: 777-222ER GE90-76B
|
||||
type: 772-22ER-GE90-76B
|
||||
cost_block_hour: 500
|
||||
ground_handling_multiplier: 150
|
||||
- id: 3
|
||||
airline_id: 1
|
||||
name: 777-367 ER GE90-115B
|
||||
type: 772-36ER-GE90-115B
|
||||
cost_block_hour: 100
|
||||
ground_handling_multiplier: 150
|
||||
|
||||
# add a few mods to aircraft and fares
|
||||
@@ -384,6 +387,7 @@ pireps:
|
||||
state: 1 # accepted
|
||||
status: 0
|
||||
source: 1
|
||||
flight_type: J
|
||||
route: KAUS SID TNV J87 IAH J2 LCH J22 MEI J239 ATL J52 AJFEB J14 BYJAC Q60 JAXSN J14 COLIN J61 HUBBS J55 SIE STAR KJFK
|
||||
notes: just a pilot report
|
||||
created_at: NOW
|
||||
@@ -397,6 +401,7 @@ pireps:
|
||||
arr_airport_id: LGRP
|
||||
flight_time: 180 # 6 hours
|
||||
state: 1
|
||||
flight_type: J
|
||||
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
|
||||
notes: just a pilot report
|
||||
source: 1 # pending
|
||||
@@ -413,6 +418,7 @@ pireps:
|
||||
flight_time: 180 # 6 hours
|
||||
state: 1 # pending
|
||||
source: 0 # manual
|
||||
flight_type: J
|
||||
route: PLMMR2 SPA Q22 BEARI FAK PHLBO3
|
||||
notes: just a pilot report
|
||||
created_at: NOW
|
||||
@@ -610,9 +616,9 @@ journal_transactions:
|
||||
tags: '"pilot_pay"'
|
||||
ref_class: App\Models\Pirep
|
||||
ref_class_id: pirepid_1
|
||||
created_at: '2018-03-06 12:34:15'
|
||||
updated_at: '2018-03-06 12:34:15'
|
||||
post_date: '2018-03-06 12:34:15'
|
||||
created_at: now
|
||||
updated_at: now
|
||||
post_date: now
|
||||
-
|
||||
id: ed516367-eeb9-4a09-bfb7-531ec4be2f93
|
||||
transaction_group: Fares
|
||||
@@ -624,9 +630,9 @@ journal_transactions:
|
||||
tags: '"fare"'
|
||||
ref_class: App\Models\Pirep
|
||||
ref_class_id: pirepid_1
|
||||
created_at: '2018-03-06 12:34:15'
|
||||
updated_at: '2018-03-06 12:34:15'
|
||||
post_date: '2018-03-06 12:34:15'
|
||||
created_at: now
|
||||
updated_at: now
|
||||
post_date: now
|
||||
-
|
||||
id: f3f8585e-894c-4491-b19b-d07b6ad20208
|
||||
transaction_group: 'Ground Handling'
|
||||
@@ -638,6 +644,21 @@ journal_transactions:
|
||||
tags: '"ground_handling"'
|
||||
ref_class: App\Models\Pirep
|
||||
ref_class_id: pirepid_1
|
||||
created_at: '2018-03-06 12:34:15'
|
||||
updated_at: '2018-03-06 12:34:15'
|
||||
post_date: '2018-03-06 12:34:15'
|
||||
created_at: now
|
||||
updated_at: now
|
||||
post_date: now
|
||||
|
||||
-
|
||||
id: 1bd1616c-eaa4-4ab9-b5c1-441004ceef14
|
||||
transaction_group: 'Subfleet 744-3X-RB211'
|
||||
journal_id: 1
|
||||
credit: null
|
||||
debit: 300000
|
||||
currency: USD
|
||||
memo: 'Subfleet 744-3X-RB211: Block Time Cost'
|
||||
tags: '"subfleet"'
|
||||
ref_class: App\Models\Pirep
|
||||
ref_class_id: pirepid_1
|
||||
created_at: now
|
||||
updated_at: now
|
||||
post_date: now
|
||||
|
||||
@@ -26,6 +26,7 @@ class FileRequest extends FormRequest
|
||||
'flight_time' => 'required|integer',
|
||||
'fuel_used' => 'required|numeric',
|
||||
|
||||
'block_time' => 'nullable|integer',
|
||||
'airline_id' => 'nullable|exists:airlines,id',
|
||||
'aircraft_id' => 'nullable|exists:aircraft,id',
|
||||
'flight_number' => 'nullable',
|
||||
|
||||
@@ -29,6 +29,7 @@ class PrefileRequest extends FormRequest
|
||||
'route_code' => 'nullable',
|
||||
'route_leg' => 'nullable',
|
||||
'distance' => 'nullable|numeric',
|
||||
'block_time' => 'nullable|integer',
|
||||
'flight_time' => 'nullable|integer',
|
||||
'planned_distance' => 'nullable|numeric',
|
||||
'planned_flight_time' => 'nullable|integer',
|
||||
|
||||
@@ -31,8 +31,9 @@ class UpdateRequest extends FormRequest
|
||||
'route_leg' => 'nullable',
|
||||
'distance' => 'nullable|numeric',
|
||||
'planned_distance' => 'nullable|numeric',
|
||||
'planned_flight_time' => 'nullable|integer',
|
||||
'block_time' => 'nullable|integer',
|
||||
'flight_time' => 'nullable|integer',
|
||||
'planned_flight_time' => 'nullable|integer',
|
||||
'level' => 'nullable|numeric',
|
||||
'zfw' => 'nullable|numeric',
|
||||
'fuel_used' => 'nullable|numeric',
|
||||
|
||||
@@ -24,6 +24,7 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
|
||||
* @property Airline airline
|
||||
* @property Airport arr_airport
|
||||
* @property Airport dep_airport
|
||||
* @property integer block_time
|
||||
* @property integer flight_time In minutes
|
||||
* @property User user
|
||||
* @property Flight|null flight
|
||||
@@ -53,6 +54,7 @@ class Pirep extends Model
|
||||
'level',
|
||||
'distance',
|
||||
'planned_distance',
|
||||
'block_time',
|
||||
'flight_time',
|
||||
'planned_flight_time',
|
||||
'zfw',
|
||||
@@ -77,6 +79,7 @@ class Pirep extends Model
|
||||
'level' => 'integer',
|
||||
'distance' => 'float',
|
||||
'planned_distance' => 'float',
|
||||
'block_time' => 'integer',
|
||||
'flight_time' => 'integer',
|
||||
'planned_flight_time' => 'integer',
|
||||
'zfw' => 'float',
|
||||
|
||||
@@ -10,8 +10,11 @@ use App\Models\Traits\ExpensableTrait;
|
||||
* Class Subfleet
|
||||
* @property int id
|
||||
* @property string type
|
||||
* @property string name
|
||||
* @property string ground_handling_multiplier
|
||||
* @property Fare[] fares
|
||||
* @property float cost_block_hour
|
||||
* @property float cost_delay_minute
|
||||
* @package App\Models
|
||||
*/
|
||||
class Subfleet extends Model
|
||||
@@ -24,6 +27,7 @@ class Subfleet extends Model
|
||||
'airline_id',
|
||||
'type',
|
||||
'name',
|
||||
'turn_time',
|
||||
'fuel_type',
|
||||
'ground_handling_multiplier',
|
||||
'cargo_capacity',
|
||||
@@ -33,6 +37,9 @@ class Subfleet extends Model
|
||||
|
||||
public $casts = [
|
||||
'airline_id' => 'integer',
|
||||
'turn_time' => 'integer',
|
||||
'cost_block_hour' => 'float',
|
||||
'cost_delay_minute' => 'float',
|
||||
'fuel_type' => 'integer',
|
||||
'ground_handling_multiplier' => 'float',
|
||||
'cargo_capacity' => 'float',
|
||||
|
||||
@@ -14,6 +14,7 @@ use App\Services\FareService;
|
||||
use App\Services\PirepService;
|
||||
use App\Support\Math;
|
||||
use App\Support\Money;
|
||||
use App\Support\Units\Time;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -73,6 +74,7 @@ class PirepFinanceService extends Service
|
||||
|
||||
# Now start and pay from scratch
|
||||
$this->payFaresForPirep($pirep);
|
||||
$this->payExpensesForSubfleet($pirep);
|
||||
$this->payExpensesForPirep($pirep);
|
||||
$this->payExpensesEventsForPirep($pirep);
|
||||
$this->payGroundHandlingForPirep($pirep);
|
||||
@@ -128,6 +130,48 @@ class PirepFinanceService extends Service
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate what the cost is for the operating an aircraft
|
||||
* in this subfleet, as-per the block time
|
||||
* @param Pirep $pirep
|
||||
* @throws \UnexpectedValueException
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \Prettus\Validator\Exceptions\ValidatorException
|
||||
*/
|
||||
public function payExpensesForSubfleet(Pirep $pirep): void
|
||||
{
|
||||
$sf = $pirep->aircraft->subfleet;
|
||||
|
||||
Log::info('subfleet: ', $sf->toArray());
|
||||
# Haven't entered a cost
|
||||
if (!filled($sf->cost_block_hour)) {
|
||||
return;
|
||||
}
|
||||
|
||||
# Convert to cost per-minute
|
||||
$cost_per_min = round($sf->cost_block_hour / 60, 2);
|
||||
|
||||
# Time to use - use the block time if it's there, actual
|
||||
# flight time if that hasn't been used
|
||||
$block_time = $pirep->block_time;
|
||||
if(!filled($block_time)) {
|
||||
$block_time = $pirep->flight_time;
|
||||
}
|
||||
|
||||
$debit = Money::createFromAmount($cost_per_min * $block_time);
|
||||
|
||||
$this->journalRepo->post(
|
||||
$pirep->airline->journal,
|
||||
null,
|
||||
$debit,
|
||||
$pirep,
|
||||
'Subfleet '.$sf->type.': Block Time Cost',
|
||||
null,
|
||||
'Subfleet '.$sf->type,
|
||||
'subfleet'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect all of the expenses and apply those to the journal
|
||||
* @param Pirep $pirep
|
||||
|
||||
@@ -12,13 +12,19 @@
|
||||
@endcomponent
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-6">
|
||||
<div class="form-group col-sm-4">
|
||||
{{ Form::label('airline_id', 'Airline:') }}
|
||||
{{ Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) }}
|
||||
<p class="text-danger">{{ $errors->first('airline_id') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-4">
|
||||
{{ Form::label('type', 'Type:') }}
|
||||
{{ Form::text('type', null, ['class' => 'form-control']) }}
|
||||
<p class="text-danger">{{ $errors->first('type') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-6">
|
||||
<div class="form-group col-sm-4">
|
||||
{{ Form::label('name', 'Name:') }}
|
||||
{{ Form::text('name', null, ['class' => 'form-control']) }}
|
||||
<p class="text-danger">{{ $errors->first('name') }}</p>
|
||||
@@ -27,19 +33,25 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
<div class="form-group col-sm-4">
|
||||
{{ Form::label('airline_id', 'Airline:') }}
|
||||
{{ Form::select('airline_id', $airlines, null , ['class' => 'form-control select2']) }}
|
||||
<p class="text-danger">{{ $errors->first('airline_id') }}</p>
|
||||
<div class="form-group col-sm-3">
|
||||
{{ Form::label('cost_block_hour', 'Cost Per Hour:') }}
|
||||
{{ Form::number('cost_block_hour', null , ['class' => 'form-control']) }}
|
||||
<p class="text-danger">{{ $errors->first('cost_block_hour') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-4">
|
||||
<div class="form-group col-sm-3">
|
||||
{{ Form::label('cost_delay_minute', 'Cost Delay Per Minute:') }}
|
||||
{{ Form::number('cost_delay_minute', null , ['class' => 'form-control']) }}
|
||||
<p class="text-danger">{{ $errors->first('cost_delay_minute') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-3">
|
||||
{{ Form::label('fuel_type', 'Fuel Type:') }}
|
||||
{{ Form::select('fuel_type', $fuel_types, null , ['class' => 'form-control select2']) }}
|
||||
<p class="text-danger">{{ $errors->first('fuel_type') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-sm-4">
|
||||
<div class="form-group col-sm-3">
|
||||
{{ Form::label('ground_handling_multiplier', 'Ground Handling Multiplier:') }}
|
||||
{{ Form::text('ground_handling_multiplier', null, ['class' => 'form-control']) }}
|
||||
<p class="text-danger">{{ $errors->first('ground_handling_multiplier') }}</p>
|
||||
|
||||
Reference in New Issue
Block a user