Skip to content

Commit

Permalink
Added Client phone number and company name in generate invoice api (#238
Browse files Browse the repository at this point in the history
)

* added company name

* added client phone number

* refactored client_list method with do end block
  • Loading branch information
aniketkaushik authored Apr 6, 2022
1 parent 20d884c commit e23008a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/models/company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 do |client|
{ id: client.id, name: client.name, email: client.email, phone: client.phone, address: client.address }
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion spec/models/company_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e23008a

Please sign in to comment.