def get_customers(book): customers = [] query = Query() query.set_book(book) query.search_for("gncCustomer") for result in query.run(): customers.append(Customer(instance=result)) query.destroy() return customers
def isvendor(company): book = GncFile.book query = Query() query.search_for('gncVendor') query.set_book(book) for result in query.run(): vendor = Vendor(instance=result) if vendor.GetName() == company: query.destroy() return vendor query.destroy() return None
def iscustomer(company): book = GncFile.book query = Query() query.search_for('gncCustomer') query.set_book(book) for result in query.run(): customer = Customer(instance=result) if customer.GetName() == company: query.destroy() return customer query.destroy() return None
def GetCustomerByEmail(self, email): q = Query() q.search_for('gncCustomer') q.set_book(self._book) c = None for result in q.run(): tmp = Customer(instance=result) if tmp.GetAddr().GetEmail().lower() == email.lower(): c = tmp break q.destroy() return c
def GetCustomerByName(self, name): q = Query() q.search_for('gncCustomer') q.set_book(self._book) c = None for result in q.run(): tmp = Customer(instance=result) if tmp.GetName().lower() in name.lower(): c = tmp break q.destroy() return c
def GetCustomerByEmail(self, email): q = Query() q.search_for("gncCustomer") q.set_book(self._book) c = None for result in q.run(): tmp = Customer(instance=result) if tmp.GetAddr().GetEmail().lower() == email.lower(): c = tmp break q.destroy() return c
def query_transactions(book, terms=[]): query = Query() query.search_for('Trans') query.set_book(book) if terms: for term in terms: query.add_term(*term) transactions = [] for transaction in query.run(): transaction = Transaction( instance=transaction) # ToDo: query.run() should return objects transactions.append(transaction) query.destroy() return transactions
def query_splits(book, terms=[]): query = Query() query.search_for('Split') query.set_book(book) if terms: for term in terms: query.add_term(*term) splits = [] for split in query.run(): split = Split( instance=split) # ToDo: query.run() should return objects splits.append(split) query.destroy() return splits