mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
55 lines
2.1 KiB
PHP
55 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Ninja\Reports;
|
|
|
|
use App\Models\Client;
|
|
use Auth;
|
|
|
|
class ProductReport extends AbstractReport
|
|
{
|
|
public $columns = [
|
|
'client',
|
|
'invoice_number',
|
|
'invoice_date',
|
|
'quantity',
|
|
'product',
|
|
];
|
|
|
|
public function run()
|
|
{
|
|
$account = Auth::user()->account;
|
|
|
|
$clients = Client::scope()
|
|
->withTrashed()
|
|
->with('contacts')
|
|
->where('is_deleted', '=', false)
|
|
->with(['invoices' => function ($query) {
|
|
$query->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();
|
|
}]);
|
|
|
|
foreach ($clients->get() as $client) {
|
|
foreach ($client->invoices as $invoice) {
|
|
foreach ($invoice->invoice_items as $invoiceItem) {
|
|
$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,
|
|
];
|
|
//$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);
|
|
}
|
|
}
|
|
}
|
|
}
|