Run rubocop --fix-layout and remove encoding comments
This commit is contained in:
parent
fa63e6e81d
commit
ea2862fdef
283 changed files with 1164 additions and 1969 deletions
|
|
@ -16,13 +16,13 @@ class CreateUsers < ActiveRecord::Migration[4.2]
|
|||
end
|
||||
add_index(:users, :nick, :unique => true)
|
||||
add_index(:users, :email, :unique => true)
|
||||
|
||||
|
||||
# Create the default admin user...
|
||||
puts "Creating user #{USER_ADMIN} with password 'secret'..."
|
||||
user = User.new(:nick => USER_ADMIN, :first_name => "Anton", :last_name => "Administrator", :email => "admin@foo.test")
|
||||
user.password = "secret"
|
||||
raise "Failed!" unless user.save && User.find_by_nick(USER_ADMIN).has_password("secret")
|
||||
|
||||
|
||||
# Create a normal user...
|
||||
puts "Creating user #{USER_TEST} with password 'foobar'..."
|
||||
user = User.new(:nick => USER_TEST, :first_name => "Tim", :last_name => "Tester", :email => "test@foo.test")
|
||||
|
|
|
|||
|
|
@ -1,49 +1,50 @@
|
|||
class CreateGroups < ActiveRecord::Migration[4.2]
|
||||
GROUP_ADMIN = 'Administrators'
|
||||
GROUP_ORDER = 'Sample Order Group'
|
||||
|
||||
|
||||
def self.up
|
||||
create_table :groups do |t|
|
||||
t.column :type, :string, :null => false # inheritance, types: Group, OrderGroup
|
||||
t.column :name, :string, :null => false
|
||||
t.column :description, :string
|
||||
t.column :actual_size, :integer # OrderGroup column
|
||||
t.column :account_balance, :decimal, :precision => 8, :scale => 2, :null => false, :default => 0 # OrderGroup column
|
||||
t.column :account_updated, :timestamp # OrderGroup column
|
||||
t.column :actual_size, :integer # OrderGroup column
|
||||
t.column :account_balance, :decimal, :precision => 8, :scale => 2, :null => false, :default => 0 # OrderGroup column
|
||||
t.column :account_updated, :timestamp # OrderGroup column
|
||||
t.column :created_on, :timestamp, :null => false
|
||||
t.column :role_admin, :boolean, :default => false, :null => false
|
||||
end
|
||||
add_index(:groups, :name, :unique => true)
|
||||
|
||||
|
||||
create_table :memberships do |t|
|
||||
t.column :group_id, :integer, :null => false
|
||||
t.column :user_id, :integer, :null => false
|
||||
end
|
||||
add_index(:memberships, [:user_id, :group_id], :unique => true)
|
||||
|
||||
|
||||
# Create the default "Administrators" group...
|
||||
puts "Creating group #{GROUP_ADMIN}..."
|
||||
Group.create(:name => GROUP_ADMIN, :description => "System administrators.", :role_admin => true)
|
||||
raise 'Failed!' unless administrators = Group.find_by_name(GROUP_ADMIN)
|
||||
|
||||
|
||||
# Create a sample order group...
|
||||
puts "Creating order group #{GROUP_ORDER}..."
|
||||
ordergroup = OrderGroup.create!(:name => GROUP_ORDER, :description => "A sample order group created by the migration.", :actual_size => 1, :account_updated => Time.now)
|
||||
raise "Wrong type created!" unless ordergroup.is_a?(OrderGroup)
|
||||
|
||||
|
||||
# Get the admin user and join the admin group...
|
||||
raise "User #{CreateUsers::USER_ADMIN} not found, cannot join group '#{administrators.name}'!" unless admin = User.find_by_nick(CreateUsers::USER_ADMIN)
|
||||
|
||||
puts "Joining #{CreateUsers::USER_ADMIN} user to new '#{administrators.name}' group as a group admin..."
|
||||
membership = Membership.create(:group => administrators, :user => admin)
|
||||
raise "Failed!" unless admin.memberships.first == membership
|
||||
raise "User #{CreateUsers::USER_ADMIN} has no admin_roles" unless admin.role_admin?
|
||||
|
||||
|
||||
# Get the test user and join the order group...
|
||||
raise "User #{CreateUsers::USER_TEST} not found, cannot join group '#{ordergroup.name}'!" unless test = User.find_by_nick(CreateUsers::USER_TEST)
|
||||
|
||||
puts "Joining #{CreateUsers::USER_TEST} user to new '#{ordergroup.name}' group as a group admin..."
|
||||
membership = Membership.create(:group => ordergroup, :user => test)
|
||||
raise "Failed!" unless test.memberships.first == membership
|
||||
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
class CreateSuppliers < ActiveRecord::Migration[4.2]
|
||||
SUPPLIER_SAMPLE = 'Sample Supplier'
|
||||
|
||||
def self.up
|
||||
SUPPLIER_SAMPLE = 'Sample Supplier'
|
||||
|
||||
def self.up
|
||||
add_column :groups, :role_suppliers, :boolean, :default => false, :null => false
|
||||
Group.reset_column_information
|
||||
puts "Give #{CreateGroups::GROUP_ADMIN} the role supplier .."
|
||||
raise "Failed" unless Group.find_by_name(CreateGroups::GROUP_ADMIN).update_attribute(:role_suppliers, true)
|
||||
raise "Cannot find admin user!" unless admin = User.find_by_nick(CreateUsers::USER_ADMIN)
|
||||
raise "Failed to enable role_suppliers with admin user!" unless admin.role_suppliers?
|
||||
|
||||
|
||||
create_table :suppliers do |t|
|
||||
t.column :name, :string, :null => false
|
||||
t.column :address, :string, :null => false
|
||||
t.column :phone, :string, :null => false
|
||||
t.column :name, :string, :null => false
|
||||
t.column :address, :string, :null => false
|
||||
t.column :phone, :string, :null => false
|
||||
t.column :phone2, :string
|
||||
t.column :fax, :string
|
||||
t.column :email, :string
|
||||
|
|
@ -23,12 +23,12 @@ class CreateSuppliers < ActiveRecord::Migration[4.2]
|
|||
t.column :order_howto, :string
|
||||
t.column :note, :string
|
||||
end
|
||||
add_index(:suppliers, :name, :unique => true)
|
||||
|
||||
add_index(:suppliers, :name, :unique => true)
|
||||
|
||||
# Create sample supplier...
|
||||
puts "Creating sample supplier '#{SUPPLIER_SAMPLE}'..."
|
||||
Supplier.create(:name => SUPPLIER_SAMPLE, :address => "Organic City", :phone => "0123-555555")
|
||||
raise "Failed!" unless supplier = Supplier.find_by_name(SUPPLIER_SAMPLE)
|
||||
raise "Failed!" unless supplier = Supplier.find_by_name(SUPPLIER_SAMPLE)
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
|||
|
|
@ -2,28 +2,27 @@ class CreateArticleMeta < ActiveRecord::Migration[4.2]
|
|||
CATEGORY_SAMPLE = 'Sample Category'
|
||||
TAX_STANDARD = 'Standard'
|
||||
TAX_REDUCED = 'Reduced'
|
||||
|
||||
|
||||
def self.up
|
||||
# Add user roles...
|
||||
add_column :groups, :role_article_meta, :boolean, :default => false, :null => false
|
||||
add_column :groups, :role_article_meta, :boolean, :default => false, :null => false
|
||||
Group.reset_column_information
|
||||
puts "Give #{CreateGroups::GROUP_ADMIN} the role article_meta .."
|
||||
raise "Failed" unless Group.find_by_name(CreateGroups::GROUP_ADMIN).update_attribute(:role_article_meta, true)
|
||||
raise 'Cannot find admin user!' unless admin = User.find_by_nick(CreateUsers::USER_ADMIN)
|
||||
raise 'Failed to enable role_article_meta with admin user!' unless admin.role_article_meta?
|
||||
|
||||
|
||||
# ArticleCategories
|
||||
create_table :article_categories do |t|
|
||||
t.column :name, :string, :null => false
|
||||
t.column :description, :string
|
||||
end
|
||||
add_index(:article_categories, :name, :unique => true)
|
||||
|
||||
|
||||
# Create sample category...
|
||||
puts "Creating sample article category '#{CATEGORY_SAMPLE}'..."
|
||||
ArticleCategory.create(:name => CATEGORY_SAMPLE, :description => "This is just a sample article category.")
|
||||
raise "Failed!" unless category = ArticleCategory.find_by_name(CATEGORY_SAMPLE)
|
||||
|
||||
raise "Failed!" unless category = ArticleCategory.find_by_name(CATEGORY_SAMPLE)
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
|||
|
|
@ -21,16 +21,16 @@ class CreateFinancialTransactions < ActiveRecord::Migration[4.2]
|
|||
# Add transactions to the sample order group
|
||||
puts "Add 30 transactions to the group '#{CreateGroups::GROUP_ORDER}'..."
|
||||
raise "Group '#{CreateGroups::GROUP_ORDER}' not found!" unless ordergroup = Group.find_by_name(CreateGroups::GROUP_ORDER)
|
||||
|
||||
balance = 0
|
||||
for i in 1..30
|
||||
ordergroup.addFinancialTransaction(i, "Sample Transaction Nr. #{i}", admin)
|
||||
balance += i
|
||||
end
|
||||
raise "Failed!" unless financial_transaction = FinancialTransaction.find_by_note('Sample Transaction Nr. 1')
|
||||
raise "Failed!" unless financial_transaction = FinancialTransaction.find_by_note('Sample Transaction Nr. 1')
|
||||
raise "Failed to update account_balance!" unless OrderGroup.find(ordergroup.id).account_balance == balance
|
||||
|
||||
end
|
||||
|
||||
|
||||
def self.down
|
||||
remove_column :groups, :role_finance
|
||||
drop_table :financial_transactions
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class CreateArticles < ActiveRecord::Migration[4.2]
|
||||
SAMPLE_ARTICLE_NAMES = ['banana', 'kiwi', 'strawberry']
|
||||
SAMPLE_ARTICLE_NAMES = ['banana', 'kiwi', 'strawberry']
|
||||
|
||||
def self.up
|
||||
create_table :articles do |t|
|
||||
|
|
@ -11,23 +11,23 @@ class CreateArticles < ActiveRecord::Migration[4.2]
|
|||
t.column :availability, :boolean, :default => true, :null => false
|
||||
t.column :current_price_id, :integer
|
||||
end
|
||||
add_index(:articles, :name, :unique => true)
|
||||
|
||||
add_index(:articles, :name, :unique => true)
|
||||
|
||||
# Create 30 sample articles...
|
||||
puts "Create 3 articles of the supplier '#{CreateSuppliers::SUPPLIER_SAMPLE}'..."
|
||||
raise "Supplier '#{CreateSuppliers::SUPPLIER_SAMPLE}' not found!" unless supplier = Supplier.find_by_name(CreateSuppliers::SUPPLIER_SAMPLE)
|
||||
raise "Category '#{CreateArticleMeta::CATEGORY_SAMPLE}' not found!" unless category = ArticleCategory.find_by_name(CreateArticleMeta::CATEGORY_SAMPLE)
|
||||
|
||||
SAMPLE_ARTICLE_NAMES.each do |a|
|
||||
puts 'Create Article ' + a
|
||||
Article.create( :name => a,
|
||||
:supplier => supplier,
|
||||
:article_category => category,
|
||||
:unit => '500g',
|
||||
:note => 'delicious',
|
||||
:availability => true)
|
||||
end
|
||||
puts 'Create Article ' + a
|
||||
Article.create(:name => a,
|
||||
:supplier => supplier,
|
||||
:article_category => category,
|
||||
:unit => '500g',
|
||||
:note => 'delicious',
|
||||
:availability => true)
|
||||
end
|
||||
raise "Failed!" unless Article.find(:all).length == SAMPLE_ARTICLE_NAMES.length
|
||||
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
|||
|
|
@ -3,30 +3,30 @@ class CreateArticlePrices < ActiveRecord::Migration[4.2]
|
|||
create_table :article_prices do |t|
|
||||
t.column :article_id, :int, :null => false
|
||||
t.column :clear_price, :decimal, :precision => 8, :scale => 2, :null => false
|
||||
t.column :gross_price, :decimal, :precision => 8, :scale => 2, :null => false #gross price, incl. vat, refund and price markup
|
||||
t.column :gross_price, :decimal, :precision => 8, :scale => 2, :null => false # gross price, incl. vat, refund and price markup
|
||||
t.column :tax, :float, :null => false, :default => 0
|
||||
t.column :refund, :decimal, :precision => 8, :scale => 2, :null => false, :default => 0
|
||||
t.column :updated_on, :datetime
|
||||
t.column :unit_quantity, :int, :default => 1, :null => false
|
||||
t.column :order_number, :string
|
||||
end
|
||||
add_index(:article_prices, :article_id)
|
||||
|
||||
#add some prices ...
|
||||
puts 'add prices to the sample articles'
|
||||
CreateArticles::SAMPLE_ARTICLE_NAMES.each do |a|
|
||||
puts 'Create Price for article ' + a
|
||||
raise 'article #{a} not found!' unless article = Article.find_by_name(a)
|
||||
new_price = ArticlePrice.new(:clear_price => rand(4)+1,
|
||||
:tax => 7.0,
|
||||
:refund => 0,
|
||||
:unit_quantity => rand(10)+1,
|
||||
:order_number => rand(9999))
|
||||
article.add_price(new_price)
|
||||
raise 'Failed!' unless ArticlePrice.find_by_article_id(article.id)
|
||||
end
|
||||
raise 'Failed!' unless ArticlePrice.find(:all).length == CreateArticles::SAMPLE_ARTICLE_NAMES.length
|
||||
|
||||
add_index(:article_prices, :article_id)
|
||||
|
||||
# add some prices ...
|
||||
puts 'add prices to the sample articles'
|
||||
CreateArticles::SAMPLE_ARTICLE_NAMES.each do |a|
|
||||
puts 'Create Price for article ' + a
|
||||
raise 'article #{a} not found!' unless article = Article.find_by_name(a)
|
||||
|
||||
new_price = ArticlePrice.new(:clear_price => rand(4) + 1,
|
||||
:tax => 7.0,
|
||||
:refund => 0,
|
||||
:unit_quantity => rand(10) + 1,
|
||||
:order_number => rand(9999))
|
||||
article.add_price(new_price)
|
||||
raise 'Failed!' unless ArticlePrice.find_by_article_id(article.id)
|
||||
end
|
||||
raise 'Failed!' unless ArticlePrice.find(:all).length == CreateArticles::SAMPLE_ARTICLE_NAMES.length
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class CreateOrders < ActiveRecord::Migration[4.2]
|
||||
ORDER_TEST = 'Test Order'
|
||||
GROUP_ORDER = 'Orders'
|
||||
|
||||
|
||||
def self.up
|
||||
# Order role
|
||||
add_column :groups, :role_orders, :boolean, :default => false, :null => false
|
||||
|
|
@ -10,12 +10,12 @@ class CreateOrders < ActiveRecord::Migration[4.2]
|
|||
raise "Failed" unless Group.find_by_name(CreateGroups::GROUP_ADMIN).update_attribute(:role_orders, true)
|
||||
raise 'Cannot find admin user!' unless admin = User.find_by_nick(CreateUsers::USER_ADMIN)
|
||||
raise 'Failed to enable role_orders with admin user!' unless admin.role_orders?
|
||||
|
||||
|
||||
# Create the default "Order" group...
|
||||
puts 'Creating group "Orders"...'
|
||||
Group.create(:name => GROUP_ORDER, :description => "working group for managing orders", :role_orders => true)
|
||||
raise "Failed!" unless Group.find_by_name(GROUP_ORDER)
|
||||
|
||||
|
||||
# Order
|
||||
create_table :orders do |t|
|
||||
t.column :name, :string, :null => false
|
||||
|
|
@ -31,9 +31,10 @@ class CreateOrders < ActiveRecord::Migration[4.2]
|
|||
add_index(:orders, :starts)
|
||||
add_index(:orders, :ends)
|
||||
add_index(:orders, :finished)
|
||||
|
||||
|
||||
puts "Creating order '#{ORDER_TEST}'..."
|
||||
raise "Supplier '#{CreateSuppliers::SUPPLIER_SAMPLE}' not found!" unless supplier = Supplier.find_by_name(CreateSuppliers::SUPPLIER_SAMPLE)
|
||||
|
||||
Order.create(:name => ORDER_TEST, :supplier => supplier, :starts => Time.now)
|
||||
raise 'Creating test order failed!' unless order = Order.find_by_name(ORDER_TEST)
|
||||
|
||||
|
|
@ -47,17 +48,18 @@ class CreateOrders < ActiveRecord::Migration[4.2]
|
|||
t.column :lock_version, :integer, :null => false, :default => 0
|
||||
end
|
||||
add_index(:order_articles, [:order_id, :article_id], :unique => true)
|
||||
|
||||
|
||||
puts 'Adding articles to the order...'
|
||||
CreateArticles::SAMPLE_ARTICLE_NAMES.each { | a |
|
||||
puts "Article #{a}..."
|
||||
raise 'Article not found!' unless article = Article.find_by_name(a)
|
||||
raise 'No price found for article!' unless price = article.current_price
|
||||
OrderArticle.create(:order => order, :article => article)
|
||||
raise 'Creating OrderArticle failed!' unless OrderArticle.find_by_order_id_and_article_id(order.id, article.id)
|
||||
}
|
||||
raise 'Creating OrderArticles failed!' unless order.articles.size == CreateArticles::SAMPLE_ARTICLE_NAMES.length
|
||||
|
||||
CreateArticles::SAMPLE_ARTICLE_NAMES.each { |a|
|
||||
puts "Article #{a}..."
|
||||
raise 'Article not found!' unless article = Article.find_by_name(a)
|
||||
raise 'No price found for article!' unless price = article.current_price
|
||||
|
||||
OrderArticle.create(:order => order, :article => article)
|
||||
raise 'Creating OrderArticle failed!' unless OrderArticle.find_by_order_id_and_article_id(order.id, article.id)
|
||||
}
|
||||
raise 'Creating OrderArticles failed!' unless order.articles.size == CreateArticles::SAMPLE_ARTICLE_NAMES.length
|
||||
|
||||
# GroupOrder
|
||||
create_table :group_orders do |t|
|
||||
t.column :order_group_id, :integer, :null => false
|
||||
|
|
@ -67,14 +69,15 @@ class CreateOrders < ActiveRecord::Migration[4.2]
|
|||
t.column :updated_on, :timestamp, :null => false
|
||||
t.column :updated_by_user_id, :integer, :null => false
|
||||
end
|
||||
add_index(:group_orders, [:order_group_id, :order_id], :unique => true)
|
||||
|
||||
add_index(:group_orders, [:order_group_id, :order_id], :unique => true)
|
||||
|
||||
puts 'Adding group order...'
|
||||
raise "Cannot find user #{CreateUsers::USER_TEST}" unless user = User.find_by_nick(CreateUsers::USER_TEST)
|
||||
raise "Cannot find OrderGroup '#{CreateGroups::GROUP_ORDER}'!" unless orderGroup = OrderGroup.find_by_name(CreateGroups::GROUP_ORDER)
|
||||
|
||||
GroupOrder.create(:order_group => orderGroup, :order => order, :price => 0, :updated_by => user)
|
||||
raise 'Retrieving group order failed!' unless groupOrder = orderGroup.group_orders.find(:first, :conditions => "order_id = #{order.id}")
|
||||
|
||||
|
||||
# GroupOrderArticles
|
||||
create_table :group_order_articles do |t|
|
||||
t.column :group_order_id, :integer, :null => false
|
||||
|
|
@ -82,7 +85,7 @@ class CreateOrders < ActiveRecord::Migration[4.2]
|
|||
t.column :quantity, :integer, :null => false
|
||||
t.column :tolerance, :integer, :null => false
|
||||
t.column :updated_on, :timestamp, :null => false
|
||||
end
|
||||
end
|
||||
add_index(:group_order_articles, [:group_order_id, :order_article_id], :unique => true, :name => "goa_index")
|
||||
# GroupOrderArticleQuantity
|
||||
create_table :group_order_article_quantities do |t|
|
||||
|
|
@ -91,20 +94,22 @@ class CreateOrders < ActiveRecord::Migration[4.2]
|
|||
t.column :tolerance, :int, :default => 0
|
||||
t.column :created_on, :timestamp, :null => false
|
||||
end
|
||||
|
||||
|
||||
puts 'Adding articles to group order...'
|
||||
order.order_articles.each { | orderArticle |
|
||||
order.order_articles.each { |orderArticle|
|
||||
puts "Article #{orderArticle.article.name}..."
|
||||
GroupOrderArticle.create(:group_order => groupOrder, :order_article => orderArticle, :quantity => 0, :tolerance => 0)
|
||||
raise 'Failed to create order!' unless article = GroupOrderArticle.find(:first, :conditions => "group_order_id = #{groupOrder.id} AND order_article_id = #{orderArticle.id}")
|
||||
|
||||
article.updateQuantities(rand(6) + 1, rand(4) + 1)
|
||||
}
|
||||
raise 'Failed to create orders!' unless groupOrder.order_articles.size == order.order_articles.size
|
||||
raise 'Failed to create orders!' unless groupOrder.order_articles.size == order.order_articles.size
|
||||
|
||||
groupOrder.updatePrice
|
||||
raise 'Failed to update GroupOrder.price' unless groupOrder.save!
|
||||
|
||||
raise 'Failed to update GroupOrder.price' unless groupOrder.save!
|
||||
|
||||
# Update order
|
||||
order.updateQuantities
|
||||
order.updateQuantities
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class CreateOrderResults < ActiveRecord::Migration[4.2]
|
|||
t.column :price, :decimal, :precision => 8, :scale => 2, :null => false, :default => 0
|
||||
end
|
||||
add_index(:group_order_results, [:group_name, :order_id], :unique => true)
|
||||
|
||||
|
||||
create_table :order_article_results do |t|
|
||||
t.column :order_id, :int, :null => false
|
||||
t.column :name, :string, :null => false
|
||||
|
|
@ -22,7 +22,7 @@ class CreateOrderResults < ActiveRecord::Migration[4.2]
|
|||
t.column :units_to_order, :int, :null => false
|
||||
end
|
||||
add_index(:order_article_results, :order_id)
|
||||
|
||||
|
||||
create_table :group_order_article_results do |t|
|
||||
t.column :order_article_result_id, :int, :null => false
|
||||
t.column :group_order_result_id, :int, :null => false
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
class UserPasswordReset < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
add_column :users, :reset_password_token, :string
|
||||
add_column :users, :reset_password_expires, :timestamp
|
||||
add_column :users, :reset_password_expires, :timestamp
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ class CreateComments < ActiveRecord::Migration[4.2]
|
|||
t.column :created_at, :datetime, :null => false
|
||||
t.column :commentable_id, :integer, :default => 0, :null => false
|
||||
t.column :commentable_type, :string, :limit => 15,
|
||||
:default => "", :null => false
|
||||
:default => "", :null => false
|
||||
t.column :user_id, :integer, :default => 0, :null => false
|
||||
end
|
||||
|
||||
|
||||
add_index :comments, ["user_id"], :name => "fk_comments_user"
|
||||
end
|
||||
|
||||
|
||||
def self.down
|
||||
drop_table :comments
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class CreateOrderClearing < ActiveRecord::Migration[4.2]
|
||||
|
||||
def self.up
|
||||
add_column :orders, :invoice_amount, :decimal, :precision => 8, :scale => 2, :null => false, :default => 0
|
||||
add_column :orders, :refund, :decimal, :precision => 8, :scale => 2, :null => false, :default => 0
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class AddMessaging < ActiveRecord::Migration[4.2]
|
|||
end
|
||||
add_index(:messages, :sender_id)
|
||||
add_index(:messages, :recipient_id)
|
||||
|
||||
|
||||
# Setup acts_as_configurable plugin for user options etc.
|
||||
ConfigurableSetting.create_table
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ class CreateTasks < ActiveRecord::Migration[4.2]
|
|||
end
|
||||
add_index :tasks, :name
|
||||
add_index :tasks, :due_date
|
||||
|
||||
|
||||
create_table :assignments do |t|
|
||||
t.column :user_id, :integer, :null => false
|
||||
t.column :task_id, :integer, :null => false
|
||||
t.column :accepted, :boolean, :default => false
|
||||
end
|
||||
add_index :assignments, [:user_id, :task_id], :unique => true
|
||||
|
||||
|
||||
add_column :groups, :weekly_task, :boolean, :default => false # if group has an job for every week
|
||||
add_column :groups, :weekday, :integer # e.g. 1 means monday, 2 = tuesday an so on
|
||||
add_column :groups, :task_name, :string # the name of the weekly task
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ class ChangeResultQuantities < ActiveRecord::Migration[4.2]
|
|||
|
||||
def self.down
|
||||
change_column :group_order_article_results, :quantity, :integer, :null => false
|
||||
change_column :order_article_results, :units_to_order,:integer, :default => 0, :null => false
|
||||
change_column :order_article_results, :units_to_order, :integer, :default => 0, :null => false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class AddSharedListsConnection < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
add_column :suppliers, :shared_supplier_id, :integer
|
||||
add_column :articles, :manufacturer , :string
|
||||
add_column :articles, :manufacturer, :string
|
||||
add_column :articles, :origin, :string
|
||||
add_column :articles, :shared_updated_on, :timestamp
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
class RemoveTableArticlePrices < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
|
||||
puts "create columns in articles ..."
|
||||
add_column "articles", "clear_price", :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
add_column "articles", "gross_price", :decimal, :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
|
|
@ -10,24 +9,23 @@ class RemoveTableArticlePrices < ActiveRecord::Migration[4.2]
|
|||
add_column "articles", "order_number", :string
|
||||
add_column "articles", "created_at", :datetime
|
||||
add_column "articles", "updated_at", :datetime
|
||||
|
||||
|
||||
# stop auto-updating the timestamps to make the data-copy safe!
|
||||
Article.record_timestamps = false
|
||||
|
||||
|
||||
puts "now copy values of article_prices into new articles-columns..."
|
||||
Article.find(:all).each do |article|
|
||||
price = article.current_price
|
||||
article.update_attributes!(:clear_price => price.clear_price,
|
||||
:gross_price => price.gross_price,
|
||||
:tax => price.tax,
|
||||
:refund => price.refund,
|
||||
:unit_quantity => price.unit_quantity,
|
||||
:order_number => price.order_number,
|
||||
:updated_at => price.updated_on,
|
||||
:created_at => price.updated_on)
|
||||
:gross_price => price.gross_price,
|
||||
:tax => price.tax,
|
||||
:refund => price.refund,
|
||||
:unit_quantity => price.unit_quantity,
|
||||
:order_number => price.order_number,
|
||||
:updated_at => price.updated_on,
|
||||
:created_at => price.updated_on)
|
||||
end
|
||||
|
||||
|
||||
|
||||
puts "delete article_prices, current_price attribute"
|
||||
drop_table :article_prices
|
||||
remove_column :articles, :current_price_id
|
||||
|
|
@ -40,29 +38,28 @@ class RemoveTableArticlePrices < ActiveRecord::Migration[4.2]
|
|||
t.decimal "clear_price", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
t.decimal "gross_price", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
t.float "tax", :default => 0.0, :null => false
|
||||
t.decimal "refund", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
t.decimal "refund", :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
t.datetime "updated_on"
|
||||
t.integer "unit_quantity", :default => 1, :null => false
|
||||
t.integer "unit_quantity", :default => 1, :null => false
|
||||
t.string "order_number"
|
||||
end
|
||||
|
||||
|
||||
# copy data from article now into old ArticlePrice-object
|
||||
Article.find(:all).each do |article|
|
||||
price = ArticlePrice.create(:clear_price => article.clear_price,
|
||||
:gross_price => article.gross_price,
|
||||
:tax => article.tax,
|
||||
:refund => article.refund,
|
||||
:unit_quantity => article.unit_quantity,
|
||||
:order_number => article.order_number.blank? ? nil : article.order_number,
|
||||
:updated_on => article.updated_at)
|
||||
|
||||
:gross_price => article.gross_price,
|
||||
:tax => article.tax,
|
||||
:refund => article.refund,
|
||||
:unit_quantity => article.unit_quantity,
|
||||
:order_number => article.order_number.blank? ? nil : article.order_number,
|
||||
:updated_on => article.updated_at)
|
||||
|
||||
article.update_attribute(:current_price, price)
|
||||
price.update_attribute(:article, article)
|
||||
|
||||
end
|
||||
|
||||
|
||||
# remove new columns
|
||||
remove_column "articles", "clear_price"
|
||||
remove_column "articles", "clear_price"
|
||||
remove_column "articles", "gross_price"
|
||||
remove_column "articles", "tax"
|
||||
remove_column "articles", "refund"
|
||||
|
|
@ -70,6 +67,5 @@ class RemoveTableArticlePrices < ActiveRecord::Migration[4.2]
|
|||
remove_column "articles", "order_number"
|
||||
remove_column "articles", "created_at"
|
||||
remove_column "articles", "updated_at"
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ class NewWording < ActiveRecord::Migration[4.2]
|
|||
def self.up
|
||||
rename_column :articles, :clear_price, :net_price
|
||||
rename_column :articles, :refund, :deposit
|
||||
|
||||
|
||||
rename_column :order_article_results, :clear_price, :net_price
|
||||
rename_column :order_article_results, :refund, :deposit
|
||||
|
||||
|
||||
rename_column :orders, :refund, :deposit
|
||||
rename_column :orders, :refund_credit, :deposit_credit
|
||||
end
|
||||
|
|
@ -13,10 +13,10 @@ class NewWording < ActiveRecord::Migration[4.2]
|
|||
def self.down
|
||||
rename_column :articles, :net_price, :clear_price
|
||||
rename_column :articles, :deposit, :refund
|
||||
|
||||
|
||||
rename_column :order_article_results, :net_price, :clear_price
|
||||
rename_column :order_article_results, :deposit, :refund
|
||||
|
||||
|
||||
rename_column :orders, :deposit, :refund
|
||||
rename_column :orders, :deposit_credit, :refund_credit
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
class OrderGroup < Group; end # Needed for renaming of OrderGroup to Ordergroup
|
||||
|
||||
class RoadToVersionThree < ActiveRecord::Migration[4.2]
|
||||
|
|
@ -30,7 +29,7 @@ class RoadToVersionThree < ActiveRecord::Migration[4.2]
|
|||
end
|
||||
|
||||
# == Ordergroups
|
||||
remove_column :groups, :actual_size # Useless, desposits are better stored within a transaction.note
|
||||
remove_column :groups, :actual_size # Useless, desposits are better stored within a transaction.note
|
||||
# rename from OrderGroup to Ordergroup
|
||||
rename_column :financial_transactions, :order_group_id, :ordergroup_id
|
||||
rename_column :group_orders, :order_group_id, :ordergroup_id
|
||||
|
|
@ -49,7 +48,7 @@ class RoadToVersionThree < ActiveRecord::Migration[4.2]
|
|||
contact = ordergroup.users.first
|
||||
if contact
|
||||
ordergroup.update_attributes :contact_person => contact.name,
|
||||
:contact_phone => contact.phone, :contact_address => contact.address
|
||||
:contact_phone => contact.phone, :contact_address => contact.address
|
||||
end
|
||||
end
|
||||
remove_column :users, :address
|
||||
|
|
@ -66,7 +65,7 @@ class RoadToVersionThree < ActiveRecord::Migration[4.2]
|
|||
t.text :note
|
||||
t.datetime :starts
|
||||
t.datetime :ends
|
||||
t.string :state, :default => "open" # Statemachine ... open -> finished -> closed
|
||||
t.string :state, :default => "open" # Statemachine ... open -> finished -> closed
|
||||
t.integer :lock_version, :default => 0, :null => false
|
||||
t.integer :updated_by_user_id
|
||||
end
|
||||
|
|
@ -81,13 +80,13 @@ class RoadToVersionThree < ActiveRecord::Migration[4.2]
|
|||
t.date :paid_on
|
||||
t.text :note
|
||||
t.decimal :amount, :null => false, :precision => 8, :scale => 2, :default => 0.0
|
||||
t.decimal :deposit, :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
t.decimal :deposit_credit, :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
t.decimal :deposit, :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
t.decimal :deposit_credit, :precision => 8, :scale => 2, :default => 0.0, :null => false
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
# == Delivery
|
||||
create_table :deliveries do |t|
|
||||
create_table :deliveries do |t|
|
||||
t.integer :supplier_id
|
||||
t.date :delivered_on
|
||||
t.datetime :created_at
|
||||
|
|
@ -118,11 +117,11 @@ class RoadToVersionThree < ActiveRecord::Migration[4.2]
|
|||
# Create price history for every Article
|
||||
Article.all.each do |a|
|
||||
a.article_prices.create :price => a.price, :tax => a.tax,
|
||||
:deposit => a.deposit, :unit_quantity => a.unit_quantity
|
||||
:deposit => a.deposit, :unit_quantity => a.unit_quantity
|
||||
end
|
||||
# Every Article has now a Category. Fix it if neccessary.
|
||||
Article.all(:conditions => { :article_category_id => nil }).each do |article|
|
||||
article.update_attribute(:article_category, ArticleCategory.first)
|
||||
article.update_attribute(:article_category, ArticleCategory.first)
|
||||
end
|
||||
# order-articles
|
||||
add_column :order_articles, :article_price_id, :integer
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class AddProfitToOrders < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
add_column :orders, :foodcoop_result, :decimal, :precision => 8, :scale => 2
|
||||
|
||||
|
||||
Order.closed.each do |order|
|
||||
order.update_attribute(:foodcoop_result, order.profit)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
class AddMissingIndexes < ActiveRecord::Migration[4.2]
|
||||
def self.up
|
||||
add_index "article_prices", ["article_id"]
|
||||
|
||||
|
||||
add_index "articles", ["supplier_id"]
|
||||
add_index "articles", ["article_category_id"]
|
||||
add_index "articles", ["type"]
|
||||
|
||||
|
||||
add_index "deliveries", ["supplier_id"]
|
||||
|
||||
add_index "financial_transactions", ["ordergroup_id"]
|
||||
|
|
@ -18,16 +18,16 @@ class AddMissingIndexes < ActiveRecord::Migration[4.2]
|
|||
add_index "invoices", ["delivery_id"]
|
||||
|
||||
add_index "order_articles", ["order_id"]
|
||||
|
||||
|
||||
add_index "order_comments", ["order_id"]
|
||||
|
||||
|
||||
add_index "orders", ["state"]
|
||||
|
||||
add_index "stock_changes", ["delivery_id"]
|
||||
add_index "stock_changes", ["stock_article_id"]
|
||||
add_index "stock_changes", ["delivery_id"]
|
||||
add_index "stock_changes", ["stock_article_id"]
|
||||
add_index "stock_changes", ["stock_taking_id"]
|
||||
|
||||
add_index "tasks", ["workgroup_id"]
|
||||
add_index "tasks", ["workgroup_id"]
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ class MoveWeeklyTasks < ActiveRecord::Migration[4.2]
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def weekly_task?(workgroup, task)
|
||||
return false if task.due_date.nil?
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ class CreateSettings < ActiveRecord::Migration[4.2]
|
|||
t.string :thing_type, limit: 30, null: true
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :settings, [ :thing_type, :thing_id, :var ], unique: true
|
||||
|
||||
add_index :settings, [:thing_type, :thing_id, :var], unique: true
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
class MigrateUserSettings < ActiveRecord::Migration[4.2]
|
||||
def up
|
||||
say_with_time 'Save old user settings in new RailsSettings module' do
|
||||
|
||||
# Allow setting default locale via env parameter
|
||||
# This is used, when setting users language settings
|
||||
default_locale = I18n.default_locale
|
||||
|
|
@ -15,7 +14,7 @@ class MigrateUserSettings < ActiveRecord::Migration[4.2]
|
|||
type = old_setting.configurable_type
|
||||
id = old_setting.configurable_id
|
||||
begin
|
||||
user = type.constantize.find(id)
|
||||
user = type.constantize.find(id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
Rails.logger.debug "Can't find configurable object with type: #{type.inspect}, id: #{id.inspect}"
|
||||
next
|
||||
|
|
@ -32,9 +31,9 @@ class MigrateUserSettings < ActiveRecord::Migration[4.2]
|
|||
|
||||
# set the settings_attributes (thanks to settings.merge! we can set them one by one)
|
||||
user.settings_attributes = {
|
||||
"#{namespace}" => {
|
||||
"#{key}" => value
|
||||
}
|
||||
"#{namespace}" => {
|
||||
"#{key}" => value
|
||||
}
|
||||
}
|
||||
|
||||
# save the user to apply after_save callback
|
||||
|
|
@ -52,4 +51,4 @@ class MigrateUserSettings < ActiveRecord::Migration[4.2]
|
|||
end
|
||||
|
||||
# this is the base class of all configurable settings
|
||||
class ConfigurableSetting < ActiveRecord::Base; end
|
||||
class ConfigurableSetting < ActiveRecord::Base; end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class AddResultComputedToGroupOrderArticles < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :group_order_articles, :result_computed,
|
||||
:decimal, :precision => 8, :scale => 3
|
||||
:decimal, :precision => 8, :scale => 3
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ class CreateDoorkeeperTables < ActiveRecord::Migration[4.2]
|
|||
create_table :oauth_access_tokens do |t|
|
||||
t.integer :resource_owner_id
|
||||
t.integer :application_id
|
||||
t.string :token, null: false
|
||||
t.string :token, null: false
|
||||
t.string :refresh_token
|
||||
t.integer :expires_in
|
||||
t.datetime :revoked_at
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :created_at, null: false
|
||||
t.string :scopes
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
class CreateSupplierCategories < ActiveRecord::Migration[4.2]
|
||||
class FinancialTransactionClass < ActiveRecord::Base; end
|
||||
|
||||
class SupplierCategory < ActiveRecord::Base; end
|
||||
|
||||
class Supplier < ActiveRecord::Base; end
|
||||
|
||||
def change
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
class ClearInvalidInvoicesFromOrders < ActiveRecord::Migration[4.2]
|
||||
class Order < ActiveRecord::Base; end
|
||||
|
||||
class Invoice < ActiveRecord::Base; end
|
||||
|
||||
def up
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
class CreateStockEvents < ActiveRecord::Migration[4.2]
|
||||
class StockEvent < ActiveRecord::Base; end
|
||||
|
||||
class StockTaking < ActiveRecord::Base; end
|
||||
|
||||
def change
|
||||
|
|
|
|||
|
|
@ -2,24 +2,24 @@
|
|||
|
||||
# Create working group with full rights
|
||||
administrators = Workgroup.create!(
|
||||
:name => "Administrators",
|
||||
:description => "System administrators.",
|
||||
:role_admin => true,
|
||||
:role_finance => true,
|
||||
:role_article_meta => true,
|
||||
:role_pickups => true,
|
||||
:role_suppliers => true,
|
||||
:role_orders => true
|
||||
:name => "Administrators",
|
||||
:description => "System administrators.",
|
||||
:role_admin => true,
|
||||
:role_finance => true,
|
||||
:role_article_meta => true,
|
||||
:role_pickups => true,
|
||||
:role_suppliers => true,
|
||||
:role_orders => true
|
||||
)
|
||||
|
||||
# Create admin user
|
||||
User.create!(
|
||||
:nick => "admin",
|
||||
:first_name => "Anton",
|
||||
:last_name => "Administrator",
|
||||
:email => "admin@foo.test",
|
||||
:password => "secret",
|
||||
:groups => [administrators]
|
||||
:nick => "admin",
|
||||
:first_name => "Anton",
|
||||
:last_name => "Administrator",
|
||||
:email => "admin@foo.test",
|
||||
:password => "secret",
|
||||
:groups => [administrators]
|
||||
)
|
||||
|
||||
# First entry for financial transaction types
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# only works properly for open orders, at the moment
|
||||
def seed_group_orders
|
||||
Order.all.each do |order|
|
||||
|
|
@ -6,12 +5,13 @@ def seed_group_orders
|
|||
Ordergroup.all.each do |og|
|
||||
# 20% of the order-ordergroup combinations don't order
|
||||
next if rand(10) < 2
|
||||
|
||||
# order 3..12 times a random article
|
||||
go = og.group_orders.create!(order: order, updated_by_user_id: 1)
|
||||
(3+rand(10)).times do
|
||||
(3 + rand(10)).times do
|
||||
goa = go.group_order_articles.find_or_create_by!(order_article: order.order_articles.offset(rand(noas)).first)
|
||||
unit_quantity = goa.order_article.price.unit_quantity
|
||||
goa.update_quantities rand([4, 2*unit_quantity+2].max), rand(unit_quantity)
|
||||
goa.update_quantities rand([4, 2 * unit_quantity + 2].max), rand(unit_quantity)
|
||||
end
|
||||
end
|
||||
# update totals
|
||||
|
|
@ -20,8 +20,8 @@ def seed_group_orders
|
|||
end
|
||||
end
|
||||
|
||||
def seed_order(options={})
|
||||
options[:article_ids] ||= (options[:supplier]||Supplier.find(options[:supplier_id])).articles.map(&:id)
|
||||
def seed_order(options = {})
|
||||
options[:article_ids] ||= (options[:supplier] || Supplier.find(options[:supplier_id])).articles.map(&:id)
|
||||
options[:created_by_user_id] ||= 1
|
||||
options[:updated_by_user_id] ||= 1
|
||||
Order.create! options
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ FinancialTransactionClass.create!(:id => 2, :name => 'Foodsoft')
|
|||
SupplierCategory.create!(:id => 1, :name => "Other", :financial_transaction_class_id => 1)
|
||||
|
||||
Supplier.create!([
|
||||
{:id => 1, :name => "Beautiful bakery", :supplier_category_id => 1, :address => "Smallstreet 1, Cookilage", :phone => "0123456789", :email => "info@bbakery.test", :min_order_quantity => "100"},
|
||||
{:id => 2, :name => "Chocolatiers", :supplier_category_id => 1, :address => "Multatuliroad 1, Amsterdam", :phone => "0123456789", :email => "info@chocolatiers.test", :url => "http://www.chocolatiers.test/", :contact_person => "Max Pure", :delivery_days => "Tue, Fr (Amsterdam)"},
|
||||
{:id => 3, :name => "Cheesemaker", :supplier_category_id => 1, :address => "Cheesestreet 5, London", :phone => "0123456789", :url => "http://www.cheesemaker.test/"},
|
||||
{:id => 4, :name => "The Nuthome", :supplier_category_id => 1, :address => "Alexanderplatz, Berlin", :phone => "0123456789", :email => "info@thenuthome.test", :url => "http://www.thenuthome.test/", :note => "delivery in Berlin; €9 delivery costs for orders under €123"}
|
||||
])
|
||||
{ :id => 1, :name => "Beautiful bakery", :supplier_category_id => 1, :address => "Smallstreet 1, Cookilage", :phone => "0123456789", :email => "info@bbakery.test", :min_order_quantity => "100" },
|
||||
{ :id => 2, :name => "Chocolatiers", :supplier_category_id => 1, :address => "Multatuliroad 1, Amsterdam", :phone => "0123456789", :email => "info@chocolatiers.test", :url => "http://www.chocolatiers.test/", :contact_person => "Max Pure", :delivery_days => "Tue, Fr (Amsterdam)" },
|
||||
{ :id => 3, :name => "Cheesemaker", :supplier_category_id => 1, :address => "Cheesestreet 5, London", :phone => "0123456789", :url => "http://www.cheesemaker.test/" },
|
||||
{ :id => 4, :name => "The Nuthome", :supplier_category_id => 1, :address => "Alexanderplatz, Berlin", :phone => "0123456789", :email => "info@thenuthome.test", :url => "http://www.thenuthome.test/", :note => "delivery in Berlin; €9 delivery costs for orders under €123" }
|
||||
])
|
||||
|
||||
ArticleCategory.create!(:id => 1, :name => "Other", :description => "other, misc, unknown")
|
||||
ArticleCategory.create!(:id => 2, :name => "Fruit")
|
||||
|
|
@ -140,7 +140,6 @@ Article.create!(:name => "Blueberries", :supplier_id => 4, :article_category_id
|
|||
Article.create!(:name => "Chia seeds", :supplier_id => 4, :article_category_id => 13, :unit => "kg", :availability => true, :price => 0.55555E3, :tax => 6.0, :deposit => 0.0, :unit_quantity => 1, :order_number => ":416d57b")
|
||||
Article.create!(:name => "Coconut grated", :supplier_id => 4, :article_category_id => 13, :unit => "kg", :availability => true, :price => 0.55E0, :tax => 6.0, :deposit => 0.0, :unit_quantity => 1, :order_number => ":b3f65e4")
|
||||
|
||||
|
||||
## Members & groups
|
||||
|
||||
User.create!(:id => 1, :nick => "admin", :password => "secret", :first_name => "Anton", :last_name => "Administrator", :email => "admin@foo.test", :created_on => 'Wed, 15 Jan 2014 16:15:33 UTC +00:00')
|
||||
|
|
@ -153,10 +152,10 @@ Workgroup.create!(:id => 1, :name => "Administrators", :description => "System a
|
|||
Workgroup.create!(:id => 2, :name => "Finances", :account_balance => 0.0, :created_on => 'Sun, 19 Jan 2014 17:40:03 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => true, :role_orders => false, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Workgroup.create!(:id => 3, :name => "Ordering", :account_balance => 0.0, :created_on => 'Thu, 20 Feb 2014 14:44:47 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => true, :role_finance => false, :role_orders => true, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Workgroup.create!(:id => 4, :name => "Assortment", :account_balance => 0.0, :created_on => 'Wed, 09 Apr 2014 12:24:55 UTC +00:00', :role_admin => false, :role_suppliers => true, :role_article_meta => true, :role_finance => false, :role_orders => false, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 5, :name => "Admin Administrator", :account_balance => 0.0, :created_on => 'Sat, 18 Jan 2014 00:38:48 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :stats => {:jobs_size=>0, :orders_sum=>1021.74}, :next_weekly_tasks_number => 8, :ignore_apple_restriction => true)
|
||||
Ordergroup.create!(:id => 6, :name => "Pete's house", :account_balance => -0.35E2, :created_on => 'Sat, 25 Jan 2014 20:20:37 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "Piet Pieterssen", :stats => {:jobs_size=>0, :orders_sum=>60.96}, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 7, :name => "Jan Klaassen", :account_balance => -0.35E2, :created_on => 'Mon, 27 Jan 2014 16:22:14 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "Jan Klaassen", :stats => {:jobs_size=>0, :orders_sum=>0}, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 8, :name => "John Doe", :account_balance => 0.90E2, :created_on => 'Wed, 09 Apr 2014 12:23:29 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "John Doe", :stats => {:jobs_size=>0, :orders_sum=>0}, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 5, :name => "Admin Administrator", :account_balance => 0.0, :created_on => 'Sat, 18 Jan 2014 00:38:48 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :stats => { :jobs_size => 0, :orders_sum => 1021.74 }, :next_weekly_tasks_number => 8, :ignore_apple_restriction => true)
|
||||
Ordergroup.create!(:id => 6, :name => "Pete's house", :account_balance => -0.35E2, :created_on => 'Sat, 25 Jan 2014 20:20:37 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "Piet Pieterssen", :stats => { :jobs_size => 0, :orders_sum => 60.96 }, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 7, :name => "Jan Klaassen", :account_balance => -0.35E2, :created_on => 'Mon, 27 Jan 2014 16:22:14 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "Jan Klaassen", :stats => { :jobs_size => 0, :orders_sum => 0 }, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 8, :name => "John Doe", :account_balance => 0.90E2, :created_on => 'Wed, 09 Apr 2014 12:23:29 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "John Doe", :stats => { :jobs_size => 0, :orders_sum => 0 }, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
|
||||
Membership.create!(:group_id => 1, :user_id => 1)
|
||||
Membership.create!(:group_id => 5, :user_id => 1)
|
||||
|
|
@ -170,19 +169,16 @@ Membership.create!(:group_id => 7, :user_id => 5)
|
|||
Membership.create!(:group_id => 3, :user_id => 5)
|
||||
Membership.create!(:group_id => 4, :user_id => 5)
|
||||
|
||||
|
||||
## Orders & OrderArticles
|
||||
|
||||
seed_order(supplier_id: 1, starts: 2.days.ago, ends: 5.days.from_now)
|
||||
seed_order(supplier_id: 3, starts: 2.days.ago, ends: 5.days.from_now)
|
||||
seed_order(supplier_id: 2, starts: 2.days.ago, ends: 4.days.from_now)
|
||||
|
||||
|
||||
## GroupOrders & such
|
||||
|
||||
seed_group_orders
|
||||
|
||||
|
||||
## Finances
|
||||
|
||||
FinancialTransactionType.create!(:id => 1, :name => "Foodcoop", :financial_transaction_class_id => 1)
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ FinancialTransactionClass.create!(:id => 2, :name => 'Foodsoft')
|
|||
SupplierCategory.create!(:id => 1, :name => "Other", :financial_transaction_class_id => 1)
|
||||
|
||||
Supplier.create!([
|
||||
{:id => 1, :name => "Koekenbakker", :supplier_category_id => 1, :address => "Dorpsstraat 1, Koekange", :phone => "012 3456789", :email => "info@dekoekenbakker.test", :min_order_quantity => "100"},
|
||||
{:id => 2, :name => "Chocolademakkers", :supplier_category_id => 1, :address => "Multatuliweg 1, Amsterdam", :phone => "012 3456789", :email => "info@chocolademakkers.test", :url => "http://www.chocolademakkers.test/", :contact_person => "Max Puur", :delivery_days => "di, vr (Amsterdam)"},
|
||||
{:id => 3, :name => "Kaasmaker", :supplier_category_id => 1, :address => "Waagplein, Alkmaar", :phone => "012 3456789", :url => "http://www.kaaskamer.test/"},
|
||||
{:id => 4, :name => "Notenhuis", :supplier_category_id => 1, :address => "Damrak 1, Amsterdam", :phone => "012 3456789", :email => "info@notenhuis.test", :url => "http://www.notenhuis.test/", :note => "leveren in Amsterdam; €9 leverkosten bij bestellingen onder €123"}
|
||||
])
|
||||
{ :id => 1, :name => "Koekenbakker", :supplier_category_id => 1, :address => "Dorpsstraat 1, Koekange", :phone => "012 3456789", :email => "info@dekoekenbakker.test", :min_order_quantity => "100" },
|
||||
{ :id => 2, :name => "Chocolademakkers", :supplier_category_id => 1, :address => "Multatuliweg 1, Amsterdam", :phone => "012 3456789", :email => "info@chocolademakkers.test", :url => "http://www.chocolademakkers.test/", :contact_person => "Max Puur", :delivery_days => "di, vr (Amsterdam)" },
|
||||
{ :id => 3, :name => "Kaasmaker", :supplier_category_id => 1, :address => "Waagplein, Alkmaar", :phone => "012 3456789", :url => "http://www.kaaskamer.test/" },
|
||||
{ :id => 4, :name => "Notenhuis", :supplier_category_id => 1, :address => "Damrak 1, Amsterdam", :phone => "012 3456789", :email => "info@notenhuis.test", :url => "http://www.notenhuis.test/", :note => "leveren in Amsterdam; €9 leverkosten bij bestellingen onder €123" }
|
||||
])
|
||||
|
||||
ArticleCategory.create!(:id => 1, :name => "Other", :description => "overig, anders, onbekend")
|
||||
ArticleCategory.create!(:id => 2, :name => "Fruit")
|
||||
|
|
@ -140,7 +140,6 @@ Article.create!(:name => "Blueberries", :supplier_id => 4, :article_category_id
|
|||
Article.create!(:name => "Chia zaad", :supplier_id => 4, :article_category_id => 13, :unit => "kg", :availability => true, :price => 0.55555E3, :tax => 6.0, :deposit => 0.0, :unit_quantity => 1, :order_number => ":416d57b")
|
||||
Article.create!(:name => "Cocos Rasp", :supplier_id => 4, :article_category_id => 13, :unit => "kg", :availability => true, :price => 0.55E0, :tax => 6.0, :deposit => 0.0, :unit_quantity => 1, :order_number => ":b3f65e4")
|
||||
|
||||
|
||||
## Members & groups
|
||||
|
||||
User.create!(:id => 1, :nick => "admin", :password => "secret", :first_name => "Anton", :last_name => "Administrator", :email => "admin@foo.test", :created_on => 'Wed, 15 Jan 2014 16:15:33 UTC +00:00')
|
||||
|
|
@ -153,10 +152,10 @@ Workgroup.create!(:id => 1, :name => "Admins", :description => "Beheerders", :ac
|
|||
Workgroup.create!(:id => 2, :name => "Financiën", :account_balance => 0.0, :created_on => 'Sun, 19 Jan 2014 17:40:03 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => true, :role_orders => false, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Workgroup.create!(:id => 3, :name => "Bestellen", :account_balance => 0.0, :created_on => 'Thu, 20 Feb 2014 14:44:47 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => true, :role_finance => false, :role_orders => true, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Workgroup.create!(:id => 4, :name => "Assortiment", :account_balance => 0.0, :created_on => 'Wed, 09 Apr 2014 12:24:55 UTC +00:00', :role_admin => false, :role_suppliers => true, :role_article_meta => true, :role_finance => false, :role_orders => false, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 5, :name => "Admin Administrator", :account_balance => 0.0, :created_on => 'Sat, 18 Jan 2014 00:38:48 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :stats => {:jobs_size=>0, :orders_sum=>1021.74}, :next_weekly_tasks_number => 8, :ignore_apple_restriction => true)
|
||||
Ordergroup.create!(:id => 6, :name => "Peter's huis", :account_balance => -0.35E2, :created_on => 'Sat, 25 Jan 2014 20:20:37 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "Piet Pieterssen", :stats => {:jobs_size=>0, :orders_sum=>60.96}, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 7, :name => "Jan Klaassen", :account_balance => -0.35E2, :created_on => 'Mon, 27 Jan 2014 16:22:14 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "Jan Klaassen", :stats => {:jobs_size=>0, :orders_sum=>0}, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 8, :name => "John Doe", :account_balance => 0.90E2, :created_on => 'Wed, 09 Apr 2014 12:23:29 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "John Doe", :stats => {:jobs_size=>0, :orders_sum=>0}, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 5, :name => "Admin Administrator", :account_balance => 0.0, :created_on => 'Sat, 18 Jan 2014 00:38:48 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :stats => { :jobs_size => 0, :orders_sum => 1021.74 }, :next_weekly_tasks_number => 8, :ignore_apple_restriction => true)
|
||||
Ordergroup.create!(:id => 6, :name => "Peter's huis", :account_balance => -0.35E2, :created_on => 'Sat, 25 Jan 2014 20:20:37 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "Piet Pieterssen", :stats => { :jobs_size => 0, :orders_sum => 60.96 }, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 7, :name => "Jan Klaassen", :account_balance => -0.35E2, :created_on => 'Mon, 27 Jan 2014 16:22:14 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "Jan Klaassen", :stats => { :jobs_size => 0, :orders_sum => 0 }, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
Ordergroup.create!(:id => 8, :name => "John Doe", :account_balance => 0.90E2, :created_on => 'Wed, 09 Apr 2014 12:23:29 UTC +00:00', :role_admin => false, :role_suppliers => false, :role_article_meta => false, :role_finance => false, :role_orders => false, :contact_person => "John Doe", :stats => { :jobs_size => 0, :orders_sum => 0 }, :next_weekly_tasks_number => 8, :ignore_apple_restriction => false)
|
||||
|
||||
Membership.create!(:group_id => 1, :user_id => 1)
|
||||
Membership.create!(:group_id => 5, :user_id => 1)
|
||||
|
|
@ -170,19 +169,16 @@ Membership.create!(:group_id => 7, :user_id => 5)
|
|||
Membership.create!(:group_id => 3, :user_id => 5)
|
||||
Membership.create!(:group_id => 4, :user_id => 5)
|
||||
|
||||
|
||||
## Orders & OrderArticles
|
||||
|
||||
seed_order(supplier_id: 1, starts: 2.days.ago, ends: 5.days.from_now)
|
||||
seed_order(supplier_id: 3, starts: 2.days.ago, ends: 5.days.from_now)
|
||||
seed_order(supplier_id: 2, starts: 2.days.ago, ends: 4.days.from_now)
|
||||
|
||||
|
||||
## GroupOrders & such
|
||||
|
||||
seed_group_orders
|
||||
|
||||
|
||||
## Finances
|
||||
|
||||
FinancialTransactionType.create!(:id => 1, :name => "Foodcoop", :financial_transaction_class_id => 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue