added setting funciton for reports
This commit is contained in:
parent
64d065785e
commit
6d6bf1f393
@ -142,17 +142,17 @@ abstract class Report
|
||||
{
|
||||
$chart = new Chartjs();
|
||||
|
||||
if (empty($this->model->settings->chart)) {
|
||||
if (!$type = $this->getSetting('chart')) {
|
||||
return $chart;
|
||||
}
|
||||
|
||||
$config = $this->chart[$this->model->settings->chart];
|
||||
$config = $this->chart[$type];
|
||||
|
||||
$default_options = $this->getLineChartOptions();
|
||||
|
||||
$options = array_merge($default_options, (array) $config['options']);
|
||||
|
||||
$chart->type($this->model->settings->chart)
|
||||
$chart->type($type)
|
||||
->width((int) $config['width'])
|
||||
->height((int) $config['height'])
|
||||
->options($options)
|
||||
@ -199,13 +199,13 @@ abstract class Report
|
||||
|
||||
public function setColumnWidth()
|
||||
{
|
||||
if (empty($this->model->settings->period)) {
|
||||
if (!$period = $this->getSetting('period')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$width = '';
|
||||
|
||||
switch ($this->model->settings->period) {
|
||||
switch ($period) {
|
||||
case 'quarterly':
|
||||
$width = 'col-sm-2';
|
||||
break;
|
||||
@ -253,16 +253,16 @@ abstract class Report
|
||||
|
||||
public function setDates()
|
||||
{
|
||||
if (empty($this->model->settings->period)) {
|
||||
if (!$period = $this->getSetting('period')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$function = 'sub' . ucfirst(str_replace('ly', '', $this->model->settings->period));
|
||||
$function = 'sub' . ucfirst(str_replace('ly', '', $period));
|
||||
|
||||
$start = $this->getFinancialStart()->copy()->$function();
|
||||
|
||||
for ($j = 1; $j <= 12; $j++) {
|
||||
switch ($this->model->settings->period) {
|
||||
switch ($period) {
|
||||
case 'yearly':
|
||||
$start->addYear();
|
||||
|
||||
@ -332,7 +332,7 @@ abstract class Report
|
||||
|
||||
$date = $this->getFormattedDate(Date::parse($item->$date_field));
|
||||
|
||||
$id_field = $this->model->settings->group . '_id';
|
||||
$id_field = $this->getSetting('group') . '_id';
|
||||
|
||||
if (
|
||||
!isset($this->row_values[$table][$item->$id_field])
|
||||
@ -374,7 +374,7 @@ abstract class Report
|
||||
|
||||
public function getFormattedDate($date)
|
||||
{
|
||||
switch ($this->model->settings->period) {
|
||||
switch ($this->getSetting('period')) {
|
||||
case 'yearly':
|
||||
$i = $date->copy()->format($this->getYearlyDateFormat());
|
||||
break;
|
||||
@ -411,6 +411,11 @@ abstract class Report
|
||||
return $print_url;
|
||||
}
|
||||
|
||||
public function getSetting($name, $default = '')
|
||||
{
|
||||
return $this->model->settings->$name ?? $default;
|
||||
}
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
return [
|
||||
|
@ -32,7 +32,7 @@ class ExpenseSummary extends Report
|
||||
{
|
||||
$transactions = $this->applyFilters(Transaction::with('recurring')->expense()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||
|
||||
switch ($this->model->settings->basis) {
|
||||
switch ($this->getSetting('basis')) {
|
||||
case 'cash':
|
||||
// Payments
|
||||
$payments = $transactions->get();
|
||||
|
@ -19,7 +19,7 @@ class IncomeExpenseSummary extends Report
|
||||
$income_transactions = $this->applyFilters(Transaction::with('recurring')->income()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||
$expense_transactions = $this->applyFilters(Transaction::with('recurring')->expense()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||
|
||||
switch ($this->model->settings->basis) {
|
||||
switch ($this->getSetting('basis')) {
|
||||
case 'cash':
|
||||
// Revenues
|
||||
$revenues = $income_transactions->get();
|
||||
|
@ -32,7 +32,7 @@ class IncomeSummary extends Report
|
||||
{
|
||||
$transactions = $this->applyFilters(Transaction::with('recurring')->income()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||
|
||||
switch ($this->model->settings->basis) {
|
||||
switch ($this->getSetting('basis')) {
|
||||
case 'cash':
|
||||
// Revenues
|
||||
$revenues = $transactions->get();
|
||||
|
@ -38,7 +38,7 @@ class ProfitLoss extends Report
|
||||
$income_transactions = $this->applyFilters(Transaction::with('recurring')->income()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||
$expense_transactions = $this->applyFilters(Transaction::with('recurring')->expense()->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||
|
||||
switch ($this->model->settings->basis) {
|
||||
switch ($this->getSetting('basis')) {
|
||||
case 'cash':
|
||||
// Revenues
|
||||
$revenues = $income_transactions->get();
|
||||
|
@ -39,7 +39,7 @@ class TaxSummary extends Report
|
||||
|
||||
public function setData()
|
||||
{
|
||||
switch ($this->model->settings->basis) {
|
||||
switch ($this->getSetting('basis')) {
|
||||
case 'cash':
|
||||
// Invoice Payments
|
||||
$invoices = $this->applyFilters(Transaction::with('recurring', 'invoice', 'invoice.totals')->income()->isDocument()->isNotTransfer(), ['date_field' => 'paid_at'])->get();
|
||||
|
Loading…
x
Reference in New Issue
Block a user