From dd6fc10d984f79f84a5f99a0c8849ed43a35d3fb Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 28 Feb 2018 14:43:15 +0200 Subject: [PATCH] Working on charts --- app/Ninja/Reports/AbstractReport.php | 2 +- app/Ninja/Reports/AgingReport.php | 1 - app/Ninja/Reports/ClientReport.php | 4 +++- app/Ninja/Reports/CreditReport.php | 6 ++++-- app/Ninja/Reports/DocumentReport.php | 7 ++++++- app/Ninja/Reports/ExpenseReport.php | 1 + 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/Ninja/Reports/AbstractReport.php b/app/Ninja/Reports/AbstractReport.php index 46199e3f7256..fe5d8a290837 100644 --- a/app/Ninja/Reports/AbstractReport.php +++ b/app/Ninja/Reports/AbstractReport.php @@ -242,7 +242,7 @@ class AbstractReport $color = Utils::brewerColorRGB(count($datasets)); $record->data = $records; - $record->label = trans("texts.{$dimension}"); + $record->label = $dimension; $record->lineTension = 0; $record->borderWidth = 3; $record->borderColor = "rgba({$color}, 1)"; diff --git a/app/Ninja/Reports/AgingReport.php b/app/Ninja/Reports/AgingReport.php index 1def788fea6b..ed59c105aa9d 100644 --- a/app/Ninja/Reports/AgingReport.php +++ b/app/Ninja/Reports/AgingReport.php @@ -63,7 +63,6 @@ class AgingReport extends AbstractReport } else { $dimension = $this->getDimension($client); } - $this->addChartData($dimension, $invoice->invoice_date, $invoice->balance); } } diff --git a/app/Ninja/Reports/ClientReport.php b/app/Ninja/Reports/ClientReport.php index 97d5030c9e9b..36a0e13eb920 100644 --- a/app/Ninja/Reports/ClientReport.php +++ b/app/Ninja/Reports/ClientReport.php @@ -35,6 +35,7 @@ class ClientReport extends AbstractReport public function run() { $account = Auth::user()->account; + $subgroup = $this->options['subgroup']; $clients = Client::scope() ->orderBy('name') @@ -56,7 +57,8 @@ class ClientReport extends AbstractReport $amount += $invoice->amount; $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 = [ diff --git a/app/Ninja/Reports/CreditReport.php b/app/Ninja/Reports/CreditReport.php index eb6b2678247c..976a3e537acc 100644 --- a/app/Ninja/Reports/CreditReport.php +++ b/app/Ninja/Reports/CreditReport.php @@ -22,11 +22,12 @@ class CreditReport extends AbstractReport public function run() { $account = Auth::user()->account; + $subgroup = $this->options['subgroup']; $clients = Client::scope() ->orderBy('name') ->withArchived() - ->with(['user', 'credits' => function ($query) { + ->with(['contacts', 'user', 'credits' => function ($query) { $query->where('credit_date', '>=', $this->startDate) ->where('credit_date', '<=', $this->endDate) ->withArchived(); @@ -40,7 +41,8 @@ class CreditReport extends AbstractReport $amount += $credit->amount; $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) { diff --git a/app/Ninja/Reports/DocumentReport.php b/app/Ninja/Reports/DocumentReport.php index bfa195034dbd..a5e4de3c474b 100644 --- a/app/Ninja/Reports/DocumentReport.php +++ b/app/Ninja/Reports/DocumentReport.php @@ -24,6 +24,7 @@ class DocumentReport extends AbstractReport $account = auth()->user()->account; $filter = $this->options['document_filter']; $exportFormat = $this->options['export_format']; + $subgroup = $this->options['subgroup']; $records = false; if (! $filter || $filter == ENTITY_INVOICE) { @@ -70,12 +71,16 @@ class DocumentReport extends AbstractReport foreach ($records as $record) { foreach ($record->documents as $document) { + $date = $record->getEntityType() == ENTITY_INVOICE ? $record->invoice_date : $record->expense_date; $this->data[] = [ $this->isExport ? $document->name : link_to($document->getUrl(), $document->name), $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)), - $record->getEntityType() == ENTITY_INVOICE ? $record->invoice_date : $record->expense_date, + $date, ]; + + $dimension = $this->getDimension($record); + $this->addChartData($dimension, $date, 1); } } } diff --git a/app/Ninja/Reports/ExpenseReport.php b/app/Ninja/Reports/ExpenseReport.php index 85c915d8a159..58ac550eb4d1 100644 --- a/app/Ninja/Reports/ExpenseReport.php +++ b/app/Ninja/Reports/ExpenseReport.php @@ -34,6 +34,7 @@ class ExpenseReport extends AbstractReport { $account = Auth::user()->account; $exportFormat = $this->options['export_format']; + $subgroup = $this->options['subgroup']; $with = ['client.contacts', 'vendor']; $hasTaxRates = TaxRate::scope()->count();