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

Added quote report

This commit is contained in:
Hillel Coren 2017-03-29 21:17:05 +03:00
parent 36c9104cbf
commit 76c1b0efac
3 changed files with 54 additions and 0 deletions

View File

@ -77,6 +77,7 @@ class ReportController extends BaseController
'profit_and_loss',
'task',
'tax_rate',
'quote',
];
$params = [

View File

@ -12,6 +12,7 @@ class InvoiceReport extends AbstractReport
'invoice_number',
'invoice_date',
'amount',
'status',
'payment_date',
'paid',
'method',
@ -56,6 +57,7 @@ class InvoiceReport extends AbstractReport
$this->isExport ? $invoice->invoice_number : $invoice->present()->link,
$invoice->present()->invoice_date,
$account->formatMoney($invoice->amount, $client),
$invoice->present()->status(),
$payment ? $payment->present()->payment_date : '',
$payment ? $account->formatMoney($payment->getCompletedAmount(), $client) : '',
$payment ? $payment->present()->method : '',

View File

@ -0,0 +1,51 @@
<?php
namespace App\Ninja\Reports;
use App\Models\Client;
use Auth;
class QuoteReport extends AbstractReport
{
public $columns = [
'client',
'quote_number',
'quote_date',
'amount',
'status',
];
public function run()
{
$account = Auth::user()->account;
$status = $this->options['invoice_status'];
$clients = Client::scope()
->withArchived()
->with('contacts')
->with(['invoices' => function ($query) use ($status) {
if ($status == 'draft') {
$query->whereIsPublic(false);
}
$query->quotes()
->withArchived()
->where('invoice_date', '>=', $this->startDate)
->where('invoice_date', '<=', $this->endDate)
->with(['invoice_items']);
}]);
foreach ($clients->get() as $client) {
foreach ($client->invoices as $invoice) {
$this->data[] = [
$this->isExport ? $client->getDisplayName() : $client->present()->link,
$this->isExport ? $invoice->invoice_number : $invoice->present()->link,
$invoice->present()->invoice_date,
$account->formatMoney($invoice->amount, $client),
$invoice->present()->status(),
];
}
$this->addToTotals($client->currency_id, 'amount', $invoice->amount);
}
}
}