Sha256: ddaa1a07c366d5da662a2e5f87a1fd3d886af7c43bc6564d6af258b1e5042fbf
Contents?: true
Size: 2 KB
Versions: 2
Compression:
Stored size: 2 KB
Contents
require 'pathname' require 'yaml' require_relative '../lib/skr' module Skr user = Lanes::User.where(login: 'admin').first if user.nil? user = Lanes::User.create!(name: "Admin", email: "admin@test.com", password: 'password', password_confirmation: 'password', login: 'admin', role_names: ['administrator']) end Lanes::User.scoped_to(user) do seeds_path = Pathname.new(__FILE__).dirname.join('seed') unless Location.default Location.create( code: Skr.config.default_location_code, name: "System default", address: Address.new(name:"System default") ) end YAML::load( seeds_path.join('chart_of_accounts.yml').read ).each do | acct_data | GlAccount.where(number: acct_data['number'].to_s).any? || GlAccount.create!(acct_data) end YAML::load( seeds_path.join('payment_terms.yml').read ).each do | acct_data | PaymentTerm.where(code: acct_data['code'].to_s).any? || PaymentTerm.create!(acct_data) end YAML::load( seeds_path.join('skus.yml').read ).each do | sku_data | unless Sku.where(code: sku_data['code'].to_s).any? glasset = GlAccount.where(number: sku_data.delete('gl_asset_account')).first sku = Sku.new(sku_data) sku.uoms << Uom.new(code: sku_data['default_uom_code'], size:1, price: '0.0') sku.gl_asset_account = glasset sku.save! end end YAML::load( seeds_path.join('payment_categories.yml').read ).each do | category_data | next if Skr::PaymentCategory.exists?(code: category_data['code']) Skr::PaymentCategory.create!( code: category_data['code'], name: category_data['name'], gl_account: GlAccount.find_by_number(category_data['gl_account']) ) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stockor-0.3.0 | db/seed.rb |
stockor-0.2 | db/seed.rb |