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