Beispiel #1
0
def _insert_transaction(session, record, currency, rec_date, account_to,
                        account_from):
    book = session.book

    # set currency
    comm_table = book.get_table()
    currency = comm_table.lookup("CURRENCY", currency)

    transaction = gnucash.Transaction(book)
    transaction.BeginEdit()

    split_to = Split(book)
    # TODO - create money representation based on fractions
    value = GncNumeric(record.value.cents(), 100)
    split_to.SetValue(value)
    split_to.SetAccount(account_to)
    split_to.SetParent(transaction)

    split_from = Split(book)
    split_from.SetValue(value.neg())
    split_from.SetAccount(account_from)
    split_from.SetParent(transaction)

    # set transaction values
    transaction.SetDate(rec_date.day, rec_date.month, rec_date.year)
    transaction.SetDescription(record.description)
    transaction.SetCurrency(currency)
    transaction.CommitEdit()
Beispiel #2
0
    if d[3] > 0:
        num1 = GncNumeric(d[3] * 100, 100)
    elif d[4] > 0:
        num1 = GncNumeric(0 - d[4] * 100, 100)

    child_account = get_child_account(d[2].split(':'), account)
    print(child_account.name)

    trans = Transaction(book)
    trans.BeginEdit()
    trans.SetDate(d[0].day, d[0].month, d[0].year)
    trans.SetCurrency(cur)
    trans.SetDescription(d[1])
    split = Split(book)
    split.SetValue(num1)
    split.SetAccount(current_account)
    split.SetParent(trans)

    split1 = Split(book)
    split1.SetValue(num1.neg())
    split1.SetAccount(child_account)
    split1.SetParent(trans)

    trans.CommitEdit()

session.save()
session.end()
session.destroy()

stock = commod_table
Beispiel #3
0
split1.SetAccount(expenses_acct)
split1.SetParent(trans1)

split3.SetValue(num2)
split3.SetAccount(savings_acct)
split3.SetParent(trans2)

trans1.SetCurrency(cad)
trans1.SetDescription("Groceries")

trans2.SetCurrency(cad)
trans2.SetDescription("Opening Savings Balance")

split2 = Split(book)
split2.SetAccount(savings_acct)
split2.SetParent(trans1)
split2.SetValue(num1.neg())

split4 = Split(book)
split4.SetAccount(opening_acct)
split4.SetParent(trans2)
split4.SetValue(num2.neg())


trans1.CommitEdit()
trans2.CommitEdit()

session.save()
session.end()
session.destroy()
Beispiel #4
0
split3.SetValue(num2)
split3.SetAccount(savings_acct)
split3.SetParent(trans2)

trans1.SetCurrency(cad)
trans1.SetDate(14, 3, 2006)
trans1.SetDescription("Groceries")

trans2.SetCurrency(cad)
trans2.SetDate(7, 11, 1995)
trans2.SetDescription("Opening Savings Balance")

split2 = Split(book)
split2.SetAccount(savings_acct)
split2.SetParent(trans1)
split2.SetValue(num1.neg())

split4 = Split(book)
split4.SetAccount(opening_acct)
split4.SetParent(trans2)
split4.SetValue(num2.neg())


trans1.CommitEdit()
trans2.CommitEdit()

session.save()
session.end()
session.destroy()