Class: MoySklad::Model::Good
Instance Method Summary
collapse
#applicable?, collection_name, #create, #destroy, element_path, find, new_element_path, #save
#find_object
Constructor Details
#initialize(*args) ⇒ Good
Returns a new instance of Good.
3
4
5
6
|
# File 'lib/moy_sklad/model/good.rb', line 3
def initialize(*args)
super(*args)
create_nested_collection(:barcode)
end
|
Instance Method Details
#add_barcode(code, options) ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/moy_sklad/model/good.rb', line 24
def add_barcode(code, options)
barcode = create_and_load_resource("barcode", {barcode: code}.merge(options))
if to_a(:barcode).empty?
self.barcode = [barcode]
else
self.barcode << barcode
end
end
|
#get_sale_price(uuid) ⇒ Object
19
20
21
22
|
# File 'lib/moy_sklad/model/good.rb', line 19
def get_sale_price(uuid)
create_nested_resource(:salePrices)
self.salePrices.find_object(:price, :priceTypeUuid, uuid)
end
|
#set_sale_price(type, value, currency) ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/moy_sklad/model/good.rb', line 8
def set_sale_price(type, value, currency)
create_nested_resource(:salePrices)
v = self.salePrices.find_object(:price, :priceTypeUuid, type)
if v.nil?
create_price(type, value, currency)
else
v.value = value.to_i
end
end
|