Skip to content

Commit

Permalink
A bit of cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
marick committed Apr 7, 2021
1 parent ed4ba77 commit 151173d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
9 changes: 0 additions & 9 deletions lib/hillel_budget.ex
Expand Up @@ -8,8 +8,6 @@ defmodule HillelBudget do
limit - Enum.sum(item_charges)
end

# The similarities between the following and the above give me a cunning plan!
# But first make it work.
def remaining_category_total_after_bill(categories, category, bill_amount) do
case Map.has_key?(categories, category) do
true ->
Expand All @@ -23,13 +21,6 @@ defmodule HillelBudget do
remaining_total_after_bill(budget.total_limit, bill) >= 0
end

def budget(total_limit) do
%{total_limit: total_limit}
end

# I noticed that I'd gotten my terminology messed up, using "bills and bill"
# instead of "bill and item"

def normalize(item) when is_map(item) do
cost = item.cost
categories = Map.get(item, :categories, [])
Expand Down
17 changes: 17 additions & 0 deletions test/hillel_budget_test.exs
Expand Up @@ -51,4 +51,21 @@ defmodule HillelBudgetTest do
@tag :skip
test "category with total"
end


# ----------------------------------------------------------------------------

# Note that these are normalized items. Getting close to wanting
# a structure. Heck, let's do it.
def item(cost, categories) do
%{cost: cost, categories: categories}
end

# I realized that budget really belongs here
def budget(total_limit) do
%{total_limit: total_limit}
end



end

0 comments on commit 151173d

Please sign in to comment.