예제 #1
0
파일: sandbox.py 프로젝트: univic/piecash
    # The lookup string needs to match your account path exactly.
    sp1.SetAccount(lookup_account(root, "Expenses:Some Expense Account"))
    # amount is an int (no $ or .), so $5.23 becomes amount=523
    sp1.SetValue(GncNumeric(amount, 100))  # Assuming you only have one split
    # For multiple splits, you need to make sure the totals all balance out.
    sp1.SetAmount(GncNumeric(amount, 100))
    sp1.SetMemo("Split Memo!")  # optional

    sp2 = Split(book)  # Need a balancing split
    sp2.SetParent(tx)
    sp2.SetAccount(lookup_account(root, "Assets:Current Assets:Checking"))
    sp2.SetValue(sp1.GetValue().neg())
    sp2.SetAmount(sp1.GetValue().neg())
    sp2.SetMemo("Other Split Memo!")  # optional

    tx.CommitEdit()  # Finish editing transaction
    session.save()
    session.end()

    fdsfsfds

if True:

    with create_book("../gnucash_books/example.gnucash", overwrite=True) as mybook:
        mybook.root_account.children = [
            Account(name="Expenses",
                    type="EXPENSE",
                    commodity=mybook.currencies(mnemonic="USD"),
                    placeholder=True,
                    children=[
                        Account(name="Some Expense Account",