示例#1
0
 def calculate_total_price(self, dollar_quote):
     total = 0
     for purchase in self.purchases:
         if purchase.price.currency == self.local_currency:
             total += purchase.price.amount
         else:
             total += purchase.price.amount * dollar_quote.amount
     return Money(total)
示例#2
0
 def call_print(self):
     report = self.bill.print(dollar_quote=Money(4))
     return report
示例#3
0
 def test_report_with_one_international_purchase(self):
     self.bill.add_purchase(Purchase(name='ROSS', price=Money(amount=100, currency='USD')))
     report = self.call_print()
     self.assertEqual('COMPRA|VALOR\nROSS|100 USD\n_\nCOTACAO USD|4 BRL\n_\nVALOR TOTAL|400 BRL', report)
示例#4
0
 def test_report_with_more_than_one_local_purchase(self):
     self.bill.add_purchase(Purchase(name='LOJAS AMERICANAS', price=Money(amount=250)))
     self.bill.add_purchase(Purchase(name='LOJAS RENNER', price=Money(amount=100)))
     report = self.call_print()
     self.assertEqual('COMPRA|VALOR\nLOJAS AMERICANAS|250 BRL\nLOJAS RENNER|100 BRL\n_\nVALOR TOTAL|350 BRL', report)
示例#5
0
 def test_add_purchases(self):
     self.bill.add_purchase(Purchase(name='LOJAS AMERICANAS', price=Money(amount=250)))
     self.bill.add_purchase(Purchase(name='A', price=Money(amount=250)))
     self.assertEqual(2, len(self.bill.purchases))
示例#6
0
 def test_print_money(self):
     money = Money(amount=25)
     self.assertEqual(money.print(), '25 BRL')
示例#7
0
 def test_default_currency_on_money(self):
     money = Money(amount=25)
     self.assertEqual(money.currency, 'BRL')