mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 04:07:32 -05:00 
			
		
		
		
	Working on reports
This commit is contained in:
		
							parent
							
								
									2387d45960
								
							
						
					
					
						commit
						4750362961
					
				@ -12,7 +12,6 @@ class AbstractReport
 | 
			
		||||
    public $options;
 | 
			
		||||
 | 
			
		||||
    public $totals = [];
 | 
			
		||||
    public $columns = [];
 | 
			
		||||
    public $data = [];
 | 
			
		||||
 | 
			
		||||
    public function __construct($startDate, $endDate, $isExport, $options = false)
 | 
			
		||||
@ -28,10 +27,15 @@ class AbstractReport
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        return [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function results()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'columns' => $this->columns,
 | 
			
		||||
            'columns' => $this->getColumns(),
 | 
			
		||||
            'displayData' => $this->data,
 | 
			
		||||
            'reportTotals' => $this->totals,
 | 
			
		||||
        ];
 | 
			
		||||
@ -55,7 +59,7 @@ class AbstractReport
 | 
			
		||||
    public function tableHeaderArray() {
 | 
			
		||||
        $columns_labeled = [];
 | 
			
		||||
 | 
			
		||||
        foreach ($this->columns as $key => $val) {
 | 
			
		||||
        foreach ($this->getColumns() as $key => $val) {
 | 
			
		||||
            if (is_array($val)) {
 | 
			
		||||
                $field = $key;
 | 
			
		||||
                $class = $val;
 | 
			
		||||
@ -74,8 +78,12 @@ class AbstractReport
 | 
			
		||||
                $class[] = 'group-number-30';
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $class = count($class) ? implode(' ', $class) : 'group-false';
 | 
			
		||||
            if (! in_array('custom', $class)) {
 | 
			
		||||
                $label = trans("texts.{$field}");
 | 
			
		||||
            } else {
 | 
			
		||||
                $label = $field;
 | 
			
		||||
            }
 | 
			
		||||
            $class = count($class) ? implode(' ', $class) : 'group-false';
 | 
			
		||||
 | 
			
		||||
            $columns_labeled[] = [
 | 
			
		||||
                'label' => $label,
 | 
			
		||||
 | 
			
		||||
@ -7,12 +7,15 @@ use Auth;
 | 
			
		||||
 | 
			
		||||
class ActivityReport extends AbstractReport
 | 
			
		||||
{
 | 
			
		||||
    public $columns = [
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'date',
 | 
			
		||||
            'client',
 | 
			
		||||
            'user',
 | 
			
		||||
            'activity',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function run()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,9 @@ use Auth;
 | 
			
		||||
 | 
			
		||||
class AgingReport extends AbstractReport
 | 
			
		||||
{
 | 
			
		||||
    public $columns = [
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'client',
 | 
			
		||||
            'invoice_number',
 | 
			
		||||
            'invoice_date',
 | 
			
		||||
@ -16,6 +18,8 @@ class AgingReport extends AbstractReport
 | 
			
		||||
            'amount',
 | 
			
		||||
            'balance',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public function run()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -7,13 +7,30 @@ use Auth;
 | 
			
		||||
 | 
			
		||||
class ClientReport extends AbstractReport
 | 
			
		||||
{
 | 
			
		||||
    public $columns = [
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        $columns = [
 | 
			
		||||
            'client',
 | 
			
		||||
            'amount',
 | 
			
		||||
            'paid',
 | 
			
		||||
            'balance',
 | 
			
		||||
            'public_notes' => ['columnSelector-false'],
 | 
			
		||||
            'private_notes' => ['columnSelector-false'],
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        $user = auth()->user();
 | 
			
		||||
        $account = $user->account;
 | 
			
		||||
 | 
			
		||||
        if ($account->custom_client_label1) {
 | 
			
		||||
            $columns[$account->custom_client_label1] = ['columnSelector-false', 'custom'];
 | 
			
		||||
        }
 | 
			
		||||
        if ($account->custom_client_label2) {
 | 
			
		||||
            $columns[$account->custom_client_label2] = ['columnSelector-false', 'custom'];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $columns;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function run()
 | 
			
		||||
    {
 | 
			
		||||
        $account = Auth::user()->account;
 | 
			
		||||
@ -39,13 +56,24 @@ class ClientReport extends AbstractReport
 | 
			
		||||
                $paid += $invoice->getAmountPaid();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $this->data[] = [
 | 
			
		||||
            $row = [
 | 
			
		||||
                $this->isExport ? $client->getDisplayName() : $client->present()->link,
 | 
			
		||||
                $account->formatMoney($amount, $client),
 | 
			
		||||
                $account->formatMoney($paid, $client),
 | 
			
		||||
                $account->formatMoney($amount - $paid, $client),
 | 
			
		||||
                $client->public_notes,
 | 
			
		||||
                $client->private_notes,
 | 
			
		||||
            ];
 | 
			
		||||
 | 
			
		||||
            if ($account->custom_client_label1) {
 | 
			
		||||
                $row[] = $client->custom_value1;
 | 
			
		||||
            }
 | 
			
		||||
            if ($account->custom_client_label2) {
 | 
			
		||||
                $row[] = $client->custom_value2;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $this->data[] = $row;
 | 
			
		||||
 | 
			
		||||
            $this->addToTotals($client->currency_id, 'amount', $amount);
 | 
			
		||||
            $this->addToTotals($client->currency_id, 'paid', $paid);
 | 
			
		||||
            $this->addToTotals($client->currency_id, 'balance', $amount - $paid);
 | 
			
		||||
 | 
			
		||||
@ -8,12 +8,16 @@ use Barracuda\ArchiveStream\Archive;
 | 
			
		||||
 | 
			
		||||
class DocumentReport extends AbstractReport
 | 
			
		||||
{
 | 
			
		||||
    public $columns = [
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'document',
 | 
			
		||||
            'client',
 | 
			
		||||
            'invoice_or_expense',
 | 
			
		||||
            'date',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public function run()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -9,13 +9,18 @@ use Utils;
 | 
			
		||||
 | 
			
		||||
class ExpenseReport extends AbstractReport
 | 
			
		||||
{
 | 
			
		||||
    public $columns = [
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'vendor',
 | 
			
		||||
            'client',
 | 
			
		||||
            'date',
 | 
			
		||||
            'category',
 | 
			
		||||
            'amount',
 | 
			
		||||
            'public_notes' => ['columnSelector-false'],
 | 
			
		||||
            'private_notes' => ['columnSelector-false'],
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function run()
 | 
			
		||||
    {
 | 
			
		||||
@ -57,6 +62,8 @@ class ExpenseReport extends AbstractReport
 | 
			
		||||
                $this->isExport ? $expense->present()->expense_date : link_to($expense->present()->url, $expense->present()->expense_date),
 | 
			
		||||
                $expense->present()->category,
 | 
			
		||||
                Utils::formatMoney($amount, $expense->currency_id),
 | 
			
		||||
                $expense->public_notes,
 | 
			
		||||
                $expense->private_notes,
 | 
			
		||||
            ];
 | 
			
		||||
 | 
			
		||||
            $this->addToTotals($expense->expense_currency_id, 'amount', $amount);
 | 
			
		||||
 | 
			
		||||
@ -8,7 +8,9 @@ use Barracuda\ArchiveStream\Archive;
 | 
			
		||||
 | 
			
		||||
class InvoiceReport extends AbstractReport
 | 
			
		||||
{
 | 
			
		||||
    public $columns = [
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'client',
 | 
			
		||||
            'invoice_number',
 | 
			
		||||
            'invoice_date',
 | 
			
		||||
@ -17,7 +19,9 @@ class InvoiceReport extends AbstractReport
 | 
			
		||||
            'payment_date',
 | 
			
		||||
            'paid',
 | 
			
		||||
            'method',
 | 
			
		||||
            'private_notes' => ['columnSelector-false'],
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function run()
 | 
			
		||||
    {
 | 
			
		||||
@ -70,6 +74,7 @@ class InvoiceReport extends AbstractReport
 | 
			
		||||
                        $payment ? $payment->present()->payment_date : '',
 | 
			
		||||
                        $payment ? $account->formatMoney($payment->getCompletedAmount(), $client) : '',
 | 
			
		||||
                        $payment ? $payment->present()->method : '',
 | 
			
		||||
                        $invoice->private_notes,
 | 
			
		||||
                    ];
 | 
			
		||||
 | 
			
		||||
                    $this->addToTotals($client->currency_id, 'paid', $payment ? $payment->getCompletedAmount() : 0);
 | 
			
		||||
 | 
			
		||||
@ -8,7 +8,9 @@ use Utils;
 | 
			
		||||
 | 
			
		||||
class PaymentReport extends AbstractReport
 | 
			
		||||
{
 | 
			
		||||
    public $columns = [
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'client',
 | 
			
		||||
            'invoice_number',
 | 
			
		||||
            'invoice_date',
 | 
			
		||||
@ -16,7 +18,9 @@ class PaymentReport extends AbstractReport
 | 
			
		||||
            'payment_date',
 | 
			
		||||
            'paid',
 | 
			
		||||
            'method',
 | 
			
		||||
            'private_notes' => ['columnSelector-false'],
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function run()
 | 
			
		||||
    {
 | 
			
		||||
@ -60,6 +64,7 @@ class PaymentReport extends AbstractReport
 | 
			
		||||
                $payment->present()->payment_date,
 | 
			
		||||
                $amount,
 | 
			
		||||
                $payment->present()->method,
 | 
			
		||||
                $payment->private_notes,
 | 
			
		||||
            ];
 | 
			
		||||
 | 
			
		||||
            if (! isset($invoiceMap[$invoice->id])) {
 | 
			
		||||
 | 
			
		||||
@ -8,7 +8,9 @@ use Utils;
 | 
			
		||||
 | 
			
		||||
class ProductReport extends AbstractReport
 | 
			
		||||
{
 | 
			
		||||
    public $columns = [
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'client',
 | 
			
		||||
            'invoice_number',
 | 
			
		||||
            'invoice_date',
 | 
			
		||||
@ -19,6 +21,7 @@ class ProductReport extends AbstractReport
 | 
			
		||||
            //'tax_rate1',
 | 
			
		||||
            //'tax_rate2',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function run()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -8,13 +8,16 @@ use Auth;
 | 
			
		||||
 | 
			
		||||
class ProfitAndLossReport extends AbstractReport
 | 
			
		||||
{
 | 
			
		||||
    public $columns = [
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'type',
 | 
			
		||||
            'client',
 | 
			
		||||
            'amount',
 | 
			
		||||
            'date',
 | 
			
		||||
            'notes',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function run()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -8,13 +8,17 @@ use Barracuda\ArchiveStream\Archive;
 | 
			
		||||
 | 
			
		||||
class QuoteReport extends AbstractReport
 | 
			
		||||
{
 | 
			
		||||
    public $columns = [
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'client',
 | 
			
		||||
            'quote_number',
 | 
			
		||||
            'quote_date',
 | 
			
		||||
            'amount',
 | 
			
		||||
            'status',
 | 
			
		||||
            'private_notes' => ['columnSelector-false'],
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function run()
 | 
			
		||||
    {
 | 
			
		||||
@ -58,6 +62,7 @@ class QuoteReport extends AbstractReport
 | 
			
		||||
                    $invoice->present()->invoice_date,
 | 
			
		||||
                    $account->formatMoney($invoice->amount, $client),
 | 
			
		||||
                    $invoice->present()->status(),
 | 
			
		||||
                    $invoice->private_notes,
 | 
			
		||||
                ];
 | 
			
		||||
 | 
			
		||||
                $this->addToTotals($client->currency_id, 'amount', $invoice->amount);
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,9 @@ use Utils;
 | 
			
		||||
 | 
			
		||||
class TaskReport extends AbstractReport
 | 
			
		||||
{
 | 
			
		||||
    public $columns = [
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'client',
 | 
			
		||||
            'date',
 | 
			
		||||
            'project',
 | 
			
		||||
@ -15,6 +17,7 @@ class TaskReport extends AbstractReport
 | 
			
		||||
            'duration',
 | 
			
		||||
            'amount',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function run()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,9 @@ use Auth;
 | 
			
		||||
 | 
			
		||||
class TaxRateReport extends AbstractReport
 | 
			
		||||
{
 | 
			
		||||
    public $columns = [
 | 
			
		||||
    public function getColumns()
 | 
			
		||||
    {
 | 
			
		||||
        return [
 | 
			
		||||
            'client',
 | 
			
		||||
            'invoice',
 | 
			
		||||
            'tax_name',
 | 
			
		||||
@ -15,6 +17,7 @@ class TaxRateReport extends AbstractReport
 | 
			
		||||
            'amount',
 | 
			
		||||
            'paid',
 | 
			
		||||
        ];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function run()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user