Esempio n. 1
0
class BusinessSession( BookSession ):
    def setUp(self):
        BookSession.setUp(self)

        self.today = datetime.today()

        self.bank = Account(self.book)
        self.bank.SetType(ACCT_TYPE_BANK)
        self.bank.SetCommodity(self.currency)
        self.income = Account(self.book)
        self.income.SetType(ACCT_TYPE_INCOME)
        self.income.SetCommodity(self.currency)
        self.receivable = Account(self.book)
        self.receivable.SetType(ACCT_TYPE_RECEIVABLE)
        self.receivable.SetCommodity(self.currency)

        self.customer = Customer(self.book,'CustomerID',self.currency)
        self.vendor = Vendor(self.book,'VendorID',self.currency)
        self.employee = Employee(self.book,'EmployeeID',self.currency)
        self.job = Job(self.book,'JobID',self.customer)

        self.invoice = Invoice(self.book,'InvoiceID',self.currency,self.customer)
        self.invoice.SetDateOpened(self.today)
        entry = Entry(self.book)
        entry.SetDate(self.today)
        entry.SetDescription("Some income")
        entry.SetQuantity(GncNumeric(1))
        entry.SetInvAccount(self.income)
        entry.SetInvPrice(GncNumeric(100))
        self.invoice.AddEntry(entry)

        self.invoice.PostToAccount(self.receivable,
            self.today, self.today, "", True, False)
Esempio n. 2
0
File: tax.py Progetto: jfishe/qb2gnc
def new_tax(root, book, USD, row):
    if row['type'] == 'Sales Tax Item':
        tablename = row['item']
        parent = root.lookup_by_name(row['account'])
        account = Account(book)
        parent.append_child(account)
        account.SetName(tablename)
        account.SetType(ACCT_TYPE_LIABILITY)
        account.SetCommodity(USD)
        rate = gnc_numeric_from(row['rate'])
        # Skip existing tax table and create new ones
        try:
            assert (
                not isinstance(book.TaxTableLookupByName(tablename), TaxTable)
            )
            TaxTable(book, tablename, TaxTableEntry(account, True, rate))
        except AssertionError:
            print '"%s" tax table already exists, skipping' \
                  % tablename
            # Add method to update rate
            return 0
    return 1
Esempio n. 3
0
#!/usr/bin/env python3
##  @file
#   @brief Example Script simple sqlite create 
#   @ingroup python_bindings_examples

from gnucash import Session, Account
from os.path import abspath
from gnucash.gnucash_core_c import ACCT_TYPE_ASSET

s = Session('sqlite3://%s' % abspath('test.blob'), is_new=True)
# this seems to make a difference in more complex cases
s.save()

book = s.book
root = book.get_root_account()
a = Account(book)
root.append_child(a)
a.SetName('wow')
a.SetType(ACCT_TYPE_ASSET)

commod_table = book.get_table()
a.SetCommodity( commod_table.lookup('CURRENCY', 'CAD') )
s.save()

s.end()
Esempio n. 4
0
    print(
        "python3 simple_business_create.py sqlite3:///home/blah/blah.gnucash")
    exit()

try:
    s = Session(argv[1], SessionOpenMode.SESSION_NEW_STORE)

    book = s.book
    root = book.get_root_account()
    commod_table = book.get_table()
    CAD = commod_table.lookup('CURRENCY', 'CAD')

    a = Account(book)
    root.append_child(a)
    a.SetName('Assets')
    a.SetType(ACCT_TYPE_ASSET)
    a.SetCommodity(CAD)

    a2 = Account(book)
    a.append_child(a2)
    a2.SetName('Receivables')
    a2.SetType(ACCT_TYPE_RECEIVABLE)
    a2.SetCommodity(CAD)

    a3 = Account(book)
    root.append_child(a3)
    a3.SetName('Income')
    a3.SetType(ACCT_TYPE_INCOME)
    a3.SetCommodity(CAD)

    a4 = Account(book)
# and trading accounts disabled
session = Session(argv[1])
book = session.book

root = book.get_root_account()
root.get_instance()
commod_tab = session.book.get_table()
CAD = commod_tab.lookup("ISO4217", "CAD")
USD = commod_tab.lookup("ISO4217", "USD")
account = Account(book)
account2 = Account(book)
root.append_child(account)
root.append_child(account2)
account.SetCommodity(CAD)
account.SetName("blahblah")
account.SetType(3)
account2.SetCommodity(USD)
account2.SetName("blahblahsdfs ")
account2.SetType(3)

a = Transaction(book)
a.BeginEdit()

s = Split(book)
s.SetParent(a)
s2 = Split(book)
s2.SetParent(a)

a.SetCurrency(CAD)
s.SetAccount(account)
s.SetValue(GncNumeric(2))
Esempio n. 6
0
trans2.BeginEdit()

split1 = Split(book)
split3 = Split(book)
comm_table = book.get_table()
cad = comm_table.lookup("CURRENCY", "CAD")

num1 = GncNumeric(4, 1)
num2 = GncNumeric(100, 1)

#Set new root account
book.set_root_account(root_acct)

#Set up root account and add sub-accounts
root_acct.SetName("Root")
root_acct.SetType(13) #ACCT_TYPE_ROOT = 13
root_acct.append_child(expenses_acct)
root_acct.append_child(savings_acct)
root_acct.append_child(opening_acct)

#Set up Expenses account
expenses_acct.SetCommodity(cad)
expenses_acct.SetName("Expenses")
expenses_acct.SetType(9) #ACCT_TYPE_EXPENSE = 9

#Set up Savings account
savings_acct.SetCommodity(cad)
savings_acct.SetName("Savings")
savings_acct.SetType(0) #ACCT_TYPE_BANK = 0

#Set up Opening Balance account