Пример #1
0
    def setUp(self):

        create_accounts(self)
        journ5 = posts.Journals(journalstat = posts.Journals.UNPROCESSED,\
                                extkey='NR501')
        journ5.add()
        journ6 = posts.Journals(journalstat = posts.Journals.UNPROCESSED,\
                                extkey='NR503')
        journ6.add()
        gledger.db.session.flush()
        self.journ5id = journ5.id
        self.journ5extkey = journ5.extkey
        self.journ6id = journ6.id
        self.journ6extkey = journ6.extkey
        posting_to_journal(journ5)
        post9 = posts.Postings(
            accounts_id=accmodel.Accounts.get_by_name("verkopen").id,
            journals_id=journ6.id,
            postmonth=201609,
            value_date=datetime.now(),
            amount=20,
            debcred='Cr')
        post9.add()
        post10 = posts.Postings(
            accounts_id=accmodel.Accounts.get_by_name("kas").id,
            journals_id=journ6.id,
            postmonth=201609,
            value_date=datetime.now(),
            amount=20,
            debcred='Db')
        post10.add()
Пример #2
0
def posting_to_journal(journ2):
    post3 = posts.Postings(
        accounts_id=accmodel.Accounts.get_by_name("verkopen").id,
        journals_id=journ2.id,
        postmonth=201609,
        value_date=datetime.now(),
        amount=250,
        debcred='Cr')
    post3.add()
    post4 = posts.Postings(accounts_id=accmodel.Accounts.get_by_name("kas").id,
                           journals_id=journ2.id,
                           postmonth=201609,
                           value_date=datetime.now(),
                           amount=230,
                           debcred='Db')
    post4.add()
    post5 = posts.Postings(
        accounts_id=accmodel.Accounts.get_by_name("btw (ontvangen)").id,
        journals_id=journ2.id,
        postmonth=201609,
        value_date=datetime.now(),
        amount=20,
        debcred='Db')
    post5.add()
    return journ2
Пример #3
0
 def test_unbalanced_journal_fails(self):
     """ When a debit and credit amount is not the same,
     the journal must be refused! """
     journ2 = posts.Journals.get_by_id(self.journ2id)
     post6 = posts.Postings(
         accounts_id=accmodel.Accounts.get_by_name("verkopen").id,
         journals_id=journ2.id,
         postmonth=201609,
         value_date=datetime.now(),
         amount=230,
         debcred='Cr')
     post6.add()
     post7 = posts.Postings(
         accounts_id=accmodel.Accounts.get_by_name("kas").id,
         journals_id=journ2.id,
         postmonth=201609,
         value_date=datetime.now(),
         amount=230,
         debcred='Db')
     post7.add()
     post8 = posts.Postings(
         accounts_id=accmodel.Accounts.get_by_name("btw (ontvangen)").id,
         journals_id=journ2.id,
         postmonth=201609,
         value_date=datetime.now(),
         amount=20,
         debcred='Cr')
     post8.add()
     gledger.db.session.flush()
     with self.assertRaises(posts.JournalBalanceError):
         journ2.post_journal()
Пример #4
0
 def test_create_journal(self):
     """ Create a journal with its postings """
     journ2 = posts.Journals.get_by_id(self.journ2id)
     post3 = posts.Postings(
         accounts_id=accmodel.Accounts.get_by_name("verkopen").id,
         journals_id=journ2.id,
         postmonth=201609,
         value_date=datetime.now(),
         amount=230,
         debcred='Cr')
     post3.add()
     post4 = posts.Postings(
         accounts_id=accmodel.Accounts.get_by_name("kas").id,
         journals_id=journ2.id,
         postmonth=201609,
         value_date=datetime.now(),
         amount=250,
         debcred='Db')
     post4.add()
     post5 = posts.Postings(
         accounts_id=accmodel.Accounts.get_by_name("btw (ontvangen)").id,
         journals_id=journ2.id,
         postmonth=201609,
         value_date=datetime.now(),
         amount=20,
         debcred='Cr')
     post5.add()
     gledger.db.session.flush()
     q = gledger.db.session.query(posts.Postings).join(posts.Journals).\
         filter(posts.Journals.id==journ2.id)
     self.assertEqual(q.count(), 3, "Too little postings in journal")
Пример #5
0
def create_posting_to_kas(instance, posting_amount, postmonth, journal_id):
    """ Post an amount to kas for test purposes """

    postn = posts.Postings(accounts_id=accmodel.Accounts.get_by_name("kas").id,
                           journals_id=journal_id,
                           postmonth=postmonth,
                           value_date=datetime.now(),
                           amount=posting_amount,
                           debcred='Db')
    postn.add()
