Account for fuel in the finance calculations #313

This commit is contained in:
Nabeel Shahzad
2019-07-23 08:41:20 -04:00
parent ee1c8ee3fa
commit 62a10224a0
31 changed files with 246 additions and 89 deletions

View File

@@ -35,6 +35,8 @@ use PhpUnitsOfMeasure\Exception\NonStringUnitName;
* @property int block_time
* @property int flight_time In minutes
* @property int planned_flight_time
* @property float block_fuel
* @property float fuel_used
* @property float distance
* @property float planned_distance
* @property string route
@@ -124,6 +126,8 @@ class Pirep extends Model
'flight_number' => 'required',
'dpt_airport_id' => 'required',
'arr_airport_id' => 'required',
'block_fuel' => 'required|numeric',
'fuel_used' => 'required|numeric',
'notes' => 'nullable',
'route' => 'nullable',
];
@@ -132,7 +136,6 @@ class Pirep extends Model
* If a PIREP is in these states, then it can't be changed.
*/
public static $read_only_states = [
//PirepState::PENDING,
PirepState::ACCEPTED,
PirepState::REJECTED,
PirepState::CANCELLED,
@@ -200,7 +203,7 @@ class Pirep extends Model
*
* @return int|Distance
*/
public function getDistanceAttribute()
/*public function getDistanceAttribute()
{
if (!array_key_exists('distance', $this->attributes)) {
return 0;
@@ -218,7 +221,7 @@ class Pirep extends Model
} catch (NonStringUnitName $e) {
return 0;
}
}
}*/
/**
* Set the distance unit, convert to our internal default unit
@@ -249,7 +252,7 @@ class Pirep extends Model
*
* @return int|Fuel
*/
public function getFuelUsedAttribute()
/*public function getFuelUsedAttribute()
{
if (!array_key_exists('fuel_used', $this->attributes)) {
return 0;
@@ -264,14 +267,14 @@ class Pirep extends Model
} catch (NonStringUnitName $e) {
return 0;
}
}
}*/
/**
* Return the planned_distance in a converter class
*
* @return int|Distance
*/
public function getPlannedDistanceAttribute()
/*public function getPlannedDistanceAttribute()
{
if (!array_key_exists('planned_distance', $this->attributes)) {
return 0;
@@ -289,7 +292,7 @@ class Pirep extends Model
} catch (NonStringUnitName $e) {
return 0;
}
}
}*/
/**
* Return the flight progress in a percent.