class SpreeAvataxOfficial::Seeder

Public Instance Methods

seed!() click to toggle source
# File lib/spree_avatax_official/seeder.rb, line 3
def seed!
  create_default_tax_category
  create_and_assign_shipping_tax_category
  create_entry_use_codes
end

Private Instance Methods

create_and_assign_shipping_tax_category() click to toggle source
# File lib/spree_avatax_official/seeder.rb, line 16
def create_and_assign_shipping_tax_category
  shipping_tax_category = ::Spree::TaxCategory.find_or_create_by!(name: 'Shipping')
  shipping_tax_category.update!(tax_code: ::Spree::TaxCategory::DEFAULT_TAX_CODES['Shipment'])

  ::Spree::ShippingMethod.update_all(tax_category_id: shipping_tax_category.id)
end
create_default_tax_category() click to toggle source
# File lib/spree_avatax_official/seeder.rb, line 11
def create_default_tax_category
  ::Spree::TaxCategory.find_or_create_by!(name: 'Clothing')
                      .update!(tax_code: ::Spree::TaxCategory::DEFAULT_TAX_CODES['LineItem'], is_default: true)
end
create_entry_use_codes() click to toggle source
# File lib/spree_avatax_official/seeder.rb, line 23
def create_entry_use_codes
  use_codes.each do |key, val|
    SpreeAvataxOfficial::EntityUseCode.find_or_create_by!(code: key, name: val)
  end
end
use_codes() click to toggle source
# File lib/spree_avatax_official/seeder.rb, line 29
def use_codes
  {
    'A': 'FEDERAL GOV',
    'B': 'STATE GOV',
    'C': 'TRIBAL GOVERNMENT',
    'D': 'FOREIGN DIPLOMAT',
    'E': 'CHARITABLE/EXEMPT ORG',
    'F': 'RELIGIOUS ORG',
    'G': 'RESALE',
    'H': 'AGRICULTURE',
    'I': 'INDUSTRIAL PROD/MANUFACTURERS',
    'J': 'DIRECT PAY',
    'K': 'DIRECT MAIL',
    'L': 'OTHER/CUSTOM',
    'N': 'EDUCATIONAL ORG',
    'P': 'COMMERCIAL AQUACULTURE',
    'Q': 'COMMERCIAL FISHERY',
    'R': 'NON-RESIDENT',
    'TAXABLE': 'NON-EXEMPT TAXABLE CUSTOMER'
  }
end