Пример #6
0
 def test_no_post_wo_journal(self):
     """Inserting posting w/o journal fails """
     post2 = posts.Postings(
         accounts_id=accmodel.Accounts.get_by_name("verkopen").id,
         postmonth=201608,
         value_date=datetime.now(),
         amount=250,
         debcred='Cr')
     post2.add()
     with self.assertRaises(DatabaseError):
         gledger.db.session.flush()
Пример #7
0
    def test_posting_no_id_fails(self):
        """ Making a view for a posting with no id fails """

        post12 = posts.Postings(
            accounts_id=accmodel.Accounts.get_by_name("verkopen").id,
            journals_id=self.journ7id,
            postmonth=201609,
            value_date=datetime.now(),
            amount=12,
            debcred='Cr')
        post12.add()
        with self.assertRaises(ValueError):
            post12view = postviews.PostingView(post12.id)
Пример #8
0
 def test_post_debcred_invalid(self):
     """ Posting with invalid debit/credit indicator must be refused """
     journ4 = posts.Journals(journalstat=posts.Journals.UNPROCESSED)
     journ4.add()
     gledger.db.session.flush()
     with self.assertRaises(posts.InvalidDebitCreditError):
         post3 = posts.Postings(
             accounts_id=accmodel.Accounts.get_by_name("verkopen").id,
             journals_id=journ4.id,
             postmonth=201609,
             value_date=datetime.now(),
             amount=230,
             debcred='Ct')
         gledger.db.session.flush()
Пример #9
0
 def test_post_one_posting(self):
     """ A posting can be inserted """
     post1 = posts.Postings(
         accounts_id=accmodel.Accounts.get_by_name("verkopen").id,
         postmonth=201608,
         value_date=datetime.now(),
         amount=250,
         debcred='Cr')
     journ3 = posts.Journals(journalstat=posts.Journals.UNPROCESSED)
     journ3.add()
     journ3.journalpostings.append(post1)
     post1.add()
     q = gledger.db.session.query(posts.Postings)
     self.assertNotEqual(q.count(), 0, 'Posting not inserted')
Пример #10
0
    def test_createview(self):
        """ Create a view for one posting """

        post11 = posts.Postings(
            accounts_id=accmodel.Accounts.get_by_name("verkopen").id,
            journals_id=self.journ7id,
            postmonth=201609,
            value_date=datetime.now(),
            amount=120,
            debcred='Cr')
        post11.add()
        gledger.db.session.flush()
        post11view = postviews.PostingView(post11.id)
        self.assertEqual(post11view.posting.amount, 120,
                         'Amount in view incorrect')
Пример #11
0
    def test_posting_account(self):
        """ A postingview contains the account name """

        post14 = posts.Postings(
            accounts_id=accmodel.Accounts.get_by_name("kas").id,
            journals_id=self.journ7id,
            postmonth=201608,
            value_date=datetime.now(),
            amount=5500,
            debcred='Db')
        post14.add()
        gledger.db.session.flush()
        post14view = postviews.PostingView(post14.id)
        post14viewdict = post14view.as_dict()
        self.assertEqual(post14viewdict['account'], 'kas',
                         'Wrong account in postview')
Пример #12
0
    def test_postingview_as_dict(self):
        """ A postingview can be returned as a dictionary """

        post13 = posts.Postings(
            accounts_id=accmodel.Accounts.get_by_name("verkopen").id,
            journals_id=self.journ7id,
            postmonth=201609,
            value_date=datetime.now(),
            amount=6500,
            debcred='Cr')
        post13.add()
        gledger.db.session.flush()
        post13view = postviews.PostingView(post13.id)
        post13viewdict = post13view.as_dict()
        self.assertIn("id", post13viewdict, 'No id in posting dictionary')
        self.assertEqual(post13viewdict['amount'], '65.00', 'Amount incorrect')
Пример #13
0
 def test_read_by_account_month(self):
     """ Read postings by account and postmonth """
     post9 = posts.Postings(
         accounts_id=accmodel.Accounts.get_by_name("verkopen").id,
         journals_id=self.journ5id,
         postmonth=201608,
         value_date=datetime.now(),
         amount=20,
         debcred='Cr')
     post9.add()
     gledger.db.session.flush()
     acc10 = accmodel.Accounts.get_by_name("verkopen")
     account_postings = \
         posts.Postings.postings_for_account(acc10, month='09-2016')
     self.assertEqual(len(account_postings), 2,
                      'Incorrect no. of posts for account')