Extract helper method.
This commit is contained in:
parent
384817ba6e
commit
a5346c7796
1 changed files with 6 additions and 3 deletions
|
@ -31,9 +31,7 @@ class GnuCashSQL(BaseOutput):
|
||||||
).encode("utf-8")
|
).encode("utf-8")
|
||||||
)
|
)
|
||||||
guid = m.hexdigest()[0:32]
|
guid = m.hexdigest()[0:32]
|
||||||
# TODO extract this logic to a helper method
|
value_num, value_denom = self._fractional(price.amount)
|
||||||
value_num = str(price.amount).replace(".", "")
|
|
||||||
value_denom = 10 ** len(f"{price.amount}.".split(".")[1])
|
|
||||||
v = (
|
v = (
|
||||||
"("
|
"("
|
||||||
f"'{guid}', "
|
f"'{guid}', "
|
||||||
|
@ -58,3 +56,8 @@ class GnuCashSQL(BaseOutput):
|
||||||
)
|
)
|
||||||
|
|
||||||
return sql
|
return sql
|
||||||
|
|
||||||
|
def _fractional(num):
|
||||||
|
num = str(num).replace(".", "")
|
||||||
|
denom = 10 ** len(f"{num}.".split(".")[1])
|
||||||
|
return (num, denom)
|
||||||
|
|
Loading…
Add table
Reference in a new issue