diff --git a/app/Http/Requests/Expense/StoreExpenseRequest.php b/app/Http/Requests/Expense/StoreExpenseRequest.php index bffb4012c265..828217b4ee63 100644 --- a/app/Http/Requests/Expense/StoreExpenseRequest.php +++ b/app/Http/Requests/Expense/StoreExpenseRequest.php @@ -38,12 +38,9 @@ class StoreExpenseRequest extends Request if (isset($this->number)) { $rules['number'] = Rule::unique('expenses')->where('company_id', auth()->user()->company()->id); } - - // $rules['number'] = 'unique:expenses,number,'.$this->id.',id,company_id,'.auth()->user()->company()->id; - // $rules['contacts.*.email'] = 'nullable|distinct'; - //$rules['number'] = new UniqueExpenseNumberRule($this->all()); - $rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id; + if(!empty($this->client_id)) + $rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id; return $this->globalRules($rules); } diff --git a/app/Http/Requests/Expense/UpdateExpenseRequest.php b/app/Http/Requests/Expense/UpdateExpenseRequest.php index 3295603f4f1e..71a8a7773a24 100644 --- a/app/Http/Requests/Expense/UpdateExpenseRequest.php +++ b/app/Http/Requests/Expense/UpdateExpenseRequest.php @@ -36,7 +36,7 @@ class UpdateExpenseRequest extends Request /* Ensure we have a client name, and that all emails are unique*/ $rules['country_id'] = 'integer|nullable'; - //$rules['id_number'] = 'unique:clients,id_number,,id,company_id,' . auth()->user()->company()->id; + $rules['contacts.*.email'] = 'nullable|distinct'; if (isset($this->number)) { diff --git a/app/Models/Company.php b/app/Models/Company.php index c5fd0465595f..90a266d18e99 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -83,7 +83,6 @@ class Company extends BaseModel 'default_task_is_date_based', 'enable_product_discount', 'expense_inclusive_taxes', - 'expense_amount_is_pretax', ]; protected $hidden = [ diff --git a/app/Models/Expense.php b/app/Models/Expense.php index 6b54ef387364..c50a3f59f7f9 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -55,7 +55,7 @@ class Expense extends BaseModel 'tax_amount2', 'tax_amount3', 'uses_inclusive_taxes', - 'amount_is_pretax', + 'calculate_tax_by_amount', ]; protected $casts = [ diff --git a/app/Models/RecurringInvoice.php b/app/Models/RecurringInvoice.php index 1c34f6c5e98e..549aa08333ee 100644 --- a/app/Models/RecurringInvoice.php +++ b/app/Models/RecurringInvoice.php @@ -91,6 +91,7 @@ class RecurringInvoice extends BaseModel 'remaining_cycles', 'auto_bill', 'auto_bill_enabled', + 'design_id', ]; protected $casts = [ diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index 0e7158f3235e..b0ea39bb5788 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -131,7 +131,7 @@ class CompanyTransformer extends EntityTransformer 'archived_at' => (int) $company->deleted_at, 'created_at' =>(int) $company->created_at, 'slack_webhook_url' => (string) $company->slack_webhook_url, - 'google_analytics_url' => (string) $company->google_analytics_key, //@deprecate + 'google_analytics_url' => (string) $company->google_analytics_key, //@deprecate 1-2-2021 'google_analytics_key' => (string) $company->google_analytics_key, 'enabled_item_tax_rates' => (int) $company->enabled_item_tax_rates, 'client_can_register' => (bool) $company->client_can_register, @@ -145,13 +145,13 @@ class CompanyTransformer extends EntityTransformer 'auto_start_tasks' => (bool) $company->auto_start_tasks, 'invoice_task_documents' => (bool) $company->invoice_task_documents, 'show_tasks_table' => (bool) $company->show_tasks_table, - 'use_credits_payment' => 'always', //todo remove + 'use_credits_payment' => 'always', // @deprecate 1-2-2021 'default_task_is_date_based' => (bool)$company->default_task_is_date_based, 'enable_product_discount' => (bool)$company->enable_product_discount, 'calculate_expense_tax_by_amount' =>(bool)$company->calculate_expense_tax_by_amount, - 'hide_empty_columns_on_pdf' => false, //@deprecate + 'hide_empty_columns_on_pdf' => false, // @deprecate 1-2-2021 'expense_inclusive_taxes' => (bool)$company->expense_inclusive_taxes, - 'expense_amount_is_pretax' =>( bool)$company->expense_amount_is_pretax, + 'expense_amount_is_pretax' =>(bool)true, //@deprecate 1-2-2021 ]; } diff --git a/app/Transformers/ExpenseTransformer.php b/app/Transformers/ExpenseTransformer.php index 200e4991a5fc..2fca0c6a27d1 100644 --- a/app/Transformers/ExpenseTransformer.php +++ b/app/Transformers/ExpenseTransformer.php @@ -95,7 +95,7 @@ class ExpenseTransformer extends EntityTransformer 'tax_amount2' => (float) $expense->tax_amount2, 'tax_amount3' => (float) $expense->tax_amount3, 'uses_inclusive_taxes' => (bool) $expense->uses_inclusive_taxes, - 'amount_is_pretax' => (bool) $expense->amount_is_pretax, + 'calculate_tax_by_amount' => (bool) $expense->calculate_tax_by_amount, ]; } } diff --git a/database/migrations/2021_01_11_092056_fix_company_settings_url.php b/database/migrations/2021_01_11_092056_fix_company_settings_url.php index f04d1615b048..472025550c9b 100644 --- a/database/migrations/2021_01_11_092056_fix_company_settings_url.php +++ b/database/migrations/2021_01_11_092056_fix_company_settings_url.php @@ -31,11 +31,18 @@ class FixCompanySettingsUrl extends Migration Schema::table('companies', function (Blueprint $table) { $table->dropColumn('logo'); + $tbale->dropColumn('expense_amount_is_pretax'); }); Schema::table('tasks', function (Blueprint $table) { $table->dropColumn('start_time'); }); + + Schema::table('expenses', function (Blueprint $table) { + $table->dropColumn('expense_amount_is_pretax'); + $table->dropColumn('amount_is_pretax'); + $table->boolean('calculate_tax_by_amount')->default(false); + }); } /**