Beispiel #1
0
 def setUp(self):
     super(TestAccountingEntry, self).setUp()
     self.trans = Transaction()
     ##customer
     self.customer = CustomerAccount(name="Juan Customer")
     
     self.acEntry = AccountingEntry( number=1, pos=PointOfSale(), customerAccount=self.customer)
     self.trans.track(self.acEntry)
     ##from
     self.debit = MovementAccount(name="Sales")
     ##to
     self.credit = MovementAccount(name="Petty Cash")
     
     self.amount = 175.5
     self.otherAmount = 180
     
     self.trans.track(self.debit)
     self.trans.track(self.credit)
     self.trans.track(self.customer)
Beispiel #2
0
 def register(self,
              ourParty,
              otherParty,
              debitAccount,
              creditAccount,
              customerAccount=None):
     transaction = self.transaction()
     assert transaction is not None, "document must be tracked!"
     #The persons or subjects related with te document that are not self
     #(such as client in invoice or provider in alienInvoice) must be
     #called otherParty so their value can be assigned in register
     self.setOtherParty(otherParty)
     self.customerAccount = customerAccount
     entry = AccountingEntry(customerAccount=customerAccount)
     entry.pointOfSale = ourParty
     entry.recordDate = now()
     transaction.track(entry)
     entry.debit(self.amount, debitAccount)
     entry.credit(self.amount, creditAccount)
 def setUp(self):
     super(TestAccountingEntry, self).setUp()
     self.trans = Transaction()
     ##customer
     self.customer = CustomerAccount(name="Juan Customer")
     
     self.acEntry = AccountingEntry( number=1, pos=PointOfSale(), customerAccount=self.customer)
     self.trans.track(self.acEntry)
     ##from
     self.debit = MovementAccount(name="Sales")
     ##to
     self.credit = MovementAccount(name="Petty Cash")
     
     self.amount = 175.5
     self.otherAmount = 180
     
     self.trans.track(self.debit)
     self.trans.track(self.credit)
     self.trans.track(self.customer)
 def register(self, ourParty, otherParty, debitAccount, creditAccount,
              customerAccount=None):
     transaction = self.transaction()
     assert transaction is not None, "document must be tracked!"
     #The persons or subjects related with te document that are not self
     #(such as client in invoice or provider in alienInvoice) must be
     #called otherParty so their value can be assigned in register
     try:
         self.setOtherParty(otherParty)
     except:
         self.setPointOfSale(ourParty)
     self.customerAccount = customerAccount
     entry = AccountingEntry(customerAccount=customerAccount)
     entry.pointOfSale = ourParty
     entry.recordDate = now()
     transaction.track(entry)
     self.entry = entry
     entry.debit(self.amount, debitAccount)
     entry.credit(self.amount, creditAccount)
