Ejemplo n.º 1
0
 def test_void_with_overridden_notes_and_type(self):
     """
     Test voiding while setting notes and type.
     """
     amount = D(100)
     evidence = UserFactory.create_batch(3)
     transaction = create_transaction(
         user=UserFactory(),
         evidence=evidence,
         ledger_entries=[
             LedgerEntry(
                 ledger=self.ar_ledger,
                 amount=credit(amount),
             ),
             LedgerEntry(
                 ledger=self.rev_ledger,
                 amount=debit(amount),
             ),
         ],
         type=self.ttype,
     )
     voiding_transaction = void_transaction(
         transaction,
         self.creation_user,
         notes='test notes',
     )
     self.assertEqual(voiding_transaction.notes, 'test notes')
     self.assertEqual(voiding_transaction.type, transaction.type)
Ejemplo n.º 2
0
 def test_simple_void(self):
     """
     Test voiding a `Transaction`.
     """
     amount = D(100)
     evidence = UserFactory.create_batch(3)
     transaction = create_transaction(
         user=UserFactory(),
         evidence=evidence,
         ledger_entries=[
             LedgerEntry(
                 ledger=self.ar_ledger,
                 amount=credit(amount),
             ),
             LedgerEntry(
                 ledger=self.rev_ledger,
                 amount=debit(amount),
             ),
         ],
     )
     self.assertEqual(self.ar_ledger.get_balance(), credit(amount))
     self.assertEqual(self.rev_ledger.get_balance(), debit(amount))
     voiding_transaction = void_transaction(transaction, self.creation_user)
     self.assertEqual(
         set(tro.related_object for tro
             in voiding_transaction.related_objects.all()),
         set(evidence),
     )
     self.assertEqual(self.ar_ledger.get_balance(), D(0))
     self.assertEqual(self.rev_ledger.get_balance(), D(0))
     self.assertEqual(voiding_transaction.voids, transaction)
     self.assertEqual(
         voiding_transaction.posted_timestamp,
         transaction.posted_timestamp)
     self.assertEqual(
         voiding_transaction.type,
         transaction.type)
     self.assertEqual(
         voiding_transaction.notes,
         'Voiding transaction {}'.format(transaction))