Skip to content

Commit

Permalink
fix: remove unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRodrigues10 committed Dec 2, 2023
1 parent a9b8bf2 commit 37d47e2
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/store/inventory.ex
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ defmodule Store.Inventory do
alias Store.Accounts.User

def purchase(%User{} = user, %Product{} = product, product_params) do
order = get_user_draft_order(user)
order = get_order_draft_by_id(user.id, preloads: [])


case order do
%Order{} ->
Expand All @@ -355,13 +356,6 @@ defmodule Store.Inventory do
end
end

defp get_user_draft_order(user) do
Order
|> where(user_id: ^user.id, status: :draft)
|> Repo.one()
|> Repo.preload([:user, :products])
end

defp handle_existing_order(order, product, product_params) do
quantity = String.to_integer(product_params["quantity"])

Expand Down

0 comments on commit 37d47e2

Please sign in to comment.