Exemplo n.º 1
0
 def test_uninvoiced_should_ignore_deleted_charges(self):
     Charge.objects.create(account=self.account, amount=Money(10, 'CHF'), product_code='ACHARGE')
     Charge.objects.create(account=self.account, deleted=True, amount=Money(5, 'CHF'), product_code='BCHARGE')
     with self.assertNumQueries(2):
         uc = Charge.objects.uninvoiced(account_id=self.account.pk)
         assert len(uc) == 1
         assert total_amount(uc) == Total(10, 'CHF')
Exemplo n.º 2
0
 def test_uninvoiced_should_consider_credits(self):
     Charge.objects.create(account=self.account, amount=Money(10, 'CHF'), product_code='ACHARGE')
     Charge.objects.create(account=self.account, amount=Money(-30, 'CHF'), product_code='ACREDIT')
     with self.assertNumQueries(2):
         uc = Charge.objects.uninvoiced(account_id=self.account.pk)
         assert len(uc) == 2
         assert total_amount(uc) == Total(-20, 'CHF')
Exemplo n.º 3
0
 def test_uninvoiced_can_be_in_multiple_currencies(self):
     Charge.objects.create(account=self.account, amount=Money(10, 'CHF'), product_code='ACHARGE')
     Charge.objects.create(account=self.account, amount=Money(-30, 'EUR'), product_code='ACREDIT')
     with self.assertNumQueries(2):
         uc = Charge.objects.uninvoiced(account_id=self.account.pk)
         assert len(uc) == 2
         assert total_amount(uc) == Total(10, 'CHF', -30, 'EUR')
Exemplo n.º 4
0
 def test_uninvoiced_should_ignore_invoiced_charges(self):
     Invoice.objects.create(id=1, account=self.account, due_date=date.today())
     Charge.objects.create(account=self.account, invoice_id=1, amount=Money(10, 'CHF'), product_code='ACHARGE')
     with self.assertNumQueries(2):
         uc = Charge.objects.uninvoiced(account_id=self.account.pk)
         assert len(uc) == 0
         assert total_amount(uc) == Total()