diff --git a/app/Ninja/Reports/AbstractReport.php b/app/Ninja/Reports/AbstractReport.php index fe5d8a290837..d1dddad616cd 100644 --- a/app/Ninja/Reports/AbstractReport.php +++ b/app/Ninja/Reports/AbstractReport.php @@ -246,7 +246,7 @@ class AbstractReport $record->lineTension = 0; $record->borderWidth = 3; $record->borderColor = "rgba({$color}, 1)"; - $record->backgroundColor = "rgba({$color}, 0.1)"; + $record->backgroundColor = "rgba(255,255,255,0)"; } $data = new stdClass(); diff --git a/app/Ninja/Reports/ClientReport.php b/app/Ninja/Reports/ClientReport.php index 36a0e13eb920..18a46d15b07e 100644 --- a/app/Ninja/Reports/ClientReport.php +++ b/app/Ninja/Reports/ClientReport.php @@ -57,7 +57,11 @@ class ClientReport extends AbstractReport $amount += $invoice->amount; $paid += $invoice->getAmountPaid(); - $dimension = $this->getDimension($client); + if ($subgroup == 'country') { + $dimension = $client->present()->country; + } else { + $dimension = $this->getDimension($client); + } $this->addChartData($dimension, $invoice->invoice_date, $invoice->amount); } diff --git a/app/Ninja/Reports/ExpenseReport.php b/app/Ninja/Reports/ExpenseReport.php index 58ac550eb4d1..b129ed3646ad 100644 --- a/app/Ninja/Reports/ExpenseReport.php +++ b/app/Ninja/Reports/ExpenseReport.php @@ -89,6 +89,16 @@ class ExpenseReport extends AbstractReport $this->addToTotals($expense->expense_currency_id, 'amount', $amount); $this->addToTotals($expense->invoice_currency_id, 'amount', 0); + + if ($subgroup == 'category') { + $dimension = $expense->present()->category; + } elseif ($subgroup == 'vendor') { + $dimension = $expense->vendor ? $expense->vendor->name : trans('texts.unset'); + } else { + $dimension = $this->getDimension($expense); + } + + $this->addChartData($dimension, $expense->expense_date, $amount); } } } diff --git a/app/Ninja/Reports/InvoiceReport.php b/app/Ninja/Reports/InvoiceReport.php index 51be25981c2a..dc120a9b1118 100644 --- a/app/Ninja/Reports/InvoiceReport.php +++ b/app/Ninja/Reports/InvoiceReport.php @@ -46,6 +46,7 @@ class InvoiceReport extends AbstractReport $account = Auth::user()->account; $statusIds = $this->options['status_ids']; $exportFormat = $this->options['export_format']; + $subgroup = $this->options['subgroup']; $hasTaxRates = TaxRate::scope()->count(); $clients = Client::scope() @@ -122,6 +123,14 @@ class InvoiceReport extends AbstractReport $this->addToTotals($client->currency_id, 'amount', $invoice->amount); $this->addToTotals($client->currency_id, 'balance', $invoice->balance); + + if ($subgroup == 'status') { + $dimension = $invoice->statusLabel(); + } else { + $dimension = $this->getDimension($client); + } + + $this->addChartData($dimension, $invoice->invoice_date, $invoice->amount); } } } diff --git a/app/Ninja/Reports/PaymentReport.php b/app/Ninja/Reports/PaymentReport.php index 13dd355b83bb..e1c73710a721 100644 --- a/app/Ninja/Reports/PaymentReport.php +++ b/app/Ninja/Reports/PaymentReport.php @@ -28,6 +28,7 @@ class PaymentReport extends AbstractReport $account = Auth::user()->account; $currencyType = $this->options['currency_type']; $invoiceMap = []; + $subgroup = $this->options['subgroup']; $payments = Payment::scope() ->orderBy('payment_date', 'desc') @@ -80,6 +81,15 @@ class PaymentReport extends AbstractReport } } + if ($subgroup == 'method') { + $dimension = $payment->present()->method; + } else { + $dimension = $this->getDimension($payment); + } + + $convertedAmount = $currencyType == 'converted' ? ($invoice->amount * $payment->exchange_rate) : $invoice->amount; + $this->addChartData($dimension, $payment->payment_date, $convertedAmount); + $lastInvoiceId = $invoice->id; } } diff --git a/app/Ninja/Reports/ProductReport.php b/app/Ninja/Reports/ProductReport.php index 9ccc7ea03c5e..922e6b148bc4 100644 --- a/app/Ninja/Reports/ProductReport.php +++ b/app/Ninja/Reports/ProductReport.php @@ -46,11 +46,12 @@ class ProductReport extends AbstractReport { $account = Auth::user()->account; $statusIds = $this->options['status_ids']; + $subgroup = $this->options['subgroup']; $clients = Client::scope() ->orderBy('name') ->withArchived() - ->with('contacts') + ->with('contacts', 'user') ->with(['invoices' => function ($query) use ($statusIds) { $query->invoices() ->withArchived() @@ -90,6 +91,13 @@ class ProductReport extends AbstractReport $this->data[] = $row; + if ($subgroup == 'product') { + $dimension = $item->product_key; + } else { + $dimension = $this->getDimension($client); + } + + $this->addChartData($dimension, $invoice->invoice_date, $invoice->amount); } //$this->addToTotals($client->currency_id, 'paid', $payment ? $payment->getCompletedAmount() : 0); diff --git a/app/Ninja/Reports/ProfitAndLossReport.php b/app/Ninja/Reports/ProfitAndLossReport.php index fd2372d96531..085cdd5a269b 100644 --- a/app/Ninja/Reports/ProfitAndLossReport.php +++ b/app/Ninja/Reports/ProfitAndLossReport.php @@ -22,10 +22,11 @@ class ProfitAndLossReport extends AbstractReport public function run() { $account = Auth::user()->account; + $subgroup = $this->options['subgroup']; $payments = Payment::scope() ->orderBy('payment_date', 'desc') - ->with('client.contacts', 'invoice') + ->with('client.contacts', 'invoice', 'user') ->withArchived() ->excludeFailed() ->where('payment_date', '>=', $this->startDate) @@ -48,6 +49,13 @@ class ProfitAndLossReport extends AbstractReport $this->addToTotals($client->currency_id, 'revenue', $payment->getCompletedAmount(), $payment->present()->month); $this->addToTotals($client->currency_id, 'expenses', 0, $payment->present()->month); $this->addToTotals($client->currency_id, 'profit', $payment->getCompletedAmount(), $payment->present()->month); + + if ($subgroup == 'type') { + $dimension = trans('texts.payment'); + } else { + $dimension = $this->getDimension($payment); + } + $this->addChartData($dimension, $payment->payment_date, $payment->getCompletedAmount()); } $expenses = Expense::scope() @@ -70,6 +78,13 @@ class ProfitAndLossReport extends AbstractReport $this->addToTotals($expense->expense_currency_id, 'revenue', 0, $expense->present()->month); $this->addToTotals($expense->expense_currency_id, 'expenses', $expense->amountWithTax(), $expense->present()->month); $this->addToTotals($expense->expense_currency_id, 'profit', $expense->amountWithTax() * -1, $expense->present()->month); + + if ($subgroup == 'type') { + $dimension = trans('texts.expense'); + } else { + $dimension = $this->getDimension($payment); + } + $this->addChartData($dimension, $payment->expense_date, $expense->amountWithTax()); } //$this->addToTotals($client->currency_id, 'paid', $payment ? $payment->getCompletedAmount() : 0); diff --git a/app/Ninja/Reports/QuoteReport.php b/app/Ninja/Reports/QuoteReport.php index fbc1e2152aaa..5dbc529ba877 100644 --- a/app/Ninja/Reports/QuoteReport.php +++ b/app/Ninja/Reports/QuoteReport.php @@ -43,6 +43,7 @@ class QuoteReport extends AbstractReport $statusIds = $this->options['status_ids']; $exportFormat = $this->options['export_format']; $hasTaxRates = TaxRate::scope()->count(); + $subgroup = $this->options['subgroup']; $clients = Client::scope() ->orderBy('name') @@ -102,6 +103,14 @@ class QuoteReport extends AbstractReport $this->data[] = $row; $this->addToTotals($client->currency_id, 'amount', $invoice->amount); + + if ($subgroup == 'status') { + $dimension = $invoice->statusLabel(); + } else { + $dimension = $this->getDimension($client); + } + + $this->addChartData($dimension, $invoice->invoice_date, $invoice->amount); } } } diff --git a/app/Ninja/Reports/TaskReport.php b/app/Ninja/Reports/TaskReport.php index 9419af24b43c..d6a2398a4760 100644 --- a/app/Ninja/Reports/TaskReport.php +++ b/app/Ninja/Reports/TaskReport.php @@ -24,6 +24,7 @@ class TaskReport extends AbstractReport { $startDate = date_create($this->startDate); $endDate = date_create($this->endDate); + $subgroup = $this->options['subgroup']; $tasks = Task::scope() ->orderBy('created_at', 'desc') @@ -52,6 +53,13 @@ class TaskReport extends AbstractReport $this->addToTotals($currencyId, 'duration', $duration); $this->addToTotals($currencyId, 'amount', $amount); + + if ($subgroup == 'project') { + $dimension = $task->present()->project; + } else { + $dimension = $this->getDimension($task); + } + $this->addChartData($dimension, $task->created_at, round($duration / 60 / 60, 2)); } } } diff --git a/app/Ninja/Reports/TaxRateReport.php b/app/Ninja/Reports/TaxRateReport.php index f4005134091b..4cc9df12468c 100644 --- a/app/Ninja/Reports/TaxRateReport.php +++ b/app/Ninja/Reports/TaxRateReport.php @@ -24,11 +24,12 @@ class TaxRateReport extends AbstractReport public function run() { $account = Auth::user()->account; + $subgroup = $this->options['subgroup']; $clients = Client::scope() ->orderBy('name') ->withArchived() - ->with('contacts') + ->with('contacts', 'user') ->with(['invoices' => function ($query) { $query->with('invoice_items') ->withArchived() @@ -85,6 +86,9 @@ class TaxRateReport extends AbstractReport $this->addToTotals($client->currency_id, 'amount', $tax['amount']); $this->addToTotals($client->currency_id, 'paid', $tax['paid']); + + $dimension = $this->getDimension($client); + $this->addChartData($dimension, $invoice->invoice_date, $tax['amount']); } } } diff --git a/resources/views/reports/report_builder.blade.php b/resources/views/reports/report_builder.blade.php index dded863bd7d1..8a0c39874bcd 100644 --- a/resources/views/reports/report_builder.blade.php +++ b/resources/views/reports/report_builder.blade.php @@ -468,7 +468,6 @@ if (['client'].indexOf(reportType) == -1) { $subgroup.append(new Option("{{ trans('texts.client') }}", 'client')); } - $subgroup.append(new Option("{{ trans('texts.user') }}", 'user')); if (reportType == 'activity') { @@ -484,6 +483,12 @@ $subgroup.append(new Option("{{ trans('texts.type') }}", 'type')); } else if (reportType == 'task') { $subgroup.append(new Option("{{ trans('texts.project') }}", 'project')); + } else if (reportType == 'client') { + $subgroup.append(new Option("{{ trans('texts.country') }}", 'country')); + } else if (reportType == 'invoice' || reportType == 'quote') { + $subgroup.append(new Option("{{ trans('texts.status') }}", 'status')); + } else if (reportType == 'product') { + $subgroup.append(new Option("{{ trans('texts.product') }}", 'product')); } if (isStorageSupported()) {