Fix Advanced Fuel Calculations (#1190)
* Fix Advanced Fuel Calculations Current code works fine with a fresh submitted pirep but when a re-calculation is needed, fuel amount will not be correct if the aircraft was flown later on. Commit provides fix for such re-calculation scenarios. * StyleFix for the Comment Line !
This commit is contained in:
@@ -176,11 +176,13 @@ class PirepFinanceService extends Service
|
|||||||
|
|
||||||
if (setting('pireps.advanced_fuel', false)) {
|
if (setting('pireps.advanced_fuel', false)) {
|
||||||
// Reading second row by skip(1) to reach the previous accepted pirep. Current pirep is at the first row
|
// Reading second row by skip(1) to reach the previous accepted pirep. Current pirep is at the first row
|
||||||
|
// To get proper fuel values, we need to fetch current pirep and older ones only. Scenario: ReCalculating finances
|
||||||
$prev_flight = Pirep::where([
|
$prev_flight = Pirep::where([
|
||||||
'aircraft_id' => $pirep->aircraft->id,
|
'aircraft_id' => $pirep->aircraft->id,
|
||||||
'state' => PirepState::ACCEPTED,
|
'state' => PirepState::ACCEPTED,
|
||||||
'status' => PirepStatus::ARRIVED,
|
'status' => PirepStatus::ARRIVED,
|
||||||
])
|
])
|
||||||
|
->where('submitted_at', '<=', $pirep->submitted_at)
|
||||||
->orderby('submitted_at', 'desc')
|
->orderby('submitted_at', 'desc')
|
||||||
->skip(1)
|
->skip(1)
|
||||||
->first();
|
->first();
|
||||||
|
|||||||
Reference in New Issue
Block a user