Class: Agris::Api::AccountsReceivables::Invoice

Inherits:
Object
  • Object
show all
Includes:
XmlModel
Defined in:
lib/agris/api/accounts_receivables/invoice.rb

Defined Under Namespace

Classes: GeneralLedgerDetail, LineItem

Constant Summary collapse

ATTRIBUTE_NAMES =
%w(
  invoice_location
  invoice_location_description
  invoice_no
  invoice_date
  ship_date
  pickup_delivery
  due_date
  discount_date
  original_date
  last_pay_date
  trans_status
  tran_status_desc
  aging_period
  aging_period_description
  doc_type
  doc_type_desc
  invoice_desc
  ref_order_no
  xref_doc_loc
  xref_doc_loc_description
  xref_doc
  days_to_pay
  terms_code
  terms_desc
  first_inv_settle_no
  name_id_type
  name_id_type_desc
  invoice_type
  invoice_type_desc
  state_county_code
  state_county_desc
  usr_order_field_1
  usr_order_field_2
  usr_invoice_field1
  usr_invoice_field2
  bill_to_id
  bill_to_description
  ship_to_id
  ship_to_description
  shipper_id
  shipper_description
  agent_id
  agent_description
  invoice_amount
  discount_amount
  applied_amount
  due_amount
  net_amount
  discount_remaining
  discount_applied
  sales_tax
  field_history_updated
  use_standard_discount_ratio
  delete
  lastchange_datetime
  lastchange_user_id
  lastchange_user_name
  currency_code
  currency_description
  exchange_rate
  exchange_rate_date
  integration_guid
  unique_id
).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from XmlModel

included

Constructor Details

#initialize(hash = {}) ⇒ Invoice

Returns a new instance of Invoice.



91
92
93
94
95
96
97
# File 'lib/agris/api/accounts_receivables/invoice.rb', line 91

def initialize(hash = {})
  super

  @record_type = 'ACRI0'
  @line_items = []
  @general_ledger_details = []
end

Instance Attribute Details

#record_typeObject (readonly)

Returns the value of attribute record_type.



74
75
76
# File 'lib/agris/api/accounts_receivables/invoice.rb', line 74

def record_type
  @record_type
end

Class Method Details

.from_xml_hash(hash) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/agris/api/accounts_receivables/invoice.rb', line 77

def self.from_xml_hash(hash)
  super.tap do |document|
    if hash['lineitems']
      document.line_items.concat(
        [hash['lineitems']['lineitem']]
          .flatten
          .map do |lineitem|
            LineItem.from_xml_hash(lineitem)
          end
      )
    end
  end
end

Instance Method Details

#add_general_ledger_detail(general_ledger_detail) ⇒ Object



122
123
124
125
126
127
# File 'lib/agris/api/accounts_receivables/invoice.rb', line 122

def add_general_ledger_detail(general_ledger_detail)
  @general_ledger_details ||= []
  @general_ledger_details << general_ledger_detail

  self
end

#add_line_item(line_item) ⇒ Object



99
100
101
102
103
104
# File 'lib/agris/api/accounts_receivables/invoice.rb', line 99

def add_line_item(line_item)
  @line_items ||= []
  @line_items << line_item

  self
end

#general_ledger_detailsObject



114
115
116
# File 'lib/agris/api/accounts_receivables/invoice.rb', line 114

def general_ledger_details
  @general_ledger_details || []
end

#line_itemsObject



110
111
112
# File 'lib/agris/api/accounts_receivables/invoice.rb', line 110

def line_items
  @line_items || []
end

#recordsObject



106
107
108
# File 'lib/agris/api/accounts_receivables/invoice.rb', line 106

def records
  [self] + line_items + general_ledger_details
end

#xml_ignore_attributesObject



118
119
120
# File 'lib/agris/api/accounts_receivables/invoice.rb', line 118

def xml_ignore_attributes
  %i(line_items general_ledger_details)
end