From e46cf8080d36e4320c74dc668e4efe1aab74d26b Mon Sep 17 00:00:00 2001 From: nikz Date: Sun, 25 Feb 2018 18:38:41 +0000 Subject: [PATCH 1/2] Adds Expected/Planned payment dates to Invoices --- lib/xero_gateway/invoice.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/xero_gateway/invoice.rb b/lib/xero_gateway/invoice.rb index 073c7b92..a1c70f7f 100644 --- a/lib/xero_gateway/invoice.rb +++ b/lib/xero_gateway/invoice.rb @@ -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 = {}) @@ -226,6 +226,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 From d736ea0b28e89fb10ffaf0b5b5d79b5aaa48b642 Mon Sep 17 00:00:00 2001 From: nikz Date: Sun, 25 Feb 2018 18:40:06 +0000 Subject: [PATCH 2/2] Also add dates when building Invoices --- lib/xero_gateway/invoice.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/xero_gateway/invoice.rb b/lib/xero_gateway/invoice.rb index a1c70f7f..4e6f2500 100644 --- a/lib/xero_gateway/invoice.rb +++ b/lib/xero_gateway/invoice.rb @@ -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