From 0c86e828a42defef070448665e1ac44c9a608783 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 16 Jan 2023 10:05:44 +1100 Subject: [PATCH 1/8] Refactor and code cleanup for filters --- app/Filters/BankIntegrationFilters.php | 31 ++---- app/Filters/BankTransactionFilters.php | 6 +- app/Filters/BankTransactionRuleFilters.php | 39 -------- app/Filters/ClientFilters.php | 93 +---------------- app/Filters/CompanyGatewayFilters.php | 52 ---------- app/Filters/CreditFilters.php | 52 ---------- app/Filters/DesignFilters.php | 39 -------- app/Filters/DocumentFilters.php | 13 --- app/Filters/ExpenseCategoryFilters.php | 56 +---------- app/Filters/ExpenseFilters.php | 80 --------------- app/Filters/InvoiceFilters.php | 90 ++++------------- app/Filters/PaymentFilters.php | 54 +--------- app/Filters/PaymentTermFilters.php | 52 ---------- app/Filters/ProductFilters.php | 51 ---------- app/Filters/ProjectFilters.php | 78 --------------- app/Filters/PurchaseOrderFilters.php | 52 ---------- app/Filters/QueryFilters.php | 32 ++++++ app/Filters/QuoteFilters.php | 110 +++++++-------------- app/Filters/RecurringExpenseFilters.php | 78 --------------- app/Filters/RecurringInvoiceFilters.php | 52 ---------- app/Filters/RecurringQuoteFilters.php | 51 ---------- app/Filters/SubscriptionFilters.php | 64 ------------ app/Filters/SystemLogFilters.php | 12 --- app/Filters/TaskFilters.php | 52 ---------- app/Filters/TaskStatusFilters.php | 52 ---------- app/Filters/TaxRateFilters.php | 52 ---------- app/Filters/TokenFilters.php | 76 +------------- app/Filters/UserFilters.php | 50 ---------- app/Filters/VendorFilters.php | 92 ----------------- app/Filters/WebhookFilters.php | 74 -------------- 30 files changed, 99 insertions(+), 1586 deletions(-) diff --git a/app/Filters/BankIntegrationFilters.php b/app/Filters/BankIntegrationFilters.php index 09ba40cc0e70..381966b35a50 100644 --- a/app/Filters/BankIntegrationFilters.php +++ b/app/Filters/BankIntegrationFilters.php @@ -68,28 +68,22 @@ class BankIntegrationFilters extends QueryFilters return $this->builder; } - $table = 'bank_integrations'; $filters = explode(',', $filter); - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - + return $this->builder->where(function ($query) use ($filters) { + if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); + $query->orWhereNull('deleted_at'); } if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } + $query->orWhere(function ($query) { + $query->whereNotNull('deleted_at'); }); } if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); + $query->orWhere('is_deleted', 1); } }); } @@ -107,19 +101,6 @@ class BankIntegrationFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/BankTransactionFilters.php b/app/Filters/BankTransactionFilters.php index a993cb2aa7a5..96eec99db028 100644 --- a/app/Filters/BankTransactionFilters.php +++ b/app/Filters/BankTransactionFilters.php @@ -134,14 +134,12 @@ class BankTransactionFilters extends QueryFilters return $this->builder; } - $table = 'bank_transactions'; $filters = explode(',', $filter); - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); + return $this->builder->where(function ($query) use ($filters) { if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); + $query->orWhereNull('deleted_at'); } if (in_array(parent::STATUS_ARCHIVED, $filters)) { diff --git a/app/Filters/BankTransactionRuleFilters.php b/app/Filters/BankTransactionRuleFilters.php index bda5158e2a16..10e80b57ddb9 100644 --- a/app/Filters/BankTransactionRuleFilters.php +++ b/app/Filters/BankTransactionRuleFilters.php @@ -55,45 +55,6 @@ class BankTransactionRuleFilters extends QueryFilters } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'bank_transaction_rules'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * diff --git a/app/Filters/ClientFilters.php b/app/Filters/ClientFilters.php index 65923049a754..df4b86fdbca3 100644 --- a/app/Filters/ClientFilters.php +++ b/app/Filters/ClientFilters.php @@ -122,45 +122,6 @@ class ClientFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'clients'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -176,59 +137,7 @@ class ClientFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - $query = DB::table('clients') - ->join('companies', 'companies.id', '=', 'clients.company_id') - ->join('client_contacts', 'client_contacts.client_id', '=', 'clients.id') - ->where('clients.company_id', '=', $company_id) - ->where('client_contacts.is_primary', '=', true) - ->where('client_contacts.deleted_at', '=', null) - ->select( - DB::raw('COALESCE(clients.country_id, companies.country_id) country_id'), - DB::raw("CONCAT(COALESCE(client_contacts.first_name, ''), ' ', COALESCE(client_contacts.last_name, '')) contact"), - 'clients.id', - 'clients.name', - 'clients.private_notes', - 'client_contacts.first_name', - 'client_contacts.last_name', - 'clients.custom_value1', - 'clients.custom_value2', - 'clients.custom_value3', - 'clients.custom_value4', - 'clients.balance', - 'clients.last_login', - 'clients.created_at', - 'clients.created_at as client_created_at', - 'client_contacts.phone', - 'client_contacts.email', - 'clients.deleted_at', - 'clients.is_deleted', - 'clients.user_id', - 'clients.id_number', - 'clients.settings' - ); - - /* - * If the user does not have permissions to view all invoices - * limit the user to only the invoices they have created - */ - if (Gate::denies('view-list', Client::class)) { - $query->where('clients.user_id', '=', $user->id); - } - - return $query; - } - + /** * Filters the query by the users company ID. * diff --git a/app/Filters/CompanyGatewayFilters.php b/app/Filters/CompanyGatewayFilters.php index ef2d6594da87..291f43388dda 100644 --- a/app/Filters/CompanyGatewayFilters.php +++ b/app/Filters/CompanyGatewayFilters.php @@ -37,45 +37,6 @@ class CompanyGatewayFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'company_gateways'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -89,19 +50,6 @@ class CompanyGatewayFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - return $this->builder; - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/CreditFilters.php b/app/Filters/CreditFilters.php index f09be79c70f1..df34873d438f 100644 --- a/app/Filters/CreditFilters.php +++ b/app/Filters/CreditFilters.php @@ -88,45 +88,6 @@ class CreditFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted - legacy from V1. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'credits'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -140,19 +101,6 @@ class CreditFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - // .. - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/DesignFilters.php b/app/Filters/DesignFilters.php index 5db04472ff30..08f235e932c5 100644 --- a/app/Filters/DesignFilters.php +++ b/app/Filters/DesignFilters.php @@ -40,45 +40,6 @@ class DesignFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'designs'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * diff --git a/app/Filters/DocumentFilters.php b/app/Filters/DocumentFilters.php index bf7b589aeef0..ec7b34eb7072 100644 --- a/app/Filters/DocumentFilters.php +++ b/app/Filters/DocumentFilters.php @@ -64,19 +64,6 @@ class DocumentFilters extends QueryFilters return $this->builder; } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - return $this->builder; - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/ExpenseCategoryFilters.php b/app/Filters/ExpenseCategoryFilters.php index 1c9965a38fa0..aebfc5c91971 100644 --- a/app/Filters/ExpenseCategoryFilters.php +++ b/app/Filters/ExpenseCategoryFilters.php @@ -35,49 +35,10 @@ class ExpenseCategoryFilters extends QueryFilters return $this->builder; } - return $this->builder->where('expense_categories.name', 'like', '%'.$filter.'%'); + return $this->builder->where('name', 'like', '%'.$filter.'%'); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'expense_categories'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -95,21 +56,6 @@ class ExpenseCategoryFilters extends QueryFilters return $this->builder; } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - - return $this->builder; - - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/ExpenseFilters.php b/app/Filters/ExpenseFilters.php index 8b17219efff4..fefd6c038e3c 100644 --- a/app/Filters/ExpenseFilters.php +++ b/app/Filters/ExpenseFilters.php @@ -135,46 +135,6 @@ class ExpenseFilters extends QueryFilters return $this->builder; } - - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'expenses'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -192,46 +152,6 @@ class ExpenseFilters extends QueryFilters return $this->builder; } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - $query = DB::table('expenses') - ->join('companies', 'companies.id', '=', 'expenses.company_id') - ->where('expenses.company_id', '=', $company_id) - ->select( - DB::raw('COALESCE(expenses.country_id, companies.country_id) country_id'), - DB::raw("CONCAT(COALESCE(expense_contacts.first_name, ''), ' ', COALESCE(expense_contacts.last_name, '')) contact"), - 'expenses.id', - 'expenses.private_notes', - 'expenses.custom_value1', - 'expenses.custom_value2', - 'expenses.custom_value3', - 'expenses.custom_value4', - 'expenses.created_at', - 'expenses.created_at as expense_created_at', - 'expenses.deleted_at', - 'expenses.is_deleted', - 'expenses.user_id', - ); - - /* - * If the user does not have permissions to view all invoices - * limit the user to only the invoices they have created - */ - if (Gate::denies('view-list', Expense::class)) { - $query->where('expenses.user_id', '=', $user->id); - } - - return $query; - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/InvoiceFilters.php b/app/Filters/InvoiceFilters.php index 8d412853539f..da66d3a9b792 100644 --- a/app/Filters/InvoiceFilters.php +++ b/app/Filters/InvoiceFilters.php @@ -47,30 +47,33 @@ class InvoiceFilters extends QueryFilters $status_parameters = explode(',', $value); - $invoice_filters = []; - if (in_array('all', $status_parameters)) { return $this->builder; } - if (in_array('paid', $status_parameters)) { - $invoice_filters[] = Invoice::STATUS_PAID; - } + $this->builder->where(function ($query) use($status_parameters){ - if (in_array('unpaid', $status_parameters)) { - $invoice_filters[] = Invoice::STATUS_SENT; - $invoice_filters[] = Invoice::STATUS_PARTIAL; - } + $invoice_filters = []; - if(count($invoice_filters) >0){ - $this->builder->whereIn('status_id', $invoice_filters); - } - - if (in_array('overdue', $status_parameters)) { - $this->builder->orWhereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) - ->where('due_date', '<', Carbon::now()) - ->orWhere('partial_due_date', '<', Carbon::now()); - } + if (in_array('paid', $status_parameters)) { + $invoice_filters[] = Invoice::STATUS_PAID; + } + + if (in_array('unpaid', $status_parameters)) { + $invoice_filters[] = Invoice::STATUS_SENT; + $invoice_filters[] = Invoice::STATUS_PARTIAL; + } + + if(count($invoice_filters) >0){ + $query->whereIn('status_id', $invoice_filters); + } + + if (in_array('overdue', $status_parameters)) { + $query->orWhereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]) + ->where('due_date', '<', Carbon::now()) + ->orWhere('partial_due_date', '<', Carbon::now()); + } + }); return $this->builder; } @@ -106,45 +109,6 @@ class InvoiceFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted - legacy from V1. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'invoices'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * @return Builder * @throws RuntimeException @@ -221,18 +185,6 @@ class InvoiceFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/PaymentFilters.php b/app/Filters/PaymentFilters.php index d26f7b15db85..dc012dff3aa2 100644 --- a/app/Filters/PaymentFilters.php +++ b/app/Filters/PaymentFilters.php @@ -42,45 +42,6 @@ class PaymentFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'payments'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Returns a list of payments that can be matched to bank transactions */ @@ -92,7 +53,8 @@ class PaymentFilters extends QueryFilters ->where('is_deleted',0) ->where(function ($query){ $query->whereNull('transaction_id') - ->orWhere("transaction_id",""); + ->orWhere("transaction_id","") + ->company(); }); } @@ -118,18 +80,6 @@ class PaymentFilters extends QueryFilters return $this->builder->where('number', $number); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/PaymentTermFilters.php b/app/Filters/PaymentTermFilters.php index cac3b4a890fc..0352cca5f213 100644 --- a/app/Filters/PaymentTermFilters.php +++ b/app/Filters/PaymentTermFilters.php @@ -40,45 +40,6 @@ class PaymentTermFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'payment_terms'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -92,19 +53,6 @@ class PaymentTermFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - return $this->builder; - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/ProductFilters.php b/app/Filters/ProductFilters.php index 4e4ed2f500d8..8fa1d25264ed 100644 --- a/app/Filters/ProductFilters.php +++ b/app/Filters/ProductFilters.php @@ -53,45 +53,6 @@ class ProductFilters extends QueryFilters return $this->builder->where('product_key', $filter); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'products'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -108,18 +69,6 @@ class ProductFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/ProjectFilters.php b/app/Filters/ProjectFilters.php index f6202c25ee60..e489488b0cd1 100644 --- a/app/Filters/ProjectFilters.php +++ b/app/Filters/ProjectFilters.php @@ -42,45 +42,6 @@ class ProjectFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'projects'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -94,43 +55,6 @@ class ProjectFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - $query = DB::table('projects') - ->join('companies', 'companies.id', '=', 'projects.company_id') - ->where('projects.company_id', '=', $company_id) - ->select( - 'projects.id', - 'projects.name', - 'projects.public_notes', - 'projects.private_notes', - 'projects.created_at', - 'projects.created_at as project_created_at', - 'projects.deleted_at', - 'projects.is_deleted', - 'projects.user_id', - 'projects.assigned_user_id', - ); - - /* - * If the user does not have permissions to view all invoices - * limit the user to only the invoices they have created - */ - if (Gate::denies('view-list', Project::class)) { - $query->where('projects.user_id', '=', $user->id); - } - - return $query; - } - /** * Filters the query by the users company ID. * @@ -138,8 +62,6 @@ class ProjectFilters extends QueryFilters */ public function entityFilter() { - //return $this->builder->whereCompanyId(auth()->user()->company()->id); - // return $this->builder->whereCompanyId(auth()->user()->company()->id)->orWhere('company_id', null); return $this->builder->company(); } } diff --git a/app/Filters/PurchaseOrderFilters.php b/app/Filters/PurchaseOrderFilters.php index 77fd4ede62c0..971ab0554679 100644 --- a/app/Filters/PurchaseOrderFilters.php +++ b/app/Filters/PurchaseOrderFilters.php @@ -93,45 +93,6 @@ class PurchaseOrderFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted - legacy from V1. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'purchase_orders'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -145,19 +106,6 @@ class PurchaseOrderFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - // .. - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/QueryFilters.php b/app/Filters/QueryFilters.php index a735d70ffdca..ed2f666f226b 100644 --- a/app/Filters/QueryFilters.php +++ b/app/Filters/QueryFilters.php @@ -129,6 +129,38 @@ abstract class QueryFilters return $parts; } + /** + * Filters the list based on the status + * archived, active, deleted. + * + * @param string filter + * @return Builder + */ + public function status(string $filter = '') : Builder + { + if (strlen($filter) == 0) { + return $this->builder; + } + + $filters = explode(',', $filter); + + return $this->builder->where(function ($query) use ($filters) { + if (in_array(self::STATUS_ACTIVE, $filters)) { + $query->orWhereNull('deleted_at'); + } + + if (in_array(self::STATUS_ARCHIVED, $filters)) { + $query->orWhere(function ($query) { + $query->whereNotNull('deleted_at')->where('is_deleted',0); + }); + } + + if (in_array(self::STATUS_DELETED, $filters)) { + $query->orWhere('is_deleted', 1); + } + }); + } + /** * String to operator convertor. * diff --git a/app/Filters/QuoteFilters.php b/app/Filters/QuoteFilters.php index 2f342c4413f6..4a83a46553c5 100644 --- a/app/Filters/QuoteFilters.php +++ b/app/Filters/QuoteFilters.php @@ -68,81 +68,49 @@ class QuoteFilters extends QueryFilters $quote_filters = []; - if (in_array('draft', $status_parameters)) { - $quote_filters[] = Quote::STATUS_DRAFT; - } + $this->builder->where(function ($query) use ($status_parameters){ - if (in_array('sent', $status_parameters)) { - $quote_filters[] = Quote::STATUS_SENT; - } + if (in_array('draft', $status_parameters)) { + $query->orWhere(function ($q){ + $q->where('status_id', Quote::STATUS_DRAFT); + }); - if (in_array('approved', $status_parameters)) { - $quote_filters[] = Quote::STATUS_APPROVED; - } - - if(count($quote_filters) >=1){ - $this->builder->whereIn('status_id', $quote_filters); - } - - if (in_array('expired', $status_parameters)) { - $this->builder->orWhere(function ($query){ - $query->where('status_id', Quote::STATUS_SENT) - ->company() - ->whereNotNull('due_date') - ->where('due_date', '<=', now()->toDateString()); - }); - } - - if (in_array('upcoming', $status_parameters)) { - $this->builder->orWhere(function ($query){ - $query->where('status_id', Quote::STATUS_SENT) - ->company() - ->where('due_date', '>=', now()->toDateString()) - ->orderBy('due_date', 'DESC'); - }); - } - - return $this->builder; - } - - - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'quotes'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); } - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); + if (in_array('sent', $status_parameters)) { + $query->orWhere(function ($q){ + $q->where('status_id', Quote::STATUS_SENT) + ->whereNull('due_date') + ->orWhere('due_date', '>=', now()->toDateString()); + }); + } - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } + if (in_array('approved', $status_parameters)) { + $query->orWhere(function ($q){ + $q->where('status_id', Quote::STATUS_APPROVED)->company(); }); } - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); + + if (in_array('expired', $status_parameters)) { + $query->orWhere(function ($q){ + $q->where('status_id', Quote::STATUS_SENT) + ->whereNotNull('due_date') + ->where('due_date', '<=', now()->toDateString()); + }); } + + if (in_array('upcoming', $status_parameters)) { + $query->orWhere(function ($q){ + $q->where('status_id', Quote::STATUS_SENT) + ->where('due_date', '>=', now()->toDateString()) + ->orderBy('due_date', 'DESC'); + }); + } + }); + + return $this->builder; } public function number($number = '') @@ -166,18 +134,6 @@ class QuoteFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/RecurringExpenseFilters.php b/app/Filters/RecurringExpenseFilters.php index 2da8ab8d3229..bf82facccc70 100644 --- a/app/Filters/RecurringExpenseFilters.php +++ b/app/Filters/RecurringExpenseFilters.php @@ -45,45 +45,6 @@ class RecurringExpenseFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'recurring_expenses'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -97,45 +58,6 @@ class RecurringExpenseFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - $query = DB::table('recurring_expenses') - ->join('companies', 'companies.id', '=', 'recurring_expenses.company_id') - ->where('recurring_expenses.company_id', '=', $company_id) - ->select( - DB::raw('COALESCE(recurring_expenses.country_id, companies.country_id) country_id'), - 'recurring_expenses.id', - 'recurring_expenses.private_notes', - 'recurring_expenses.custom_value1', - 'recurring_expenses.custom_value2', - 'recurring_expenses.custom_value3', - 'recurring_expenses.custom_value4', - 'recurring_expenses.created_at', - 'recurring_expenses.created_at as expense_created_at', - 'recurring_expenses.deleted_at', - 'recurring_expenses.is_deleted', - 'recurring_expenses.user_id', - ); - - /* - * If the user does not have permissions to view all invoices - * limit the user to only the invoices they have created - */ - if (Gate::denies('view-list', RecurringExpense::class)) { - $query->where('recurring_expenses.user_id', '=', $user->id); - } - - return $query; - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/RecurringInvoiceFilters.php b/app/Filters/RecurringInvoiceFilters.php index 541f24c03617..c62ba1287576 100644 --- a/app/Filters/RecurringInvoiceFilters.php +++ b/app/Filters/RecurringInvoiceFilters.php @@ -80,46 +80,6 @@ class RecurringInvoiceFilters extends QueryFilters return $this->builder; } - - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'recurring_invoices'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -133,18 +93,6 @@ class RecurringInvoiceFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/RecurringQuoteFilters.php b/app/Filters/RecurringQuoteFilters.php index 9063a47a7d0d..3a1879e9ed79 100644 --- a/app/Filters/RecurringQuoteFilters.php +++ b/app/Filters/RecurringQuoteFilters.php @@ -40,45 +40,6 @@ class RecurringQuoteFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'recurring_'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -92,18 +53,6 @@ class RecurringQuoteFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/SubscriptionFilters.php b/app/Filters/SubscriptionFilters.php index a7217fae7ea8..4ae2e1aec1fb 100644 --- a/app/Filters/SubscriptionFilters.php +++ b/app/Filters/SubscriptionFilters.php @@ -40,45 +40,6 @@ class SubscriptionFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'subscriptions'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -92,31 +53,6 @@ class SubscriptionFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - $query = DB::table('subscriptions') - ->join('companies', 'companies.id', '=', 'subscriptions.company_id') - ->where('subscriptions.company_id', '=', $company_id); - - /* - * If the user does not have permissions to view all invoices - * limit the user to only the invoices they have created - */ - if (Gate::denies('view-list', Webhook::class)) { - $query->where('subscriptions.user_id', '=', $user->id); - } - - return $query; - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/SystemLogFilters.php b/app/Filters/SystemLogFilters.php index a4da66fb8d64..126c81209955 100644 --- a/app/Filters/SystemLogFilters.php +++ b/app/Filters/SystemLogFilters.php @@ -63,18 +63,6 @@ class SystemLogFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/TaskFilters.php b/app/Filters/TaskFilters.php index 733f35880ff2..f4a0fb519912 100644 --- a/app/Filters/TaskFilters.php +++ b/app/Filters/TaskFilters.php @@ -74,46 +74,6 @@ class TaskFilters extends QueryFilters return $this->builder; } - - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'tasks'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - public function project_tasks($project) { @@ -137,18 +97,6 @@ class TaskFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/TaskStatusFilters.php b/app/Filters/TaskStatusFilters.php index 67886d83aad4..d197b764603c 100644 --- a/app/Filters/TaskStatusFilters.php +++ b/app/Filters/TaskStatusFilters.php @@ -37,45 +37,6 @@ class TaskStatusFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'task_statuses'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -89,19 +50,6 @@ class TaskStatusFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - return $this->builder; - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/TaxRateFilters.php b/app/Filters/TaxRateFilters.php index ab8bdbfc79b9..a161ccec7750 100644 --- a/app/Filters/TaxRateFilters.php +++ b/app/Filters/TaxRateFilters.php @@ -37,45 +37,6 @@ class TaxRateFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'tax_rates'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -89,19 +50,6 @@ class TaxRateFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - return $this->builder; - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/TokenFilters.php b/app/Filters/TokenFilters.php index a771aaab7f59..ac9507fb4ad9 100644 --- a/app/Filters/TokenFilters.php +++ b/app/Filters/TokenFilters.php @@ -39,45 +39,6 @@ class TokenFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'company_tokens'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -90,42 +51,7 @@ class TokenFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - $query = DB::table('company_tokens') - ->join('companies', 'companies.id', '=', 'company_tokens.company_id') - ->where('company_tokens.company_id', '=', $company_id) - ->select( - 'company_tokens.id', - 'company_tokens.name', - 'company_tokens.token', - 'company_tokens.created_at', - 'company_tokens.created_at as token_created_at', - 'company_tokens.deleted_at', - 'company_tokens.is_deleted', - 'company_tokens.user_id', - ); - - /* - * If the user does not have permissions to view all invoices - * limit the user to only the invoices they have created - */ - if (Gate::denies('view-list', CompanyToken::class)) { - $query->where('company_tokens.user_id', '=', $user->id); - } - - return $query; - } - + /** * Filters the query by the users company ID. * diff --git a/app/Filters/UserFilters.php b/app/Filters/UserFilters.php index 917727787898..bded4c02eb9e 100644 --- a/app/Filters/UserFilters.php +++ b/app/Filters/UserFilters.php @@ -40,44 +40,6 @@ class UserFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'users'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } /** * Sorts the list based on $sort. @@ -92,18 +54,6 @@ class UserFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/VendorFilters.php b/app/Filters/VendorFilters.php index b330d53a334d..914025ac0457 100644 --- a/app/Filters/VendorFilters.php +++ b/app/Filters/VendorFilters.php @@ -50,45 +50,6 @@ class VendorFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'vendors'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -102,59 +63,6 @@ class VendorFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - $query = DB::table('vendors') - ->join('companies', 'companies.id', '=', 'vendors.company_id') - ->join('vendor_contacts', 'vendor_contacts.vendor_id', '=', 'vendors.id') - ->where('vendors.company_id', '=', $company_id) - ->where('vendor_contacts.is_primary', '=', true) - ->where('vendor_contacts.deleted_at', '=', null) - ->select( - // DB::raw('COALESCE(vendors.currency_id, companies.currency_id) currency_id'), - DB::raw('COALESCE(vendors.country_id, companies.country_id) country_id'), - DB::raw("CONCAT(COALESCE(vendor_contacts.first_name, ''), ' ', COALESCE(vendor_contacts.last_name, '')) contact"), - 'vendors.id', - 'vendors.name', - 'vendors.private_notes', - 'vendor_contacts.first_name', - 'vendor_contacts.last_name', - 'vendors.custom_value1', - 'vendors.custom_value2', - 'vendors.custom_value3', - 'vendors.custom_value4', - 'vendors.balance', - 'vendors.last_login', - 'vendors.created_at', - 'vendors.created_at as vendor_created_at', - 'vendor_contacts.phone', - 'vendor_contacts.email', - 'vendors.deleted_at', - 'vendors.is_deleted', - 'vendors.user_id', - 'vendors.id_number', - 'vendors.settings' - ); - - /* - * If the user does not have permissions to view all invoices - * limit the user to only the invoices they have created - */ - if (Gate::denies('view-list', Vendor::class)) { - $query->where('vendors.user_id', '=', $user->id); - } - - return $query; - } - /** * Filters the query by the users company ID. * diff --git a/app/Filters/WebhookFilters.php b/app/Filters/WebhookFilters.php index b42f49909890..056b1adf4818 100644 --- a/app/Filters/WebhookFilters.php +++ b/app/Filters/WebhookFilters.php @@ -40,45 +40,6 @@ class WebhookFilters extends QueryFilters }); } - /** - * Filters the list based on the status - * archived, active, deleted. - * - * @param string filter - * @return Builder - */ - public function status(string $filter = '') : Builder - { - if (strlen($filter) == 0) { - return $this->builder; - } - - $table = 'webhooks'; - $filters = explode(',', $filter); - - return $this->builder->where(function ($query) use ($filters, $table) { - $query->whereNull($table.'.id'); - - if (in_array(parent::STATUS_ACTIVE, $filters)) { - $query->orWhereNull($table.'.deleted_at'); - } - - if (in_array(parent::STATUS_ARCHIVED, $filters)) { - $query->orWhere(function ($query) use ($table) { - $query->whereNotNull($table.'.deleted_at'); - - if (! in_array($table, ['users'])) { - $query->where($table.'.is_deleted', '=', 0); - } - }); - } - - if (in_array(parent::STATUS_DELETED, $filters)) { - $query->orWhere($table.'.is_deleted', '=', 1); - } - }); - } - /** * Sorts the list based on $sort. * @@ -92,41 +53,6 @@ class WebhookFilters extends QueryFilters return $this->builder->orderBy($sort_col[0], $sort_col[1]); } - /** - * Returns the base query. - * - * @param int company_id - * @param User $user - * @return Builder - * @deprecated - */ - public function baseQuery(int $company_id, User $user) : Builder - { - $query = DB::table('webhooks') - ->join('companies', 'companies.id', '=', 'webhooks.company_id') - ->where('webhooks.company_id', '=', $company_id) - ->select( - 'webhooks.id', - 'webhooks.target_url', - 'webhooks.event_id', - 'webhooks.created_at', - 'webhooks.created_at as token_created_at', - 'webhooks.deleted_at', - 'webhooks.format', - 'webhooks.user_id', - ); - - /* - * If the user does not have permissions to view all invoices - * limit the user to only the invoices they have created - */ - if (Gate::denies('view-list', Webhook::class)) { - $query->where('webhooks.user_id', '=', $user->id); - } - - return $query; - } - /** * Filters the query by the users company ID. * From 45fac7055719e01df670683d5998be4756ad703b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 16 Jan 2023 10:38:52 +1100 Subject: [PATCH 2/8] Fixes for quote queries --- app/Filters/QuoteFilters.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/app/Filters/QuoteFilters.php b/app/Filters/QuoteFilters.php index 4a83a46553c5..c83ed856293d 100644 --- a/app/Filters/QuoteFilters.php +++ b/app/Filters/QuoteFilters.php @@ -66,17 +66,8 @@ class QuoteFilters extends QueryFilters return $this->builder; } - $quote_filters = []; - $this->builder->where(function ($query) use ($status_parameters){ - if (in_array('draft', $status_parameters)) { - $query->orWhere(function ($q){ - $q->where('status_id', Quote::STATUS_DRAFT); - }); - - } - if (in_array('sent', $status_parameters)) { $query->orWhere(function ($q){ $q->where('status_id', Quote::STATUS_SENT) @@ -84,13 +75,21 @@ class QuoteFilters extends QueryFilters ->orWhere('due_date', '>=', now()->toDateString()); }); } + + $quote_filters = []; - if (in_array('approved', $status_parameters)) { - $query->orWhere(function ($q){ - $q->where('status_id', Quote::STATUS_APPROVED)->company(); - }); + if (in_array('draft', $status_parameters)) { + $quote_filters[] = Quote::STATUS_DRAFT; } + + if (in_array('approved', $status_parameters)) { + $quote_filters[] = Quote::STATUS_APPROVED; + } + + if(count($quote_filters) >0){ + $query->orWhereIn('status_id', $quote_filters); + } if (in_array('expired', $status_parameters)) { $query->orWhere(function ($q){ From 59faed5e59fcca8bd51fcb9f004384fbf3cead2b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 16 Jan 2023 10:48:57 +1100 Subject: [PATCH 3/8] Adjustments for expense filters --- app/Filters/ExpenseFilters.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Filters/ExpenseFilters.php b/app/Filters/ExpenseFilters.php index fefd6c038e3c..2a1892e9f2a3 100644 --- a/app/Filters/ExpenseFilters.php +++ b/app/Filters/ExpenseFilters.php @@ -69,14 +69,15 @@ class ExpenseFilters extends QueryFilters return $this->builder; } - $this->builder->whereNested(function ($query) use($status_parameters){ + $this->builder->where(function ($query) use($status_parameters){ if (in_array('logged', $status_parameters)) { $query->orWhere(function ($query){ $query->where('amount', '>', 0) ->whereNull('invoice_id') - ->whereNull('payment_date'); + ->whereNull('payment_date') + ->where('should_be_invoiced',false); }); } From e822550c38a914e4a8ce663a90b66d87ec4d73fe Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 16 Jan 2023 11:46:41 +1100 Subject: [PATCH 4/8] Cleanup for filters --- app/Filters/PurchaseOrderFilters.php | 40 +++++++++++++++---------- app/Filters/RecurringInvoiceFilters.php | 21 ++++++------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/app/Filters/PurchaseOrderFilters.php b/app/Filters/PurchaseOrderFilters.php index 971ab0554679..ad86221ff6a8 100644 --- a/app/Filters/PurchaseOrderFilters.php +++ b/app/Filters/PurchaseOrderFilters.php @@ -42,27 +42,35 @@ class PurchaseOrderFilters extends QueryFilters return $this->builder; } - $po_status = []; + $this->builder->where(function ($query) use ($status_parameters){ - if (in_array('draft', $status_parameters)) { - $po_status[] = PurchaseOrder::STATUS_DRAFT; - } + $po_status = []; - if (in_array('sent', $status_parameters)) { - $po_status[] = PurchaseOrder::STATUS_SENT; - } + if (in_array('draft', $status_parameters)) { + $po_status[] = PurchaseOrder::STATUS_DRAFT; + } - if (in_array('accepted', $status_parameters)) { - $po_status[] = PurchaseOrder::STATUS_ACCEPTED; - } + if (in_array('sent', $status_parameters)) { + $query->orWhere(function ($q){ + $q->where('status_id', PurchaseOrder::STATUS_SENT) + ->whereNull('due_date') + ->orWhere('due_date', '>=', now()->toDateString()); + }); + + } - if (in_array('cancelled', $status_parameters)) { - $po_status[] = PurchaseOrder::STATUS_CANCELLED; - } + if (in_array('accepted', $status_parameters)) { + $po_status[] = PurchaseOrder::STATUS_ACCEPTED; + } - if(count($status_parameters) >=1) { - $this->builder->whereIn('status_id', $status_parameters); - } + if (in_array('cancelled', $status_parameters)) { + $po_status[] = PurchaseOrder::STATUS_CANCELLED; + } + + if(count($status_parameters) >=1) { + $query->whereIn('status_id', $status_parameters); + } + }) return $this->builder; } diff --git a/app/Filters/RecurringInvoiceFilters.php b/app/Filters/RecurringInvoiceFilters.php index c62ba1287576..dfd0ee60e438 100644 --- a/app/Filters/RecurringInvoiceFilters.php +++ b/app/Filters/RecurringInvoiceFilters.php @@ -65,19 +65,20 @@ class RecurringInvoiceFilters extends QueryFilters return $this->builder; } - if (in_array('active', $status_parameters)) { - $this->builder->where('status_id', RecurringInvoice::STATUS_ACTIVE); - } + $recurring_filters = []; - if (in_array('paused', $status_parameters)) { - $this->builder->where('status_id', RecurringInvoice::STATUS_PAUSED); - } + if (in_array('active', $status_parameters)) + $recurring_filters[] = RecurringInvoice::STATUS_ACTIVE; - if (in_array('completed', $status_parameters)) { - $this->builder->where('status_id', RecurringInvoice::STATUS_COMPLETED); - } - return $this->builder; + if (in_array('paused', $status_parameters)) + $recurring_filters[] = RecurringInvoice::STATUS_PAUSED; + + if (in_array('completed', $status_parameters)) + $recurring_filters[] = RecurringInvoice::STATUS_COMPLETED; + + return $this->builder->whereIn('status_id', $recurring_filters); + } /** From 633537570fa9bf742eb825d67357d871d10b255f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 16 Jan 2023 11:59:24 +1100 Subject: [PATCH 5/8] Remove unique constraint from bank matching service --- app/Services/Bank/BankMatchingService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/Bank/BankMatchingService.php b/app/Services/Bank/BankMatchingService.php index 6abf9a9c11cf..dc5b350431f5 100644 --- a/app/Services/Bank/BankMatchingService.php +++ b/app/Services/Bank/BankMatchingService.php @@ -30,7 +30,7 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Cache; -class BankMatchingService implements ShouldQueue, ShouldBeUnique +class BankMatchingService implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; From 396c5ec21b465450dc635a2f56e957731447f8b4 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 16 Jan 2023 13:31:54 +1100 Subject: [PATCH 6/8] Handle 429s for gmail --- app/Helpers/Mail/GmailTransport.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/Helpers/Mail/GmailTransport.php b/app/Helpers/Mail/GmailTransport.php index 6e36804720b4..479fbdbdeb59 100644 --- a/app/Helpers/Mail/GmailTransport.php +++ b/app/Helpers/Mail/GmailTransport.php @@ -65,8 +65,20 @@ class GmailTransport extends AbstractTransport $body->setRaw($this->base64_encode($bcc_list.$message->toString())); - $service->users_messages->send('me', $body, []); - + try{ + $service->users_messages->send('me', $body, []); + } + catch(Google\Service\Exception $e) { + + /* Need to slow down */ + if($e->getCode() == '429') { + + sleep(5); + $service->users_messages->send('me', $body, []); + + } + + } } private function base64_encode($data) From e93163d57cc85a5667ceb2e5ca1e3602ab3c0a52 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 17 Jan 2023 07:44:25 +1100 Subject: [PATCH 7/8] Add contributing.md --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- app/Utils/Traits/GeneratesCounter.php | 5 +- contributing.md | 119 ++++++++++++++++++++++++++ 3 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 contributing.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index a4e94fa4b0b5..f420a18a04e9 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -38,4 +38,4 @@ Add any other context about the problem here. -**(v5) Can you replicate the issue on our demo site? https://demo.invoiceninja.com** +**(v5) Can you replicate the issue on our demo site? https://demo.invoiceninja.com** or here for our react app **(v5) Can you replicate the issue on our demo site? https://react.invoicing.co/demo** diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index 0484facd316a..037ab14e4262 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -60,13 +60,12 @@ trait GeneratesCounter $counter_entity = $client; } elseif ((strpos($pattern, 'groupCounter') !== false) || (strpos($pattern, 'group_counter') !== false)) { - if (property_exists($client, 'group_settings') && property_exists($client->group_settings, $counter_string)) { - $counter = $client->group_settings->{$counter_string}; + if ($client->group_settings()->exists() && property_exists($client->group_settings?->settings, $counter_string)) { + $counter = $client->group_settings?->settings?->{$counter_string}; } else { $counter = 1; } -// $counter_entity = $client->group_settings; $counter_entity = $client->group_settings ?: $client->company; } else { $counter = $client->company->settings->{$counter_string}; diff --git a/contributing.md b/contributing.md new file mode 100644 index 000000000000..03f589a43acb --- /dev/null +++ b/contributing.md @@ -0,0 +1,119 @@ +# Contributing to CONTRIBUTING.md + +First off, thanks for taking the time to contribute! + +All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. + +> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: +> - Star the project +> - Tweet about it +> - Refer this project in your project's readme +> - Mention the project at local meetups and tell your friends/colleagues + + +## Table of Contents + +- [Code of Conduct](#code-of-conduct) +- [I Have a Question](#i-have-a-question) +- [I Want To Contribute](#i-want-to-contribute) +- [Reporting Bugs](#reporting-bugs) +- [Suggesting Enhancements](#suggesting-enhancements) +- [Your First Code Contribution](#your-first-code-contribution) +- [Improving The Documentation](#improving-the-documentation) +- [Styleguides](#styleguides) +- [Commit Messages](#commit-messages) +- [Join The Project Team](#join-the-project-team) + + +## Code of Conduct + +This project and everyone participating in it is governed by the +[CONTRIBUTING.md Code of Conduct](blob/v5-stable/CODE_OF_CONDUCT.md). +By participating, you are expected to uphold this code. Please report unacceptable behavior +to <>. + + +## I Have a Question + +> If you want to ask a question, we assume that you have read the available [Documentation](https://invoiceninja.github.io), Searched the [Forum](https://forum.invoiceninja.com), or tried chatting with us on [Slack](https://invoiceninja.slack.com) [generate a slack invite here](http://slack.invoiceninja.com) + +Please reserve issues for bugs, general questions posted in the issues section will be closed and redirected to other support venues. + +## I Want To Contribute + + +> ### Legal Notice +> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license. Please note that you'll need to sign the CLA for any PRs to be accepted + +### Reporting Bugs + + +#### Before Submitting a Bug Report + +A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible. + +- Make sure that you are using the latest version. +- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://invoiceninja.github.io). If you are looking for support, you might want to check [this section](#i-have-a-question)). +- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](issues?q=label%3Abug). +- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue. +- Collect information about the bug: +- Stack trace (Traceback) +- OS, Platform and Version (Windows, Linux, macOS, x86, ARM) +- Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant. +- Possibly your input and the output +- Can you reliably reproduce the issue? And can you also reproduce it with older versions? + + +#### How Do I Submit a Good Bug Report? + +> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to <>. + + +We use GitHub issues to track bugs and errors. If you run into an issue with the project: + +- Open an [Issue](/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.) +- Explain the behavior you would expect and the actual behavior. +- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case. +- Provide the information you collected in the previous section. + +Once it's filed: + +- The project team will label the issue accordingly. +- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. +- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution). + + + + +### Suggesting Enhancements + +This section guides you through submitting an enhancement suggestion for CONTRIBUTING.md, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions. + + +#### Before Submitting an Enhancement + +- Make sure that you are using the latest version. +- Read the [documentation]() carefully and find out if the functionality is already covered, maybe by an individual configuration. +- Perform a [search](/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. +- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library. + + +#### How Do I Submit a Good Enhancement Suggestion? + +Enhancement suggestions are tracked as [GitHub issues](/issues). + +- Use a **clear and descriptive title** for the issue to identify the suggestion. +- Provide a **step-by-step description of the suggested enhancement** in as many details as possible. +- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you. +- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. +- **Explain why this enhancement would be useful** to most CONTRIBUTING.md users. You may also want to point out the other projects that solved it better and which could serve as inspiration. + + + +### Your First Code Contribution + +All PRs should be created against the v5-develop branch. + + +## Attribution +This guide is based on the **contributing.md**. [Make your own](https://contributing.md/)! From b7d1f67d6abbeb0a51cf60a9da246aee5d51f165 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 17 Jan 2023 07:46:10 +1100 Subject: [PATCH 8/8] Fix case for contributing --- contributing.md | 119 ------------------------------------------------ 1 file changed, 119 deletions(-) delete mode 100644 contributing.md diff --git a/contributing.md b/contributing.md deleted file mode 100644 index 03f589a43acb..000000000000 --- a/contributing.md +++ /dev/null @@ -1,119 +0,0 @@ -# Contributing to CONTRIBUTING.md - -First off, thanks for taking the time to contribute! - -All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. - -> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: -> - Star the project -> - Tweet about it -> - Refer this project in your project's readme -> - Mention the project at local meetups and tell your friends/colleagues - - -## Table of Contents - -- [Code of Conduct](#code-of-conduct) -- [I Have a Question](#i-have-a-question) -- [I Want To Contribute](#i-want-to-contribute) -- [Reporting Bugs](#reporting-bugs) -- [Suggesting Enhancements](#suggesting-enhancements) -- [Your First Code Contribution](#your-first-code-contribution) -- [Improving The Documentation](#improving-the-documentation) -- [Styleguides](#styleguides) -- [Commit Messages](#commit-messages) -- [Join The Project Team](#join-the-project-team) - - -## Code of Conduct - -This project and everyone participating in it is governed by the -[CONTRIBUTING.md Code of Conduct](blob/v5-stable/CODE_OF_CONDUCT.md). -By participating, you are expected to uphold this code. Please report unacceptable behavior -to <>. - - -## I Have a Question - -> If you want to ask a question, we assume that you have read the available [Documentation](https://invoiceninja.github.io), Searched the [Forum](https://forum.invoiceninja.com), or tried chatting with us on [Slack](https://invoiceninja.slack.com) [generate a slack invite here](http://slack.invoiceninja.com) - -Please reserve issues for bugs, general questions posted in the issues section will be closed and redirected to other support venues. - -## I Want To Contribute - - -> ### Legal Notice -> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license. Please note that you'll need to sign the CLA for any PRs to be accepted - -### Reporting Bugs - - -#### Before Submitting a Bug Report - -A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible. - -- Make sure that you are using the latest version. -- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://invoiceninja.github.io). If you are looking for support, you might want to check [this section](#i-have-a-question)). -- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](issues?q=label%3Abug). -- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue. -- Collect information about the bug: -- Stack trace (Traceback) -- OS, Platform and Version (Windows, Linux, macOS, x86, ARM) -- Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant. -- Possibly your input and the output -- Can you reliably reproduce the issue? And can you also reproduce it with older versions? - - -#### How Do I Submit a Good Bug Report? - -> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to <>. - - -We use GitHub issues to track bugs and errors. If you run into an issue with the project: - -- Open an [Issue](/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.) -- Explain the behavior you would expect and the actual behavior. -- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case. -- Provide the information you collected in the previous section. - -Once it's filed: - -- The project team will label the issue accordingly. -- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced. -- If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](#your-first-code-contribution). - - - - -### Suggesting Enhancements - -This section guides you through submitting an enhancement suggestion for CONTRIBUTING.md, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions. - - -#### Before Submitting an Enhancement - -- Make sure that you are using the latest version. -- Read the [documentation]() carefully and find out if the functionality is already covered, maybe by an individual configuration. -- Perform a [search](/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. -- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library. - - -#### How Do I Submit a Good Enhancement Suggestion? - -Enhancement suggestions are tracked as [GitHub issues](/issues). - -- Use a **clear and descriptive title** for the issue to identify the suggestion. -- Provide a **step-by-step description of the suggested enhancement** in as many details as possible. -- **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you. -- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux. -- **Explain why this enhancement would be useful** to most CONTRIBUTING.md users. You may also want to point out the other projects that solved it better and which could serve as inspiration. - - - -### Your First Code Contribution - -All PRs should be created against the v5-develop branch. - - -## Attribution -This guide is based on the **contributing.md**. [Make your own](https://contributing.md/)!