20 from gnucash.gnucash_business
import Customer, Employee, Vendor, Job, \
21 Address, Invoice, Entry, TaxTable, TaxTableEntry, GNC_AMT_TYPE_PERCENT, \
24 except ImportError
as import_error:
25 print(
"Problem importing modules.")
29 def get_all_lots(account):
30 """Return all lots in account and descendants""" 32 descs = account.get_descendants()
38 def get_all_invoices_from_lots(account):
39 """Return all invoices in account and descendants 41 This is based on lots. So invoices without lots will be missed.""" 43 lot_list=get_all_lots(account)
46 invoice=gnucash.gnucash_core_c.gncInvoiceGetInvoiceFromLot(lot.instance)
48 invoice_list.append(Invoice(instance=invoice))
51 def get_all_invoices(book, is_paid=None, is_active=None):
52 """Returns a list of all invoices in the book. 54 Posts a query to search for all invoices. 57 book the gnucash book to work with 59 is_paid int 1 to search for invoices having been paid, 0 for not, None to ignore. 60 is_active int 1 to search for active invoices 63 query = gnucash.Query()
64 query.search_for(
'gncInvoice')
68 query.add_boolean_match([gnucash.INVOICE_IS_PAID],
False, gnucash.QOF_QUERY_AND)
70 query.add_boolean_match([gnucash.INVOICE_IS_PAID],
True, gnucash.QOF_QUERY_AND)
76 query.add_boolean_match([
'active'],
False, gnucash.QOF_QUERY_AND)
78 query.add_boolean_match([
'active'],
True, gnucash.QOF_QUERY_AND)
79 elif is_active ==
None:
83 pred_data = gnucash.gnucash_core.QueryInt32Predicate(gnucash.QOF_COMPARE_EQUAL, 1)
84 query.add_term([gnucash.INVOICE_TYPE], pred_data, gnucash.QOF_QUERY_AND)
88 for result
in query.run():
89 invoice_list.append(Invoice(instance=result))
95 def get_all_customers(book):
96 """Returns all customers in book. 98 Posts a query to search for all customers. 101 book the gnucash book to work with 104 query = gnucash.Query()
105 query.search_for(
'gncCustomer')
110 for result
in query.run():
111 customer_list.append(Customer(instance=result))