Class: Xsys::Model::Product
- Inherits:
-
Object
- Object
- Xsys::Model::Product
- Defined in:
- lib/xsys/model/product.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#category ⇒ Object
Returns the value of attribute category.
-
#cost ⇒ Object
Returns the value of attribute cost.
-
#cost_date ⇒ Object
Returns the value of attribute cost_date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#list_price_1 ⇒ Object
Returns the value of attribute list_price_1.
-
#list_price_1_date ⇒ Object
Returns the value of attribute list_price_1_date.
-
#list_price_35 ⇒ Object
Returns the value of attribute list_price_35.
-
#list_price_35_date ⇒ Object
Returns the value of attribute list_price_35_date.
-
#list_price_6 ⇒ Object
Returns the value of attribute list_price_6.
-
#list_price_6_date ⇒ Object
Returns the value of attribute list_price_6_date.
-
#markup_1 ⇒ Object
Returns the value of attribute markup_1.
-
#markup_35 ⇒ Object
Returns the value of attribute markup_35.
-
#markup_6 ⇒ Object
Returns the value of attribute markup_6.
-
#name ⇒ Object
Returns the value of attribute name.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#remaining_quantity ⇒ Object
Returns the value of attribute remaining_quantity.
-
#sales ⇒ Object
Returns the value of attribute sales.
-
#sellable ⇒ Object
Returns the value of attribute sellable.
-
#stocks ⇒ Object
Returns the value of attribute stocks.
-
#value_added_tax ⇒ Object
Returns the value of attribute value_added_tax.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Product
constructor
A new instance of Product.
- #sellable_stock ⇒ Object
- #stock_in(shop_code) ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Product
Returns a new instance of Product.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/xsys/model/product.rb', line 9 def initialize(attributes={}) attributes.each do |k,v| if k == 'category' @category = ProductCategory.new(v) elsif k == 'provider' @provider = ProductProvider.new(v) elsif k == 'stocks' @stocks = v.map { |s| Stock.new(s) } else self.send("#{k}=", v) end end end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def active @active end |
#category ⇒ Object
Returns the value of attribute category.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def category @category end |
#cost ⇒ Object
Returns the value of attribute cost.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def cost @cost end |
#cost_date ⇒ Object
Returns the value of attribute cost_date.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def cost_date @cost_date end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def id @id end |
#list_price_1 ⇒ Object
Returns the value of attribute list_price_1.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def list_price_1 @list_price_1 end |
#list_price_1_date ⇒ Object
Returns the value of attribute list_price_1_date.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def list_price_1_date @list_price_1_date end |
#list_price_35 ⇒ Object
Returns the value of attribute list_price_35.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def list_price_35 @list_price_35 end |
#list_price_35_date ⇒ Object
Returns the value of attribute list_price_35_date.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def list_price_35_date @list_price_35_date end |
#list_price_6 ⇒ Object
Returns the value of attribute list_price_6.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def list_price_6 @list_price_6 end |
#list_price_6_date ⇒ Object
Returns the value of attribute list_price_6_date.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def list_price_6_date @list_price_6_date end |
#markup_1 ⇒ Object
Returns the value of attribute markup_1.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def markup_1 @markup_1 end |
#markup_35 ⇒ Object
Returns the value of attribute markup_35.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def markup_35 @markup_35 end |
#markup_6 ⇒ Object
Returns the value of attribute markup_6.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def markup_6 @markup_6 end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def name @name end |
#provider ⇒ Object
Returns the value of attribute provider.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def provider @provider end |
#remaining_quantity ⇒ Object
Returns the value of attribute remaining_quantity.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def remaining_quantity @remaining_quantity end |
#sales ⇒ Object
Returns the value of attribute sales.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def sales @sales end |
#sellable ⇒ Object
Returns the value of attribute sellable.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def sellable @sellable end |
#stocks ⇒ Object
Returns the value of attribute stocks.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def stocks @stocks end |
#value_added_tax ⇒ Object
Returns the value of attribute value_added_tax.
4 5 6 |
# File 'lib/xsys/model/product.rb', line 4 def value_added_tax @value_added_tax end |
Instance Method Details
#sellable_stock ⇒ Object
23 24 25 |
# File 'lib/xsys/model/product.rb', line 23 def sellable_stock stocks.find_all { |s| ![:ser, :ext].include?(s.shop_code.to_sym) }.map(&:quantity).sum end |
#stock_in(shop_code) ⇒ Object
27 28 29 |
# File 'lib/xsys/model/product.rb', line 27 def stock_in(shop_code) stocks.find { |s| s.shop_code.to_sym == shop_code.to_sym }.try(:quantity) end |