2009-01-08 16:33:27 +01:00
|
|
|
# == Schema Information
|
|
|
|
# Schema version: 20090102171850
|
|
|
|
#
|
|
|
|
# Table name: articles
|
|
|
|
#
|
|
|
|
# id :integer(4) not null, primary key
|
|
|
|
# name :string(255) not null
|
|
|
|
# supplier_id :integer(4) not null
|
|
|
|
# number :string(255)
|
|
|
|
# note :string(255)
|
|
|
|
# manufacturer :string(255)
|
|
|
|
# origin :string(255)
|
|
|
|
# unit :string(255)
|
|
|
|
# price :decimal(8, 2) default(0.0), not null
|
|
|
|
# tax :decimal(3, 1) default(7.0), not null
|
|
|
|
# deposit :decimal(8, 2) default(0.0), not null
|
|
|
|
# unit_quantity :decimal(4, 1) default(1.0), not null
|
|
|
|
# scale_quantity :decimal(4, 2)
|
|
|
|
# scale_price :decimal(8, 2)
|
|
|
|
# created_on :datetime
|
|
|
|
# updated_on :datetime
|
|
|
|
# list :string(255)
|
|
|
|
#
|
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
class SharedArticle < ActiveRecord::Base
|
2011-05-19 22:22:05 +02:00
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
# connect to database from sharedLists-Application
|
2009-03-24 17:25:33 +01:00
|
|
|
SharedArticle.establish_connection(Foodsoft.config[:shared_lists])
|
2009-01-06 11:49:19 +01:00
|
|
|
# set correct table_name in external DB
|
|
|
|
set_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
|
|
|
|
|
|
|
def build_new_article
|
|
|
|
shared_supplier.supplier.articles.build(
|
|
|
|
:name => name,
|
|
|
|
:unit => unit,
|
|
|
|
:note => note,
|
|
|
|
:manufacturer => manufacturer,
|
|
|
|
:origin => origin,
|
|
|
|
:price => price,
|
|
|
|
:tax => tax,
|
|
|
|
:deposit => deposit,
|
|
|
|
:unit_quantity => unit_quantity,
|
|
|
|
:order_number => number,
|
|
|
|
# convert to db-compatible-string
|
|
|
|
:shared_updated_on => updated_on.to_formatted_s(:db)
|
|
|
|
)
|
|
|
|
end
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|