Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Expected/Planned payment dates to Invoices #131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/xero_gateway/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Invoice
# 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, :currency_rate, :payments, :fully_paid_on, :amount_due, :amount_paid, :amount_credited,
:sent_to_contact, :url, :updated_date_utc
:sent_to_contact, :expected_payment_date, :planned_payment_date, :url, :updated_date_utc
attr_writer :contact, :line_items

def initialize(params = {})
Expand Down Expand Up @@ -196,6 +196,8 @@ def to_xml(b = Builder::XmlMarkup.new)
}
b.Url url if url
b.SentToContact sent_to_contact unless sent_to_contact.nil?
b.ExpectedPaymentDate expected_payment_date unless expected_payment_date.nil?
b.PlannedPaymentDate planned_payment_date unless planned_payment_date.nil?
}
end

Expand Down Expand Up @@ -226,6 +228,8 @@ def self.from_xml(invoice_element, gateway = nil, options = {})
when "AmountPaid" then invoice.amount_paid = BigDecimal.new(element.text)
when "AmountCredited" then invoice.amount_credited = BigDecimal.new(element.text)
when "SentToContact" then invoice.sent_to_contact = (element.text.strip.downcase == "true")
when "ExpectedPaymentDate" then invoice.expected_payment_date = parse_date(element.text)
when "PlannedPaymentDate" then invoice.planned_payment_date = parse_date(element.text)
when "Url" then invoice.url = element.text
when "ValidationErrors" then invoice.errors = element.children.map { |error| Error.parse(error) }
end
Expand Down