1 from unittest
import main
3 from datetime
import datetime, timezone, timedelta
5 from gnucash
import Account, \
6 ACCT_TYPE_RECEIVABLE, ACCT_TYPE_INCOME, ACCT_TYPE_BANK, \
8 from gnucash.gnucash_business
import Vendor, Employee, Customer, Job, Invoice, Entry
10 from test_book
import BookSession
14 BookSession.setUp(self)
16 self.
today = datetime.today()
19 self.
bank.SetType(ACCT_TYPE_BANK)
22 self.
income.SetType(ACCT_TYPE_INCOME)
35 entry = Entry(self.
book)
36 entry.SetDate(self.
today)
37 entry.SetDescription(
"Some income")
39 entry.SetInvAccount(self.
income)
48 self.assertTrue( self.
vendor.Equal( self.
vendor.GetVendor() ) )
49 self.assertTrue( self.
customer.Equal( self.
job.GetOwner() ) )
52 def test_employee_name(self):
54 self.assertEqual(
'', self.
employee.GetUsername() )
56 self.assertEqual( NAME, self.
employee.GetUsername() )
59 utc_offset = datetime.now().astimezone().utcoffset()
60 now = datetime.now().astimezone()
61 neutral_time = (now + utc_offset).astimezone(timezone.utc).replace(hour=10, minute=59, second=0, microsecond=0)
62 if utc_offset > timedelta(hours=13):
63 neutral_time -= utc_offset - timedelta(hours=13);
64 if utc_offset < timedelta(hours=-10):
65 neutral_time += timedelta(hours=-10) - utc_offset
66 self.assertEqual(neutral_time,
67 self.
invoice.GetDatePosted().astimezone(timezone.utc))
68 self.assertTrue( self.
invoice.IsPosted() )
72 self.assertTrue( self.
customer.Equal( OWNER ) )
74 def test_commodities(self):
75 self.assertTrue( self.
currency.equal( self.
customer.GetCommoditiesList()[0] ) )
79 Test that you can get the posted transaction from a posted invoice and that you can get the invoice back from the transaction. 81 posted_transaction = self.
invoice.GetPostedTxn()
82 self.assertTrue( posted_transaction !=
None )
83 invoice_from_transaction = posted_transaction.GetInvoiceFromTxn()
84 self.assertTrue( invoice_from_transaction !=
None and invoice_from_transaction.GetID() == self.
invoice.GetID() )
86 if __name__ ==
'__main__':
The primary numeric class for representing amounts and values.
def test_invoice_transaction(self)