sov bill journal

This commit is contained in:
2020-04-03 03:15:46 -05:00
parent a2673187d3
commit 06dd0669fe
11 changed files with 231 additions and 17 deletions
@@ -30,6 +30,7 @@ use App\Library\Finances\OfficeFee;
use App\Library\Finances\PlanetProductionTax;
use App\Library\Finances\PISale;
use App\Library\Lookups\LookupHelper;
use App\Library\Finances\SovBillExpenses;
//Seat Stuff
use Seat\Eseye\Exceptions\RequestFailedException;
@@ -47,6 +48,7 @@ class FinanceHelper {
$industry = new StructureIndustryTax();
$office = new OfficeFee();
$esiHelper = new Esi();
$sovBillHelper = new SovBillExpenses();
$lookup = new LookupHelper;
//Get the ESI refresh token for the corporation to add new wallet journals into the database
@@ -113,6 +115,8 @@ class FinanceHelper {
$industry->InsertStructureIndustryTax($entry, $corpId, $division);
} else if($entry['ref_type'] == 'office_rental_fee' && $entry['second_party_id'] == 98287666) {
$office->InsertOfficeFee($entry, $corpId, $division);
} else if($entry['ref_type'] == 'infrastructure_hub_bill' && $entry['second_party_id'] == 9828766) {
$sovBillHelper->InsertSovBillExpense($entry, $corpId, $division);
}
}
}
+63
View File
@@ -0,0 +1,63 @@
<?php
/**
* W4RP Services
* GNU Public License
*/
namespace App\Library\Finances;
//Library
use App\Library\Esi\Esi;
//Models
use App\Models\Finances\SovBillJournal;
class SovBillExpenses {
public function InsertSovBillExpense($journal, $corpId, $division) {
//Create the ESI Helper class
$esiHelper = new Esi;
//Check to see if we can find the entry in the database already.
//If we don't then add it to the database
if(!SovBillJournal::where(['id' => $journal['id']])->exists()) {
$entry = new SovBillJournal;
$entry->id = $journal['id'];
$entry->corporation_id = $corpId;
$entry->division = $division;
if(isset($journal['amount'])) {
$entry->amount = $journal['amount'];
}
if(isset($journal['balance'])) {
$entry->balance = $journal['balance'];
}
if(isset($journal['context_id'])) {
$entry->context_id = $journal['context_id'];
}
if(isset($journal['context_id_type'])) {
$entry->context_id_type = $journal['context_id_type'];
}
$entry->date = $esiHelper->DecodeDate($journal['date']);
$entry->description = $journal['description'];
if(isset($journal['first_party_id'])) {
$entry->first_party_id = $journal['first_party_id'];
}
if(isset($journal['reason'])) {
$entry->reason = $journal['reason'];
}
$entry->ref_type = $journal['ref_type'];
if(isset($journal['second_party_id'])) {
$entry->second_party_id = $journal['second_party_id'];
}
if(isset($journal['tax'])) {
$entry->tax = $journal['tax'];
}
if(isset($journal['tax_receiver_id'])) {
$entry->tax_receiver_id = $journal['tax_receiver_id'];
}
$entry->save();
}
}
}
?>