Merge pull request #3289 from CihanSenturk/add-report-data-to-array
Added report data to array
This commit is contained in:
commit
56ac86ad3c
|
|
@ -40,6 +40,8 @@ abstract class Report
|
|||
|
||||
public $has_money = true;
|
||||
|
||||
public $group;
|
||||
|
||||
public $groups = [];
|
||||
|
||||
public $year;
|
||||
|
|
@ -259,6 +261,41 @@ abstract class Report
|
|||
return view($this->views['print'], ['print' => true])->with('class', $this);
|
||||
}
|
||||
|
||||
public function array(): array
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$group = Str::plural($this->group ?? $this->getSetting('group'));
|
||||
|
||||
foreach ($this->tables as $table_key => $table_name) {
|
||||
if (! isset($this->row_values[$table_key])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($this->row_values[$table_key] as $key => $values) {
|
||||
if (empty($this->row_names[$table_key][$key])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->has_money) {
|
||||
$values = array_map(fn($value) => money($value)->format(), $values);
|
||||
}
|
||||
|
||||
$data[$table_key][$group][$this->row_names[$table_key][$key]] = $values;
|
||||
}
|
||||
|
||||
$footer_totals = $this->footer_totals[$table_key];
|
||||
|
||||
if ($this->has_money) {
|
||||
$footer_totals = array_map(fn($value) => money($value)->format(), $footer_totals);
|
||||
}
|
||||
|
||||
$data[$table_key]['totals'] = $footer_totals;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function pdf()
|
||||
{
|
||||
$view = view($this->views['print'], ['print' => true])->with('class', $this)->render();
|
||||
|
|
|
|||
|
|
@ -97,4 +97,19 @@ class ProfitLoss extends Report
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function array(): array
|
||||
{
|
||||
$data = parent::array();
|
||||
|
||||
$net_profit = $this->net_profit;
|
||||
|
||||
if ($this->has_money) {
|
||||
$net_profit = array_map(fn($value) => money($value)->format(), $net_profit);
|
||||
}
|
||||
|
||||
$data['net_profit'] = $net_profit;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ class TaxSummary extends Report
|
|||
|
||||
public $category = 'general.accounting';
|
||||
|
||||
public $group = 'tax';
|
||||
|
||||
public $icon = 'percent';
|
||||
|
||||
public $type = 'detail';
|
||||
|
|
|
|||
Loading…
Reference in New Issue