v2 first commit
This commit is contained in:
91
app/Utilities/Reports.php
Normal file
91
app/Utilities/Reports.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
use App\Models\Module\Module;
|
||||
|
||||
class Reports
|
||||
{
|
||||
public static function getClasses()
|
||||
{
|
||||
$classes = [];
|
||||
|
||||
$core_classes = [
|
||||
'App\Reports\IncomeSummary',
|
||||
'App\Reports\ExpenseSummary',
|
||||
'App\Reports\IncomeExpenseSummary',
|
||||
'App\Reports\TaxSummary',
|
||||
'App\Reports\ProfitLoss',
|
||||
];
|
||||
|
||||
static::parseClasses($classes, $core_classes);
|
||||
|
||||
$modules = Module::enabled()->get();
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$m = module($module->alias);
|
||||
|
||||
// Check if the module exists and has reports
|
||||
if (!$m || empty($m->get('reports'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
static::parseClasses($classes, $m->get('reports'));
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
protected static function parseClasses(&$classes, $list)
|
||||
{
|
||||
foreach ($list as $class) {
|
||||
if (!class_exists($class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$name = (new $class())->getName();
|
||||
|
||||
$classes[$class] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getGroups()
|
||||
{
|
||||
return [
|
||||
'category' => trans_choice('general.categories', 1),
|
||||
'account' => trans_choice('general.accounts', 1),
|
||||
'customer' => trans_choice('general.customers', 1),
|
||||
'vendor' => trans_choice('general.vendors', 1),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPeriods()
|
||||
{
|
||||
return [
|
||||
'monthly' => trans('general.monthly'),
|
||||
'quarterly' => trans('general.quarterly'),
|
||||
'yearly' => trans('general.yearly'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getBasises()
|
||||
{
|
||||
return [
|
||||
'accrual' => trans('general.accrual'),
|
||||
'cash' => trans('general.cash'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCharts()
|
||||
{
|
||||
return [
|
||||
'0' => trans('general.disabled'),
|
||||
'line' => trans('reports.charts.line'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getClassInstance($report, $get_totals = true)
|
||||
{
|
||||
return (new $report->class($report, $get_totals));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user