Finance overview page added to admin with monthly breakdown #130

This commit is contained in:
Nabeel Shahzad
2018-03-05 19:55:48 -06:00
parent 01af6f6855
commit 505931736c
18 changed files with 276 additions and 31 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use App\Models\Enums\JournalType;
use App\Models\Traits\JournalTrait;
/**
@@ -15,6 +16,11 @@ class Airline extends BaseModel
public $table = 'airlines';
/**
* The journal type for the callback
*/
public $journal_type = JournalType::AIRLINE;
public $fillable = [
'icao',
'iata',

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Models\Enums;
/**
* Class AcarsType
* @package App\Models\Enums
*/
class JournalType extends EnumBase
{
public const AIRLINE = 0;
public const USER = 1;
}

View File

@@ -12,20 +12,26 @@ use Carbon\Carbon;
/**
* Class Journal
* @package Scottlaurent\Accounting
* @property Money $balance
* @property string $currency
* @property Carbon $updated_at
* @property Carbon $post_date
* @property Carbon $created_at
* @property Money $balance
* @property string $currency
* @property Carbon $updated_at
* @property Carbon $post_date
* @property Carbon $created_at
* @property \App\Models\Enums\JournalType type
*/
class Journal extends BaseModel
{
/**
* @var string
*/
protected $table = 'journals';
public $fillable = [
'ledger_id',
'journal_type',
'balance',
'currency',
'morphed_type',
'morphed_id',
];
/**
* @var array
*/

View File

@@ -14,6 +14,7 @@ class SubfleetExpense extends BaseModel
'subfleet_id',
'name',
'amount',
'type',
];
/**
@@ -23,6 +24,7 @@ class SubfleetExpense extends BaseModel
*/
protected $casts = [
'amount' => 'float',
'type' => 'integer',
];
public static $rules = [

View File

@@ -38,6 +38,7 @@ trait JournalTrait
{
if (!$this->journal) {
$journal = new Journal();
$journal->type = $this->journal_type;
$journal->currency = $currency_code;
$journal->balance = 0;
$this->journal()->save($journal);

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use App\Models\Enums\JournalType;
use App\Models\Enums\PirepState;
use App\Models\Traits\JournalTrait;
use Illuminate\Foundation\Auth\User as Authenticatable;
@@ -32,6 +33,11 @@ class User extends Authenticatable
public $table = 'users';
/**
* The journal type for when it's being created
*/
public $journal_type = JournalType::USER;
protected $fillable = [
'name',
'email',