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

@@ -85,7 +85,7 @@ class Acars extends Model
*
* @return int|Distance
*/
public function getDistanceAttribute()
/*public function getDistanceAttribute()
{
if (!array_key_exists('distance', $this->attributes)) {
return 0;
@@ -103,7 +103,7 @@ class Acars extends Model
} catch (NonStringUnitName $e) {
return 0;
}
}
}*/
/**
* Set the distance unit, convert to our internal default unit
@@ -126,7 +126,7 @@ class Acars extends Model
*
* @return int|Fuel
*/
public function getFuelAttribute()
/*public function getFuelAttribute()
{
if (!array_key_exists('fuel', $this->attributes)) {
return 0;
@@ -140,7 +140,7 @@ class Acars extends Model
} catch (NonStringUnitName $e) {
return 0;
}
}
}*/
/**
* Set the amount of fuel

View File

@@ -17,6 +17,9 @@ use App\Models\Traits\FilesTrait;
* @property string country
* @property string timezone
* @property float ground_handling_cost
* @property float fuel_100ll_cost
* @property float fuel_jeta_cost
* @property float fuel_mogas_cost
* @property float lat
* @property float lon
*/
@@ -67,6 +70,9 @@ class Airport extends Model
'lat' => 'required|numeric',
'lon' => 'required|numeric',
'ground_handling_cost' => 'nullable|numeric',
'fuel_100ll_cost' => 'nullable|numeric',
'fuel_jeta_cost' => 'nullable|numeric',
'fuel_mogas_cost' => 'nullable|numeric',
];
/**

View File

@@ -137,7 +137,7 @@ class Flight extends Model
*
* @return Distance
*/
public function getDistanceAttribute()
/*public function getDistanceAttribute()
{
if (!array_key_exists('distance', $this->attributes)) {
return 0;
@@ -152,7 +152,7 @@ class Flight extends Model
} catch (NonStringUnitName $e) {
return new Distance(0, config('phpvms.internal_units.distance', 'nmi'));
}
}
}*/
/**
* Set the distance unit, convert to our internal default unit

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.