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

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

Instance Method Details

#billing_email_address=(email_address_string) ⇒ Object



82
83
84
# File 'lib/quickbooks/model/invoice.rb', line 82

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

#email_status_for_delivery?Boolean

Returns:

  • (Boolean)


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

def email_status_for_delivery?
  email_status == EMAIL_STATUS_NEED_TO_SEND
end

#existence_of_customer_refObject



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

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



74
75
76
77
78
79
80
# File 'lib/quickbooks/model/invoice.rb', line 74

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



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

def wants_billing_email_sent!
  self.email_status = EMAIL_STATUS_NEED_TO_SEND
end