Class: Quickbooks::Model::Invoice

Inherits:
BaseModel
  • Object
show all
Includes:
DocumentNumbering, GlobalTaxCalculation, HasLineItems
Defined in:
lib/quickbooks/model/invoice.rb

Constant Summary collapse

REST_RESOURCE =

Constants

'invoice'
XML_COLLECTION_NODE =
"Invoice"
XML_NODE =
"Invoice"
EMAIL_STATUS_NEED_TO_SEND =
'NeedToSend'

Constants included from GlobalTaxCalculation

GlobalTaxCalculation::GLOBAL_TAX_CALCULATION, GlobalTaxCalculation::NOT_APPLICABLE, GlobalTaxCalculation::TAX_EXCLUDED, GlobalTaxCalculation::TAX_INCLUSIVE

Instance Method Summary collapse

Methods included from HasLineItems

#ensure_line_items_initialization, #initialize

Methods included from DocumentNumbering

#auto_doc_number!

Methods inherited from BaseModel

#as_json, attribute_names, #attributes, attrs_with_types, #initialize, inspect, #inspect, reference_attrs, reference_setters, resource_for_collection, resource_for_singular, to_xml_big_decimal, #to_xml_inject_ns, #to_xml_ns

Methods included from Validator

#line_item_size

Methods included from Definition

included, #is_name_list_entity?, #is_transaction_entity?

Instance Method Details

#billing_email_address=(email_address_string) ⇒ Object



88
89
90
# File 'lib/quickbooks/model/invoice.rb', line 88

def billing_email_address=(email_address_string)
  self.bill_email = EmailAddress.new(email_address_string)
end

#billing_email_cc_address=(email_address_string) ⇒ Object



92
93
94
# File 'lib/quickbooks/model/invoice.rb', line 92

def billing_email_cc_address=(email_address_string)
  self.bill_email_cc = EmailAddress.new(email_address_string)
end

#email_status_for_delivery?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/quickbooks/model/invoice.rb', line 100

def email_status_for_delivery?
  email_status == EMAIL_STATUS_NEED_TO_SEND
end

#existence_of_customer_refObject



104
105
106
107
108
# File 'lib/quickbooks/model/invoice.rb', line 104

def existence_of_customer_ref
  if customer_ref.nil? || (customer_ref && customer_ref.value == 0)
    errors.add(:customer_ref, "CustomerRef is required and must be a non-zero value.")
  end
end

#required_bill_email_if_email_deliveryObject



80
81
82
83
84
85
86
# File 'lib/quickbooks/model/invoice.rb', line 80

def required_bill_email_if_email_delivery
  return unless email_status_for_delivery?

  if bill_email.nil?
    errors.add(:bill_email, "BillEmail is required if EmailStatus=NeedToSend")
  end
end

#wants_billing_email_sent!Object



96
97
98
# File 'lib/quickbooks/model/invoice.rb', line 96

def wants_billing_email_sent!
  self.email_status = EMAIL_STATUS_NEED_TO_SEND
end