diff --git a/app/Ninja/Reports/InvoiceReport.php b/app/Ninja/Reports/InvoiceReport.php index 74b418b912..a7a2aac796 100644 --- a/app/Ninja/Reports/InvoiceReport.php +++ b/app/Ninja/Reports/InvoiceReport.php @@ -10,7 +10,7 @@ class InvoiceReport extends AbstractReport { public function getColumns() { - return [ + $columns = [ 'client', 'invoice_number', 'invoice_date', @@ -21,6 +21,17 @@ class InvoiceReport extends AbstractReport 'method', 'private_notes' => ['columnSelector-false'], ]; + + $account = auth()->user()->account; + + if ($account->custom_invoice_text_label1) { + $columns[$account->custom_invoice_text_label1] = ['columnSelector-false', 'custom']; + } + if ($account->custom_invoice_text_label1) { + $columns[$account->custom_invoice_text_label1] = ['columnSelector-false', 'custom']; + } + + return $columns; } public function run() @@ -65,7 +76,7 @@ class InvoiceReport extends AbstractReport foreach ($client->invoices as $invoice) { $payments = $invoice->payments->count() ? $invoice->payments : [false]; foreach ($payments as $payment) { - $this->data[] = [ + $row = [ $this->isExport ? $client->getDisplayName() : $client->present()->link, $this->isExport ? $invoice->invoice_number : $invoice->present()->link, $invoice->present()->invoice_date, @@ -77,6 +88,15 @@ class InvoiceReport extends AbstractReport $invoice->private_notes, ]; + if ($account->custom_invoice_text_label1) { + $row[] = $invoice->custom_text_value1; + } + if ($account->custom_invoice_text_label2) { + $row[] = $invoice->custom_text_value2; + } + + $this->data[] = $row; + $this->addToTotals($client->currency_id, 'paid', $payment ? $payment->getCompletedAmount() : 0); } diff --git a/app/Ninja/Reports/ProductReport.php b/app/Ninja/Reports/ProductReport.php index cddc9a80c0..2d08e114cf 100644 --- a/app/Ninja/Reports/ProductReport.php +++ b/app/Ninja/Reports/ProductReport.php @@ -10,7 +10,7 @@ class ProductReport extends AbstractReport { public function getColumns() { - return [ + $columns = [ 'client', 'invoice_number', 'invoice_date', @@ -21,6 +21,17 @@ class ProductReport extends AbstractReport //'tax_rate1', //'tax_rate2', ]; + + $account = auth()->user()->account; + + if ($account->custom_invoice_item_label1) { + $columns[$account->custom_invoice_item_label1] = ['columnSelector-false', 'custom']; + } + if ($account->custom_invoice_item_labe2) { + $columns[$account->custom_invoice_item_labe2] = ['columnSelector-false', 'custom']; + } + + return $columns; } public function run() @@ -44,7 +55,7 @@ class ProductReport extends AbstractReport foreach ($clients->get() as $client) { foreach ($client->invoices as $invoice) { foreach ($invoice->invoice_items as $item) { - $this->data[] = [ + $row = [ $this->isExport ? $client->getDisplayName() : $client->present()->link, $this->isExport ? $invoice->invoice_number : $invoice->present()->link, $invoice->present()->invoice_date, @@ -53,6 +64,16 @@ class ProductReport extends AbstractReport Utils::roundSignificant($item->qty, 0), Utils::roundSignificant($item->cost, 2), ]; + + if ($account->custom_invoice_item_label1) { + $row[] = $item->custom_value1; + } + if ($account->custom_invoice_item_labe2) { + $row[] = $item->custom_value2; + } + + $this->data[] = $row; + } //$this->addToTotals($client->currency_id, 'paid', $payment ? $payment->getCompletedAmount() : 0); diff --git a/app/Ninja/Reports/QuoteReport.php b/app/Ninja/Reports/QuoteReport.php index 167d2831af..64f300bd83 100644 --- a/app/Ninja/Reports/QuoteReport.php +++ b/app/Ninja/Reports/QuoteReport.php @@ -10,7 +10,7 @@ class QuoteReport extends AbstractReport { public function getColumns() { - return [ + $columns = [ 'client', 'quote_number', 'quote_date', @@ -18,6 +18,17 @@ class QuoteReport extends AbstractReport 'status', 'private_notes' => ['columnSelector-false'], ]; + + $account = auth()->user()->account; + + if ($account->custom_invoice_text_label1) { + $columns[$account->custom_invoice_text_label1] = ['columnSelector-false', 'custom']; + } + if ($account->custom_invoice_text_label1) { + $columns[$account->custom_invoice_text_label1] = ['columnSelector-false', 'custom']; + } + + return $columns; } public function run() @@ -56,7 +67,7 @@ class QuoteReport extends AbstractReport foreach ($clients->get() as $client) { foreach ($client->invoices as $invoice) { - $this->data[] = [ + $row = [ $this->isExport ? $client->getDisplayName() : $client->present()->link, $this->isExport ? $invoice->invoice_number : $invoice->present()->link, $invoice->present()->invoice_date, @@ -65,6 +76,15 @@ class QuoteReport extends AbstractReport $invoice->private_notes, ]; + if ($account->custom_invoice_text_label1) { + $row[] = $invoice->custom_text_value1; + } + if ($account->custom_invoice_text_label2) { + $row[] = $invoice->custom_text_value2; + } + + $this->data[] = $row; + $this->addToTotals($client->currency_id, 'amount', $invoice->amount); } }