@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class FlightsAddPilotPay extends Migration
|
||||
{
|
||||
/**
|
||||
* Add a `pilot_pay` column for a fixed amount to pay to a pilot for a flight
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('flights', function (Blueprint $table) {
|
||||
$table->decimal('pilot_pay')
|
||||
->nullable()
|
||||
->after('route');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('flights', function (Blueprint $table) {
|
||||
$table->dropColumn('pilot_pay');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ use Illuminate\Support\Collection;
|
||||
* @property int level
|
||||
* @property float load_factor
|
||||
* @property float load_factor_variance
|
||||
* @property float pilot_pay
|
||||
* @property Airport dpt_airport
|
||||
* @property Airport arr_airport
|
||||
* @property Airport alt_airport
|
||||
@@ -69,6 +70,7 @@ class Flight extends Model
|
||||
'flight_type',
|
||||
'load_factor',
|
||||
'load_factor_variance',
|
||||
'pilot_pay',
|
||||
'route',
|
||||
'notes',
|
||||
'start_date',
|
||||
@@ -88,6 +90,7 @@ class Flight extends Model
|
||||
'end_date' => 'date',
|
||||
'load_factor' => 'double',
|
||||
'load_factor_variance' => 'double',
|
||||
'pilot_pay' => 'float',
|
||||
'has_bid' => 'boolean',
|
||||
'route_leg' => 'integer',
|
||||
'active' => 'boolean',
|
||||
|
||||
@@ -374,11 +374,18 @@ class PirepFinanceService extends Service
|
||||
public function payPilotForPirep(Pirep $pirep): void
|
||||
{
|
||||
$pilot_pay = $this->getPilotPay($pirep);
|
||||
$pilot_pay_rate = $this->getPilotPayRateForPirep($pirep);
|
||||
$memo = 'Pilot Payment @ '.$pilot_pay_rate;
|
||||
|
||||
Log::info('Finance: PIREP: '.$pirep->id
|
||||
.'; pilot pay: '.$pilot_pay_rate.', total: '.$pilot_pay);
|
||||
if ($pirep->flight && !empty($pirep->flight->pilot_pay)) {
|
||||
$memo = 'Pilot fixed payment for flight: '.$pirep->flight->pilot_pay;
|
||||
Log::info('Finance: PIREP: '.$pirep->id
|
||||
.'; pilot pay: fixed for flight='.$pirep->flight->pilot_pay.', total: '.$pilot_pay);
|
||||
} else {
|
||||
$pilot_pay_rate = $this->getPilotPayRateForPirep($pirep);
|
||||
$memo = 'Pilot Payment @ '.$pilot_pay_rate;
|
||||
|
||||
Log::info('Finance: PIREP: '.$pirep->id
|
||||
.'; pilot pay: '.$pilot_pay_rate.', total: '.$pilot_pay);
|
||||
}
|
||||
|
||||
$this->financeSvc->debitFromJournal(
|
||||
$pirep->airline->journal,
|
||||
@@ -530,6 +537,13 @@ class PirepFinanceService extends Service
|
||||
*/
|
||||
public function getPilotPay(Pirep $pirep)
|
||||
{
|
||||
// If there is a fixed price for this flight, return that amount
|
||||
$flight = $pirep->flight;
|
||||
if ($flight && !empty($flight->pilot_pay)) {
|
||||
return new Money(Money::convertToSubunit($flight->pilot_pay));
|
||||
}
|
||||
|
||||
// Divided by 60 to get the rate per minute
|
||||
$pilot_rate = $this->getPilotPayRateForPirep($pirep) / 60;
|
||||
$payment = round($pirep->flight_time * $pilot_rate, 2);
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ class FlightImporter extends ImportExport
|
||||
'flight_type' => 'required|alpha',
|
||||
'load_factor' => 'nullable',
|
||||
'load_factor_variance' => 'nullable',
|
||||
'pilot_pay' => 'nullable',
|
||||
'route' => 'nullable',
|
||||
'notes' => 'nullable',
|
||||
'active' => 'nullable|boolean',
|
||||
|
||||
Reference in New Issue
Block a user