1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00

Working on charts

This commit is contained in:
Hillel Coren 2018-02-28 16:57:10 +02:00
parent dd6fc10d98
commit b3047fb202
11 changed files with 88 additions and 6 deletions

View File

@ -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();

View File

@ -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);
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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);
}
}
}

View File

@ -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));
}
}
}

View File

@ -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']);
}
}
}

View File

@ -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()) {