Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Commits
dd190c1c
Commit
dd190c1c
authored
5 days ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
Use CENT_MULT_TO_UNIT instead of constant hanging around (
#193
)
parent
4b4d3e0b
No related branches found
No related tags found
1 merge request
!276
Fix history CSV test (#258)
Pipeline
#40198
waiting for manual action
Stage: checks
Stage: tests
Stage: package
Stage: website
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
silkaj/money/history.py
+5
-5
5 additions, 5 deletions
silkaj/money/history.py
silkaj/money/tools.py
+2
-1
2 additions, 1 deletion
silkaj/money/tools.py
silkaj/money/transfer.py
+2
-2
2 additions, 2 deletions
silkaj/money/transfer.py
with
9 additions
and
8 deletions
silkaj/money/history.py
+
5
−
5
View file @
dd190c1c
...
...
@@ -26,7 +26,7 @@ from duniterpy.api.client import Client
from
duniterpy.documents.transaction
import
OutputSource
,
Transaction
from
duniterpy.grammars.output
import
Condition
from
silkaj.constants
import
ALL
,
ALL_DIGITAL
from
silkaj.constants
import
ALL
,
ALL_DIGITAL
,
CENT_MULT_TO_UNIT
from
silkaj.money
import
tools
as
mt
from
silkaj.network
import
client_instance
from
silkaj.public_key
import
(
...
...
@@ -107,7 +107,7 @@ def generate_header(pubkey: str, currency_symbol: str, ud_value: int) -> str:
balance_ud
=
round
(
balance
[
1
]
/
ud_value
,
2
)
date
=
arrow
.
now
().
format
(
ALL
)
return
f
"
Transactions history from:
{
idty
[
'
uid
'
]
}
{
gen_pubkey_checksum
(
pubkey
)
}
\n\
Current balance:
{
balance
[
1
]
/
100
}
{
currency_symbol
}
,
{
balance_ud
}
UD
{
currency_symbol
}
on
{
date
}
\n
"
Current balance:
{
balance
[
1
]
/
CENT_MULT_TO_UNIT
}
{
currency_symbol
}
,
{
balance_ud
}
UD
{
currency_symbol
}
on
{
date
}
\n
"
def
get_transactions_history
(
...
...
@@ -207,7 +207,7 @@ def parse_received_tx(
full_pubkey
,
)
amounts
=
tx_amount
(
received_tx
,
pubkey
,
received_func
)[
0
]
tx_list
.
append
(
amounts
/
100
)
tx_list
.
append
(
amounts
/
CENT_MULT_TO_UNIT
)
tx_list
.
append
(
round
(
amounts
/
ud_value
,
2
))
tx_list
.
append
(
received_tx
.
comment
)
received_txs_table
.
append
(
tx_list
)
...
...
@@ -244,7 +244,7 @@ def parse_sent_tx(
total_amount
,
outputs
=
tx_amount
(
sent_tx
,
pubkey
,
sent_func
)
if
len
(
outputs
)
>
1
:
tx_list
.
append
(
"
Total
"
)
amounts
=
str
(
total_amount
/
100
)
amounts
=
str
(
total_amount
/
CENT_MULT_TO_UNIT
)
amounts_ud
=
str
(
round
(
total_amount
/
ud_value
,
2
))
else
:
tx_list
.
append
(
""
)
...
...
@@ -254,7 +254,7 @@ def parse_sent_tx(
for
i
,
output
in
enumerate
(
outputs
):
if
output_available
(
output
.
condition
,
ne
,
pubkey
):
amounts
+=
prefix
(
None
,
outputs
,
i
)
+
str
(
neg
(
mt
.
amount_in_current_base
(
output
))
/
100
,
neg
(
mt
.
amount_in_current_base
(
output
))
/
CENT_MULT_TO_UNIT
,
)
amounts_ud
+=
prefix
(
None
,
outputs
,
i
)
+
str
(
round
(
neg
(
mt
.
amount_in_current_base
(
output
))
/
ud_value
,
2
),
...
...
This diff is collapsed.
Click to expand it.
silkaj/money/tools.py
+
2
−
1
View file @
dd190c1c
...
...
@@ -19,6 +19,7 @@ from typing import Union
from
duniterpy.api
import
bma
from
duniterpy.documents.transaction
import
InputSource
,
OutputSource
from
silkaj.constants
import
CENT_MULT_TO_UNIT
from
silkaj.network
import
client_instance
from
silkaj.public_key
import
gen_pubkey_checksum
from
silkaj.wot
import
tools
as
wt
...
...
@@ -35,7 +36,7 @@ def display_amount(
Displays an amount in unit and relative reference.
"""
UD_amount
=
str
(
round
((
amount
/
ud_value
),
2
))
unit_amount
=
str
(
amount
/
100
)
unit_amount
=
str
(
amount
/
CENT_MULT_TO_UNIT
)
tx
.
append
(
[
f
"
{
message
}
(unit|relative)
"
,
...
...
This diff is collapsed.
Click to expand it.
silkaj/money/transfer.py
+
2
−
2
View file @
dd190c1c
...
...
@@ -480,7 +480,7 @@ def generate_and_send_transaction(
print
(
"
- From:
"
+
gen_pubkey_checksum
(
issuers
))
for
tx_amount
,
outputAddress
in
zip
(
tx_amounts
,
outputAddresses
):
display_sent_tx
(
outputAddress
,
tx_amount
)
print
(
"
- Total:
"
+
str
(
sum
(
tx_amounts
)
/
100
))
print
(
"
- Total:
"
+
str
(
sum
(
tx_amounts
)
/
CENT_MULT_TO_UNIT
))
transaction
=
generate_transaction_document
(
issuers
,
...
...
@@ -499,7 +499,7 @@ def display_sent_tx(outputAddress: str, amount: int) -> None:
"
- To:
"
,
gen_pubkey_checksum
(
outputAddress
),
"
\n
- Amount:
"
,
amount
/
100
,
amount
/
CENT_MULT_TO_UNIT
,
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment