diff --git a/app/Transformers/Shop/CompanyShopProfileTransformer.php b/app/Transformers/Shop/CompanyShopProfileTransformer.php index 2cb26eeb21a2..0ae0d3033827 100644 --- a/app/Transformers/Shop/CompanyShopProfileTransformer.php +++ b/app/Transformers/Shop/CompanyShopProfileTransformer.php @@ -72,6 +72,9 @@ class CompanyShopProfileTransformer extends EntityTransformer 'email' => $company->settings->email, 'country_id' => $company->settings->country_id, 'vat_number' => $company->settings->vat_number, + 'product' => $company->settings->translations->product ?? ctrans('texts.product'), + 'products' => $company->settings->translations->products ?? ctrans('texts.products'), + 'client_registration_fields' => $company->client_registration_fields, ]; $new_settings = new stdClass(); diff --git a/database/migrations/2024_05_19_215103_2024_05_20_einvoice_columns.php b/database/migrations/2024_05_19_215103_2024_05_20_einvoice_columns.php index 5fca9a9feb95..b9183d0c753a 100644 --- a/database/migrations/2024_05_19_215103_2024_05_20_einvoice_columns.php +++ b/database/migrations/2024_05_19_215103_2024_05_20_einvoice_columns.php @@ -36,7 +36,6 @@ return new class extends Migration $table->mediumText('e_invoice')->nullable(); }); - Schema::table('accounts', function (Blueprint $table) { $table->integer('email_quota')->default(20)->nullable(); }); diff --git a/tests/Unit/Shop/ShopProfileTest.php b/tests/Unit/Shop/ShopProfileTest.php index 6e6e773c3103..51ce81779c24 100644 --- a/tests/Unit/Shop/ShopProfileTest.php +++ b/tests/Unit/Shop/ShopProfileTest.php @@ -48,4 +48,60 @@ class ShopProfileTest extends TestCase $this->assertArrayHasKey('custom_value1', $arr['data']['settings']); $this->assertEquals($this->company->company_key, $arr['data']['company_key']); } + + public function testProfileSettingsUpdate() + { + + $this->company->enable_shop_api = true; + + $settings = $this->company->settings; + + $trans = new \stdClass; + $trans->product = "Service"; + $trans->products = "Services"; + + $settings->translations = $trans; + $this->company->settings = $settings; + + $this->company->save(); + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-COMPANY-KEY' => $this->company->company_key, + ])->getJson('/api/v1/shop/profile'); + + + $response->assertStatus(200); + + $arr = $response->json(); + + $this->assertEquals("Service", $arr['data']['settings']['product']); + $this->assertEquals("Services", $arr['data']['settings']['products']); + + } + + public function testProfileSettingsUpdate2() + { + + $this->company->enable_shop_api = true; + + $this->company->save(); + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-COMPANY-KEY' => $this->company->company_key, + ])->getJson('/api/v1/shop/profile'); + + + $response->assertStatus(200); + + $arr = $response->json(); + + $this->assertEquals("Product", $arr['data']['settings']['product']); + $this->assertEquals("Products", $arr['data']['settings']['products']); + $this->assertIsArray($arr['data']['settings']['client_registration_fields']); + + } + + }