Cleanup the transaction memos
This commit is contained in:
parent
9d3953f3ac
commit
453ca5b180
@ -6,14 +6,10 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateExpensesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('expenses', function (Blueprint $table) {
|
||||
|
||||
$table->increments('id');
|
||||
$table->unsignedInteger('airline_id')->nullable();
|
||||
|
||||
@ -27,17 +23,13 @@ class CreateExpensesTable extends Migration
|
||||
# EG, the airports has an internal expense for gate costs
|
||||
$table->string('ref_class')->nullable();
|
||||
$table->string('ref_class_id', 36)->nullable();
|
||||
$table->index(['ref_class', 'ref_class_id']);
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['ref_class', 'ref_class_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('expenses');
|
||||
|
@ -15,17 +15,17 @@ class CreateJournalTransactionsTable extends Migration
|
||||
{
|
||||
Schema::create('journal_transactions', function (Blueprint $table) {
|
||||
$table->char('id', 36)->unique();
|
||||
$table->char('transaction_group', 36)->nullable();
|
||||
$table->string('transaction_group')->nullable();
|
||||
$table->integer('journal_id');
|
||||
$table->unsignedBigInteger('credit')->nullable();
|
||||
$table->unsignedBigInteger('debit')->nullable();
|
||||
$table->char('currency', 5);
|
||||
$table->text('memo')->nullable();
|
||||
$table->char('ref_class', 32)->nullable();
|
||||
$table->string('tags')->nullable();
|
||||
$table->string('ref_class', 50)->nullable();
|
||||
$table->string('ref_class_id', 36)->nullable();
|
||||
$table->timestamps();
|
||||
$table->dateTime('post_date');
|
||||
$table->softDeletes();
|
||||
|
||||
$table->primary('id');
|
||||
$table->index('journal_id');
|
||||
|
@ -23,6 +23,7 @@ class FinanceController extends BaseController
|
||||
$journalRepo;
|
||||
|
||||
/**
|
||||
* @param AirlineRepository $airlineRepo
|
||||
* @param PirepFinanceService $financeSvc
|
||||
* @param JournalRepository $journalRepo
|
||||
*/
|
||||
|
@ -145,7 +145,7 @@ class PirepFinanceService extends BaseService
|
||||
# TODO: Modify the amount
|
||||
}
|
||||
|
||||
Log::info('Finance: PIREP: ' . $pirep->id . ', expense:', $expense->toArray());
|
||||
Log::info('Finance: PIREP: '.$pirep->id.', expense:', $expense->toArray());
|
||||
|
||||
# Get the transaction group name from the ref_class name
|
||||
# This way it can be more dynamic and don't have to add special
|
||||
@ -156,13 +156,22 @@ class PirepFinanceService extends BaseService
|
||||
$transaction_group = end($ref);
|
||||
}
|
||||
|
||||
# Form the memo, with some specific ones depending on the group
|
||||
if($transaction_group === 'Airport') {
|
||||
$memo = "Airport Expense: {$expense->name} ({$expense->ref_class_id})";
|
||||
$transaction_group = "Airport: {$expense->ref_class_id}";
|
||||
} else {
|
||||
$memo = 'Expense: ' . $expense->name;
|
||||
$transaction_group = "Expense: {$expense->name}";
|
||||
}
|
||||
|
||||
$debit = Money::createFromAmount($expense->amount);
|
||||
$this->journalRepo->post(
|
||||
$pirep->airline->journal,
|
||||
null,
|
||||
$debit,
|
||||
$pirep,
|
||||
'Expense: ' . $expense->name,
|
||||
$memo,
|
||||
null,
|
||||
$transaction_group
|
||||
);
|
||||
|
8
config/cron.php
Normal file
8
config/cron.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* These are for the cron tasks that run
|
||||
*/
|
||||
|
||||
return [
|
||||
'timezone' => 'UTC',
|
||||
];
|
@ -1,9 +1,13 @@
|
||||
|
||||
@foreach($transaction_groups as $group)
|
||||
|
||||
<h4>{!! $group['airline']->icao !!} - {!! $group['airline']->name !!}</h4>
|
||||
<h3>{!! $group['airline']->icao !!} - {!! $group['airline']->name !!}</h3>
|
||||
|
||||
<table
|
||||
id="finances-table"
|
||||
style="width: 95%; margin: 0px auto;"
|
||||
class="table table-hover table-responsive">
|
||||
|
||||
<table class="table table-hover table-responsive" id="finances-table">
|
||||
<thead>
|
||||
<th>Expenses</th>
|
||||
<th>Credit</th>
|
||||
@ -18,15 +22,11 @@
|
||||
<td>
|
||||
@if($ta->sum_credits)
|
||||
{!! money($ta->sum_credits, $ta->currency) !!}
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
@if($ta->sum_debits)
|
||||
<i>{!! money($ta->sum_debits, $ta->currency) !!}</i>
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@ -39,14 +39,16 @@
|
||||
{!! $group['credits'] !!}
|
||||
</td>
|
||||
<td>
|
||||
({!! $group['debits'] !!})
|
||||
<i>{!! $group['debits'] !!}</i>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{{-- final total --}}
|
||||
<tr style="border-top: 3px; border-top-style: double;">
|
||||
<td></td>
|
||||
<td><b>Total</b></td>
|
||||
<td align="right">
|
||||
<b>Total</b>
|
||||
</td>
|
||||
<td>
|
||||
{!! $group['credits']->subtract($group['debits']) !!}
|
||||
</td>
|
||||
|
@ -71,14 +71,14 @@ $(document).ready(() => {
|
||||
});
|
||||
|
||||
$(document).on('submit', 'form.pirep_submit_status', (event) => {
|
||||
console.log(event);
|
||||
|
||||
event.preventDefault();
|
||||
const values = {
|
||||
pirep_id: $(this).attr('pirep_id'),
|
||||
new_status: $(this).attr('new_status')
|
||||
pirep_id: $(event.currentTarget).attr('pirep_id'),
|
||||
new_status: $(event.currentTarget).attr('new_status')
|
||||
};
|
||||
|
||||
console.log('change status', values);
|
||||
|
||||
changeStatus(values, (data) => {
|
||||
const destContainer = '#pirep_' + values.pirep_id + '_actionbar';
|
||||
$(destContainer).html(data);
|
||||
@ -87,10 +87,15 @@ $(document).ready(() => {
|
||||
|
||||
$(document).on('submit', 'form.pirep_change_status', (event) => {
|
||||
event.preventDefault();
|
||||
changeStatus({
|
||||
pirep_id: $(this).attr('pirep_id'),
|
||||
new_status: $(this).attr('new_status')
|
||||
}, (data) => {
|
||||
|
||||
const values = {
|
||||
pirep_id: $(event.currentTarget).attr('pirep_id'),
|
||||
new_status: $(event.currentTarget).attr('new_status')
|
||||
};
|
||||
|
||||
console.log('change status', values);
|
||||
|
||||
changeStatus(values, (data) => {
|
||||
location.reload();
|
||||
});
|
||||
});
|
||||
|
@ -25,14 +25,16 @@
|
||||
{!! $journal['credits'] !!}
|
||||
</td>
|
||||
<td>
|
||||
({!! $journal['debits'] !!})
|
||||
<i>{!! $journal['debits'] !!}</i>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{{-- final total --}}
|
||||
<tr style="border-top: 3px; border-top-style: double;">
|
||||
<td></td>
|
||||
<td><b>Total</b></td>
|
||||
<td align="right">
|
||||
<b>Total</b>
|
||||
</td>
|
||||
<td>
|
||||
{!! $journal['credits']->subtract($journal['debits']) !!}
|
||||
</td>
|
||||
|
Loading…
Reference in New Issue
Block a user