new helper finance function

This commit is contained in:
2018-12-04 22:12:41 -06:00
parent 7d8a1a10ad
commit 6244ab6e9f
2 changed files with 27 additions and 5 deletions

View File

@@ -104,6 +104,10 @@ class FinancesController extends Controller
return view('finances.taxes')->with('totalTaxes', $totalTaxes);
}
public function displayJumpGateStatistics() {
}
public function displayTaxes() {
//Make the helper esi class
$helper = new Esi();

View File

@@ -32,9 +32,9 @@ class FinanceHelper {
public function CalculateFuelBlockCost($type) {
//Calculate how many fuel blocks are used in a month by a structure type
if($type === 'market') {
$fuelBlocks = 30*32*24;
$fuelBlocks = 24*30*32;
} else if ($type === 'reprocessing') {
$fuelBlocks = 8*30*24;
$fuelBlocks = 24*30*8;
} else {
$fuelBlocks = 0;
}
@@ -51,8 +51,6 @@ class FinanceHelper {
//Then figure out what is owed to the alliance
if($type === 'market') {
$ratioType = 2.5;
} else if ($type === 'refinery') {
$ratioType = 1.0;
} else {
$ratioType = 1.5;
}
@@ -66,6 +64,26 @@ class FinanceHelper {
return $amount;
}
/**
* Helper function to calculate a particular type of tax from the database
*
* @param corpId
* @param type
*
* @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();
return $monthly;
}
public function GetWalletJournal($division, $charId) {
//Get hte ESI token for the corporation to add new wallet journals into the database
$token = DB::table('EsiTokens')->where('character_id', $charId)->get();
@@ -114,7 +132,7 @@ class FinanceHelper {
//For each journal entry, attempt to store it in the database.
//The PutWalletJournal function checks to see if it's already in the database.
foreach($wallet as $entry) {
if($entry['ref_type'] == 'brokers_fee' || $entry['ref_type'] == 'reprocessing_tax') {
if($entry['ref_type'] == 'brokers_fee' || $entry['ref_type'] == 'reprocessing_tax' || $entry['ref_type'] == 'acceleration_gate_fee') {
$this->PutWalletJournal($entry, $corpId, $division);
}
}