renamed function
This commit is contained in:
parent
05aba16b3d
commit
0d33ffd311
@ -84,7 +84,7 @@ abstract class Report
|
|||||||
$this->load();
|
$this->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function getTotals();
|
abstract public function setData();
|
||||||
|
|
||||||
public function load()
|
public function load()
|
||||||
{
|
{
|
||||||
@ -94,7 +94,7 @@ abstract class Report
|
|||||||
$this->setDates();
|
$this->setDates();
|
||||||
$this->setFilters();
|
$this->setFilters();
|
||||||
$this->setRows();
|
$this->setRows();
|
||||||
$this->getTotals();
|
$this->setData();
|
||||||
|
|
||||||
$this->loaded = true;
|
$this->loaded = true;
|
||||||
}
|
}
|
||||||
@ -118,20 +118,24 @@ abstract class Report
|
|||||||
return $this->icon;
|
return $this->icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotal()
|
public function getGrandTotal()
|
||||||
{
|
{
|
||||||
if (!$this->loaded) {
|
if (!$this->loaded) {
|
||||||
$this->load();
|
$this->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
$sum = 0;
|
if (!empty($this->footer_totals)) {
|
||||||
|
$sum = 0;
|
||||||
|
|
||||||
foreach ($this->footer_totals as $total) {
|
foreach ($this->footer_totals as $total) {
|
||||||
$sum += is_array($total) ? array_sum($total) : $total;
|
$sum += is_array($total) ? array_sum($total) : $total;
|
||||||
|
}
|
||||||
|
|
||||||
|
$total = money($sum, setting('default.currency'), true);
|
||||||
|
} else {
|
||||||
|
$total = trans('general.na');
|
||||||
}
|
}
|
||||||
|
|
||||||
$total = money($sum, setting('default.currency'), true);
|
|
||||||
|
|
||||||
return $total;
|
return $total;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,15 +373,15 @@ abstract class Report
|
|||||||
{
|
{
|
||||||
$print_url = 'common/reports/' . $this->model->id . '/' . $action . '?year='. $this->year;
|
$print_url = 'common/reports/' . $this->model->id . '/' . $action . '?year='. $this->year;
|
||||||
|
|
||||||
collect(request('accounts'))->each(function($item) use(&$print_url) {
|
collect(request('accounts'))->each(function($item) use (&$print_url) {
|
||||||
$print_url .= '&accounts[]=' . $item;
|
$print_url .= '&accounts[]=' . $item;
|
||||||
});
|
});
|
||||||
|
|
||||||
collect(request('customers'))->each(function($item) use(&$print_url) {
|
collect(request('customers'))->each(function($item) use (&$print_url) {
|
||||||
$print_url .= '&customers[]=' . $item;
|
$print_url .= '&customers[]=' . $item;
|
||||||
});
|
});
|
||||||
|
|
||||||
collect(request('categories'))->each(function($item) use(&$print_url) {
|
collect(request('categories'))->each(function($item) use (&$print_url) {
|
||||||
$print_url .= '&categories[]=' . $item;
|
$print_url .= '&categories[]=' . $item;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class Reports extends Controller
|
|||||||
$ttl = 3600 * 6; // 6 hours
|
$ttl = 3600 * 6; // 6 hours
|
||||||
|
|
||||||
$totals[$report->id] = Cache::remember('reports.totals.' . $report->id, $ttl, function () use ($class) {
|
$totals[$report->id] = Cache::remember('reports.totals.' . $report->id, $ttl, function () use ($class) {
|
||||||
return $class->getTotal();
|
return $class->getGrandTotal();
|
||||||
});
|
});
|
||||||
|
|
||||||
$icons[$report->id] = $class->getIcon();
|
$icons[$report->id] = $class->getIcon();
|
||||||
@ -63,7 +63,7 @@ class Reports extends Controller
|
|||||||
$class = Utility::getClassInstance($report);
|
$class = Utility::getClassInstance($report);
|
||||||
|
|
||||||
// Update cache
|
// Update cache
|
||||||
Cache::put('reports.totals.' . $report->id, $class->getTotal());
|
Cache::put('reports.totals.' . $report->id, $class->getGrandTotal());
|
||||||
|
|
||||||
return $class->show();
|
return $class->show();
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ class Reports extends Controller
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache::put('reports.totals.' . $report->id, Utility::getClassInstance($report)->getTotal());
|
Cache::put('reports.totals.' . $report->id, Utility::getClassInstance($report)->getGrandTotal());
|
||||||
});
|
});
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
|
@ -28,7 +28,7 @@ class ExpenseSummary extends Report
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getTotals()
|
public function setData()
|
||||||
{
|
{
|
||||||
$transactions = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at']);
|
$transactions = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class IncomeExpenseSummary extends Report
|
|||||||
|
|
||||||
public $icon = 'fa fa-chart-pie';
|
public $icon = 'fa fa-chart-pie';
|
||||||
|
|
||||||
public function getTotals()
|
public function setData()
|
||||||
{
|
{
|
||||||
$income_transactions = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at']);
|
$income_transactions = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||||
$expense_transactions = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at']);
|
$expense_transactions = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||||
|
@ -28,7 +28,7 @@ class IncomeSummary extends Report
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getTotals()
|
public function setData()
|
||||||
{
|
{
|
||||||
$transactions = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at']);
|
$transactions = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class ProfitLoss extends Report
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotals()
|
public function setData()
|
||||||
{
|
{
|
||||||
$income_transactions = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at']);
|
$income_transactions = $this->applyFilters(Transaction::type('income')->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||||
$expense_transactions = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at']);
|
$expense_transactions = $this->applyFilters(Transaction::type('expense')->isNotTransfer(), ['date_field' => 'paid_at']);
|
||||||
|
@ -42,7 +42,7 @@ class TaxSummary extends Report
|
|||||||
$this->tables = array_combine($taxes, $taxes);
|
$this->tables = array_combine($taxes, $taxes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotals()
|
public function setData()
|
||||||
{
|
{
|
||||||
switch ($this->model->settings->basis) {
|
switch ($this->model->settings->basis) {
|
||||||
case 'cash':
|
case 'cash':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user