2018-03-06 04:18:54 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Controller;
|
2018-03-06 09:55:48 +08:00
|
|
|
use App\Models\Enums\JournalType;
|
|
|
|
use App\Models\Journal;
|
|
|
|
use App\Repositories\AirlineRepository;
|
2019-08-27 02:55:59 +08:00
|
|
|
use App\Services\FinanceService;
|
2018-03-06 09:55:48 +08:00
|
|
|
use App\Support\Dates;
|
2018-03-06 04:18:54 +08:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
2018-03-20 09:50:40 +08:00
|
|
|
class FinanceController extends Controller
|
2018-03-06 04:18:54 +08:00
|
|
|
{
|
2018-03-20 09:50:40 +08:00
|
|
|
private $airlineRepo;
|
2019-08-27 02:55:59 +08:00
|
|
|
private $financeSvc;
|
2018-03-06 04:18:54 +08:00
|
|
|
|
|
|
|
/**
|
2018-08-27 00:40:04 +08:00
|
|
|
* @param AirlineRepository $airlineRepo
|
2019-08-27 02:55:59 +08:00
|
|
|
* @param FinanceService $financeSvc
|
2018-03-06 04:18:54 +08:00
|
|
|
*/
|
|
|
|
public function __construct(
|
2019-08-27 02:55:59 +08:00
|
|
|
AirlineRepository $airlineRepo,
|
|
|
|
FinanceService $financeSvc
|
2018-03-06 04:18:54 +08:00
|
|
|
) {
|
2018-03-06 09:55:48 +08:00
|
|
|
$this->airlineRepo = $airlineRepo;
|
2019-08-27 02:55:59 +08:00
|
|
|
$this->financeSvc = $financeSvc;
|
2018-03-06 04:18:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-03-06 09:55:48 +08:00
|
|
|
* Display the summation tables for a given month by airline
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-03-06 09:55:48 +08:00
|
|
|
* @param Request $request
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-03-06 09:55:48 +08:00
|
|
|
* @throws \UnexpectedValueException
|
|
|
|
* @throws \InvalidArgumentException
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
|
|
|
* @return mixed
|
2018-03-06 04:18:54 +08:00
|
|
|
*/
|
|
|
|
public function index(Request $request)
|
|
|
|
{
|
2018-03-06 09:55:48 +08:00
|
|
|
$month = $request->query('month', date('Y-m'));
|
2019-12-11 02:53:55 +08:00
|
|
|
$transaction_groups = $this->financeSvc->getAllAirlineTransactionsBetween($month);
|
2018-03-06 04:18:54 +08:00
|
|
|
|
2019-12-11 02:53:55 +08:00
|
|
|
$first_journal = Journal::select(['created_at'])
|
|
|
|
->where(['type' => JournalType::AIRLINE])
|
2018-03-06 09:55:48 +08:00
|
|
|
->orderBy('created_at', 'asc')
|
|
|
|
->limit(1)
|
|
|
|
->first();
|
|
|
|
|
|
|
|
return view('admin.finances.index', [
|
2018-03-20 09:50:40 +08:00
|
|
|
'current_month' => $month,
|
|
|
|
'months_list' => Dates::getMonthsList($first_journal->created_at),
|
2018-03-06 09:55:48 +08:00
|
|
|
'transaction_groups' => $transaction_groups,
|
|
|
|
]);
|
2018-03-06 04:18:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a month
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
|
|
|
* @param mixed $id
|
2018-03-06 04:18:54 +08:00
|
|
|
*/
|
|
|
|
public function show($id)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|