controller for pi taxes for admin page
This commit is contained in:
@@ -63,6 +63,11 @@ class TaxesController extends Controller
|
|||||||
'date' => $date['start']->toFormattedDateString(),
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
'gross' => number_format($tHelper->GetJumpGateGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$pitransactions[] = [
|
||||||
|
'date' => $date['start']->toFormattedDateString(),
|
||||||
|
'gross' => number_format($tHelper->GetPiGross($date['start'], $date['end']), 2, ".", ","),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
//Return the view with the compact variable list
|
//Return the view with the compact variable list
|
||||||
@@ -71,6 +76,7 @@ class TaxesController extends Controller
|
|||||||
->with('reprocessings', $reprocessings)
|
->with('reprocessings', $reprocessings)
|
||||||
->with('offices', $offices)
|
->with('offices', $offices)
|
||||||
->with('markets', $markets)
|
->with('markets', $markets)
|
||||||
->with('jumpgates', $jumpgates);
|
->with('jumpgates', $jumpgates)
|
||||||
|
->with('pigross', $pitransactions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,46 +9,48 @@
|
|||||||
|
|
||||||
use DB;
|
use DB;
|
||||||
|
|
||||||
|
use App\Library\Esi\Esi;
|
||||||
|
|
||||||
use App\Models\Finances\PISaleJournal;
|
use App\Models\Finances\PISaleJournal;
|
||||||
|
|
||||||
class PISale {
|
class PISale {
|
||||||
|
|
||||||
public InsertPISale($journal, $corpId) {
|
public InsertPISale($journal, $corpId) {
|
||||||
|
//Create the ESI Helper class
|
||||||
|
$esiHelper = new Esi;
|
||||||
|
|
||||||
//Insert the PI Sale into the database
|
//Insert the PI Sale into the database
|
||||||
if(!PISaleJournal::where(['id' => $journal['id']])->exists()) {
|
if(!PISaleJournal::where(['id' => $journal['id']])->exists()) {
|
||||||
$entry = new PISaleJournal;
|
$entry = new PISaleJournal;
|
||||||
$entry->id = $journal['id'];
|
$entry->id = $journal['id'];
|
||||||
$entry->corporation_id = $corpId;
|
$entry->corporation_id = $corpId;
|
||||||
$entry->division = $division;
|
$entry->division = $division;
|
||||||
if(isset($journal['amount'])) {
|
if(isset($journal['client_id'])) {
|
||||||
$entry->amount = $journal['amount'];
|
$entry->client_id = $journal['client_id'];
|
||||||
}
|
}
|
||||||
if(isset($journal['balance'])) {
|
if(isset($journal['date'])) {
|
||||||
$entry->balance = $journal['balance'];
|
$entry->date = $esiHelper->DecoateDate($journal['date']);
|
||||||
}
|
}
|
||||||
if(isset($journal['context_id'])) {
|
if(isset($journal['is_buy'])) {
|
||||||
$entry->context_id = $journal['context_id'];
|
$entry->is_buy = $journal['is_buy'];
|
||||||
}
|
}
|
||||||
if(isset($journal['context_id_type'])) {
|
if(isset($journal['journal_ref_id'])) {
|
||||||
$entry->context_id_type = $journal['context_id_type'];
|
$entry->journal_ref_id = $journal['journal_ref_id'];
|
||||||
}
|
}
|
||||||
$entry->date = $esiHelper->DecodeDate($journal['date']);
|
if(isset($journal['location_id'])) {
|
||||||
$entry->description = $journal['description'];
|
$entry->location_id = $journal['location_id'];
|
||||||
if(isset($journal['first_party_id'])) {
|
|
||||||
$entry->first_party_id = $journal['first_party_id'];
|
|
||||||
}
|
}
|
||||||
if(isset($journal['reason'])) {
|
if(isset($journal['quantity'])) {
|
||||||
$entry->reason = $journal['reason'];
|
$entry->quantity = $journal['quantity'];
|
||||||
}
|
}
|
||||||
$entry->ref_type = $journal['ref_type'];
|
if(isset($journal['transaction_id'])) {
|
||||||
if(isset($journal['second_party_id'])) {
|
$entry->transaction_id = $journal['transaction_id'];
|
||||||
$entry->second_party_id = $journal['second_party_id'];
|
|
||||||
}
|
}
|
||||||
if(isset($journal['tax'])) {
|
if(isset($journal['type_id'])) {
|
||||||
$entry->tax = $journal['tax'];
|
$entry->type_id = $journal['type_id'];
|
||||||
}
|
}
|
||||||
if(isset($journal['tax_receiver_id'])) {
|
if(isset($journal['unit_price'])) {
|
||||||
$entry->tax_receiver_id = $journal['tax_receiver_id'];
|
$entry->unit_price = $journal['unit_price'];
|
||||||
}
|
}
|
||||||
$entry->save();
|
$entry->save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,18 @@ class TaxesHelper {
|
|||||||
return $revenue;
|
return $revenue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function GetPiGross($start, $end) {
|
||||||
|
$revenue = 0.00;
|
||||||
|
|
||||||
|
$grosses = PISaleJournal::whereBetween('date', [$start, $end]);
|
||||||
|
|
||||||
|
foreach($grosses as $gross) {
|
||||||
|
$revenue += ($gross['quantity'] * $gross['unit_price']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $revenue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a set of dates from now until the amount of months has passed
|
* Returns a set of dates from now until the amount of months has passed
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -23,19 +23,16 @@ class PISaleJournal extends Model
|
|||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'id',
|
'id',
|
||||||
'corporation_id',
|
'corp_id',
|
||||||
'division',
|
'division',
|
||||||
'amount',
|
'client_id',
|
||||||
'balance',
|
|
||||||
'context_id',
|
|
||||||
'context_id_type',
|
|
||||||
'date',
|
'date',
|
||||||
'description',
|
'is_buy',
|
||||||
'first_party_id',
|
'journal_ref_id',
|
||||||
'reason',
|
'location_id',
|
||||||
'ref_type',
|
'quantity',
|
||||||
'second_party_id',
|
'transaction_id',
|
||||||
'tax',
|
'type_id',
|
||||||
'tax_receiver_id',
|
'unit_price',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,20 +16,17 @@ class CreatePiSaleJournalsTable extends Migration
|
|||||||
if(!Schema::hasTable('pi_sale_journal')) {
|
if(!Schema::hasTable('pi_sale_journal')) {
|
||||||
Schema::create('pi_sale_journal', function(Blueprint $table) {
|
Schema::create('pi_sale_journal', function(Blueprint $table) {
|
||||||
$table->string('id')->unique();
|
$table->string('id')->unique();
|
||||||
$table->integer('corporation_id')->nullabe();
|
$table->integer('corp_id');
|
||||||
$table->integer('division')->default(0);
|
$table->integer('division');
|
||||||
$table->decimal('amount', 20, 2)->nullable();
|
$table->integer('client_id');
|
||||||
$table->decimal('balance', 20, 2)->nullable();
|
$table->string('date');
|
||||||
$table->bigInteger('context_id')->nullable();
|
$table->boolean('is_buy');
|
||||||
$table->string('context_id_type')->nullable();
|
$table->integer('journal_ref_id');
|
||||||
$table->dateTime('date')->nullabe();
|
$table->integer('location_id');
|
||||||
$table->string('description')->nullabe();
|
$table->integer('quantity');
|
||||||
$table->integer('first_party_id')->nullable();
|
$table->integer('transaction_id');
|
||||||
$table->string('reason')->default(' ');
|
$table->integer('type_id');
|
||||||
$table->string('ref_type')->nullabe();
|
$table->decimal('unit_price');
|
||||||
$table->integer('second_party_id')->nullable();
|
|
||||||
$table->decimal('tax', 20, 2)->default(0.00);
|
|
||||||
$table->integer('tax_receiver_id')->nullable();
|
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user