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)) {
|
||||
// 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([
|
||||
'aircraft_id' => $pirep->aircraft->id,
|
||||
'state' => PirepState::ACCEPTED,
|
||||
'status' => PirepStatus::ARRIVED,
|
||||
])
|
||||
->where('submitted_at', '<=', $pirep->submitted_at)
|
||||
->orderby('submitted_at', 'desc')
|
||||
->skip(1)
|
||||
->first();
|
||||
|
||||
Reference in New Issue
Block a user