Beispiel #1
0
 def __str__(self):
     currency = current_app.config.get("STORE_CURRENCY")
     m = Money.from_sub_units(self.amount, Currency[currency.upper()])
     locale = current_app.config.get("STORE_LOCALE")
     return str(m.format(locale))
Beispiel #2
0
    def test_from_sub_units(self):
        money = Money.from_sub_units(101, Currency.USD)
        assert money == Money('1.01', Currency.USD)

        money = Money.from_sub_units(5, Currency.JPY)
        assert money == Money('5', Currency.JPY)
def USD(cents):
    return Money.from_sub_units(cents, Currency.USD)
Beispiel #4
0
 def fake(cls) -> "Proposal":
     return Proposal(
         flexibility_level=random.choice(["NOFLEX", "FLEX", "UPSELL"]),
         price=Money.from_sub_units(random.randint(100, 10000),
                                    Currency.EUR),
     )