diff --git a/app/Database/migrations/2017_06_21_165410_create_ranks_table.php b/app/Database/migrations/2017_06_21_165410_create_ranks_table.php index 18eef7cf..fe719df7 100644 --- a/app/Database/migrations/2017_06_21_165410_create_ranks_table.php +++ b/app/Database/migrations/2017_06_21_165410_create_ranks_table.php @@ -18,7 +18,8 @@ class CreateRanksTable extends Migration $table->string('name', 50); $table->string('image_link')->nullable(); $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_manual')->nullable()->default(false); $table->boolean('auto_promote')->nullable()->default(true); diff --git a/app/Database/seeds/sample.yml b/app/Database/seeds/sample.yml index cac7823b..4c5b61e7 100644 --- a/app/Database/seeds/sample.yml +++ b/app/Database/seeds/sample.yml @@ -75,17 +75,20 @@ ranks: - id: 2 name: Junior First Officer hours: 10 - base_pay_rate: 100 + acars_base_pay_rate: 100 + manual_base_pay_rate: 90 - id: 3 name: First Officer hours: 15 - base_pay_rate: 250 + acars_base_pay_rate: 250 + manual_base_pay_rate: 200 auto_approve_acars: 1 auto_approve_manual: 1 - id: 4 name: Senior Captain hours: 20 - base_pay_rate: 500 + acars_base_pay_rate: 500 + manual_base_pay_rate: 400 auto_approve_acars: 1 auto_approve_manual: 1 auto_promote: 0 diff --git a/app/Models/Rank.php b/app/Models/Rank.php index 48e076d5..67ab1f8e 100644 --- a/app/Models/Rank.php +++ b/app/Models/Rank.php @@ -14,7 +14,8 @@ class Rank extends BaseModel 'name', 'hours', 'image_link', - 'base_pay_rate', + 'acars_base_pay_rate', + 'manual_base_pay_rate', 'auto_approve_acars', 'auto_approve_manual', 'auto_promote', @@ -31,7 +32,8 @@ class Rank extends BaseModel public static $rules = [ 'name' => 'required', 'hours' => 'required|integer', - 'base_pay_rate' => 'nullable|numeric', + 'acars_base_pay_rate' => 'nullable|numeric', + 'manual_base_pay_rate' => 'nullable|numeric', ]; public function subfleets() { diff --git a/app/Services/FinanceService.php b/app/Services/FinanceService.php index 1b11d364..a299c255 100644 --- a/app/Services/FinanceService.php +++ b/app/Services/FinanceService.php @@ -5,6 +5,9 @@ namespace App\Services; +use App\Models\Enums\PirepSource; +use App\Models\Pirep; + class FinanceService extends BaseService { private $fareSvc, @@ -22,4 +25,19 @@ class FinanceService extends BaseService $this->fareSvc = $fareSvc; $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; + } + } } diff --git a/resources/views/admin/ranks/fields.blade.php b/resources/views/admin/ranks/fields.blade.php index bad453a9..796e2bc0 100644 --- a/resources/views/admin/ranks/fields.blade.php +++ b/resources/views/admin/ranks/fields.blade.php @@ -13,22 +13,33 @@
{{ $errors->first('base_pay_rate') }}
- @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 -{{ $errors->first('hours') }}
{{ $errors->first('acars_base_pay_rate') }}
+ @component('admin.components.info') + Base rate, per-flight hour, for ACARS PIREPs. + Can be adjusted via a multiplier on the subfleet. + @endcomponent +{{ $errors->first('manual_base_pay_rate') }}
+ @component('admin.components.info') + Base rate, per-flight hour, for manually-filed PIREPs. + Can be adjusted via a multiplier on the subfleet. + @endcomponent +| Name | -Hours | +Hours | Auto Approve Acars | Auto Approve Manual | Auto Promote | @@ -12,7 +12,7 @@ @foreach($ranks as $rank)
|---|---|---|---|
| {!! $rank->name !!} | -{!! $rank->hours !!} | +{!! $rank->hours !!} | @if($rank->auto_approve_acars == 1) Yes |