mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add GncNumeric to native Python Fraction
Add helper method to return the native Python fraction type from GncNumeric.
This commit is contained in:
@@ -320,6 +320,10 @@ class GncNumeric(GnuCashCoreClass):
|
||||
else:
|
||||
raise TypeError('Required single int/float/str or two ints: ' + str(args))
|
||||
|
||||
def to_fraction(self):
|
||||
from fractions import Fraction
|
||||
return Fraction(self.num(), self.denom())
|
||||
|
||||
def __unicode__(self):
|
||||
"""Returns a human readable numeric value string as UTF8."""
|
||||
return gnc_numeric_to_string(self.instance)
|
||||
|
||||
Reference in New Issue
Block a user