mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-20 11:48:30 -06:00
Update query for get_all_customers
Use same time of query in get_all_customers as in get_all_invoices
This commit is contained in:
parent
1a5c2dd254
commit
5675dad2f3
@ -56,7 +56,7 @@ def get_all_invoices_from_lots(account):
|
|||||||
def get_all_invoices(book, is_paid=None, is_active=None):
|
def get_all_invoices(book, is_paid=None, is_active=None):
|
||||||
"""Returns a list of all invoices in the book.
|
"""Returns a list of all invoices in the book.
|
||||||
|
|
||||||
posts a query to search for all invoices.
|
Posts a query to search for all invoices.
|
||||||
|
|
||||||
arguments:
|
arguments:
|
||||||
book the gnucash book to work with
|
book the gnucash book to work with
|
||||||
@ -90,7 +90,6 @@ def get_all_invoices(book, is_paid=None, is_active=None):
|
|||||||
|
|
||||||
invoice_list = []
|
invoice_list = []
|
||||||
|
|
||||||
result = query.run()
|
|
||||||
for result in query.run():
|
for result in query.run():
|
||||||
invoice_list.append(Invoice(instance=result))
|
invoice_list.append(Invoice(instance=result))
|
||||||
|
|
||||||
@ -101,16 +100,21 @@ def get_all_invoices(book, is_paid=None, is_active=None):
|
|||||||
def get_all_customers(book):
|
def get_all_customers(book):
|
||||||
"""Returns all customers in book.
|
"""Returns all customers in book.
|
||||||
|
|
||||||
Counts IDs upwards. May miss customers with irregular IDs.
|
Posts a query to search for all customers.
|
||||||
Should be replaced by query as in get_all_invoices."""
|
|
||||||
|
arguments:
|
||||||
|
book the gnucash book to work with
|
||||||
|
"""
|
||||||
|
|
||||||
|
query = gnucash.Query()
|
||||||
|
query.search_for('gncCustomer')
|
||||||
|
query.set_book(book)
|
||||||
|
|
||||||
customer_list = []
|
customer_list = []
|
||||||
customer = True
|
|
||||||
customer_id = 0
|
for result in query.run():
|
||||||
while customer:
|
customer_list.append(Customer(instance=result))
|
||||||
customer_id += 1
|
|
||||||
customer = book.CustomerLookupByID('%06d' % customer_id)
|
query.destroy()
|
||||||
if customer:
|
|
||||||
customer_list.append(customer)
|
|
||||||
|
|
||||||
return customer_list
|
return customer_list
|
||||||
|
Loading…
Reference in New Issue
Block a user