|
|
|
|
@ -25,7 +25,8 @@ import gnucash_core_c
|
|
|
|
|
|
|
|
|
|
from function_class import \
|
|
|
|
|
ClassFromFunctions, extract_attributes_with_prefix, \
|
|
|
|
|
default_arguments_decorator, method_function_returns_instance
|
|
|
|
|
default_arguments_decorator, method_function_returns_instance, \
|
|
|
|
|
methods_return_instance
|
|
|
|
|
|
|
|
|
|
class GnuCashCoreClass(ClassFromFunctions):
|
|
|
|
|
_module = gnucash_core_c
|
|
|
|
|
@ -118,9 +119,7 @@ class GncCommodity(GnuCashCoreClass):
|
|
|
|
|
def __init__(self, book, name=None, namespace=None, mnemonic=None, cusip=None, fraction=1, **kargs):
|
|
|
|
|
GnuCashCoreClass.__init__(self, book, name, namespace, mnemonic, cusip, fraction, **kargs)
|
|
|
|
|
|
|
|
|
|
class GncCommodityTable(GnuCashCoreClass):
|
|
|
|
|
def __init__(self, book, **kargs):
|
|
|
|
|
GnuCashCoreClass.__init__(self, book, **kargs)
|
|
|
|
|
class GncCommodityTable(GnuCashCoreClass): pass
|
|
|
|
|
|
|
|
|
|
class GncLot(GnuCashCoreClass):
|
|
|
|
|
def __init__(self, book, **kargs):
|
|
|
|
|
@ -128,12 +127,19 @@ class GncLot(GnuCashCoreClass):
|
|
|
|
|
|
|
|
|
|
class Transaction(GnuCashCoreClass):
|
|
|
|
|
_new_instance = 'xaccMallocTransaction'
|
|
|
|
|
def GetNthSplit(self, n):
|
|
|
|
|
return self.GetSplitList().pop(n)
|
|
|
|
|
|
|
|
|
|
class Split(GnuCashCoreClass):
|
|
|
|
|
_new_instance = 'xaccMallocSplit'
|
|
|
|
|
|
|
|
|
|
class Account(GnuCashCoreClass):
|
|
|
|
|
_new_instance = 'xaccMallocAccount'
|
|
|
|
|
def GetNthChild(self, n):
|
|
|
|
|
return self.get_children().pop(n)
|
|
|
|
|
|
|
|
|
|
class GUID(GnuCashCoreClass):
|
|
|
|
|
_new_instance = 'guid_new_return'
|
|
|
|
|
|
|
|
|
|
# Session
|
|
|
|
|
Session.add_constructor_and_methods_with_prefix('qof_session_', 'new')
|
|
|
|
|
@ -158,43 +164,32 @@ for error_name, error_value, error_name_after_prefix in \
|
|
|
|
|
#Book
|
|
|
|
|
Book.add_constructor_and_methods_with_prefix('qof_book_', 'new')
|
|
|
|
|
Book.add_method('gnc_book_get_root_account', 'get_root_account')
|
|
|
|
|
Book.add_method('gnc_book_set_root_account', 'set_root_account')
|
|
|
|
|
#Functions that return Account
|
|
|
|
|
Book.get_root_account = method_function_returns_instance(
|
|
|
|
|
Book.get_root_account, Account )
|
|
|
|
|
|
|
|
|
|
# GncNumeric
|
|
|
|
|
GncNumeric.add_constructor_and_methods_with_prefix('gnc_numeric_', 'create')
|
|
|
|
|
#Functions that return GncNumeric
|
|
|
|
|
GncNumeric.same = method_function_returns_instance(
|
|
|
|
|
GncNumeric.same, GncNumeric )
|
|
|
|
|
GncNumeric.add = method_function_returns_instance(
|
|
|
|
|
GncNumeric.add, GncNumeric )
|
|
|
|
|
GncNumeric.sub = method_function_returns_instance(
|
|
|
|
|
GncNumeric.sub, GncNumeric )
|
|
|
|
|
GncNumeric.mul = method_function_returns_instance(
|
|
|
|
|
GncNumeric.mul, GncNumeric )
|
|
|
|
|
GncNumeric.div = method_function_returns_instance(
|
|
|
|
|
GncNumeric.div, GncNumeric )
|
|
|
|
|
GncNumeric.neg = method_function_returns_instance(
|
|
|
|
|
GncNumeric.neg, GncNumeric )
|
|
|
|
|
GncNumeric.abs = method_function_returns_instance(
|
|
|
|
|
GncNumeric.abs, GncNumeric )
|
|
|
|
|
GncNumeric.add_fixed = method_function_returns_instance(
|
|
|
|
|
GncNumeric.add_fixed, GncNumeric )
|
|
|
|
|
GncNumeric.sub_fixed = method_function_returns_instance(
|
|
|
|
|
GncNumeric.sub_fixed, GncNumeric )
|
|
|
|
|
GncNumeric.add_with_error = method_function_returns_instance(
|
|
|
|
|
GncNumeric.add_with_error, GncNumeric )
|
|
|
|
|
GncNumeric.sub_with_error = method_function_returns_instance(
|
|
|
|
|
GncNumeric.sub_with_error, GncNumeric )
|
|
|
|
|
GncNumeric.mul_with_error = method_function_returns_instance(
|
|
|
|
|
GncNumeric.mul_with_error, GncNumeric )
|
|
|
|
|
GncNumeric.div_with_error = method_function_returns_instance(
|
|
|
|
|
GncNumeric.div_with_error, GncNumeric )
|
|
|
|
|
GncNumeric.convert = method_function_returns_instance(
|
|
|
|
|
GncNumeric.convert, GncNumeric )
|
|
|
|
|
GncNumeric.reduce = method_function_returns_instance(
|
|
|
|
|
GncNumeric.reduce, GncNumeric )
|
|
|
|
|
|
|
|
|
|
gncnumeric_dict = {
|
|
|
|
|
'same' : GncNumeric,
|
|
|
|
|
'add' : GncNumeric,
|
|
|
|
|
'sub' : GncNumeric,
|
|
|
|
|
'mul' : GncNumeric,
|
|
|
|
|
'div' : GncNumeric,
|
|
|
|
|
'neg' : GncNumeric,
|
|
|
|
|
'abs' : GncNumeric,
|
|
|
|
|
'add_fixed' : GncNumeric,
|
|
|
|
|
'sub_fixed' : GncNumeric,
|
|
|
|
|
'add_with_error' : GncNumeric,
|
|
|
|
|
'sub_with_error' : GncNumeric,
|
|
|
|
|
'mul_with_error' : GncNumeric,
|
|
|
|
|
'div_with_error' : GncNumeric,
|
|
|
|
|
'convert' : GncNumeric,
|
|
|
|
|
'reduce' : GncNumeric
|
|
|
|
|
}
|
|
|
|
|
methods_return_instance(GncNumeric, gncnumeric_dict)
|
|
|
|
|
|
|
|
|
|
# GncCommodity
|
|
|
|
|
GncCommodity.add_constructor_and_methods_with_prefix('gnc_commodity_', 'new')
|
|
|
|
|
@ -204,105 +199,69 @@ GncCommodity.clone = method_function_returns_instance(
|
|
|
|
|
|
|
|
|
|
# GncCommodityTable
|
|
|
|
|
GncCommodityTable.add_constructor_and_methods_with_prefix('gnc_commodity_table_', 'get_table')
|
|
|
|
|
#Functions that return GncCommodity
|
|
|
|
|
GncCommodityTable.lookup = method_function_returns_instance(
|
|
|
|
|
GncCommodityTable.lookup, GncCommodity )
|
|
|
|
|
GncCommodityTable.lookup_unique = method_function_returns_instance(
|
|
|
|
|
GncCommodityTable.lookup_unique, GncCommodity )
|
|
|
|
|
GncCommodityTable.find_full = method_function_returns_instance(
|
|
|
|
|
GncCommodityTable.find_full, GncCommodity )
|
|
|
|
|
GncCommodityTable.insert = method_function_returns_instance(
|
|
|
|
|
GncCommodityTable.insert, GncCommodity )
|
|
|
|
|
|
|
|
|
|
commoditytable_dict = {
|
|
|
|
|
'lookup' : GncCommodity,
|
|
|
|
|
'lookup_unique' : GncCommodity,
|
|
|
|
|
'find_full' : GncCommodity,
|
|
|
|
|
'insert' : GncCommodity
|
|
|
|
|
}
|
|
|
|
|
methods_return_instance(GncCommodityTable, commoditytable_dict)
|
|
|
|
|
|
|
|
|
|
# GncLot
|
|
|
|
|
GncLot.add_constructor_and_methods_with_prefix('gnc_lot_', 'new')
|
|
|
|
|
#Functions that return Account
|
|
|
|
|
GncLot.get_account = method_function_returns_instance(
|
|
|
|
|
GncLot.get_account, Account )
|
|
|
|
|
#Functions that return Book
|
|
|
|
|
GncLot.get_book = method_function_returns_instance(
|
|
|
|
|
GncLot.get_book, Book )
|
|
|
|
|
#Functions that return Split
|
|
|
|
|
GncLot.get_earliest_split = method_function_returns_instance(
|
|
|
|
|
GncLot.get_earliest_split, Split )
|
|
|
|
|
GncLot.get_latest_split = method_function_returns_instance(
|
|
|
|
|
GncLot.get_latest_split, Split )
|
|
|
|
|
#Functions that return GncNumeric
|
|
|
|
|
GncLot.get_balance = method_function_returns_instance(
|
|
|
|
|
GncLot.get_balance, GncNumeric )
|
|
|
|
|
#Functions that return GncLot
|
|
|
|
|
GncLot.lookup = method_function_returns_instance(
|
|
|
|
|
GncLot.lookup, GncLot )
|
|
|
|
|
GncLot.make_default = method_function_returns_instance(
|
|
|
|
|
GncLot.make_default, GncLot )
|
|
|
|
|
|
|
|
|
|
gnclot_dict = {
|
|
|
|
|
'get_account' : Account,
|
|
|
|
|
'get_book' : Book,
|
|
|
|
|
'get_earliest_split' : Split,
|
|
|
|
|
'get_latest_split' : Split,
|
|
|
|
|
'get_balance' : GncNumeric,
|
|
|
|
|
'lookup' : GncLot,
|
|
|
|
|
'make_default' : GncLot
|
|
|
|
|
}
|
|
|
|
|
methods_return_instance(GncLot, gnclot_dict)
|
|
|
|
|
|
|
|
|
|
# Transaction
|
|
|
|
|
Transaction.add_methods_with_prefix('xaccTrans')
|
|
|
|
|
#Functions that return Split
|
|
|
|
|
Transaction.GetSplit = method_function_returns_instance(
|
|
|
|
|
Transaction.GetSplit, Split )
|
|
|
|
|
Transaction.FindSplitByAccount = method_function_returns_instance(
|
|
|
|
|
Transaction.FindSplitByAccount, Split )
|
|
|
|
|
#Functions that return Transaction
|
|
|
|
|
Transaction.Clone = method_function_returns_instance(
|
|
|
|
|
Transaction.Clone, Transaction )
|
|
|
|
|
Transaction.Reverse = method_function_returns_instance(
|
|
|
|
|
Transaction.Reverse, Transaction )
|
|
|
|
|
Transaction.GetReversedBy = method_function_returns_instance(
|
|
|
|
|
Transaction.GetReversedBy, Transaction )
|
|
|
|
|
#Functions that return GncCommodity
|
|
|
|
|
Transaction.GetCurrency = method_function_returns_instance(
|
|
|
|
|
Transaction.GetCurrency, GncCommodity )
|
|
|
|
|
#Functions that return GncNumeric
|
|
|
|
|
Transaction.GetImbalance = method_function_returns_instance(
|
|
|
|
|
Transaction.GetImbalance, GncNumeric )
|
|
|
|
|
Transaction.GetAccountValue = method_function_returns_instance(
|
|
|
|
|
Transaction.GetAccountValue, GncNumeric )
|
|
|
|
|
Transaction.GetAccountAmount = method_function_returns_instance(
|
|
|
|
|
Transaction.GetAccountAmount, GncNumeric )
|
|
|
|
|
Transaction.GetAccountConvRate = method_function_returns_instance(
|
|
|
|
|
Transaction.GetAccountConvRate, GncNumeric )
|
|
|
|
|
Transaction.GetAccountBalance = method_function_returns_instance(
|
|
|
|
|
Transaction.GetAccountBalance, GncNumeric )
|
|
|
|
|
|
|
|
|
|
trans_dict = {
|
|
|
|
|
'GetSplit': Split,
|
|
|
|
|
'FindSplitByAccount': Split,
|
|
|
|
|
'GetNthSplit': Split,
|
|
|
|
|
'Clone': Transaction,
|
|
|
|
|
'Reverse': Transaction,
|
|
|
|
|
'GetReversedBy': Transaction,
|
|
|
|
|
'GetImbalance': GncNumeric,
|
|
|
|
|
'GetAccountValue': GncNumeric,
|
|
|
|
|
'GetAccountAmount': GncNumeric,
|
|
|
|
|
'GetAccountConvRate': GncNumeric,
|
|
|
|
|
'GetAccountBalance': GncNumeric,
|
|
|
|
|
'GetCurrency': GncCommodity
|
|
|
|
|
}
|
|
|
|
|
methods_return_instance(Transaction, trans_dict)
|
|
|
|
|
|
|
|
|
|
# Split
|
|
|
|
|
Split.add_methods_with_prefix('xaccSplit')
|
|
|
|
|
#Functions that return Book
|
|
|
|
|
Split.GetBook = method_function_returns_instance(
|
|
|
|
|
Split.GetBook, Book )
|
|
|
|
|
#Functions that return Account
|
|
|
|
|
Split.GetAccount = method_function_returns_instance(
|
|
|
|
|
Split.GetAccount, Account )
|
|
|
|
|
#Functions that return Transaction
|
|
|
|
|
Split.GetParent = method_function_returns_instance(
|
|
|
|
|
Split.GetParent, Transaction )
|
|
|
|
|
#Functions that return Split
|
|
|
|
|
Split.Lookup = method_function_returns_instance(
|
|
|
|
|
Split.Lookup, Split )
|
|
|
|
|
Split.GetOtherSplit = method_function_returns_instance(
|
|
|
|
|
Split.GetOtherSplit, Split )
|
|
|
|
|
#Functions that return GncNumeric
|
|
|
|
|
Split.GetAmount = method_function_returns_instance(
|
|
|
|
|
Split.GetAmount, GncNumeric )
|
|
|
|
|
Split.GetValue = method_function_returns_instance(
|
|
|
|
|
Split.GetValue, GncNumeric )
|
|
|
|
|
Split.GetSharePrice = method_function_returns_instance(
|
|
|
|
|
Split.GetSharePrice, GncNumeric )
|
|
|
|
|
Split.ConvertAmount = method_function_returns_instance(
|
|
|
|
|
Split.ConvertAmount, GncNumeric )
|
|
|
|
|
Split.GetBaseValue = method_function_returns_instance(
|
|
|
|
|
Split.GetBaseValue, GncNumeric )
|
|
|
|
|
Split.GetBalance = method_function_returns_instance(
|
|
|
|
|
Split.GetBalance, GncNumeric )
|
|
|
|
|
Split.GetClearedBalance = method_function_returns_instance(
|
|
|
|
|
Split.GetClearedBalance, GncNumeric )
|
|
|
|
|
Split.GetReconciledBalance = method_function_returns_instance(
|
|
|
|
|
Split.GetReconciledBalance, GncNumeric )
|
|
|
|
|
Split.VoidFormerAmount = method_function_returns_instance(
|
|
|
|
|
Split.VoidFormerAmount, GncNumeric )
|
|
|
|
|
Split.VoidFormerValue = method_function_returns_instance(
|
|
|
|
|
Split.VoidFormerValue, GncNumeric )
|
|
|
|
|
|
|
|
|
|
split_dict = {
|
|
|
|
|
'GetBook': Book,
|
|
|
|
|
'GetAccount': Account,
|
|
|
|
|
'GetParent': Transaction,
|
|
|
|
|
'Lookup': Split,
|
|
|
|
|
'GetOtherSplit': Split,
|
|
|
|
|
'GetAmount': GncNumeric,
|
|
|
|
|
'GetValue': GncNumeric,
|
|
|
|
|
'GetSharePrice': GncNumeric,
|
|
|
|
|
'ConvertAmount': GncNumeric,
|
|
|
|
|
'GetBaseValue': GncNumeric,
|
|
|
|
|
'GetBalance': GncNumeric,
|
|
|
|
|
'GetClearedBalance': GncNumeric,
|
|
|
|
|
'GetReconciledBalance': GncNumeric,
|
|
|
|
|
'VoidFormerAmount': GncNumeric,
|
|
|
|
|
'VoidFormerValue': GncNumeric
|
|
|
|
|
}
|
|
|
|
|
methods_return_instance(Split, split_dict)
|
|
|
|
|
|
|
|
|
|
Split.account = property( Split.GetAccount, Split.SetAccount )
|
|
|
|
|
Split.parent = property( Split.GetParent, Split.SetParent )
|
|
|
|
|
@ -310,65 +269,41 @@ Split.parent = property( Split.GetParent, Split.SetParent )
|
|
|
|
|
# Account
|
|
|
|
|
Account.add_methods_with_prefix('xaccAccount')
|
|
|
|
|
Account.add_methods_with_prefix('gnc_account_')
|
|
|
|
|
#Functions that return Book
|
|
|
|
|
Account.get_book = method_function_returns_instance(
|
|
|
|
|
Account.get_book, Book )
|
|
|
|
|
#Functions that return Account
|
|
|
|
|
Account.Lookup = method_function_returns_instance(
|
|
|
|
|
Account.Lookup, Account )
|
|
|
|
|
Account.get_parent = method_function_returns_instance(
|
|
|
|
|
Account.get_parent, Account )
|
|
|
|
|
Account.get_root = method_function_returns_instance(
|
|
|
|
|
Account.get_root, Account )
|
|
|
|
|
Account.nth_child = method_function_returns_instance(
|
|
|
|
|
Account.nth_child, Account )
|
|
|
|
|
Account.lookup_by_name = method_function_returns_instance(
|
|
|
|
|
Account.lookup_by_name, Account )
|
|
|
|
|
Account.lookup_by_full_name = method_function_returns_instance(
|
|
|
|
|
Account.lookup_by_full_name, Account )
|
|
|
|
|
#Functions that return Transaction
|
|
|
|
|
Account.FindTransByDesc = method_function_returns_instance(
|
|
|
|
|
Account.FindTransByDesc, Transaction )
|
|
|
|
|
#Functions that return Split
|
|
|
|
|
Account.FindSplitByDesc = method_function_returns_instance(
|
|
|
|
|
Account.FindSplitByDesc, Split )
|
|
|
|
|
#Functions that return GncNumeric
|
|
|
|
|
Account.get_start_balance = method_function_returns_instance(
|
|
|
|
|
Account.get_start_balance, GncNumeric )
|
|
|
|
|
Account.get_start_cleared_balance = method_function_returns_instance(
|
|
|
|
|
Account.get_start_cleared_balance, GncNumeric )
|
|
|
|
|
Account.GetBalance = method_function_returns_instance(
|
|
|
|
|
Account.GetBalance, GncNumeric )
|
|
|
|
|
Account.GetClearedBalance = method_function_returns_instance(
|
|
|
|
|
Account.GetClearedBalance, GncNumeric )
|
|
|
|
|
Account.GetReconciledBalance = method_function_returns_instance(
|
|
|
|
|
Account.GetReconciledBalance, GncNumeric )
|
|
|
|
|
Account.GetPresentBalance = method_function_returns_instance(
|
|
|
|
|
Account.GetPresentBalance, GncNumeric )
|
|
|
|
|
Account.GetProjectedMinimumBalance = method_function_returns_instance(
|
|
|
|
|
Account.GetProjectedMinimumBalance, GncNumeric )
|
|
|
|
|
Account.GetBalanceAsOfDate = method_function_returns_instance(
|
|
|
|
|
Account.GetBalanceAsOfDate, GncNumeric )
|
|
|
|
|
Account.ConvertBalanceToCurrency = method_function_returns_instance(
|
|
|
|
|
Account.ConvertBalanceToCurrency, GncNumeric )
|
|
|
|
|
Account.ConvertBalanceToCurrencyAsOfDate = method_function_returns_instance(
|
|
|
|
|
Account.ConvertBalanceToCurrencyAsOfDate, GncNumeric )
|
|
|
|
|
Account.GetBalanceInCurrency = method_function_returns_instance(
|
|
|
|
|
Account.GetBalanceInCurrency, GncNumeric )
|
|
|
|
|
Account.GetClearedBalanceInCurrency = method_function_returns_instance(
|
|
|
|
|
Account.GetClearedBalanceInCurrency, GncNumeric )
|
|
|
|
|
Account.GetReconciledBalanceInCurrency = method_function_returns_instance(
|
|
|
|
|
Account.GetReconciledBalanceInCurrency, GncNumeric )
|
|
|
|
|
Account.GetPresentBalanceInCurrency = method_function_returns_instance(
|
|
|
|
|
Account.GetPresentBalanceInCurrency, GncNumeric )
|
|
|
|
|
Account.GetProjectedMinimumBalanceInCurrency = method_function_returns_instance(
|
|
|
|
|
Account.GetProjectedMinimumBalanceInCurrency, GncNumeric )
|
|
|
|
|
Account.GetBalanceAsOfDateInCurrency = method_function_returns_instance(
|
|
|
|
|
Account.GetBalanceInCurrency, GncNumeric )
|
|
|
|
|
Account.GetBalanceChangeForPeriod = method_function_returns_instance(
|
|
|
|
|
Account.GetBalanceChangeForPeriod, GncNumeric )
|
|
|
|
|
#Functions that return GncCommodity
|
|
|
|
|
Account.GetCommodity = method_function_returns_instance(
|
|
|
|
|
Account.GetCommodity, GncCommodity )
|
|
|
|
|
|
|
|
|
|
account_dict = {
|
|
|
|
|
'get_book' : Book,
|
|
|
|
|
'Lookup' : Account,
|
|
|
|
|
'get_parent' : Account,
|
|
|
|
|
'get_root' : Account,
|
|
|
|
|
'nth_child' : Account,
|
|
|
|
|
'lookup_by_name' : Account,
|
|
|
|
|
'lookup_by_full_name' : Account,
|
|
|
|
|
'GetNthChild' : Account,
|
|
|
|
|
'FindTransByDesc' : Transaction,
|
|
|
|
|
'FindSplitByDesc' : Split,
|
|
|
|
|
'get_start_balance' : GncNumeric,
|
|
|
|
|
'get_start_cleared_balance' : GncNumeric,
|
|
|
|
|
'GetBalance' : GncNumeric,
|
|
|
|
|
'GetClearedBalance' : GncNumeric,
|
|
|
|
|
'GetReconciledBalance' : GncNumeric,
|
|
|
|
|
'GetPresentBalance' : GncNumeric,
|
|
|
|
|
'GetProjectedMinimumBalance' : GncNumeric,
|
|
|
|
|
'GetBalanceAsOfDate' : GncNumeric,
|
|
|
|
|
'ConvertBalanceToCurrency' : GncNumeric,
|
|
|
|
|
'ConvertBalanceToCurrencyAsOfDate' : GncNumeric,
|
|
|
|
|
'GetBalanceInCurrency' : GncNumeric,
|
|
|
|
|
'GetClearedBalanceInCurrency' : GncNumeric,
|
|
|
|
|
'GetReconciledBalanceInCurrency' : GncNumeric,
|
|
|
|
|
'GetPresentBalanceInCurrency' : GncNumeric,
|
|
|
|
|
'GetProjectedMinimumBalanceInCurrency' : GncNumeric,
|
|
|
|
|
'GetBalanceAsOfDateInCurrency' : GncNumeric,
|
|
|
|
|
'GetBalanceChangeForPeriod' : GncNumeric,
|
|
|
|
|
'GetCommodity' : GncCommodity
|
|
|
|
|
}
|
|
|
|
|
methods_return_instance(Account, account_dict)
|
|
|
|
|
|
|
|
|
|
Account.name = property( Account.GetName, Account.SetName )
|
|
|
|
|
|
|
|
|
|
#GUID
|
|
|
|
|
GUID.add_methods_with_prefix('guid_')
|
|
|
|
|
|
|
|
|
|
|