diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index c2b6ce2a9d..3de9318251 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -364,7 +364,9 @@ class Utils if ($field == 'checkbox') { $data[] = $field; } elseif ($field) { - if ($module) { + if (substr($field, 0, 1) == '-') { + $data[] = substr($field, 1); + } elseif ($module) { $data[] = mtrans($module, $field); } else { $data[] = trans("texts.$field"); diff --git a/app/Ninja/Datatables/ProductDatatable.php b/app/Ninja/Datatables/ProductDatatable.php index 62775313c2..be2001fc29 100644 --- a/app/Ninja/Datatables/ProductDatatable.php +++ b/app/Ninja/Datatables/ProductDatatable.php @@ -14,6 +14,8 @@ class ProductDatatable extends EntityDatatable public function columns() { + $account = Auth::user()->account; + return [ [ 'product_key', @@ -38,8 +40,22 @@ class ProductDatatable extends EntityDatatable function ($model) { return $model->tax_rate ? ($model->tax_name . ' ' . $model->tax_rate . '%') : ''; }, - Auth::user()->account->invoice_item_taxes, + $account->invoice_item_taxes, ], + [ + '-' . Utils::getCustomLabel($account->custom_invoice_item_label1), + function ($model) { + return $model->custom_value1; + }, + $account->custom_invoice_item_label1 + ], + [ + '-' . Utils::getCustomLabel($account->custom_invoice_item_label2), + function ($model) { + return $model->custom_value2; + }, + $account->custom_invoice_item_label2 + ] ]; } diff --git a/app/Ninja/Reports/ProductReport.php b/app/Ninja/Reports/ProductReport.php index 1f5aba19c3..3a0bb74755 100644 --- a/app/Ninja/Reports/ProductReport.php +++ b/app/Ninja/Reports/ProductReport.php @@ -32,10 +32,11 @@ class ProductReport extends AbstractReport } if ($account->custom_invoice_item_label1) { - $columns[$account->custom_invoice_item_label1] = ['columnSelector-false', 'custom']; + $columns[Utils::getCustomLabel($account->custom_invoice_item_label1)] = ['columnSelector-false', 'custom']; } - if ($account->custom_invoice_item_labe2) { - $columns[$account->custom_invoice_item_labe2] = ['columnSelector-false', 'custom']; + + if ($account->custom_invoice_item_label2) { + $columns[Utils::getCustomLabel($account->custom_invoice_item_label2)] = ['columnSelector-false', 'custom']; } return $columns; @@ -82,7 +83,8 @@ class ProductReport extends AbstractReport if ($account->custom_invoice_item_label1) { $row[] = $item->custom_value1; } - if ($account->custom_invoice_item_labe2) { + + if ($account->custom_invoice_item_label2) { $row[] = $item->custom_value2; } diff --git a/app/Ninja/Repositories/ProductRepository.php b/app/Ninja/Repositories/ProductRepository.php index 78212cef65..30d5f9cdb2 100644 --- a/app/Ninja/Repositories/ProductRepository.php +++ b/app/Ninja/Repositories/ProductRepository.php @@ -33,7 +33,9 @@ class ProductRepository extends BaseRepository 'products.tax_name1 as tax_name', 'products.tax_rate1 as tax_rate', 'products.deleted_at', - 'products.is_deleted' + 'products.is_deleted', + 'products.custom_value1', + 'products.custom_value2' ); if ($filter) {