Skip to content

Commit a872c7a

Browse files
committed
Update Expense_Airport.php
1 parent c83bd75 commit a872c7a

1 file changed

Lines changed: 12 additions & 35 deletions

File tree

Listeners/Expense_Airport.php

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public function handle(Expenses $event)
5858
$orig = $pirep->dpt_airport;
5959
$dest = $pirep->arr_airport;
6060
// Max Defs
61-
$mtow = null;
61+
$mtow = $aircraft->mtow->internal(0) > 0 ? $aircraft->mtow->internal(2) : null;
62+
$mlw = $aircraft->mlw->internal(0) > 0 ? $aircraft->mlw->internal(2) : null;
6263
$maxpax = null;
6364
$maxcgo = null;
6465
// Actual Defs
@@ -69,8 +70,8 @@ public function handle(Expenses $event)
6970

7071
// High Season Dates
7172
$pirep_year = $pirep->submitted_at->format('Y');
72-
$season_s = $pirep_year.'05-01';
73-
$season_e = $pirep_year.'10-31';
73+
$season_s = $pirep_year.'-05-01';
74+
$season_e = $pirep_year.'-10-31';
7475

7576
// Low Cost Airline Check
7677
$lowcost = (in_array($pirep->airline->icao, $lc_carriers) || $pirep->route_code === 'AJ') ? true : false;
@@ -83,11 +84,6 @@ public function handle(Expenses $event)
8384
// Domestic Check
8485
$int = ($orig && $dest && $orig->country === $dest->country) ? false : true;
8586

86-
// Get Aircraft Details (Certification & Capacity)
87-
if ($needmax && $aircraft && $aircraft->mtow->internal(2) > 0) {
88-
$mtow = $aircraft->mtow->internal(2);
89-
}
90-
9187
if ($needmax && $aircraft && $aircraft->subfleet->fares->count() > 0) {
9288
$pax_cap = 0;
9389
$cgo_cap = 0;
@@ -100,32 +96,17 @@ public function handle(Expenses $event)
10096
}
10197
}
10298

103-
if ($pax_cap > 0) {
104-
$maxpax = $pax_cap;
105-
}
106-
if ($cgo_cap > 0) {
107-
$maxcgo = $cgo_cap;
108-
}
99+
$maxpax = ($pax_cap > 0) ? $pax_cap : null;
100+
$maxcgo = ($cgo_cap > 0) ? $cgo_cap : null;
109101
}
110102

111103
// Get Pirep Details (Actual Figures)
112104
if ($needact && $aircraft) {
113105
$act_lw = optional($pirep->fields->where('slug', 'landing-weight')->first())->value;
114106
$act_tow = optional($pirep->fields->where('slug', 'takeoff-weight')->first())->value;
115107

116-
if (is_numeric($act_lw)) {
117-
$lw = round($act_lw);
118-
if ($units['weight'] === 'kg') {
119-
$lw = round($lw / 2.20462262185);
120-
}
121-
}
122-
123-
if (is_numeric($act_tow)) {
124-
$tow = round($act_tow);
125-
if ($units['weight'] === 'kg') {
126-
$tow = round($tow / 2.20462262185);
127-
}
128-
}
108+
$lw = (is_numeric($act_lw) && $act_lw > 0) ? round($act_lw) : null;
109+
$tow = (is_numeric($act_tow) && $act_tow > 0) ?round($act_tow) : null;
129110
}
130111

131112
if ($needact && $aircraft && $pirep->fares->count() > 0) {
@@ -140,12 +121,8 @@ public function handle(Expenses $event)
140121
}
141122
}
142123

143-
if ($act_pax >= 0) {
144-
$pax = $act_pax;
145-
}
146-
if ($act_cgo >= 0) {
147-
$cgo = $act_cgo;
148-
}
124+
$pax = ($act_pax >= 0) ? $act_pax : null;
125+
$cgo = ($act_cgo >= 0) ? $act_cgo : null;
149126
}
150127

151128
// Landing Fee
@@ -177,7 +154,7 @@ public function handle(Expenses $event)
177154
$base_fee = round($lf_base * 0.8151, 2);
178155
}
179156

180-
$base_weight = ($units['weight'] === 'kg') ? round($base_weight / 1000, 2) : round($base_weight / 2240, 2);
157+
$base_weight = round($base_weight / 2240, 2);
181158
$landing_fee = round($base_weight * $base_fee, 2);
182159

183160
$expenses[] = new Expense([
@@ -213,7 +190,7 @@ public function handle(Expenses $event)
213190
$diff_hours = $off_block->diffInHours($on_block);
214191
$diff_days = $off_block->diffInDays($on_block);
215192

216-
$base_weight = ($units['weight'] === 'kg') ? round($base_weight / 1000, 2) : round($base_weight / 2240, 2);
193+
$base_weight = round($base_weight / 2240, 2);
217194

218195
// Check High Season
219196
if ($off_block->between($season_s, $season_e)) {

0 commit comments

Comments
 (0)