예제 #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
파일: 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
예제 #3
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
예제 #4
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
예제 #5
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
예제 #6
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
예제 #7
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
예제 #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 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)
 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