diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 58cfadead8d1..4ca637fd0dd3 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -63,14 +63,13 @@ class ReportController extends BaseController } $reportTypes = [ - 'client', - 'product', - 'invoice', - 'invoice_details', 'aging', - 'profit_and_loss', - 'payment', + 'client', 'expense', + 'invoice', + 'payment', + 'product', + 'profit_and_loss', 'task', 'tax_rate', ]; diff --git a/app/Ninja/Reports/InvoiceDetailsReport.php b/app/Ninja/Reports/InvoiceDetailsReport.php deleted file mode 100644 index a8b8f1a2bcaa..000000000000 --- a/app/Ninja/Reports/InvoiceDetailsReport.php +++ /dev/null @@ -1,61 +0,0 @@ -account; - $status = $this->options['invoice_status']; - - $clients = Client::scope() - ->withArchived() - ->with('contacts') - ->with(['invoices' => function ($query) use ($status) { - if ($status == 'draft') { - $query->whereIsPublic(false); - } elseif ($status == 'unpaid' || $status == 'paid') { - $query->whereIsPublic(true); - } - $query->invoices() - ->withArchived() - ->where('invoice_date', '>=', $this->startDate) - ->where('invoice_date', '<=', $this->endDate) - ->with(['invoice_items']); - }]); - - foreach ($clients->get() as $client) { - foreach ($client->invoices as $invoice) { - foreach ($invoice->invoice_items as $item) { - $this->data[] = [ - $this->isExport ? $client->getDisplayName() : $client->present()->link, - $this->isExport ? $invoice->invoice_number : $invoice->present()->link, - $invoice->present()->invoice_date, - $item->product_key, - $item->qty, - $account->formatMoney($item->cost, $client), - ]; - } - - //$this->addToTotals($client->currency_id, 'paid', $payment ? $payment->getCompletedAmount() : 0); - //$this->addToTotals($client->currency_id, 'amount', $invoice->amount); - //$this->addToTotals($client->currency_id, 'balance', $invoice->balance); - } - } - } -} diff --git a/app/Ninja/Reports/ProductReport.php b/app/Ninja/Reports/ProductReport.php index e28ae074dfcf..19bb5c1fcc81 100644 --- a/app/Ninja/Reports/ProductReport.php +++ b/app/Ninja/Reports/ProductReport.php @@ -11,43 +11,50 @@ class ProductReport extends AbstractReport 'client', 'invoice_number', 'invoice_date', - 'quantity', 'product', + 'qty', + 'cost', + //'tax_rate1', + //'tax_rate2', ]; public function run() { $account = Auth::user()->account; + $status = $this->options['invoice_status']; $clients = Client::scope() - ->withTrashed() + ->withArchived() ->with('contacts') - ->where('is_deleted', '=', false) - ->with(['invoices' => function ($query) { - $query->where('invoice_date', '>=', $this->startDate) + ->with(['invoices' => function ($query) use ($status) { + if ($status == 'draft') { + $query->whereIsPublic(false); + } elseif ($status == 'unpaid' || $status == 'paid') { + $query->whereIsPublic(true); + } + $query->invoices() + ->withArchived() + ->where('invoice_date', '>=', $this->startDate) ->where('invoice_date', '<=', $this->endDate) - ->where('is_deleted', '=', false) - ->where('is_recurring', '=', false) - ->where('invoice_type_id', '=', INVOICE_TYPE_STANDARD) - ->with(['invoice_items']) - ->withTrashed(); + ->with(['invoice_items']); }]); foreach ($clients->get() as $client) { foreach ($client->invoices as $invoice) { - foreach ($invoice->invoice_items as $invoiceItem) { + foreach ($invoice->invoice_items as $item) { $this->data[] = [ $this->isExport ? $client->getDisplayName() : $client->present()->link, $this->isExport ? $invoice->invoice_number : $invoice->present()->link, $invoice->present()->invoice_date, - round($invoiceItem->qty, 2), - $invoiceItem->product_key, + $item->product_key, + $item->qty, + $account->formatMoney($item->cost, $client), ]; - //$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'paid', $payment ? $payment->amount : 0); } - //$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'amount', $invoice->amount); - //$reportTotals = $this->addToTotals($reportTotals, $client->currency_id, 'balance', $invoice->balance); + //$this->addToTotals($client->currency_id, 'paid', $payment ? $payment->getCompletedAmount() : 0); + //$this->addToTotals($client->currency_id, 'amount', $invoice->amount); + //$this->addToTotals($client->currency_id, 'balance', $invoice->balance); } } } diff --git a/resources/views/reports/chart_builder.blade.php b/resources/views/reports/chart_builder.blade.php index 528f88ff5e8d..2baaea5986d7 100644 --- a/resources/views/reports/chart_builder.blade.php +++ b/resources/views/reports/chart_builder.blade.php @@ -101,7 +101,7 @@ -
+
{!! Former::select('invoice_status')->label('status') ->addOption(trans('texts.all'), 'all') ->addOption(trans('texts.draft'), 'draft') @@ -256,7 +256,7 @@ } else { $('#dateField').fadeOut(); } - if (val == '{{ ENTITY_INVOICE }}' || val == 'invoice_details') { + if (val == '{{ ENTITY_INVOICE }}' || val == '{{ ENTITY_PRODUCT }}') { $('#statusField').fadeIn(); } else { $('#statusField').fadeOut();