Exemple #1
0
    def test_add_two_deposits(self):
        deposit1 = Deposit(client=self.client1,
                           wallet=self.wallet1,
                           amount=Decimal(1000))
        deposit1.save()

        deposit2 = Deposit(client=self.client1,
                           wallet=self.wallet1,
                           amount=Decimal(500))
        deposit2.save()

        self.assertAlmostEqual(self.wallet1.balance,
                               Decimal(1500),
                               delta=DECIMAL_EPSILON)

        wallet_motions = WalletMotion.objects.filter(
            wallet=self.wallet1).order_by('journal_id')

        self.assertEqual(wallet_motions.count(), 2)

        self.assertAlmostEqual(wallet_motions[0].balance,
                               Decimal(1000),
                               delta=DECIMAL_EPSILON)
        self.assertAlmostEqual(wallet_motions[0].balance_end,
                               Decimal(1000),
                               delta=DECIMAL_EPSILON)

        self.assertAlmostEqual(wallet_motions[1].balance,
                               Decimal(500),
                               delta=DECIMAL_EPSILON)
        self.assertAlmostEqual(wallet_motions[1].balance_end,
                               Decimal(1500),
                               delta=DECIMAL_EPSILON)
Exemple #2
0
    def test_add_deposit(self):
        deposit = Deposit(client=self.client1,
                          wallet=self.wallet1,
                          amount=Decimal(1000))
        deposit.save()

        # properties
        self.assertIsNotNone(deposit.pk)
        self.assertEqual(deposit.amount, Decimal(1000))
        self.assertIsNotNone(deposit.wallet)
        self.assertIsNotNone(deposit.journal)

        # wallet balance
        self.assertEqual(deposit.amount, self.wallet1.balance)

        # wallet motions
        wallet_motion = WalletMotion.objects.get(journal=deposit.journal,
                                                 wallet=deposit.wallet)
        self.assertEqual(deposit.amount, wallet_motion.balance)
        self.assertEqual(deposit.amount, wallet_motion.balance_end)