diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 1ad03907e6b4..538d1b59367c 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -192,8 +192,8 @@ class CompanySettings extends BaseSettings { public $late_fee_endless_amount = 0; public $late_fee_endless_percent = 0; - public $client_online_payment_notification = true; - public $client_manual_payment_notification = true; + public $client_online_payment_notification = true; //@todo implement in notifications + public $client_manual_payment_notification = true; //@todo implement in notifications public $system_notifications_slack = ''; public $system_notifications_email = ''; @@ -381,7 +381,7 @@ class CompanySettings extends BaseSettings { 'counter_padding' => 'integer', 'design' => 'string', 'website' => 'string', - 'pdf_variables' => 'object', + 'pdf_variables' => 'array', ]; /** diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index 4bc7ea338fbe..7276811352de 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -460,8 +460,12 @@ class CompanyController extends BaseController */ public function destroy(DestroyCompanyRequest $request, Company $company) { - $company->delete(); + $company->delete(); + + //@TODO if last company, delete the account also. + return response()->json([], 200); + } } diff --git a/app/Http/Controllers/OpenAPI/CompanySchema.php b/app/Http/Controllers/OpenAPI/CompanySchema.php index 4f70608f0944..3b6842f1fb63 100644 --- a/app/Http/Controllers/OpenAPI/CompanySchema.php +++ b/app/Http/Controllers/OpenAPI/CompanySchema.php @@ -11,7 +11,6 @@ * @OA\Property(property="portal_domain", type="string", example="https://subdomain.invoicing.co", description="The fully qualified domain for client facing URLS"), * @OA\Property(property="enabled_tax_rates", type="integer", example="1", description="Number of taxes rates used per entity"), * @OA\Property(property="fill_products", type="boolean", example=true, description="Toggles filling a product description based on product key"), - * @OA\Property(property="enable_invoice_quantity", type="boolean", example=true, description="Toggles filling a product description based on product key"), * @OA\Property(property="convert_products", type="boolean", example=true, description="___________"), * @OA\Property(property="update_products", type="boolean", example=true, description="Toggles updating a product description which description changes"), * @OA\Property(property="show_product_details", type="boolean", example=true, description="Toggles showing a product description which description changes"), diff --git a/app/Models/Company.php b/app/Models/Company.php index affd4d2fce3e..b3c13f2edb7c 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -63,7 +63,6 @@ class Company extends BaseModel 'enable_product_quantity', 'enabled_modules', 'default_quantity', - 'enable_invoice_quantity', 'enabled_tax_rates', 'portal_mode', 'portal_domain', diff --git a/app/Repositories/BaseRepository.php b/app/Repositories/BaseRepository.php index 22f251e9c1f4..62b581979114 100644 --- a/app/Repositories/BaseRepository.php +++ b/app/Repositories/BaseRepository.php @@ -179,18 +179,14 @@ class BaseRepository $class = new ReflectionClass($model); $state = []; $resource = explode('\\', $class->name)[2]; /** This will extract 'Invoice' from App\Models\Invoice */ + $lcfirst_resource_id = lcfirst($resource) . '_id'; - if ($class->name == 'App\Models\Invoice') { + if ($class->name == Invoice::class || $class->name == Quote::class) $state['starting_amount'] = $model->amount; - if (!$model->id) { - $client = Client::find($data['client_id']); - $model->uses_inclusive_taxes = $client->getSetting('inclusive_taxes'); - } - } - - if ($class->name == 'App\Models\Quote') { - $state['starting_amount'] = $model->amount; + if (!$model->id) { + $client = Client::find($data['client_id']); + $model->uses_inclusive_taxes = $client->getSetting('inclusive_taxes'); } $model->fill($data); @@ -234,7 +230,7 @@ class BaseRepository } $new_invitation = $invitation_factory_class::create($model->company_id, $model->user_id); - $new_invitation->quote_id = $model->id; + $new_invitation->{$lcfirst_resource_id} = $model->id; $new_invitation->client_contact_id = $this->decodePrimaryKey($invitation['client_contact_id']); $new_invitation->save(); @@ -253,7 +249,7 @@ class BaseRepository $model = $model->service()->applyNumber()->save(); - if ($class->name == 'App\Models\Invoice') { + if ($class->name == Invoice::class) { if (($state['finished_amount'] != $state['starting_amount']) && ($model->status_id != Invoice::STATUS_DRAFT)) { $model->ledger()->updateInvoiceBalance(($state['finished_amount'] - $state['starting_amount'])); @@ -267,11 +263,11 @@ class BaseRepository } - if ($class->name == 'App\Models\Credit') { + if ($class->name == Credit::class) { $model = $model->calc()->getCredit(); } - if ($class->name == 'App\Models\Quote') { + if ($class->name == Quote::class) { $model = $model->calc()->getQuote(); } diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index 64fa6e0dc3c6..01d22efb34f8 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -91,7 +91,6 @@ class CompanyTransformer extends EntityTransformer 'custom_surcharge_taxes3' => (bool)$company->custom_surcharge_taxes3, 'custom_surcharge_taxes4' => (bool)$company->custom_surcharge_taxes4, 'show_product_cost' => (bool)$company->show_product_cost, - 'enable_invoice_quantity' => (bool)$company->enable_invoice_quantity, 'enable_product_cost' => (bool)$company->enable_product_cost, 'show_product_details' => (bool)$company->show_product_details, 'enable_product_quantity' => (bool)$company->enable_product_quantity, diff --git a/database/migrations/2014_10_13_000000_create_users_table.php b/database/migrations/2014_10_13_000000_create_users_table.php index 4fc8401d5b65..8aedd8bd5b9b 100644 --- a/database/migrations/2014_10_13_000000_create_users_table.php +++ b/database/migrations/2014_10_13_000000_create_users_table.php @@ -67,7 +67,7 @@ class CreateUsersTable extends Migration $table->string('decimal_separator'); $table->string('code'); $table->boolean('swap_currency_symbol')->default(false); - $table->decimal('exchange_rate', 6, 6); + $table->decimal('exchange_rate', 6, 6)->default(1); }); @@ -154,7 +154,7 @@ class CreateUsersTable extends Migration $table->boolean('custom_surcharge_taxes2')->default(false); $table->boolean('custom_surcharge_taxes3')->default(false); $table->boolean('custom_surcharge_taxes4')->default(false); - $table->boolean('enable_invoice_quantity')->default(true); + //$table->boolean('enable_invoice_quantity')->default(true); $table->boolean('show_product_cost')->default(false); $table->unsignedInteger('enabled_tax_rates')->default(1); $table->unsignedInteger('enabled_modules')->default(0);