GnuCash c935c2f+
Loading...
Searching...
No Matches
Functions

some help for working with invoices, used in Python invoice export More...

Go to the source code of this file.

Functions

 gncinvoicefkt.get_all_lots (account)
 
 gncinvoicefkt.get_all_invoices_from_lots (account)
 
 gncinvoicefkt.get_all_invoices (book, is_paid=None, is_active=None)
 
 gncinvoicefkt.get_all_customers (book)
 

Detailed Description

some help for working with invoices, used in Python invoice export

Author
Christoph Holtermann (c.holtermann (at) gmx.de)
Date
2014-11

Credits to Tom Loft for the query to get_all_invoices as used in his REST-Api

Issues:

Definition in file gncinvoicefkt.py.

Function Documentation

◆ get_all_customers()

gncinvoicefkt.get_all_customers (   book)
Returns all customers in book.

Posts a query to search for all customers.

arguments:
    book                the gnucash book to work with

Definition at line 95 of file gncinvoicefkt.py.

95def get_all_customers(book):
96 """Returns all customers in book.
97
98 Posts a query to search for all customers.
99
100 arguments:
101 book the gnucash book to work with
102 """
103
104 query = gnucash.Query()
105 query.search_for('gncCustomer')
106 query.set_book(book)
107
108 customer_list = []
109
110 for result in query.run():
111 customer_list.append(Customer(instance=result))
112
113 query.destroy()
114
115 return customer_list

◆ get_all_invoices()

gncinvoicefkt.get_all_invoices (   book,
  is_paid = None,
  is_active = None 
)
Returns a list of all invoices in the book.

Posts a query to search for all invoices.

arguments:
    book                the gnucash book to work with
keyword-arguments:
    is_paid     int     1 to search for invoices having been paid, 0 for not, None to ignore.
    is_active   int     1 to search for active invoices

Definition at line 51 of file gncinvoicefkt.py.

51def get_all_invoices(book, is_paid=None, is_active=None):
52 """Returns a list of all invoices in the book.
53
54 Posts a query to search for all invoices.
55
56 arguments:
57 book the gnucash book to work with
58 keyword-arguments:
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
61 """
62
63 query = gnucash.Query()
64 query.search_for('gncInvoice')
65 query.set_book(book)
66
67 if is_paid == 0:
68 query.add_boolean_match([gnucash.INVOICE_IS_PAID], False, gnucash.QOF_QUERY_AND)
69 elif is_paid == 1:
70 query.add_boolean_match([gnucash.INVOICE_IS_PAID], True, gnucash.QOF_QUERY_AND)
71 elif is_paid == None:
72 pass
73
74 # active = JOB_IS_ACTIVE
75 if is_active == 0:
76 query.add_boolean_match(['active'], False, gnucash.QOF_QUERY_AND)
77 elif is_active == 1:
78 query.add_boolean_match(['active'], True, gnucash.QOF_QUERY_AND)
79 elif is_active == None:
80 pass
81
82 # return only invoices (1 = invoices)
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)
85
86 invoice_list = []
87
88 for result in query.run():
89 invoice_list.append(Invoice(instance=result))
90
91 query.destroy()
92
93 return invoice_list
94

◆ get_all_invoices_from_lots()

gncinvoicefkt.get_all_invoices_from_lots (   account)
Return all invoices in account and descendants

This is based on lots. So invoices without lots will be missed.

Definition at line 38 of file gncinvoicefkt.py.

38def get_all_invoices_from_lots(account):
39 """Return all invoices in account and descendants
40
41 This is based on lots. So invoices without lots will be missed."""
42
43 lot_list=get_all_lots(account)
44 invoice_list=[]
45 for lot in lot_list:
46 invoice=gnucash.gnucash_core_c.gncInvoiceGetInvoiceFromLot(lot.instance)
47 if invoice:
48 invoice_list.append(Invoice(instance=invoice))
49 return invoice_list
50

◆ get_all_lots()

gncinvoicefkt.get_all_lots (   account)
Return all lots in account and descendants

Definition at line 29 of file gncinvoicefkt.py.

29def get_all_lots(account):
30 """Return all lots in account and descendants"""
31 ltotal=[]
32 descs = account.get_descendants()
33 for desc in descs:
34 ll=desc.GetLotList()
35 ltotal+=ll
36 return ltotal
37