GnuCash 2.4.99
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__

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 239 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 254 of file gnucash_core.py.

00255                                                :
00256         """Constructor that allows you to set the numerator and denominator or
00257         leave them blank with a default value of 0 (not a good idea since there
00258         is currently no way to alter the value after instantiation)
00259         """
00260         GnuCashCoreClass.__init__(self, num, denom, **kargs)
00261         #if INSTANCE_ARG in kargs:
00262         #    GnuCashCoreClass.__init__(**kargs)
00263         #else:
00264         #    self.set_denom(denom) # currently undefined
00265         #    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 275 of file gnucash_core.py.

00276                      :
00277         """returns a human readable numeric value string as bytes."""
00278         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 266 of file gnucash_core.py.

00267                          :
00268         """Returns a human readable numeric value string as UTF8."""
00269         if self.denom() == 0:
00270             return "Division by zero"
00271         else:
00272             value_float = self.to_double() 
00273             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.
00274             return value_str


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines