GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions
python-bindings.gnucash_core.GncNumeric Class Reference
Inheritance diagram for python-bindings.gnucash_core.GncNumeric:
python-bindings.gnucash_core.GnuCashCoreClass

Public Member Functions

def __init__
 
def __unicode__
 
def __str__
 
- Public Member Functions inherited from python-bindings.gnucash_core.GnuCashCoreClass
def do_lookup_create_oo_instance
 

Detailed Description

Object used by GnuCash to store all numbers. Always consists of a
numerator and denominator.

The constants GNC_DENOM_AUTO,
GNC_HOW_RND_FLOOR, GNC_HOW_RND_CEIL, GNC_HOW_RND_TRUNC,
GNC_HOW_RND_PROMOTE, GNC_HOW_RND_ROUND_HALF_DOWN,
GNC_HOW_RND_ROUND_HALF_UP, GNC_HOW_RND_ROUND, GNC_HOW_RND_NEVER,
GNC_HOW_DENOM_EXACT, GNC_HOW_DENOM_REDUCE, GNC_HOW_DENOM_LCD,
and GNC_HOW_DENOM_FIXED are available for arithmetic
functions like GncNumeric.add

Look at gnc-numeric.h to see how to use these

Definition at line 259 of file gnucash_core.py.

Constructor & Destructor Documentation

def python-bindings.gnucash_core.GncNumeric.__init__ (   self,
  num = 0,
  denom = 1,
  kargs 
)
Constructor that allows you to set the numerator and denominator or
leave them blank with a default value of 0 (not a good idea since there
is currently no way to alter the value after instantiation)

Definition at line 274 of file gnucash_core.py.

275  def __init__(self, num=0, denom=1, **kargs):
276  """Constructor that allows you to set the numerator and denominator or
277  leave them blank with a default value of 0 (not a good idea since there
278  is currently no way to alter the value after instantiation)
279  """
280  GnuCashCoreClass.__init__(self, num, denom, **kargs)
281  #if INSTANCE_ARG in kargs:
282  # GnuCashCoreClass.__init__(**kargs)
283  #else:
284  # self.set_denom(denom) # currently undefined
285  # self.set_num(num) # currently undefined

Member Function Documentation

def python-bindings.gnucash_core.GncNumeric.__str__ (   self)
returns a human readable numeric value string as bytes.

Definition at line 295 of file gnucash_core.py.

296  def __str__(self):
297  """returns a human readable numeric value string as bytes."""
298  return unicode(self).encode('utf-8')
def python-bindings.gnucash_core.GncNumeric.__unicode__ (   self)
Returns a human readable numeric value string as UTF8.

Definition at line 286 of file gnucash_core.py.

287  def __unicode__(self):
288  """Returns a human readable numeric value string as UTF8."""
289  if self.denom() == 0:
290  return "Division by zero"
291  else:
292  value_float = self.to_double()
293  value_str = u"{0:.{1}f}".format(value_float,2) ## The second argument is the precision. It would be nice to be able to make it configurable.
294  return value_str

The documentation for this class was generated from the following file: