Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ def random_record_for_org(org, klass)
# Base Items
# ----------------------------------------------------------------------------

require 'seeds'
require "seeds"
Seeds.seed_base_items

# ----------------------------------------------------------------------------
# NDBN Members
# ----------------------------------------------------------------------------
seed_file = File.open(Rails.root.join("spec", "fixtures", "ndbn-small-import.csv"))
seed_file = Rails.root.join("spec", "fixtures", "ndbn-small-import.csv").open
SyncNDBNMembers.upload(seed_file)

# ----------------------------------------------------------------------------
Expand All @@ -40,7 +40,7 @@ def random_record_for_org(org, klass)
organization.name = "Pawnee Diaper Bank"
organization.street = "P.O. Box 22613"
organization.city = "Pawnee"
organization.state = "Indiana"
organization.state = "IN"
organization.zipcode = "12345"
organization.email = "info@pawneediaper.org"
end
Expand Down Expand Up @@ -131,7 +131,7 @@ def seed_random_item_with_name(organization, name)
end

# ----------------------------------------------------------------------------
# Item < - > ItemCategory
# Item <-> ItemCategory
# ----------------------------------------------------------------------------

Organization.all.find_each do |org|
Expand All @@ -154,10 +154,8 @@ def seed_random_item_with_name(organization, name)
org.item_categories.sample(total_item_categories_to_add).each do |item_category|
partner_group_one.item_categories << item_category
end

next unless org.name == pdx_org.name

partner_group_two = FactoryBot.create(:partner_group, organization: org)
next unless org.name== pdx_org.name
partner_group_two=FactoryBot.create(:partner_group, organization: org)
org.item_categories.each do |item_category|
partner_group_two.item_categories << item_category
end
Expand Down Expand Up @@ -619,7 +617,7 @@ def seed_quantity(item_name, organization, storage_location, quantity)
AdjustmentCreateService.new(adjustment).call
end

JSON.parse(File.read(Rails.root.join("db", "base_items.json"))).each do |_category, entries|
JSON.parse(Rails.root.join("db", "base_items.json").read).each do |_category, entries|
entries.each do |entry|
seed_quantity(entry["name"], pdx_org, inv_arbor, entry["qty"]["arbor"])
seed_quantity(entry["name"], pdx_org, inv_pdxdb, entry["qty"]["pdxdb"])
Expand Down Expand Up @@ -828,7 +826,7 @@ def seed_quantity(item_name, organization, storage_location, quantity)
amount_spent_on_other_cents: rand(0..5_000)
)

purchase.amount_spent_in_cents = amount_items.map { |i| purchase.send("amount_spent_on_#{i}_cents") }.sum
purchase.amount_spent_in_cents = amount_items.map { |i| purchase.send(:"amount_spent_on_#{i}_cents") }.sum

rand(1..5).times do
purchase.line_items.push(
Expand Down Expand Up @@ -963,7 +961,7 @@ def seed_quantity(item_name, organization, storage_location, quantity)
organization_id: pdx_org.id,
from_id: from_id,
to_id: to_id,
line_items: [ LineItem.new(quantity: quantity, item: item) ]
line_items: [LineItem.new(quantity: quantity, item: item)]
)
TransferCreateService.call(transfer)

Expand Down