Cleanup the transaction memos

This commit is contained in:
Nabeel Shahzad 2018-03-06 06:17:45 -06:00
parent 9d3953f3ac
commit 453ca5b180
8 changed files with 53 additions and 34 deletions

View File

@ -6,14 +6,10 @@ use Illuminate\Support\Facades\Schema;
class CreateExpensesTable extends Migration class CreateExpensesTable extends Migration
{ {
/**
* Run the migrations.
*
* @return void
*/
public function up() public function up()
{ {
Schema::create('expenses', function (Blueprint $table) { Schema::create('expenses', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->unsignedInteger('airline_id')->nullable(); $table->unsignedInteger('airline_id')->nullable();
@ -27,17 +23,13 @@ class CreateExpensesTable extends Migration
# EG, the airports has an internal expense for gate costs # EG, the airports has an internal expense for gate costs
$table->string('ref_class')->nullable(); $table->string('ref_class')->nullable();
$table->string('ref_class_id', 36)->nullable(); $table->string('ref_class_id', 36)->nullable();
$table->index(['ref_class', 'ref_class_id']);
$table->timestamps(); $table->timestamps();
$table->index(['ref_class', 'ref_class_id']);
}); });
} }
/**
* Reverse the migrations.
*
* @return void
*/
public function down() public function down()
{ {
Schema::dropIfExists('expenses'); Schema::dropIfExists('expenses');

View File

@ -15,17 +15,17 @@ class CreateJournalTransactionsTable extends Migration
{ {
Schema::create('journal_transactions', function (Blueprint $table) { Schema::create('journal_transactions', function (Blueprint $table) {
$table->char('id', 36)->unique(); $table->char('id', 36)->unique();
$table->char('transaction_group', 36)->nullable(); $table->string('transaction_group')->nullable();
$table->integer('journal_id'); $table->integer('journal_id');
$table->unsignedBigInteger('credit')->nullable(); $table->unsignedBigInteger('credit')->nullable();
$table->unsignedBigInteger('debit')->nullable(); $table->unsignedBigInteger('debit')->nullable();
$table->char('currency', 5); $table->char('currency', 5);
$table->text('memo')->nullable(); $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->string('ref_class_id', 36)->nullable();
$table->timestamps(); $table->timestamps();
$table->dateTime('post_date'); $table->dateTime('post_date');
$table->softDeletes();
$table->primary('id'); $table->primary('id');
$table->index('journal_id'); $table->index('journal_id');

View File

@ -23,6 +23,7 @@ class FinanceController extends BaseController
$journalRepo; $journalRepo;
/** /**
* @param AirlineRepository $airlineRepo
* @param PirepFinanceService $financeSvc * @param PirepFinanceService $financeSvc
* @param JournalRepository $journalRepo * @param JournalRepository $journalRepo
*/ */

View File

@ -156,13 +156,22 @@ class PirepFinanceService extends BaseService
$transaction_group = end($ref); $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); $debit = Money::createFromAmount($expense->amount);
$this->journalRepo->post( $this->journalRepo->post(
$pirep->airline->journal, $pirep->airline->journal,
null, null,
$debit, $debit,
$pirep, $pirep,
'Expense: ' . $expense->name, $memo,
null, null,
$transaction_group $transaction_group
); );

8
config/cron.php Normal file
View File

@ -0,0 +1,8 @@
<?php
/**
* These are for the cron tasks that run
*/
return [
'timezone' => 'UTC',
];

View File

@ -1,9 +1,13 @@
@foreach($transaction_groups as $group) @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> <thead>
<th>Expenses</th> <th>Expenses</th>
<th>Credit</th> <th>Credit</th>
@ -18,15 +22,11 @@
<td> <td>
@if($ta->sum_credits) @if($ta->sum_credits)
{!! money($ta->sum_credits, $ta->currency) !!} {!! money($ta->sum_credits, $ta->currency) !!}
@else
-
@endif @endif
</td> </td>
<td> <td>
@if($ta->sum_debits) @if($ta->sum_debits)
<i>{!! money($ta->sum_debits, $ta->currency) !!}</i> <i>{!! money($ta->sum_debits, $ta->currency) !!}</i>
@else
-
@endif @endif
</td> </td>
</tr> </tr>
@ -39,14 +39,16 @@
{!! $group['credits'] !!} {!! $group['credits'] !!}
</td> </td>
<td> <td>
({!! $group['debits'] !!}) <i>{!! $group['debits'] !!}</i>
</td> </td>
</tr> </tr>
{{-- final total --}} {{-- final total --}}
<tr style="border-top: 3px; border-top-style: double;"> <tr style="border-top: 3px; border-top-style: double;">
<td></td> <td></td>
<td><b>Total</b></td> <td align="right">
<b>Total</b>
</td>
<td> <td>
{!! $group['credits']->subtract($group['debits']) !!} {!! $group['credits']->subtract($group['debits']) !!}
</td> </td>

View File

@ -71,14 +71,14 @@ $(document).ready(() => {
}); });
$(document).on('submit', 'form.pirep_submit_status', (event) => { $(document).on('submit', 'form.pirep_submit_status', (event) => {
console.log(event);
event.preventDefault(); event.preventDefault();
const values = { const values = {
pirep_id: $(this).attr('pirep_id'), pirep_id: $(event.currentTarget).attr('pirep_id'),
new_status: $(this).attr('new_status') new_status: $(event.currentTarget).attr('new_status')
}; };
console.log('change status', values);
changeStatus(values, (data) => { changeStatus(values, (data) => {
const destContainer = '#pirep_' + values.pirep_id + '_actionbar'; const destContainer = '#pirep_' + values.pirep_id + '_actionbar';
$(destContainer).html(data); $(destContainer).html(data);
@ -87,10 +87,15 @@ $(document).ready(() => {
$(document).on('submit', 'form.pirep_change_status', (event) => { $(document).on('submit', 'form.pirep_change_status', (event) => {
event.preventDefault(); event.preventDefault();
changeStatus({
pirep_id: $(this).attr('pirep_id'), const values = {
new_status: $(this).attr('new_status') pirep_id: $(event.currentTarget).attr('pirep_id'),
}, (data) => { new_status: $(event.currentTarget).attr('new_status')
};
console.log('change status', values);
changeStatus(values, (data) => {
location.reload(); location.reload();
}); });
}); });

View File

@ -25,14 +25,16 @@
{!! $journal['credits'] !!} {!! $journal['credits'] !!}
</td> </td>
<td> <td>
({!! $journal['debits'] !!}) <i>{!! $journal['debits'] !!}</i>
</td> </td>
</tr> </tr>
{{-- final total --}} {{-- final total --}}
<tr style="border-top: 3px; border-top-style: double;"> <tr style="border-top: 3px; border-top-style: double;">
<td></td> <td></td>
<td><b>Total</b></td> <td align="right">
<b>Total</b>
</td>
<td> <td>
{!! $journal['credits']->subtract($journal['debits']) !!} {!! $journal['credits']->subtract($journal['debits']) !!}
</td> </td>