Class: SharedSupplier

Inherits:
ApplicationRecord show all
Defined in:
app/models/shared_supplier.rb

Instance Method Summary collapse

Instance Method Details

#autofill_attributesObject

These set of attributes are used to autofill attributes of new supplier, when created by import from shared supplier feature.



21
22
23
24
# File 'app/models/shared_supplier.rb', line 21

def autofill_attributes
  whitelist = %w[name address phone fax email url delivery_days note]
  attributes.select { |k, _v| whitelist.include?(k) }
end

#cached_articlesObject



15
16
17
# File 'app/models/shared_supplier.rb', line 15

def cached_articles
  @cached_articles ||= shared_articles.all
end

#find_article_by_number(order_number) ⇒ Object



10
11
12
13
# File 'app/models/shared_supplier.rb', line 10

def find_article_by_number(order_number)
  # NOTE: that `shared_articles` uses number instead order_number
  cached_articles.detect { |a| a.number == order_number }
end

#shared_sync_methodsObject

return list of synchronisation methods available for this supplier



27
28
29
30
31
32
33
34
35
# File 'app/models/shared_supplier.rb', line 27

def shared_sync_methods
  methods = []
  if shared_articles.count < FoodsoftConfig[:shared_supplier_article_sync_limit]
    methods += %w[all_available
                  all_unavailable]
  end
  methods += %w[import]
  methods
end