Skip to content

[Question] Can we improve representation of Money? #297

Open
@samitnuk

Description

@samitnuk

For example, I have Pay-In with the next data (screenshot from the dashboard):
image

When I check this Pay-In in the terminal I have:

In [3]: p = DirectDebitWebPayIn.get('xxxxxxxxxx')

In [4]: p.debited_funds
Out[4]: EUR 18043

In [5]: p.fees
Out[5]: EUR 6542

From my point of view, these values should be represented as EUR 180.43 and EUR 65.42 (as in the dashboard).

To fix this I can suggest to use self.amount / 100 instead of self.amount here:

def __repr__(self):
return "{} {}".format(self.currency, self.amount)

and here:
def __str__(self):
return force_text("{} {:,.2f}".format(self.currency, self.amount))

But of course, this "fix" will work only for the currencies with 2 digits after the decimal separator. So maybe there can be a better solution.

Also, I understand that Money in the SDK represents An amount of money in the smallest sub-division of the currency, so showing 18043 instead of 180.43 can be correct from some point of view. But we show currency near it and this can be confusing.

But I think the minimum that can be done here is to use for __str__ the same functionality as for __repr__ (means remove :,.2f. For example, when I want to log Pay-In values I have something like next in my logs:

Booking #000000001: Created Pay-In #0000000002, debited funds - EUR 18,043.00, fees - EUR 6,542.00

As you can see, the __str__ method is definitely produces an incorrect representation of the values from above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions