コード例 #1
0
ファイル: queries.py プロジェクト: drjeep/gnucash-importer
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
ファイル: gnucash_ext.py プロジェクト: davidjo/gnucash_python
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
ファイル: test_query.py プロジェクト: Gnucash/gnucash
    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
ファイル: gnucash_ext.py プロジェクト: davidjo/gnucash_python
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
ファイル: qof.py プロジェクト: christopherlam/gnucash
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
ファイル: qof.py プロジェクト: christopherlam/gnucash
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
ファイル: queries.py プロジェクト: drjeep/gnucash-importer
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)
コード例 #15
0
 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
コード例 #16
0
 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