Skip to content

Commit

Permalink
Update invoice.rb
Browse files Browse the repository at this point in the history
replaced for loop for summation by .sum()
  • Loading branch information
mjavurek authored Nov 10, 2024
1 parent c0654c2 commit ab4ff5b
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,15 @@ def net_amount
end

def orders_sum
sum = 0
for order in orders
sum += order.sum(:groups)
end
sum
orders.sum { |order| order.sum(:groups) }
end

def orders_transport_sum
orders.sum(:transport)
end

Check failure on line 40 in app/models/invoice.rb

View workflow job for this annotation

GitHub Actions / test

Layout/TrailingWhitespace: Trailing whitespace detected.
def deliveries_sum
sum = 0
for delivery in deliveries
sum += delivery.sum
end
sum
deliveries.sum(&:sum)
end

Check failure on line 44 in app/models/invoice.rb

View workflow job for this annotation

GitHub Actions / test

Layout/TrailingWhitespace: Trailing whitespace detected.
def expected_amount
Expand Down

0 comments on commit ab4ff5b

Please sign in to comment.