1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Working on reports

This commit is contained in:
Hillel Coren 2018-01-24 20:19:53 +02:00
parent 60b4bf0d54
commit 7130110f8e
4 changed files with 36 additions and 2 deletions

View File

@ -1424,6 +1424,17 @@ class Invoice extends EntityModel implements BalanceAffecting
return $taxes;
}
public function getTaxTotal()
{
$total = 0;
foreach ($this->getTaxes() as $tax) {
$total += $tax['amount'];
}
return $total;
}
public function taxAmount($taxable, $rate)
{
$account = $this->account;

View File

@ -5,6 +5,7 @@ namespace App\Ninja\Reports;
use App\Models\Client;
use Auth;
use Barracuda\ArchiveStream\Archive;
use App\Models\TaxRate;
class InvoiceReport extends AbstractReport
{
@ -22,6 +23,10 @@ class InvoiceReport extends AbstractReport
'private_notes' => ['columnSelector-false'],
];
if (TaxRate::scope()->count()) {
$columns['tax'] = ['columnSelector-false'];
}
$account = auth()->user()->account;
if ($account->custom_invoice_text_label1) {
@ -74,13 +79,14 @@ class InvoiceReport extends AbstractReport
foreach ($clients->get() as $client) {
foreach ($client->invoices as $invoice) {
$isFirst = true;
$payments = $invoice->payments->count() ? $invoice->payments : [false];
foreach ($payments as $payment) {
$row = [
$this->isExport ? $client->getDisplayName() : $client->present()->link,
$this->isExport ? $invoice->invoice_number : $invoice->present()->link,
$invoice->present()->invoice_date,
$account->formatMoney($invoice->amount, $client),
$isFirst ? $account->formatMoney($invoice->amount, $client) : '',
$invoice->statusLabel(),
$payment ? $payment->present()->payment_date : '',
$payment ? $account->formatMoney($payment->getCompletedAmount(), $client) : '',
@ -88,6 +94,10 @@ class InvoiceReport extends AbstractReport
$invoice->private_notes,
];
if (TaxRate::scope()->count()) {
$row[] = $invoice->getTaxTotal();
}
if ($account->custom_invoice_text_label1) {
$row[] = $invoice->custom_text_value1;
}
@ -98,6 +108,7 @@ class InvoiceReport extends AbstractReport
$this->data[] = $row;
$this->addToTotals($client->currency_id, 'paid', $payment ? $payment->getCompletedAmount() : 0);
$isFirst = false;
}
$this->addToTotals($client->currency_id, 'amount', $invoice->amount);

View File

@ -42,6 +42,7 @@ class PaymentReport extends AbstractReport
->where('payment_date', '>=', $this->startDate)
->where('payment_date', '<=', $this->endDate);
$lastInvoiceId = 0;
foreach ($payments->get() as $payment) {
$invoice = $payment->invoice;
$client = $payment->client;
@ -60,7 +61,7 @@ class PaymentReport extends AbstractReport
$this->isExport ? $client->getDisplayName() : $client->present()->link,
$this->isExport ? $invoice->invoice_number : $invoice->present()->link,
$invoice->present()->invoice_date,
$account->formatMoney($invoice->amount, $client),
$lastInvoiceId == $invoice->id ? '' : $account->formatMoney($invoice->amount, $client),
$payment->present()->payment_date,
$amount,
$payment->present()->method,
@ -76,6 +77,8 @@ class PaymentReport extends AbstractReport
$this->addToTotals($client->currency_id, 'amount', $invoice->amount);
}
}
$lastInvoiceId = $invoice->id;
}
}
}

View File

@ -5,6 +5,7 @@ namespace App\Ninja\Reports;
use App\Models\Client;
use Auth;
use Barracuda\ArchiveStream\Archive;
use App\Models\TaxRate;
class QuoteReport extends AbstractReport
{
@ -19,6 +20,10 @@ class QuoteReport extends AbstractReport
'private_notes' => ['columnSelector-false'],
];
if (TaxRate::scope()->count()) {
$columns['tax'] = ['columnSelector-false'];
}
$account = auth()->user()->account;
if ($account->custom_invoice_text_label1) {
@ -76,6 +81,10 @@ class QuoteReport extends AbstractReport
$invoice->private_notes,
];
if (TaxRate::scope()->count()) {
$row[] = $invoice->getTaxTotal();
}
if ($account->custom_invoice_text_label1) {
$row[] = $invoice->custom_text_value1;
}