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.


23
24
25
26
# File 'app/models/shared_supplier.rb', line 23

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

#cached_articlesObject


17
18
19
# File 'app/models/shared_supplier.rb', line 17

def cached_articles
  @cached_articles ||= shared_articles.all
end

#find_article_by_number(order_number) ⇒ Object


12
13
14
15
# File 'app/models/shared_supplier.rb', line 12

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


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

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