From 73f64eb6e6a4d41de8269b3ac98c2b64f3498e2a Mon Sep 17 00:00:00 2001 From: Aniket Kaushik Date: Wed, 6 Apr 2022 15:24:37 +0530 Subject: [PATCH 1/3] added company name --- app/views/internal_api/v1/generate_invoice/index.json.jbuilder | 1 + spec/requests/internal_api/v1/generate_invoice/index_spec.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/views/internal_api/v1/generate_invoice/index.json.jbuilder b/app/views/internal_api/v1/generate_invoice/index.json.jbuilder index 1e652f810c..504d0c3d38 100644 --- a/app/views/internal_api/v1/generate_invoice/index.json.jbuilder +++ b/app/views/internal_api/v1/generate_invoice/index.json.jbuilder @@ -3,6 +3,7 @@ json.company_details do json.id current_company.id json.logo current_company.logo.attached? ? polymorphic_url(current_company.logo) : "" + json.name current_company.name json.phone_number current_company.business_phone json.address current_company.address json.country current_company.country diff --git a/spec/requests/internal_api/v1/generate_invoice/index_spec.rb b/spec/requests/internal_api/v1/generate_invoice/index_spec.rb index ec369015bb..25757bb000 100644 --- a/spec/requests/internal_api/v1/generate_invoice/index_spec.rb +++ b/spec/requests/internal_api/v1/generate_invoice/index_spec.rb @@ -19,6 +19,7 @@ company_details = { id: user.current_workspace.id, logo: polymorphic_url(user.current_workspace.logo), + name: user.current_workspace.name, phone_number: user.current_workspace.business_phone, address: user.current_workspace.address, country: user.current_workspace.country From 1eb4facc18240bead371fdac6fc4386e08ddd00f Mon Sep 17 00:00:00 2001 From: Aniket Kaushik Date: Wed, 6 Apr 2022 15:28:02 +0530 Subject: [PATCH 2/3] added client phone number --- app/models/company.rb | 4 +++- spec/models/company_spec.rb | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/company.rb b/app/models/company.rb index b7d0ee66da..08922be0be 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -59,6 +59,8 @@ def client_details(time_frame = "week") end def client_list - clients.kept.map { |client| { id: client.id, name: client.name, email: client.email, address: client.address } } + clients.kept.map { |client| + { id: client.id, name: client.name, email: client.email, phone: client.phone, address: client.address } +} end end diff --git a/spec/models/company_spec.rb b/spec/models/company_spec.rb index a3bb8bcd0d..39cb1eed6b 100644 --- a/spec/models/company_spec.rb +++ b/spec/models/company_spec.rb @@ -106,7 +106,10 @@ let(:client) { create(:client, company:) } it "returns list of all the clients of a company" do - result = [{ id: client.id, name: client.name, email: client.email, address: client.address }] + result = [{ + id: client.id, name: client.name, email: client.email, phone: client.phone, + address: client.address + }] expect(company.client_list).to eq(result) end end From cc11d3c140317f024a4911828d6aea57a8bfea1f Mon Sep 17 00:00:00 2001 From: Aniket Kaushik Date: Wed, 6 Apr 2022 17:01:51 +0530 Subject: [PATCH 3/3] refactored client_list method with do end block --- app/models/company.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/company.rb b/app/models/company.rb index 08922be0be..bbf4c6803f 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -59,8 +59,8 @@ def client_details(time_frame = "week") end def client_list - clients.kept.map { |client| - { id: client.id, name: client.name, email: client.email, phone: client.phone, address: client.address } -} + clients.kept.map do |client| + { id: client.id, name: client.name, email: client.email, phone: client.phone, address: client.address } + end end end