Beispiel #5
0
class TestAccountingEntry(testWithDatabase):
    def setUp(self):
        super(TestAccountingEntry, self).setUp()
        self.trans = Transaction()
        ##customer
        self.customer = CustomerAccount(name="Juan Customer")
        
        self.acEntry = AccountingEntry( number=1, pos=PointOfSale(), customerAccount=self.customer)
        self.trans.track(self.acEntry)
        ##from
        self.debit = MovementAccount(name="Sales")
        ##to
        self.credit = MovementAccount(name="Petty Cash")
        
        self.amount = 175.5
        self.otherAmount = 180
        
        self.trans.track(self.debit)
        self.trans.track(self.credit)
        self.trans.track(self.customer)

    def testAddEntryDebit(self):
        """
        Checks if all the accounting entry has been made with the correct
        movements
        """
        self.acEntry.debit(amount=self.amount, account=self.debit)
        qual = Qualifier()

        a = self.trans.search("Movement", qual.entry.number.equal(self.acEntry.number))

        self.assertEqual(a[0].entry,self.acEntry)
        self.assertEqual(a[0].operation,0)
        self.assertEqual(a[0].account,self.debit)


    def testAddEntryCredit(self):
        self.acEntry.credit(amount=self.amount, account=self.credit)
        qual = Qualifier()

        a = self.trans.search("Movement", qual.entry.number.equal(
                              self.acEntry.number))

        self.assertEqual(a[0].entry, self.acEntry)
        self.assertEqual(a[0].operation, 1)
        self.assertEqual(a[0].account, self.credit)

    def testBalanceIsRight(self): 
        self.acEntry.debit(amount=self.amount, account=self.debit)
        self.acEntry.credit(amount=self.amount, account=self.credit)

        balance = self.acEntry.balance()
        
        self.assertEqual(balance, 0.0)


    def testBalanceIsWrongNegative(self):
        self.acEntry.debit(amount=self.amount, account=self.debit)
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)

        balance = self.acEntry.balance()

        self.assert_(balance < 0)

    def testBalanceIsWrongPositive(self):
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)
        self.acEntry.credit(amount=self.amount, account=self.credit)

        balance = self.acEntry.balance()

        self.assert_(balance > 0)

    def testDebitSum(self):
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)

        self.assertEqual(self.otherAmount * 3, self.acEntry.debitSum())
    def testCreditSum(self):
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)

        self.assertEqual(self.otherAmount * 3, self.acEntry.creditSum())
class TestAccountingEntry(testWithDatabase):
    def setUp(self):
        super(TestAccountingEntry, self).setUp()
        self.trans = Transaction()
        ##customer
        self.customer = CustomerAccount(name="Juan Customer")
        
        self.acEntry = AccountingEntry( number=1, pos=PointOfSale(), customerAccount=self.customer)
        self.trans.track(self.acEntry)
        ##from
        self.debit = MovementAccount(name="Sales")
        ##to
        self.credit = MovementAccount(name="Petty Cash")
        
        self.amount = 175.5
        self.otherAmount = 180
        
        self.trans.track(self.debit)
        self.trans.track(self.credit)
        self.trans.track(self.customer)

    def testAddEntryDebit(self):
        """
        Checks if all the accounting entry has been made with the correct
        movements
        """
        self.acEntry.debit(amount=self.amount, account=self.debit)
        qual = Qualifier()

        a = self.trans.search("Movement", qual.entry.number.equal(self.acEntry.number))

        self.assertEqual(a[0].entry,self.acEntry)
        self.assertEqual(a[0].operation,0)
        self.assertEqual(a[0].account,self.debit)


    def testAddEntryCredit(self):
        self.acEntry.credit(amount=self.amount, account=self.credit)
        qual = Qualifier()

        a = self.trans.search("Movement", qual.entry.number.equal(
                              self.acEntry.number))

        self.assertEqual(a[0].entry, self.acEntry)
        self.assertEqual(a[0].operation, 1)
        self.assertEqual(a[0].account, self.credit)

    def testBalanceIsRight(self): 
        self.acEntry.debit(amount=self.amount, account=self.debit)
        self.acEntry.credit(amount=self.amount, account=self.credit)

        balance = self.acEntry.balance()
        
        self.assertEqual(balance, 0.0)


    def testBalanceIsWrongNegative(self):
        self.acEntry.debit(amount=self.amount, account=self.debit)
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)

        balance = self.acEntry.balance()

        self.assertTrue(balance < 0)

    def testBalanceIsWrongPositive(self):
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)
        self.acEntry.credit(amount=self.amount, account=self.credit)

        balance = self.acEntry.balance()

        self.assertTrue(balance > 0)

    def testDebitSum(self):
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)
        self.acEntry.debit(amount=self.otherAmount, account=self.debit)

        self.assertEqual(self.otherAmount * 3, self.acEntry.debitSum())
    def testCreditSum(self):
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)
        self.acEntry.credit(amount=self.otherAmount, account=self.credit)

        self.assertEqual(self.otherAmount * 3, self.acEntry.creditSum())