Skip to content

Commit

Permalink
Avoid returning the same InvoiceID (a.o.) for all payments from get_p…
Browse files Browse the repository at this point in the history
…ayments
  • Loading branch information
jomz committed Dec 4, 2019
1 parent f68b950 commit 2af2b50
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/xero_gateway/payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def self.from_xml(payment_element)
when 'Reference' then payment.reference = element.text
when 'CurrencyRate' then payment.currency_rate = BigDecimal(element.text)
when 'Invoice'
payment.invoice_id = element.elements["//InvoiceID"].text
payment.invoice_number = element.elements["//InvoiceNumber"].text
payment.invoice_id = element.elements["InvoiceID"].text
payment.invoice_number = element.elements["InvoiceNumber"].text
when 'IsReconciled' then payment.reconciled = (element.text == "true")
when 'Account' then payment.account_id = element.elements["//AccountID"].text
when 'Account' then payment.account_id = element.elements["AccountID"].text
end
end
payment
Expand Down
7 changes: 7 additions & 0 deletions test/integration/get_payments_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ def test_get_payments
assert_kind_of(XeroGateway::Payment, payment.first)
end

def test_get_payments_gets_actual_invoice_ids
result = @gateway.get_payments
assert_not_equal result.payments[0].invoice_id, result.payments[1].invoice_id
# assert_equal result.payments[0].invoice_id, 'b0875d8b-ff26-4ce8-8aea-6955492ead48'
# assert_equal result.payments[1].invoice_id, '33c8d757-2db0-48a2-8daa-f54768fabeb1'
end

def test_get_payments_modified_since_date
# Create a test payment
@gateway.create_payment(create_test_payment)
Expand Down

0 comments on commit 2af2b50

Please sign in to comment.