From a788410b6fbe5de8302f5957150894e1ce61ae58 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 18 Mar 2022 15:39:56 +1100 Subject: [PATCH] Import company properties --- app/Jobs/Company/CompanyImport.php | 69 +++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/app/Jobs/Company/CompanyImport.php b/app/Jobs/Company/CompanyImport.php index ffc88ff8325a..5041107ecc28 100644 --- a/app/Jobs/Company/CompanyImport.php +++ b/app/Jobs/Company/CompanyImport.php @@ -149,6 +149,63 @@ class CompanyImport implements ShouldQueue 'system_logs', ]; + private $company_properties = [ + "convert_products", + "fill_products", + "update_products", + "show_product_details", + "client_can_register", + "custom_surcharge_taxes1", + "custom_surcharge_taxes2", + "custom_surcharge_taxes3", + "custom_surcharge_taxes4", + "show_product_cost", + "enabled_tax_rates", + "enabled_modules", + "enable_product_cost", + "enable_product_quantity", + "default_quantity", + "subdomain", + "size_id", + "first_day_of_week", + "first_month_of_year", + "portal_mode", + "portal_domain", + "enable_modules", + "custom_fields", + "industry_id", + "slack_webhook_url", + "google_analytics_key", + "created_at", + "updated_at", + "enabled_item_tax_rates", + "is_large", + "enable_shop_api", + "default_auto_bill", + "mark_expenses_invoiceable", + "mark_expenses_paid", + "invoice_expense_documents", + "auto_start_tasks", + "invoice_task_timelog", + "invoice_task_documents", + "show_tasks_table", + "is_disabled", + "default_task_is_date_based", + "enable_product_discount", + "calculate_expense_tax_by_amount", + "expense_inclusive_taxes", + "session_timeout", + "oauth_password_required", + "invoice_task_datelog", + "default_password_timeout", + "show_task_end_date", + "markdown_enabled", + "use_comma_as_decimal_place", + "report_include_drafts", + "client_registration_fields", + "convert_rate_to_client", + ]; + /** * Create a new job instance. * @@ -212,6 +269,7 @@ class CompanyImport implements ShouldQueue $this->preFlightChecks() ->purgeCompanyData() + ->importCompany() ->importData() ->postImportCleanup(); @@ -420,17 +478,24 @@ class CompanyImport implements ShouldQueue private function importCompany() { //$tmp_company = $this->backup_file->company; - $tmp_company = (object)$this->getObject("company"); + $tmp_company = (object)$this->getObject("company",true); $tmp_company->company_key = $this->createHash(); $tmp_company->db = config('database.default'); $tmp_company->account_id = $this->account->id; +nlog($tmp_company); + if(Ninja::isHosted()) $tmp_company->subdomain = MultiDB::randomSubdomainGenerator(); else $tmp_company->subdomain = ''; - $this->company = $tmp_company; + foreach($this->company_properties as $value){ + + $this->company->{$value} = $tmp_company->{$value}; + + } + $this->company->save(); return $this;