-
Notifications
You must be signed in to change notification settings - Fork 208
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
Filter or get multiple invoices #267
Comments
Hi there, I don't think the What you could do to fetch multiple invoices by def getInvoiceByID(listOfInvoiceIDs):
invoices = []
for invoice in listOfInvoiceIDs:
invoices.extend(self.xero.invoices.get(invoice))
return invoices This comes with a warning though! Xero is quite strict on rate limiting and using individual requests to fetch individual invoices is quite inefficient. It's OK for two or three, but if you're needing to retrieve more, or several times a day you should investigate other ways of retrieving your invoices. I have also attached the code that I use to get invoices which match a query parameter.
def getInvoices(self, raw_query):
"""
This method pulls the draft invoices from Xero. Because of the quantity it
paginated the results.
Returns: list of invoices OR False
"""
try:
invoices, i = [], 1
resp = xero.invoices.filter(raw=raw_query, order='Date DESC',
type='ACCREC', page=i, status='DRAFT')
while resp != []:
invoices.extend(resp); i += 1
resp = xero.invoices.filter(raw=raw_query, order='Date DESC',
type='ACCREC', page=i, status='DRAFT')
log.info('Retrieved draft invoices.')
return invoices
except Exception as e:
log.error('Error fetching invoices {}'.format(e))
return False I hope this was helpful in some way. |
Thank you for that suggestion IdlePhysicist. My list of invoices will be random. It basically queries Payments made on a certain date. From those Payments, I will pull the list of invoices to find out if they are fully paid. As you can see, the list of invoices will not follow any order. |
How do you retrieve multiple invoices using InvoiceID ?
I expected the below syntax to work but obviously it doesn't.
invoices = xero.invoices.get('f3ecf55f-b7b0-47d2-a0f3-97df84890af2', 'f3ecf55f-b7b0-47d2-a0f3-95af84890af2')
The text was updated successfully, but these errors were encountered: