Finance overview page added to admin with monthly breakdown #130
This commit is contained in:
@@ -30,6 +30,7 @@ class CreateSubfleetTables extends Migration
|
|||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->unsignedBigInteger('subfleet_id');
|
$table->unsignedBigInteger('subfleet_id');
|
||||||
$table->string('name', 50);
|
$table->string('name', 50);
|
||||||
|
$table->unsignedTinyInteger('type'); # ExpenseType
|
||||||
$table->unsignedDecimal('amount');
|
$table->unsignedDecimal('amount');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class CreateJournalsTable extends Migration
|
|||||||
Schema::create('journals', function (Blueprint $table) {
|
Schema::create('journals', function (Blueprint $table) {
|
||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->unsignedInteger('ledger_id')->nullable();
|
$table->unsignedInteger('ledger_id')->nullable();
|
||||||
|
$table->unsignedTinyInteger('type')->default(0);
|
||||||
$table->bigInteger('balance')->default(0);
|
$table->bigInteger('balance')->default(0);
|
||||||
$table->string('currency', 5);
|
$table->string('currency', 5);
|
||||||
$table->nullableMorphs('morphed');
|
$table->nullableMorphs('morphed');
|
||||||
|
|||||||
@@ -441,6 +441,7 @@ pirep_comments:
|
|||||||
journals:
|
journals:
|
||||||
- id: '1'
|
- id: '1'
|
||||||
ledger_id: null
|
ledger_id: null
|
||||||
|
type: 0
|
||||||
balance: '15840000'
|
balance: '15840000'
|
||||||
currency: USD
|
currency: USD
|
||||||
morphed_type: App\Models\Airline
|
morphed_type: App\Models\Airline
|
||||||
@@ -449,6 +450,7 @@ journals:
|
|||||||
updated_at: now
|
updated_at: now
|
||||||
- id: '2'
|
- id: '2'
|
||||||
ledger_id: null
|
ledger_id: null
|
||||||
|
type: 1
|
||||||
balance: '30000'
|
balance: '30000'
|
||||||
currency: USD
|
currency: USD
|
||||||
morphed_type: App\Models\User
|
morphed_type: App\Models\User
|
||||||
@@ -458,7 +460,7 @@ journals:
|
|||||||
|
|
||||||
journal_transactions:
|
journal_transactions:
|
||||||
- id: 81e9d86c-fede-467d-befd-887e046d9c48
|
- id: 81e9d86c-fede-467d-befd-887e046d9c48
|
||||||
transaction_group: fares
|
transaction_group: Fares
|
||||||
journal_id: '1'
|
journal_id: '1'
|
||||||
credit: '6000000'
|
credit: '6000000'
|
||||||
debit: '0'
|
debit: '0'
|
||||||
@@ -471,7 +473,7 @@ journal_transactions:
|
|||||||
post_date: now
|
post_date: now
|
||||||
deleted_at: null
|
deleted_at: null
|
||||||
- id: b12a81a9-1273-4413-a46a-96b2925cfefb
|
- id: b12a81a9-1273-4413-a46a-96b2925cfefb
|
||||||
transaction_group: fares
|
transaction_group: Fares
|
||||||
journal_id: '1'
|
journal_id: '1'
|
||||||
credit: '1100000'
|
credit: '1100000'
|
||||||
debit: '0'
|
debit: '0'
|
||||||
@@ -484,7 +486,7 @@ journal_transactions:
|
|||||||
post_date: now
|
post_date: now
|
||||||
deleted_at: null
|
deleted_at: null
|
||||||
- id: 8688ff40-aed4-4d60-90b7-0c5a88c12fbc
|
- id: 8688ff40-aed4-4d60-90b7-0c5a88c12fbc
|
||||||
transaction_group: fares
|
transaction_group: Fares
|
||||||
journal_id: '1'
|
journal_id: '1'
|
||||||
credit: '1000000'
|
credit: '1000000'
|
||||||
debit: '0'
|
debit: '0'
|
||||||
@@ -497,7 +499,7 @@ journal_transactions:
|
|||||||
post_date: now
|
post_date: now
|
||||||
deleted_at: null
|
deleted_at: null
|
||||||
- id: d34a9d1e-0d54-4191-bf9f-0043062c04c9
|
- id: d34a9d1e-0d54-4191-bf9f-0043062c04c9
|
||||||
transaction_group: expenses
|
transaction_group: Expenses
|
||||||
journal_id: '1'
|
journal_id: '1'
|
||||||
credit: null
|
credit: null
|
||||||
debit: '10000'
|
debit: '10000'
|
||||||
@@ -510,7 +512,7 @@ journal_transactions:
|
|||||||
post_date: now
|
post_date: now
|
||||||
deleted_at: null
|
deleted_at: null
|
||||||
- id: bdc9d50d-ac3d-4334-997c-8f13b8328ab8
|
- id: bdc9d50d-ac3d-4334-997c-8f13b8328ab8
|
||||||
transaction_group: expenses
|
transaction_group: Expenses
|
||||||
journal_id: '1'
|
journal_id: '1'
|
||||||
credit: null
|
credit: null
|
||||||
debit: '10000'
|
debit: '10000'
|
||||||
@@ -523,7 +525,7 @@ journal_transactions:
|
|||||||
post_date: now
|
post_date: now
|
||||||
deleted_at: null
|
deleted_at: null
|
||||||
- id: b5c45ad5-af73-4d7c-9352-3dfb8de292a0
|
- id: b5c45ad5-af73-4d7c-9352-3dfb8de292a0
|
||||||
transaction_group: expenses
|
transaction_group: Expenses
|
||||||
journal_id: '1'
|
journal_id: '1'
|
||||||
credit: null
|
credit: null
|
||||||
debit: '20000'
|
debit: '20000'
|
||||||
@@ -536,12 +538,12 @@ journal_transactions:
|
|||||||
post_date: now
|
post_date: now
|
||||||
deleted_at: null
|
deleted_at: null
|
||||||
- id: e65083f9-23c3-4e98-8d63-cd7f35732f7b
|
- id: e65083f9-23c3-4e98-8d63-cd7f35732f7b
|
||||||
transaction_group: ground_handling
|
transaction_group: Ground Handling
|
||||||
journal_id: '1'
|
journal_id: '1'
|
||||||
credit: null
|
credit: null
|
||||||
debit: '75000'
|
debit: '75000'
|
||||||
currency: USD
|
currency: USD
|
||||||
memo: 'Ground handling'
|
memo: 'Ground Handling'
|
||||||
ref_class: App\Models\Pirep
|
ref_class: App\Models\Pirep
|
||||||
ref_class_id: pirepid_1
|
ref_class_id: pirepid_1
|
||||||
created_at: now
|
created_at: now
|
||||||
@@ -549,7 +551,7 @@ journal_transactions:
|
|||||||
post_date: now
|
post_date: now
|
||||||
deleted_at: null
|
deleted_at: null
|
||||||
- id: 9825a96e-58b5-465f-8fb8-4c8e1e5567eb
|
- id: 9825a96e-58b5-465f-8fb8-4c8e1e5567eb
|
||||||
transaction_group: pilot_pay
|
transaction_group: Pilot Pay
|
||||||
journal_id: '1'
|
journal_id: '1'
|
||||||
credit: null
|
credit: null
|
||||||
debit: '15000'
|
debit: '15000'
|
||||||
@@ -562,7 +564,7 @@ journal_transactions:
|
|||||||
post_date: now
|
post_date: now
|
||||||
deleted_at: null
|
deleted_at: null
|
||||||
- id: 2e3118b3-c98f-41d1-b2b6-ccb4f34e86b0
|
- id: 2e3118b3-c98f-41d1-b2b6-ccb4f34e86b0
|
||||||
transaction_group: pilot_pay
|
transaction_group: Pilot Pay
|
||||||
journal_id: '2'
|
journal_id: '2'
|
||||||
credit: '15000'
|
credit: '15000'
|
||||||
debit: null
|
debit: null
|
||||||
@@ -575,7 +577,7 @@ journal_transactions:
|
|||||||
post_date: now
|
post_date: now
|
||||||
deleted_at: null
|
deleted_at: null
|
||||||
- id: b98a837a-aa59-4630-a547-5a9d90b5b541
|
- id: b98a837a-aa59-4630-a547-5a9d90b5b541
|
||||||
transaction_group: subfleet_expense
|
transaction_group: Subfleet Expense
|
||||||
journal_id: 1
|
journal_id: 1
|
||||||
credit: null
|
credit: null
|
||||||
debit: 100000
|
debit: 100000
|
||||||
|
|||||||
@@ -2,8 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use App\Models\Enums\JournalType;
|
||||||
|
use App\Models\Journal;
|
||||||
|
use App\Models\JournalTransaction;
|
||||||
|
use App\Repositories\AirlineRepository;
|
||||||
use App\Repositories\JournalRepository;
|
use App\Repositories\JournalRepository;
|
||||||
use App\Services\FinanceService;
|
use App\Services\FinanceService;
|
||||||
|
use App\Support\Dates;
|
||||||
|
use App\Support\Money;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,7 +18,8 @@ use Illuminate\Http\Request;
|
|||||||
*/
|
*/
|
||||||
class FinanceController extends BaseController
|
class FinanceController extends BaseController
|
||||||
{
|
{
|
||||||
private $financeSvc,
|
private $airlineRepo,
|
||||||
|
$financeSvc,
|
||||||
$journalRepo;
|
$journalRepo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,19 +27,73 @@ class FinanceController extends BaseController
|
|||||||
* @param JournalRepository $journalRepo
|
* @param JournalRepository $journalRepo
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
AirlineRepository $airlineRepo,
|
||||||
FinanceService $financeSvc,
|
FinanceService $financeSvc,
|
||||||
JournalRepository $journalRepo
|
JournalRepository $journalRepo
|
||||||
) {
|
) {
|
||||||
|
$this->airlineRepo = $airlineRepo;
|
||||||
$this->financeSvc = $financeSvc;
|
$this->financeSvc = $financeSvc;
|
||||||
$this->journalRepo = $journalRepo;
|
$this->journalRepo = $journalRepo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a listing of the Aircraft.
|
* Display the summation tables for a given month by airline
|
||||||
|
* @param Request $request
|
||||||
|
* @return mixed
|
||||||
|
* @throws \UnexpectedValueException
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
|
$month = $request->query('month', date('Y-m'));
|
||||||
|
$between = Dates::getMonthBoundary($month);
|
||||||
|
|
||||||
|
$first_journal = Journal::where(['type' => JournalType::AIRLINE])
|
||||||
|
->orderBy('created_at', 'asc')
|
||||||
|
->limit(1)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$transaction_groups = [];
|
||||||
|
$airlines = $this->airlineRepo->orderBy('icao')->all();
|
||||||
|
|
||||||
|
# group by the airline
|
||||||
|
foreach($airlines as $airline) {
|
||||||
|
|
||||||
|
# Return all the transactions, grouped by the transaction group
|
||||||
|
$transactions = JournalTransaction::groupBy('transaction_group')
|
||||||
|
->selectRaw('transaction_group, currency,
|
||||||
|
SUM(credit) as sum_credits,
|
||||||
|
SUM(debit) as sum_debits')
|
||||||
|
->where([
|
||||||
|
'journal_id' => $airline->journal->id
|
||||||
|
])
|
||||||
|
->whereBetween('created_at', $between, 'AND')
|
||||||
|
->orderBy('sum_credits', 'desc')
|
||||||
|
->orderBy('sum_debits', 'desc')
|
||||||
|
->orderBy('transaction_group', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
# Summate it so we can show it on the footer of the table
|
||||||
|
$sum_all_credits = 0;
|
||||||
|
$sum_all_debits = 0;
|
||||||
|
foreach ($transactions as $ta) {
|
||||||
|
$sum_all_credits += $ta->sum_credits ?? 0;
|
||||||
|
$sum_all_debits += $ta->sum_debits ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$transaction_groups[] = [
|
||||||
|
'airline' => $airline,
|
||||||
|
'credits' => new Money($sum_all_credits),
|
||||||
|
'debits' => new Money($sum_all_debits),
|
||||||
|
'transactions' => $transactions,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('admin.finances.index', [
|
||||||
|
'current_month' => $month,
|
||||||
|
'months_list' => Dates::getMonthsList($first_journal->created_at),
|
||||||
|
'transaction_groups' => $transaction_groups,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,9 +19,11 @@ class ExpenseListener
|
|||||||
|
|
||||||
# This is an example of an expense to return
|
# This is an example of an expense to return
|
||||||
# You have the pirep on $event->pirep, and any associated data
|
# You have the pirep on $event->pirep, and any associated data
|
||||||
|
# The transaction group is how it will show as a line item
|
||||||
/*$expenses[] = new Expense([
|
/*$expenses[] = new Expense([
|
||||||
'type' => ExpenseType::FLIGHT,
|
'type' => ExpenseType::FLIGHT,
|
||||||
'amount' => 15000 # $150
|
'amount' => 15000, # $150
|
||||||
|
'transaction_group' => '',
|
||||||
]);*/
|
]);*/
|
||||||
|
|
||||||
return $expenses;
|
return $expenses;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\Enums\JournalType;
|
||||||
use App\Models\Traits\JournalTrait;
|
use App\Models\Traits\JournalTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,6 +16,11 @@ class Airline extends BaseModel
|
|||||||
|
|
||||||
public $table = 'airlines';
|
public $table = 'airlines';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The journal type for the callback
|
||||||
|
*/
|
||||||
|
public $journal_type = JournalType::AIRLINE;
|
||||||
|
|
||||||
public $fillable = [
|
public $fillable = [
|
||||||
'icao',
|
'icao',
|
||||||
'iata',
|
'iata',
|
||||||
|
|||||||
13
app/Models/Enums/JournalType.php
Normal file
13
app/Models/Enums/JournalType.php
Normal 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;
|
||||||
|
}
|
||||||
@@ -12,20 +12,26 @@ use Carbon\Carbon;
|
|||||||
/**
|
/**
|
||||||
* Class Journal
|
* Class Journal
|
||||||
* @package Scottlaurent\Accounting
|
* @package Scottlaurent\Accounting
|
||||||
* @property Money $balance
|
* @property Money $balance
|
||||||
* @property string $currency
|
* @property string $currency
|
||||||
* @property Carbon $updated_at
|
* @property Carbon $updated_at
|
||||||
* @property Carbon $post_date
|
* @property Carbon $post_date
|
||||||
* @property Carbon $created_at
|
* @property Carbon $created_at
|
||||||
|
* @property \App\Models\Enums\JournalType type
|
||||||
*/
|
*/
|
||||||
class Journal extends BaseModel
|
class Journal extends BaseModel
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $table = 'journals';
|
protected $table = 'journals';
|
||||||
|
|
||||||
|
public $fillable = [
|
||||||
|
'ledger_id',
|
||||||
|
'journal_type',
|
||||||
|
'balance',
|
||||||
|
'currency',
|
||||||
|
'morphed_type',
|
||||||
|
'morphed_id',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class SubfleetExpense extends BaseModel
|
|||||||
'subfleet_id',
|
'subfleet_id',
|
||||||
'name',
|
'name',
|
||||||
'amount',
|
'amount',
|
||||||
|
'type',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,6 +24,7 @@ class SubfleetExpense extends BaseModel
|
|||||||
*/
|
*/
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'amount' => 'float',
|
'amount' => 'float',
|
||||||
|
'type' => 'integer',
|
||||||
];
|
];
|
||||||
|
|
||||||
public static $rules = [
|
public static $rules = [
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ trait JournalTrait
|
|||||||
{
|
{
|
||||||
if (!$this->journal) {
|
if (!$this->journal) {
|
||||||
$journal = new Journal();
|
$journal = new Journal();
|
||||||
|
$journal->type = $this->journal_type;
|
||||||
$journal->currency = $currency_code;
|
$journal->currency = $currency_code;
|
||||||
$journal->balance = 0;
|
$journal->balance = 0;
|
||||||
$this->journal()->save($journal);
|
$this->journal()->save($journal);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Models\Enums\JournalType;
|
||||||
use App\Models\Enums\PirepState;
|
use App\Models\Enums\PirepState;
|
||||||
use App\Models\Traits\JournalTrait;
|
use App\Models\Traits\JournalTrait;
|
||||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
@@ -32,6 +33,11 @@ class User extends Authenticatable
|
|||||||
|
|
||||||
public $table = 'users';
|
public $table = 'users';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The journal type for when it's being created
|
||||||
|
*/
|
||||||
|
public $journal_type = JournalType::USER;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
'email',
|
'email',
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class JournalRepository extends BaseRepository implements CacheableInterface
|
|||||||
'debit' => $debit ? $debit->getAmount():null,
|
'debit' => $debit ? $debit->getAmount():null,
|
||||||
'currency' => config('phpvms.currency'),
|
'currency' => config('phpvms.currency'),
|
||||||
'memo' => $memo,
|
'memo' => $memo,
|
||||||
'post_date' => $post_date ?: Carbon::now(),
|
'post_date' => $post_date ?? Carbon::now(),
|
||||||
];
|
];
|
||||||
|
|
||||||
if($reference !== null) {
|
if($reference !== null) {
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class FinanceService extends BaseService
|
|||||||
'Fares ' . $fare->code . $fare->count
|
'Fares ' . $fare->code . $fare->count
|
||||||
.'; price: '.$fare->price.', cost: '.$fare->cost,
|
.'; price: '.$fare->price.', cost: '.$fare->cost,
|
||||||
null,
|
null,
|
||||||
'fares'
|
'Fares'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ class FinanceService extends BaseService
|
|||||||
$pirep,
|
$pirep,
|
||||||
'Expense: ' . $expense->name,
|
'Expense: ' . $expense->name,
|
||||||
null,
|
null,
|
||||||
'expenses'
|
'Expenses'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,7 +198,7 @@ class FinanceService extends BaseService
|
|||||||
$pirep,
|
$pirep,
|
||||||
'Subfleet ('.$subfleet->type.'): '.$expense->name,
|
'Subfleet ('.$subfleet->type.'): '.$expense->name,
|
||||||
null,
|
null,
|
||||||
'subfleet_expense'
|
'Subfleet Expense'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,7 +221,7 @@ class FinanceService extends BaseService
|
|||||||
$pirep,
|
$pirep,
|
||||||
'Ground Handling',
|
'Ground Handling',
|
||||||
null,
|
null,
|
||||||
'ground_handling'
|
'Ground Handling'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ class FinanceService extends BaseService
|
|||||||
$pirep,
|
$pirep,
|
||||||
$memo,
|
$memo,
|
||||||
null,
|
null,
|
||||||
'pilot_pay'
|
'Pilot Pay'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->journalRepo->post(
|
$this->journalRepo->post(
|
||||||
@@ -259,7 +259,7 @@ class FinanceService extends BaseService
|
|||||||
$pirep,
|
$pirep,
|
||||||
$memo,
|
$memo,
|
||||||
null,
|
null,
|
||||||
'pilot_pay'
|
'Pilot Pay'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
47
app/Support/Dates.php
Normal file
47
app/Support/Dates.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Support;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class Dates
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the list of months, given a start date
|
||||||
|
* @param Carbon $start_date
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getMonthsList(Carbon $start_date)
|
||||||
|
{
|
||||||
|
$months = [];
|
||||||
|
$now = date('Y-m');
|
||||||
|
$last_month = $start_date;
|
||||||
|
|
||||||
|
do {
|
||||||
|
$last_value = $last_month->format('Y-m');
|
||||||
|
$months[$last_value] = $last_month->format ('Y F');
|
||||||
|
$last_month = $last_month->addMonth();
|
||||||
|
} while($last_value !== $now);
|
||||||
|
|
||||||
|
return $months;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the start/end dates for a given month/year
|
||||||
|
* @param $month YYYY-MM
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getMonthBoundary($month)
|
||||||
|
{
|
||||||
|
[$year, $month] = explode('-', $month);
|
||||||
|
$days = cal_days_in_month(CAL_GREGORIAN, $month, $year);
|
||||||
|
|
||||||
|
return [
|
||||||
|
"$year-$month-01",
|
||||||
|
"$year-$month-$days"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
24
resources/views/admin/finances/index.blade.php
Normal file
24
resources/views/admin/finances/index.blade.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
@extends('admin.app')
|
||||||
|
|
||||||
|
@section('title', 'Financial Reports')
|
||||||
|
@section('actions')
|
||||||
|
<li><a href="{!! route('admin.finances.index') !!}"><i class="ti-menu-alt"></i>Overview</a></li>
|
||||||
|
@endsection
|
||||||
|
@section('content')
|
||||||
|
<div class="card border-blue-bottom">
|
||||||
|
<div class="content">
|
||||||
|
<div style="float:right;">
|
||||||
|
{!! Form::select(
|
||||||
|
'month_select',
|
||||||
|
$months_list,
|
||||||
|
$current_month,
|
||||||
|
['id' => 'month_select']
|
||||||
|
) !!}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@include('admin.finances.table')
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
@include('admin.finances.scripts')
|
||||||
12
resources/views/admin/finances/scripts.blade.php
Normal file
12
resources/views/admin/finances/scripts.blade.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
@section('scripts')
|
||||||
|
<script>
|
||||||
|
$(document).ready(() => {
|
||||||
|
const select_id = "select#month_select";
|
||||||
|
$(select_id).change((e) => {
|
||||||
|
const date = $(select_id + " option:selected").val();
|
||||||
|
const location = window.location.toString().split('?')[0];
|
||||||
|
window.location = location + '?month='+date;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
61
resources/views/admin/finances/table.blade.php
Normal file
61
resources/views/admin/finances/table.blade.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
|
||||||
|
@foreach($transaction_groups as $group)
|
||||||
|
|
||||||
|
<h4>{!! $group['airline']->icao !!} - {!! $group['airline']->name !!}</h4>
|
||||||
|
|
||||||
|
<table class="table table-hover table-responsive" id="finances-table">
|
||||||
|
<thead>
|
||||||
|
<th>Expenses</th>
|
||||||
|
<th>Credit</th>
|
||||||
|
<th>Debit</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach($group['transactions'] as $ta)
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{!! $ta->transaction_group !!}
|
||||||
|
</td>
|
||||||
|
<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>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
{{-- show sums --}}
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
{!! $group['credits'] !!}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
({!! $group['debits'] !!})
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{{-- final total --}}
|
||||||
|
<tr style="border-top: 3px; border-top-style: double;">
|
||||||
|
<td></td>
|
||||||
|
<td><b>Total</b></td>
|
||||||
|
<td>
|
||||||
|
{!! $group['credits']->subtract($group['debits']) !!}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
@if(!$loop->last)
|
||||||
|
<hr>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
{{-- final total --}}
|
{{-- final total --}}
|
||||||
<tr>
|
<tr style="border-top: 3px; border-top-style: double;">
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><b>Total</b></td>
|
<td><b>Total</b></td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user