示例#1
0
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
示例#2
0
def GetBudgets (self):

    # use Query to find budgets
    qry = Query()

    qry.set_book(self)

    # this query finds all budgets defined
    # question is how to use Query to find budget with a name??
    # for the moment lets just search the list - in general its a small list
    qry.search_for(Book.GNC_ID_BUDGET)

    bdgtlst = qry.Run(GncBudget)

    return bdgtlst
示例#3
0
    def test_search_for(self):
        query = Query()

        query.search_for(GNC_ID_INVOICE)
        self.assertEqual(query.get_search_for(), GNC_ID_INVOICE)

        obj_type = 'gncInvoice'
        query.search_for(obj_type)
        self.assertEqual(query.get_search_for(), obj_type)
示例#4
0
    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
示例#5
0
    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
示例#6
0
    def test_search_for(self):
        query = Query()

        query.search_for(GNC_ID_INVOICE)
        self.assertEqual(query.get_search_for(), GNC_ID_INVOICE)

        obj_type = 'gncInvoice'
        query.search_for(obj_type)
        self.assertEqual(query.get_search_for(), obj_type)
示例#7
0
def BudgetLookup (self, budget_name):

    # use Query to find budgets
    qry = Query()

    qry.set_book(self)

    # this query finds all budgets defined
    # question is how to use Query to find budget with a name??
    # for the moment lets just search the list - in general its a small list
    qry.search_for(Book.GNC_ID_BUDGET)

    bdgtlst = qry.Run(GncBudget)

    # note this only finds first one if name is the same
    for bdgt in bdgtlst:
       if bdgt.name == budget_name:
           return bdgt

    raise KeyError("Unable to find budget %s"%budget_name)
示例#8
0
    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
示例#9
0
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
示例#10
0
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
示例#11
0
def get_invoices(book, customer=None, days=None):
    invoices = []
    query = Query()
    query.set_book(book)
    query.search_for("gncInvoice")
    if customer:
        query.add_guid_match(["owner", "guid"], customer.GetGUID(),
                             QOF_QUERY_AND)
    if days:
        date_posted = date.today() - timedelta(days=days)
        pred_data = QueryDatePredicate(QOF_COMPARE_GTE, 2, date_posted)
        query.add_term(["date_posted"], pred_data, QOF_QUERY_AND)
    for result in query.run():
        invoices.append(Invoice(instance=result))
    return invoices
示例#12
0
文件: tax.py 项目: jfishe/qb2gnc
    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
示例#13
0
文件: tax.py 项目: jfishe/qb2gnc
    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
示例#14
0
 def test_create(self):
     query = Query()
     self.assertIsInstance(query, Query)
 def get_vendors(self):
     q = Query()
     q.set_book(self.accounting.book)
     q.search_for(GNC_ID_VENDOR)
     items = [ Contact(Vendor(instance=item)) for item in q.run() ]
     return items
 def get_customers(self):
     q = Query()
     q.set_book(self.accounting.book)
     q.search_for(GNC_ID_CUSTOMER)
     items = [ Contact(Customer(instance=item)) for item in q.run() ]
     return items