2019-01-13 07:05:54 +01:00
|
|
|
class SharedArticle < ApplicationRecord
|
2009-01-06 11:49:19 +01:00
|
|
|
# connect to database from sharedLists-Application
|
2012-08-24 19:52:38 +02:00
|
|
|
SharedArticle.establish_connection(FoodsoftConfig[:shared_lists])
|
2009-01-06 11:49:19 +01:00
|
|
|
# set correct table_name in external DB
|
2012-10-19 01:12:47 +02:00
|
|
|
self.table_name = 'articles'
|
2011-05-19 22:22:05 +02:00
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
belongs_to :shared_supplier, :foreign_key => :supplier_id
|
2011-05-19 22:22:05 +02:00
|
|
|
|
2013-06-04 11:28:25 +02:00
|
|
|
def build_new_article(supplier)
|
|
|
|
supplier.articles.build(
|
2021-03-01 15:27:26 +01:00
|
|
|
:name => name,
|
|
|
|
:unit => unit,
|
|
|
|
:note => note,
|
|
|
|
:manufacturer => manufacturer,
|
|
|
|
:origin => origin,
|
|
|
|
:price => price,
|
|
|
|
:tax => tax,
|
|
|
|
:deposit => deposit,
|
|
|
|
:unit_quantity => unit_quantity,
|
|
|
|
:order_number => number,
|
|
|
|
:article_category => ArticleCategory.find_match(category),
|
|
|
|
# convert to db-compatible-string
|
|
|
|
:shared_updated_on => updated_on.to_formatted_s(:db)
|
2011-05-19 22:22:05 +02:00
|
|
|
)
|
|
|
|
end
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|