diff --git a/app/Http/Controllers/StructureController.php b/app/Http/Controllers/StructureController.php index c7b5e2217..8b76672f1 100644 --- a/app/Http/Controllers/StructureController.php +++ b/app/Http/Controllers/StructureController.php @@ -68,22 +68,35 @@ class StructureController extends Controller */ $fuelCost = $hFinances->CalculateFuelBlockCost('market'); + /** + * Calculate the final taxes and send to display + */ + + $tax = CorpStructure::where(['corporation_id' => $corporation, 'structure_type' => 'Citadel']) + ->avg('tax'); + $rTax = CorpStructure::where(['corporation_id' => $corporation, 'structure_type' => 'Refinery']) + ->avg('tax'); + $monthTaxesMarket = $monthTaxesMarket - $fuelCost; + $monthTaxesMarket = $hFinance->CalculateTax($monthTaxesMarket, $tax, 'market'); if($monthTaxesMarket < 0.00) { $monthTaxesMarket = 0.00; } $lastTaxesMarket = $lastTaxesMarket - $fuelCost; + $lastTaxesMarket = $hFinance->CalculateTax($lastTaxesMarket, $tax, 'market'); if($lastTaxesMarket < 0.00) { $lastTaxesMarket = 0.00; } $monthTaxesReprocessing = $monthTaxesReprocessing - $fuelCost; + $monthTaxesReprocessing = $hFinance->CalculateTax($monthTaxesReprocessing, $rTax, 'refinery'); if($monthTaxesReprocessing < 0.00) { $monthTaxesReprocessing = 0.00; } $lastTaxesReprocessing = $lastTaxesReprocessing - $fuelCost; + $lastTaxesReprocessing = $hFinance->CalculateTax($lastTaxesReprocessing, $rTax, 'refinery'); if($lastTaxesReprocessing < 0.00) { $lastTaxesReprocessing = 0.00; } diff --git a/app/Library/FinanceHelper.php b/app/Library/FinanceHelper.php index 2f7845c9d..ad8619279 100644 --- a/app/Library/FinanceHelper.php +++ b/app/Library/FinanceHelper.php @@ -50,7 +50,7 @@ class FinanceHelper { //We need to calculate the correct ratio based on structure tax, //Then figure out what is owed to the alliance if($type === 'market') { - $ratioType = 2.5; + $ratioType = 2.0; } else { $ratioType = 1.5; } @@ -73,13 +73,9 @@ class FinanceHelper { * @return tax */ public function GetMonthlyTax($corpId, $type) { - $monthly = DB::table('CorpJournals') - ->select(DB::raw('SUM(tax) as monthly')) - ->where([ - 'corporation_id' => $corpId, - 'ref_type' => $type - ])->whereBetween('date', [Carbon::now(), Carbon::now()->subMonth()]) - ->get(); + $monthly = CorpJournal::where(['corporation_id' => $corId, 'ref_type' => $type]) + ->whereBetween('date', [Carbon::now(), Carbon::now()->subMonth()]) + ->sum('tax'); return $monthly; }