diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index b8ba7573ad79..ffe011a6e3fc 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -266,6 +266,8 @@ class ClientController extends BaseController $this->client_repo->bulkUpdate($clients, $request->column, $request->new_value); + return $this->listResponse(Client::query()->withTrashed()->company()->whereIn('id', $request->ids)); + } $clients->each(function ($client) use ($action, $user) { diff --git a/app/Http/Requests/Client/BulkClientRequest.php b/app/Http/Requests/Client/BulkClientRequest.php index b16fec93abb4..31870f0e2752 100644 --- a/app/Http/Requests/Client/BulkClientRequest.php +++ b/app/Http/Requests/Client/BulkClientRequest.php @@ -18,17 +18,6 @@ use Illuminate\Validation\Rule; class BulkClientRequest extends Request { use MakesHash; - - private array $bulk_update_columns = [ - 'public_notes', - 'industry_id', - 'size_id', - 'country_id', - 'custom_value1', - 'custom_value2', - 'custom_value3', - 'custom_value4', - ]; /** * Determine if the user is authorized to make this request. @@ -52,8 +41,8 @@ class BulkClientRequest extends Request 'template_id' => 'sometimes|string', 'group_settings_id' => ['required_if:action,assign_group',Rule::exists('group_settings', 'id')->where('company_id', $user->company()->id)], 'send_email' => 'sometimes|bool', - 'column' => ['required_if:action,bulk_update','string', Rule::in($this->client_bulk_update_columns)], - 'new_value' => ['required_id:action,bulk_update|string'], + 'column' => ['required_if:action,bulk_update', 'string', Rule::in(\App\Models\Client::$bulk_update_columns)], + 'new_value' => ['required_if:action,bulk_update|string'], ]; } diff --git a/app/Models/Client.php b/app/Models/Client.php index 826b86ef1948..c34c16bf67ea 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -220,12 +220,17 @@ class Client extends BaseModel implements HasLocalePreference 'routing_id', ]; - // public function scopeExclude($query) - // { - // $query->makeHidden(['balance','paid_to_date']); + public static array $bulk_update_columns = [ + 'public_notes', + 'industry_id', + 'size_id', + 'country_id', + 'custom_value1', + 'custom_value2', + 'custom_value3', + 'custom_value4', + ]; - // return $query; - // } public function getEntityType() { diff --git a/app/Services/EDocument/Standards/ZugferdEDokument.php b/app/Services/EDocument/Standards/ZugferdEDokument.php index ddb362bbee18..412825109496 100644 --- a/app/Services/EDocument/Standards/ZugferdEDokument.php +++ b/app/Services/EDocument/Standards/ZugferdEDokument.php @@ -102,7 +102,12 @@ class ZugferdEDokument extends AbstractService $this->xdocument->setDocumentShipToAddress($client->shipping_address1, $client->shipping_address2, "", $client->shipping_postal_code, $client->shipping_city, $client->shipping_country->iso_3166_2, $client->shipping_state); } - $this->xdocument->addDocumentPaymentMean(68, ctrans("texts.xinvoice_online_payment")); + //Payment Means - Switcher + if($company->settings->custom_value1 == '42'){ + $this->xdocument->addDocumentPaymentMean(typecode: 42, payeeIban: $company->settings->custom_value2, payeeAccountName: $company->settings->custom_value4, payeeBic: $company->settings->custom_value3); + } + else + $this->xdocument->addDocumentPaymentMean(68, ctrans("texts.xinvoice_online_payment")); if (str_contains($company->getSetting('vat_number'), "/")) { $this->xdocument->addDocumentSellerTaxRegistration("FC", $company->getSetting('vat_number')); diff --git a/app/Utils/Statics.php b/app/Utils/Statics.php index 54a32dd6d249..ee36bbd80b2b 100644 --- a/app/Utils/Statics.php +++ b/app/Utils/Statics.php @@ -127,6 +127,10 @@ class Statics $data['templates'] = Cache::get('templates'); } + $data['bulk_updates'] = [ + 'client' => \App\Models\Client::$bulk_update_columns, + ]; + return $data; } } diff --git a/tests/Feature/ClientApiTest.php b/tests/Feature/ClientApiTest.php index 6bbbfb2dcc52..eb3c18ad9d4d 100644 --- a/tests/Feature/ClientApiTest.php +++ b/tests/Feature/ClientApiTest.php @@ -59,6 +59,33 @@ class ClientApiTest extends TestCase Model::reguard(); } + public function testBulkUpdates() + { + Client::factory()->count(3)->create([ + "company_id" => $this->company->id, + "user_id" => $this->user->id, + ]); + + $client_count = Client::query()->where('company_id', $this->company->id)->count(); + + $data = [ + "column" => "public_notes", + "new_value" => "THISISABULKUPDATE", + "action" => "bulk_update", + "ids" => Client::where('company_id', $this->company->id)->get()->pluck("hashed_id") + ]; + + $response = $this->withHeaders([ + 'X-API-TOKEN' => $this->token, + ])->postJson("/api/v1/clients/bulk", $data); + + + $response->assertStatus(200); + + $this->assertEquals($client_count, Client::query()->where('public_notes', "THISISABULKUPDATE")->where('company_id', $this->company->id)->count()); + + } + public function testCountryCodeValidation() {