Class: Beanie::SalesOrderItem
Constant Summary collapse
- STATE_NEW =
0- STATE_READY =
1- STATE_DONE =
2- STATE_BLOCKED =
3- STATE_NAMES =
[ ["New Order Item", STATE_NEW], ["Billable", STATE_READY], ["Complete", STATE_DONE], ["Blocked", STATE_BLOCKED] ].freeze
- SERVICE_PERIOD_ONEOFF =
0- SERVICE_PERIOD_HOURLY =
1- SERVICE_PERIOD_DAILY =
2- SERVICE_PERIOD_WEEKLY =
3- SERVICE_PERIOD_MONTHLY =
4- SERVICE_PERIOD_QUARTERLY =
5- SERVICE_PERIOD_ANNUALLY =
6- SERVICE_PERIOD_NAMES =
[ ["One-Off", SERVICE_PERIOD_ONEOFF], ["Hourly Rate", SERVICE_PERIOD_HOURLY], ["Daily Rate", SERVICE_PERIOD_DAILY], ["Weekly Rate", SERVICE_PERIOD_WEEKLY], ["Monthly Rate", SERVICE_PERIOD_MONTHLY], ["Quarterly Rate", SERVICE_PERIOD_QUARTERLY], ["Annual Rate", SERVICE_PERIOD_ANNUALLY] ].freeze
Instance Attribute Summary collapse
-
#completion ⇒ Object
Returns the value of attribute completion.
-
#description ⇒ Object
Returns the value of attribute description.
-
#discount ⇒ Object
Returns the value of attribute discount.
-
#id ⇒ Object
Returns the value of attribute id.
-
#product_id ⇒ Object
Returns the value of attribute product_id.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#rundate ⇒ Object
Returns the value of attribute rundate.
-
#sales_order_id ⇒ Object
Returns the value of attribute sales_order_id.
-
#sales_tax ⇒ Object
Returns the value of attribute sales_tax.
-
#service_period ⇒ Object
Returns the value of attribute service_period.
-
#state ⇒ Object
Returns the value of attribute state.
-
#unit_cost ⇒ Object
Returns the value of attribute unit_cost.
Instance Method Summary collapse
-
#active? ⇒ Boolean
Is this item active?.
-
#blocked? ⇒ Boolean
Is this item blocked?.
-
#initialize ⇒ SalesOrderItem
constructor
Initialize instance variables.
-
#one_off? ⇒ Boolean
Is this a one-off rather than a time-based item?.
-
#period_name ⇒ Object
Service period name.
-
#private_data ⇒ Object
Get the private data.
-
#private_data=(data) ⇒ Object
Update/set the private data.
-
#state_name ⇒ Object
Pretty name for the state.
Methods inherited from Api
all, build_url, #construct_path, delete, #extract, #field_name, find, get, #object_name, #populate, post, put, #save!, set_headers
Constructor Details
#initialize ⇒ SalesOrderItem
Initialize instance variables
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/beanie/sales_order_item.rb', line 67 def initialize @id = nil @completion = nil @description = nil @discount = nil @quantity = nil @rundate = nil @state = nil @sales_order_id = nil @product_id = nil @service_period = nil @unit_cost = nil @sales_tax = nil end |
Instance Attribute Details
#completion ⇒ Object
Returns the value of attribute completion.
32 33 34 |
# File 'lib/beanie/sales_order_item.rb', line 32 def completion @completion end |
#description ⇒ Object
Returns the value of attribute description.
32 33 34 |
# File 'lib/beanie/sales_order_item.rb', line 32 def description @description end |
#discount ⇒ Object
Returns the value of attribute discount.
32 33 34 |
# File 'lib/beanie/sales_order_item.rb', line 32 def discount @discount end |
#id ⇒ Object
Returns the value of attribute id.
32 33 34 |
# File 'lib/beanie/sales_order_item.rb', line 32 def id @id end |
#product_id ⇒ Object
Returns the value of attribute product_id.
33 34 35 |
# File 'lib/beanie/sales_order_item.rb', line 33 def product_id @product_id end |
#quantity ⇒ Object
Returns the value of attribute quantity.
32 33 34 |
# File 'lib/beanie/sales_order_item.rb', line 32 def quantity @quantity end |
#rundate ⇒ Object
Returns the value of attribute rundate.
32 33 34 |
# File 'lib/beanie/sales_order_item.rb', line 32 def rundate @rundate end |
#sales_order_id ⇒ Object
Returns the value of attribute sales_order_id.
33 34 35 |
# File 'lib/beanie/sales_order_item.rb', line 33 def sales_order_id @sales_order_id end |
#sales_tax ⇒ Object
Returns the value of attribute sales_tax.
33 34 35 |
# File 'lib/beanie/sales_order_item.rb', line 33 def sales_tax @sales_tax end |
#service_period ⇒ Object
Returns the value of attribute service_period.
33 34 35 |
# File 'lib/beanie/sales_order_item.rb', line 33 def service_period @service_period end |
#state ⇒ Object
Returns the value of attribute state.
32 33 34 |
# File 'lib/beanie/sales_order_item.rb', line 32 def state @state end |
#unit_cost ⇒ Object
Returns the value of attribute unit_cost.
33 34 35 |
# File 'lib/beanie/sales_order_item.rb', line 33 def unit_cost @unit_cost end |
Instance Method Details
#active? ⇒ Boolean
Is this item active?
96 97 98 |
# File 'lib/beanie/sales_order_item.rb', line 96 def active? state == STATE_READY end |
#blocked? ⇒ Boolean
Is this item blocked?
102 103 104 |
# File 'lib/beanie/sales_order_item.rb', line 102 def blocked? state == STATE_BLOCKED end |
#one_off? ⇒ Boolean
Is this a one-off rather than a time-based item?
108 109 110 |
# File 'lib/beanie/sales_order_item.rb', line 108 def one_off? self.service_period == SERVICE_PERIOD_ONEOFF end |
#period_name ⇒ Object
Service period name
90 91 92 |
# File 'lib/beanie/sales_order_item.rb', line 90 def period_name SERVICE_PERIOD_NAMES[service_period][0] end |
#private_data ⇒ Object
Get the private data
114 115 116 117 |
# File 'lib/beanie/sales_order_item.rb', line 114 def private_data response = SalesOrderItem.get(:url => "/sales_order_items/#{@id}/private_data") response["data"] end |
#private_data=(data) ⇒ Object
Update/set the private data
121 122 123 124 |
# File 'lib/beanie/sales_order_item.rb', line 121 def private_data=(data) pdata = {:data => data} response = SalesOrderItem.post(pdata, :url => "/sales_order_items/#{@id}/private_data") end |
#state_name ⇒ Object
Pretty name for the state
84 85 86 |
# File 'lib/beanie/sales_order_item.rb', line 84 def state_name STATE_NAMES[state][0] end |