Created
August 5, 2020 16:03
-
-
Save jongravois/ca1b43d7c8c8145bd227f112620811fe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models; | |
use App\Model; | |
/** | |
* App\Models\DealFin | |
* | |
* @property int $id | |
* @property int|null $deal_id | |
* @property string|null $lot_code | |
* @property int|null $fixed | |
* @property float|null $airframe_cost | |
* @property float|null $engines_cost | |
* @property float|null $disassembly_cost | |
* @property float|null $freight_cost | |
* @property float|null $legal_cost | |
* @property float|null $storage_cost | |
* @property float|null $other_cost | |
* @property string|null $other_cost_description | |
* @property float|null $repair_cost | |
* @property float|null $repair_upside | |
* @property float|null $cost_of_capital | |
* @property float|null $debt_payoff | |
* @property int|null $deal_timeline | |
* @property float|null $distribution_percentage_q1 | |
* @property float|null $distribution_percentage_q2 | |
* @property float|null $distribution_percentage_q3 | |
* @property float|null $distribution_percentage_q4 | |
* @property float|null $distribution_percentage_q5 | |
* @property float|null $distribution_percentage_q6 | |
* @property float|null $distribution_percentage_q7 | |
* @property float|null $distribution_percentage_q8 | |
* @property float|null $distribution_percentage_q9 | |
* @property float|null $distribution_percentage_q10 | |
* @property float|null $distribution_percentage_q11 | |
* @property float|null $distribution_percentage_q12 | |
* @property float|null $current_rate | |
* @property float|null $current_gross | |
* @property float|null $current_net | |
* @property float|null $engine_sales | |
* @property \Illuminate\Support\Carbon|null $created_at | |
* @property \Illuminate\Support\Carbon|null $updated_at | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin newModelQuery() | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin newQuery() | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin query() | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereAirframeCost($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereCostOfCapital($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereCreatedAt($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereCurrentGross($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereCurrentNet($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereCurrentRate($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDealId($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDealTimeline($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDebtPayoff($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDisassemblyCost($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDistributionPercentageQ1($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDistributionPercentageQ10($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDistributionPercentageQ11($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDistributionPercentageQ12($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDistributionPercentageQ2($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDistributionPercentageQ3($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDistributionPercentageQ4($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDistributionPercentageQ5($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDistributionPercentageQ6($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDistributionPercentageQ7($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDistributionPercentageQ8($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereDistributionPercentageQ9($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereEngineSales($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereEnginesCost($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereFixed($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereFreightCost($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereId($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereLegalCost($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereLotCode($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereOtherCost($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereOtherCostDescription($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereRepairCost($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereRepairUpside($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereStorageCost($value) | |
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\DealFin whereUpdatedAt($value) | |
* @mixin \Eloquent | |
*/ | |
class DealFin extends Model | |
{ | |
protected $table = 'deal_fins'; | |
protected $guarded = []; | |
/* CASTING */ | |
protected $casts = [ | |
'airframe_cost' => 'double', | |
'cost_of_capital' => 'double', | |
'current_gross' => 'double', | |
'current_net' => 'double', | |
'current_rate' => 'double', | |
'debt_payoff' => 'double', | |
'distribution_percentage_q1' => 'double', | |
'distribution_percentage_q2' => 'double', | |
'distribution_percentage_q3' => 'double', | |
'distribution_percentage_q4' => 'double', | |
'distribution_percentage_q5' => 'double', | |
'distribution_percentage_q6' => 'double', | |
'distribution_percentage_q7' => 'double', | |
'distribution_percentage_q8' => 'double', | |
'distribution_percentage_q9' => 'double', | |
'distribution_percentage_q10' => 'double', | |
'distribution_percentage_q11' => 'double', | |
'distribution_percentage_q12' => 'double', | |
'deal_timeline' => 'integer', | |
'disassembly_cost' => 'double', | |
'engines_cost' => 'double', | |
'engine_sales' => 'double', | |
'fixed' => 'boolean', | |
'freight_cost' => 'double', | |
'legal_cost' => 'double', | |
'other_cost' => 'double', | |
'repair_cost' => 'double', | |
'repair_upside' => 'double', | |
'storage_cost' => 'double', | |
]; | |
/* CASTING */ | |
/* RELATIONSHIPS */ | |
public function deal() | |
{ | |
return $this->belongsTo(Deal::class, 'id', 'deal_id'); | |
} // end function | |
/* RELATIONSHIPS */ | |
/* METHODS */ | |
public function accumulatedFlow() | |
{ | |
$reporter = []; | |
for($c=0; $c<13; $c++) { | |
$reporter[] = 0; | |
} // end for | |
return $reporter; | |
} // end function | |
public function allIn() | |
{ | |
return $this->airframe_cost + $this->engines_cost + $this->disassembly_cost + $this->freight_cost + $this->legal_cost + $this->storage_cost + $this->other_cost; | |
} // end function | |
public function calcInterest() | |
{ | |
return [ | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
]; | |
} // end function | |
public function fcNet() | |
{ | |
$reporter = []; | |
for($c=0; $c<13; $c++) { | |
$reporter[] = $this->fcGross()[$c] + $this->engineSale()[$c] + $this->repairs()[$c]; | |
} // end for | |
return $reporter; | |
} // end function | |
public function fcGross() | |
{ | |
$reporter = []; | |
$reporter[] = 0; | |
for($c=1; $c<13; $c++) { | |
$reporter[] = $this->forecastedRevenue()['projected'] * $this->percents()[$c]; | |
} // end for | |
return $reporter; | |
} // end function | |
public function fcIRR() | |
{ | |
return 0; | |
} // end function | |
public function fcROI() | |
{ | |
return $this->allIn(); | |
} // end function | |
public function engineSale() | |
{ | |
$reporter = []; | |
$reporter[] = 0; | |
$reporter[] = $this->engine_sales; | |
foreach(range(1,11) as $item) { $reporter[] = 0; } // end for | |
return $reporter; | |
} // end function | |
public function forecastedRevenue() | |
{ | |
$cat1 = 2733750; | |
$cat2 = 1000000; | |
$cat3 = 411210; | |
//TODO Move Modeler and Make Dynamic | |
return [ | |
'cat1' => $cat1, | |
'cat2' => $cat2, | |
'cat3' => $cat3, | |
'projected' => $cat1 + $cat2 + $this->repairsPlus() | |
]; | |
} // end function | |
public function irrFlow() | |
{ | |
return [ | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
]; | |
} // end function | |
public function netFlow() | |
{ | |
return [ | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
]; | |
} // end function | |
public function payoffPeriod() | |
{ | |
return 'XXX'; //'< 5 Quarters'; | |
} // end function | |
public function percents() | |
{ | |
return [ | |
0, | |
$this->distribution_percentage_q1, | |
$this->distribution_percentage_q2, | |
$this->distribution_percentage_q3, | |
$this->distribution_percentage_q4, | |
$this->distribution_percentage_q5, | |
$this->distribution_percentage_q6, | |
$this->distribution_percentage_q7, | |
$this->distribution_percentage_q8, | |
$this->distribution_percentage_q9, | |
$this->distribution_percentage_q10, | |
$this->distribution_percentage_q11, | |
$this->distribution_percentage_q12 | |
]; | |
} // end function | |
public function purchaseCost() | |
{ | |
return $this->airframe_cost + $this->engines_cost; | |
} // end function | |
public function principal() | |
{ | |
return [ | |
$this->purchaseCost(), | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
]; | |
} // end function | |
public function projectCost() | |
{ | |
return $this->freight_cost + $this->legal_cost + $this->storage_cost + $this->other_cost; | |
} // end function | |
public function projectCosts() | |
{ | |
return [ | |
0, | |
$this->projectCost() * -1 + $this->disassembly_cost/2 * -1, | |
$this->disassembly_cost/2 * -1, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
0, | |
]; | |
} // end function | |
public function repairs() | |
{ | |
return [ | |
0, | |
$this->distribution_percentage_q1 * -1 * $this->repair_cost, | |
$this->distribution_percentage_q2 * -1 * $this->repair_cost, | |
$this->distribution_percentage_q3 * -1 * $this->repair_cost, | |
$this->distribution_percentage_q4 * -1 * $this->repair_cost, | |
$this->distribution_percentage_q5 * -1 * $this->repair_cost, | |
$this->distribution_percentage_q6 * -1 * $this->repair_cost, | |
$this->distribution_percentage_q7 * -1 * $this->repair_cost, | |
$this->distribution_percentage_q8 * -1 * $this->repair_cost, | |
$this->distribution_percentage_q9 * -1 * $this->repair_cost, | |
$this->distribution_percentage_q10 * -1 * $this->repair_cost, | |
$this->distribution_percentage_q11 * -1 * $this->repair_cost, | |
$this->distribution_percentage_q12 * -1 * $this->repair_cost | |
]; | |
} // end function | |
public function repairsPlus() | |
{ | |
return $this->repair_cost + ($this->repair_cost * $this->repair_upside); | |
} // end function | |
public function uamProfit() | |
{ | |
return 'XXX'; | |
} // end function | |
/* METHODS */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment