71 lines
2.2 KiB
PHP
71 lines
2.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* W4RP Services
|
|
* GNU Public License
|
|
*/
|
|
|
|
namespace App\Library\Finances;
|
|
|
|
//Library
|
|
use App\Library\Esi\Esi;
|
|
|
|
//Models
|
|
use App\Models\Finances\AllianceMarketJournal;
|
|
|
|
class AllianceMarketTax {
|
|
public function EntryExists($journal) {
|
|
if(AllianceMarketJournal::where(['id' => $journal['id']])->exists()) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public function InsertMarketTax($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(!AllianceMarketJournal::where(['id' => $journal['id']])->exists()) {
|
|
$entry = new AllianceMarketJournal;
|
|
$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();
|
|
}
|
|
}
|
|
}
|
|
|
|
?>
|