Пример #1
0
 def test_single_transaction(self, book_basic):
     today = datetime.today()
     print("today=", today)
     factories.single_transaction(
         today.date(),
         today,
         "my test",
         Decimal(100),
         from_account=book_basic.accounts(name="inc"),
         to_account=book_basic.accounts(name="asset"),
     )
     book_basic.save()
     tr = book_basic.transactions(description="my test")
     assert len(tr.splits) == 2
     sp1, sp2 = tr.splits
     if sp1.value > 0:
         sp2, sp1 = sp1, sp2
     # sp1 has negative value
     assert sp1.account == book_basic.accounts(name="inc")
     assert sp2.account == book_basic.accounts(name="asset")
     assert sp1.value == -sp2.value
     assert sp1.quantity == sp1.value
     assert tr.enter_date == tzlocal.get_localzone().localize(
         today.replace(microsecond=0))
     assert tr.post_date == tzlocal.get_localzone().localize(today).date()
Пример #2
0
 def test_single_transaction_tz(self, book_basic):
     today = tzlocal.get_localzone().localize(datetime.today())
     factories.single_transaction(today,
                                  today,
                                  "my test",
                                  Decimal(100),
                                  from_account=book_basic.accounts(name="inc"),
                                  to_account=book_basic.accounts(name="asset"))
     book_basic.save()
     tr = book_basic.transactions(description="my test")
     assert tr.post_date == today.replace(hour=11, minute=0, second=0, microsecond=0)
     assert tr.enter_date == today.replace(microsecond=0)
Пример #3
0
 def test_single_transaction(self, book_basic):
     today = datetime.today()
     factories.single_transaction(today,
                                  today,
                                  "my test",
                                  Decimal(100),
                                  from_account=book_basic.accounts(name="inc"),
                                  to_account=book_basic.accounts(name="asset"))
     book_basic.save()
     tr = book_basic.transactions(description="my test")
     assert len(tr.splits) == 2
     sp1, sp2 = tr.splits
     if sp1.value > 0:
         sp2, sp1 = sp1, sp2
     # sp1 has negative value
     assert sp1.account == book_basic.accounts(name="inc")
     assert sp2.account == book_basic.accounts(name="asset")
     assert sp1.value == -sp2.value
     assert sp1.quantity == sp1.value
     assert tr.enter_date == tzlocal.get_localzone().localize(today.replace(microsecond=0))
     assert tr.post_date == tzlocal.get_localzone().localize(today.replace(hour=11, minute=0, second=0, microsecond=0))