Class: Economic::CurrentInvoiceLine
- Inherits:
-
Entity
- Object
- Entity
- Economic::CurrentInvoiceLine
- Defined in:
- lib/economic/current_invoice_line.rb
Overview
Represents a current invoice line.
API documentation: www.e-conomic.com/apidocs/Documentation/T_Economic_Api_ICurrentInvoiceLine.html
See Economic::CurrentInvoice for usage example
Instance Attribute Summary
Attributes inherited from Entity
#partial, #persisted, #session
Instance Method Summary (collapse)
-
- (Object) build_soap_data
Returns OrderedHash with the properties of CurrentInvoice in the correct order, camelcased and ready to be sent via SOAP.
- - (Object) handle
- - (Object) initialize_defaults
- - (Object) invoice
- - (Object) invoice=(invoice)
- - (Object) invoice_handle=(handle)
Methods inherited from Entity
#get_data, has_properties, #id, #initialize, #inspect, #number, #partial?, #persisted?, properties, properties_not_triggering_full_load, proxy, #proxy, #save, soap_action, #update_properties
Constructor Details
This class inherits a constructor from Economic::Entity
Instance Method Details
- (Object) build_soap_data
Returns OrderedHash with the properties of CurrentInvoice in the correct order, camelcased and ready to be sent via SOAP
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/economic/current_invoice_line.rb', line 50 def build_soap_data data = ActiveSupport::OrderedHash.new data['Number'] = 0 # Doesn't seem to be used data['InvoiceHandle'] = invoice.handle.to_hash unless invoice.blank? data['Description'] = description unless description.blank? data['DeliveryDate'] = delivery_date data['UnitHandle'] = { 'Number' => unit_handle[:number] } unless unit_handle.blank? data['ProductHandle'] = { 'Number' => product_handle[:number] } unless product_handle.blank? data['Quantity'] = quantity unless quantity.blank? data['UnitNetPrice'] = unit_net_price unless unit_net_price.blank? data['DiscountAsPercent'] = discount_as_percent unless discount_as_percent.blank? data['UnitCostPrice'] = unit_cost_price unless unit_cost_price.blank? data['TotalNetAmount'] = total_net_amount data['TotalMargin'] = total_margin unless total_margin.blank? data['MarginAsPercent'] = margin_as_percent unless margin_as_percent.blank? return data end |
- (Object) handle
14 15 16 |
# File 'lib/economic/current_invoice_line.rb', line 14 def handle Handle.new(:number => number) end |
- (Object) initialize_defaults
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/economic/current_invoice_line.rb', line 33 def initialize_defaults self.invoice_handle = nil self.description = nil self.delivery_date = nil self.unit_handle = nil self.product_handle = nil self.quantity = nil self.unit_net_price = nil self.discount_as_percent = 0 self.unit_cost_price = 0 self.total_net_amount = nil self.total_margin = 0 self.margin_as_percent = 0 end |
- (Object) invoice
18 19 20 21 |
# File 'lib/economic/current_invoice_line.rb', line 18 def invoice return nil if invoice_handle.blank? @invoice ||= session.current_invoices.find(invoice_handle) end |
- (Object) invoice=(invoice)
23 24 25 26 |
# File 'lib/economic/current_invoice_line.rb', line 23 def invoice=(invoice) self.invoice_handle = invoice.handle @invoice = invoice end |
- (Object) invoice_handle=(handle)
28 29 30 31 |
# File 'lib/economic/current_invoice_line.rb', line 28 def invoice_handle=(handle) @invoice = nil unless handle == @invoice_handle @invoice_handle = handle end |