Split rank pay rate into separate rates for acars and manual flights

This commit is contained in:
Nabeel Shahzad
2018-02-27 14:29:45 -06:00
parent 81b867fa20
commit dfa6d6da51
6 changed files with 54 additions and 19 deletions

View File

@@ -18,7 +18,8 @@ class CreateRanksTable extends Migration
$table->string('name', 50); $table->string('name', 50);
$table->string('image_link')->nullable(); $table->string('image_link')->nullable();
$table->unsignedInteger('hours')->default(0); $table->unsignedInteger('hours')->default(0);
$table->unsignedDecimal('base_pay_rate')->nullable()->default(0); $table->unsignedDecimal('acars_base_pay_rate')->nullable()->default(0);
$table->unsignedDecimal('manual_base_pay_rate')->nullable()->default(0);
$table->boolean('auto_approve_acars')->nullable()->default(false); $table->boolean('auto_approve_acars')->nullable()->default(false);
$table->boolean('auto_approve_manual')->nullable()->default(false); $table->boolean('auto_approve_manual')->nullable()->default(false);
$table->boolean('auto_promote')->nullable()->default(true); $table->boolean('auto_promote')->nullable()->default(true);

View File

@@ -75,17 +75,20 @@ ranks:
- id: 2 - id: 2
name: Junior First Officer name: Junior First Officer
hours: 10 hours: 10
base_pay_rate: 100 acars_base_pay_rate: 100
manual_base_pay_rate: 90
- id: 3 - id: 3
name: First Officer name: First Officer
hours: 15 hours: 15
base_pay_rate: 250 acars_base_pay_rate: 250
manual_base_pay_rate: 200
auto_approve_acars: 1 auto_approve_acars: 1
auto_approve_manual: 1 auto_approve_manual: 1
- id: 4 - id: 4
name: Senior Captain name: Senior Captain
hours: 20 hours: 20
base_pay_rate: 500 acars_base_pay_rate: 500
manual_base_pay_rate: 400
auto_approve_acars: 1 auto_approve_acars: 1
auto_approve_manual: 1 auto_approve_manual: 1
auto_promote: 0 auto_promote: 0

View File

@@ -14,7 +14,8 @@ class Rank extends BaseModel
'name', 'name',
'hours', 'hours',
'image_link', 'image_link',
'base_pay_rate', 'acars_base_pay_rate',
'manual_base_pay_rate',
'auto_approve_acars', 'auto_approve_acars',
'auto_approve_manual', 'auto_approve_manual',
'auto_promote', 'auto_promote',
@@ -31,7 +32,8 @@ class Rank extends BaseModel
public static $rules = [ public static $rules = [
'name' => 'required', 'name' => 'required',
'hours' => 'required|integer', 'hours' => 'required|integer',
'base_pay_rate' => 'nullable|numeric', 'acars_base_pay_rate' => 'nullable|numeric',
'manual_base_pay_rate' => 'nullable|numeric',
]; ];
public function subfleets() { public function subfleets() {

View File

@@ -5,6 +5,9 @@
namespace App\Services; namespace App\Services;
use App\Models\Enums\PirepSource;
use App\Models\Pirep;
class FinanceService extends BaseService class FinanceService extends BaseService
{ {
private $fareSvc, private $fareSvc,
@@ -22,4 +25,19 @@ class FinanceService extends BaseService
$this->fareSvc = $fareSvc; $this->fareSvc = $fareSvc;
$this->flightSvc = $flightSvc; $this->flightSvc = $flightSvc;
} }
/**
* Return the pilot's hourly pay for the given PIREP
* @param Pirep $pirep
*/
public function getPayForPirep(Pirep $pirep)
{
# Get the base rate for the rank
$rank = $pirep->user->rank;
if($pirep->source === PirepSource::ACARS) {
$base_rate = $rank->acars_base_pay_rate;
} else {
$base_rate = $rank->manual_base_pay_rate;
}
}
} }

View File

@@ -13,22 +13,33 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-md-6">
{!! Form::label('base_pay_rate', 'Base Pay Rate:') !!}
{!! Form::number('base_pay_rate', null, ['min' => 0, 'class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('base_pay_rate') }}</p>
@component('admin.components.info')
This is the base rate of pay, per-flight hour, for this rank.
This can be adjusted via a multiplier on the subfleet.
@endcomponent
</div>
<!-- Hours Field --> <!-- Hours Field -->
<div class="form-group col-sm-6"> <div class="form-group col-sm-4">
{!! Form::label('hours', 'Hours:') !!} {!! Form::label('hours', 'Hours:') !!}
{!! Form::number('hours', null, ['class' => 'form-control']) !!} {!! Form::number('hours', null, ['class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('hours') }}</p> <p class="text-danger">{{ $errors->first('hours') }}</p>
</div> </div>
<div class="form-group col-md-4">
{!! Form::label('acars_base_pay_rate', 'ACARS Base Pay Rate:') !!}
{!! Form::number('acars_base_pay_rate', null, ['min' => 0, 'class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('acars_base_pay_rate') }}</p>
@component('admin.components.info')
Base rate, per-flight hour, for ACARS PIREPs.
Can be adjusted via a multiplier on the subfleet.
@endcomponent
</div>
<div class="form-group col-md-4">
{!! Form::label('manual_base_pay_rate', 'Manual Base Pay Rate:') !!}
{!! Form::number('manual_base_pay_rate', null, ['min' => 0, 'class' => 'form-control']) !!}
<p class="text-danger">{{ $errors->first('manual_base_pay_rate') }}</p>
@component('admin.components.info')
Base rate, per-flight hour, for manually-filed PIREPs.
Can be adjusted via a multiplier on the subfleet.
@endcomponent
</div>
</div> </div>
<div class="row"> <div class="row">
<!-- Auto Approve Acars Field --> <!-- Auto Approve Acars Field -->

View File

@@ -2,7 +2,7 @@
<table class="table table-hover table-responsive"> <table class="table table-hover table-responsive">
<thead> <thead>
<th>Name</th> <th>Name</th>
<th>Hours</th> <th class="text-center">Hours</th>
<th class="text-center">Auto Approve Acars</th> <th class="text-center">Auto Approve Acars</th>
<th class="text-center">Auto Approve Manual</th> <th class="text-center">Auto Approve Manual</th>
<th class="text-center">Auto Promote</th> <th class="text-center">Auto Promote</th>
@@ -12,7 +12,7 @@
@foreach($ranks as $rank) @foreach($ranks as $rank)
<tr> <tr>
<td><a href="{!! route('admin.ranks.edit', [$rank->id]) !!}">{!! $rank->name !!}</a></td> <td><a href="{!! route('admin.ranks.edit', [$rank->id]) !!}">{!! $rank->name !!}</a></td>
<td>{!! $rank->hours !!}</td> <td class="text-center">{!! $rank->hours !!}</td>
<td class="text-center"> <td class="text-center">
@if($rank->auto_approve_acars == 1) @if($rank->auto_approve_acars == 1)
<span class="label label-success">Yes</span> <span class="label label-success">Yes</span>