Working on charts

This commit is contained in:
Hillel Coren 2018-02-28 14:43:15 +02:00
parent 238618a1c3
commit dd6fc10d98
6 changed files with 15 additions and 6 deletions

View File

@ -242,7 +242,7 @@ class AbstractReport
$color = Utils::brewerColorRGB(count($datasets)); $color = Utils::brewerColorRGB(count($datasets));
$record->data = $records; $record->data = $records;
$record->label = trans("texts.{$dimension}"); $record->label = $dimension;
$record->lineTension = 0; $record->lineTension = 0;
$record->borderWidth = 3; $record->borderWidth = 3;
$record->borderColor = "rgba({$color}, 1)"; $record->borderColor = "rgba({$color}, 1)";

View File

@ -63,7 +63,6 @@ class AgingReport extends AbstractReport
} else { } else {
$dimension = $this->getDimension($client); $dimension = $this->getDimension($client);
} }
$this->addChartData($dimension, $invoice->invoice_date, $invoice->balance); $this->addChartData($dimension, $invoice->invoice_date, $invoice->balance);
} }
} }

View File

@ -35,6 +35,7 @@ class ClientReport extends AbstractReport
public function run() public function run()
{ {
$account = Auth::user()->account; $account = Auth::user()->account;
$subgroup = $this->options['subgroup'];
$clients = Client::scope() $clients = Client::scope()
->orderBy('name') ->orderBy('name')
@ -56,7 +57,8 @@ class ClientReport extends AbstractReport
$amount += $invoice->amount; $amount += $invoice->amount;
$paid += $invoice->getAmountPaid(); $paid += $invoice->getAmountPaid();
$this->addChartData(ENTITY_INVOICE, $invoice->invoice_date, $invoice->amount); $dimension = $this->getDimension($client);
$this->addChartData($dimension, $invoice->invoice_date, $invoice->amount);
} }
$row = [ $row = [

View File

@ -22,11 +22,12 @@ class CreditReport extends AbstractReport
public function run() public function run()
{ {
$account = Auth::user()->account; $account = Auth::user()->account;
$subgroup = $this->options['subgroup'];
$clients = Client::scope() $clients = Client::scope()
->orderBy('name') ->orderBy('name')
->withArchived() ->withArchived()
->with(['user', 'credits' => function ($query) { ->with(['contacts', 'user', 'credits' => function ($query) {
$query->where('credit_date', '>=', $this->startDate) $query->where('credit_date', '>=', $this->startDate)
->where('credit_date', '<=', $this->endDate) ->where('credit_date', '<=', $this->endDate)
->withArchived(); ->withArchived();
@ -40,7 +41,8 @@ class CreditReport extends AbstractReport
$amount += $credit->amount; $amount += $credit->amount;
$balance += $credit->balance; $balance += $credit->balance;
$this->addChartData(ENTITY_CREDIT, $credit->credit_date, $credit->amount); $dimension = $this->getDimension($client);
$this->addChartData($dimension, $credit->credit_date, $credit->amount);
} }
if (! $amount && ! $balance) { if (! $amount && ! $balance) {

View File

@ -24,6 +24,7 @@ class DocumentReport extends AbstractReport
$account = auth()->user()->account; $account = auth()->user()->account;
$filter = $this->options['document_filter']; $filter = $this->options['document_filter'];
$exportFormat = $this->options['export_format']; $exportFormat = $this->options['export_format'];
$subgroup = $this->options['subgroup'];
$records = false; $records = false;
if (! $filter || $filter == ENTITY_INVOICE) { if (! $filter || $filter == ENTITY_INVOICE) {
@ -70,12 +71,16 @@ class DocumentReport extends AbstractReport
foreach ($records as $record) { foreach ($records as $record) {
foreach ($record->documents as $document) { foreach ($record->documents as $document) {
$date = $record->getEntityType() == ENTITY_INVOICE ? $record->invoice_date : $record->expense_date;
$this->data[] = [ $this->data[] = [
$this->isExport ? $document->name : link_to($document->getUrl(), $document->name), $this->isExport ? $document->name : link_to($document->getUrl(), $document->name),
$record->client ? ($this->isExport ? $record->client->getDisplayName() : $record->client->present()->link) : '', $record->client ? ($this->isExport ? $record->client->getDisplayName() : $record->client->present()->link) : '',
$this->isExport ? $record->present()->titledName : ($filter ? $record->present()->link : link_to($record->present()->url, $record->present()->titledName)), $this->isExport ? $record->present()->titledName : ($filter ? $record->present()->link : link_to($record->present()->url, $record->present()->titledName)),
$record->getEntityType() == ENTITY_INVOICE ? $record->invoice_date : $record->expense_date, $date,
]; ];
$dimension = $this->getDimension($record);
$this->addChartData($dimension, $date, 1);
} }
} }
} }

View File

@ -34,6 +34,7 @@ class ExpenseReport extends AbstractReport
{ {
$account = Auth::user()->account; $account = Auth::user()->account;
$exportFormat = $this->options['export_format']; $exportFormat = $this->options['export_format'];
$subgroup = $this->options['subgroup'];
$with = ['client.contacts', 'vendor']; $with = ['client.contacts', 'vendor'];
$hasTaxRates = TaxRate::scope()->count(); $hasTaxRates = TaxRate::scope()->count();