Skip to content

Commit

Permalink
Merge pull request #86 from 45Robots/invoice_updated_date_utc
Browse files Browse the repository at this point in the history
added updated_date_utc to invoice
  • Loading branch information
armstrjare committed Mar 5, 2016
2 parents b5154bb + 4c479f9 commit ddb955c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/xero_gateway/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Invoice
attr_accessor :line_items_downloaded

# All accessible fields
attr_accessor :invoice_id, :invoice_number, :invoice_type, :invoice_status, :date, :due_date, :reference, :branding_theme_id, :line_amount_types, :currency_code, :line_items, :contact, :payments, :fully_paid_on, :amount_due, :amount_paid, :amount_credited, :sent_to_contact, :url
attr_accessor :invoice_id, :invoice_number, :invoice_type, :invoice_status, :date, :due_date, :reference, :branding_theme_id, :line_amount_types, :currency_code, :line_items, :contact, :payments, :fully_paid_on, :amount_due, :amount_paid, :amount_credited, :sent_to_contact, :url, :updated_date_utc

def initialize(params = {})
@errors ||= []
Expand Down Expand Up @@ -220,6 +220,7 @@ def self.from_xml(invoice_element, gateway = nil, options = {})
when "Contact" then invoice.contact = Contact.from_xml(element)
when "Date" then invoice.date = parse_date(element.text)
when "DueDate" then invoice.due_date = parse_date(element.text)
when "UpdatedDateUTC" then invoice.updated_date_utc = parse_date(element.text)
when "Status" then invoice.invoice_status = element.text
when "Reference" then invoice.reference = element.text
when "BrandingThemeID" then invoice.branding_theme_id = element.text
Expand Down
10 changes: 9 additions & 1 deletion test/unit/invoice_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def test_create_test_invoice_defaults_working
assert_equal('ACCREC', invoice.invoice_type)
assert_kind_of(Date, invoice.date)
assert_kind_of(Date, invoice.due_date)
assert_kind_of(Time, invoice.updated_date_utc)
assert_equal('12345', invoice.invoice_number)
assert_equal('MY REFERENCE FOR THIS INVOICE', invoice.reference)
assert_equal("Exclusive", invoice.line_amount_types)
Expand Down Expand Up @@ -257,6 +258,12 @@ def test_optional_params
assert_equal 'a94a78db-5cc6-4e26-a52b-045237e56e6e', invoice.branding_theme_id
end

def test_updated_date_utc
time = Time.now.utc
invoice = create_test_invoice(:updated_date_utc => time)
assert_equal time, invoice.updated_date_utc
end

private

def create_test_invoice(invoice_params = {}, contact_params = {}, line_item_params = [])
Expand All @@ -267,7 +274,8 @@ def create_test_invoice(invoice_params = {}, contact_params = {}, line_item_para
:due_date => Date.today + 10, # 10 days in the future
:invoice_number => '12345',
:reference => "MY REFERENCE FOR THIS INVOICE",
:line_amount_types => "Exclusive"
:line_amount_types => "Exclusive",
:updated_date_utc => Time.now.utc
}.merge(invoice_params)
end
invoice = XeroGateway::Invoice.new(invoice_params || {})
Expand Down

0 comments on commit ddb955c

Please sign in to comment.