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

Invoices loaded with pagination needlessly load line items separately #168

Open
pinfieldharm opened this issue Sep 24, 2014 · 3 comments
Open
Labels

Comments

@pinfieldharm
Copy link
Contributor

When Invoices are loaded with a page specified, e.g. client.Invoice.all(page: 1) Xero returns line items inline with the invoices:

<Response xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Id>558b39e7-c7dc-451f-883e-e52934a8ea0a</Id>
  <Status>OK</Status>
  <ProviderName>Funding Gates (privatedev)</ProviderName>
  <DateTimeUTC>2014-09-24T16:27:01.3399614Z</DateTimeUTC>
  <Invoices>
    <Invoice>
      <Contact>
        <ContactID>018355fc-c67e-4352-b443-ef3873031983</ContactID>
        <Name>Truxton Property Management</Name>
      </Contact>
      <Date>2014-08-25T00:00:00</Date>
      <DueDate>2014-08-25T00:00:00</DueDate>
      <Status>PAID</Status>
      <LineAmountTypes>Inclusive</LineAmountTypes>
      <LineItems>
        <LineItem>
          <Description>Monthly rent in advance</Description>
          <UnitAmount>1181.25</UnitAmount>
          <TaxType>NONE</TaxType>
          <TaxAmount>0.00</TaxAmount>
          <LineAmount>1181.25</LineAmount>
          <AccountCode>660</AccountCode>
          <Quantity>1.0000</Quantity>
        </LineItem>
      </LineItems>
      <SubTotal>1181.25</SubTotal>
      <TotalTax>0.00</TotalTax>
      <Total>1181.25</Total>
      <UpdatedDateUTC>2012-05-19T00:30:56.483</UpdatedDateUTC>
      <CurrencyCode>USD</CurrencyCode>
      <FullyPaidOnDate>2014-09-05T00:00:00</FullyPaidOnDate>
      <Type>ACCPAY</Type>
      <InvoiceID>2d106259-ee44-45da-8030-fec35dd1af43</InvoiceID>
      <InvoiceNumber>RPT660-1</InvoiceNumber>
      <Payments>
        <Payment>
          <PaymentID>8f9aa345-c2b0-4dc5-b868-0402c86ced79</PaymentID>
          <Date>2014-09-05T00:00:00</Date>
          <Amount>1181.25</Amount>
          <CurrencyRate>1.000000</CurrencyRate>
        </Payment>
      </Payments>
      <AmountDue>0.00</AmountDue>
      <AmountPaid>1181.25</AmountPaid>
      <AmountCredited>0.00</AmountCredited>
      <HasAttachments>false</HasAttachments>
    </Invoice>
    ...
  </Invoices>
</Response>

However, if line_items is accessed either directly or indirectly (e.g. through Invoice#total_tax) a new request is made to Xero for the invoice details. The line_items are in fact already accessible within the invoice model, but ignored.

@pinfieldharm pinfieldharm changed the title Invoices loaded with pagination needlessly load line item separately Invoices loaded with pagination needlessly load line items separately Sep 24, 2014
@waynerobinson
Copy link
Owner

The Xeroizer library doesn't currently support pagination.

Happy to receive a PR for this issue to implement pagination. It should happen at a lower level in the API and have a way to configure which endpoints support pagination.

This should still be optional (with potentially a global configuration default) as many existing users may expect calls to these endpoints to contain all records.

When using pagination, you should return the correct result for Xeroizer::Record::Base#complete_record_downloaded? for the configured models.

@umairsiddique
Copy link

#169

@pinfieldharm
Copy link
Contributor Author

#171 is my take on a partial solution to this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants