GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
test_business.py
1 from unittest import main
2 
3 from datetime import datetime
4 
5 from gnucash import Account, \
6  ACCT_TYPE_RECEIVABLE, ACCT_TYPE_INCOME, ACCT_TYPE_BANK, \
7  GncNumeric
8 from gnucash.gnucash_business import Vendor, Employee, Customer, Job, Invoice, Entry
9 
10 from test_book import BookSession
11 
13  def setUp(self):
14  BookSession.setUp(self)
15 
16  self.today = datetime.today()
17 
18  self.bank = Account(self.book)
19  self.bank.SetType(ACCT_TYPE_BANK)
20  self.bank.SetCommodity(self.currency)
21  self.income = Account(self.book)
22  self.income.SetType(ACCT_TYPE_INCOME)
23  self.income.SetCommodity(self.currency)
24  self.receivable = Account(self.book)
25  self.receivable.SetType(ACCT_TYPE_RECEIVABLE)
26  self.receivable.SetCommodity(self.currency)
27 
28  self.customer = Customer(self.book,'CustomerID',self.currency)
29  self.vendor = Vendor(self.book,'VendorID',self.currency)
30  self.employee = Employee(self.book,'EmployeeID',self.currency)
31  self.job = Job(self.book,'JobID',self.customer)
32 
33  self.invoice = Invoice(self.book,'InvoiceID',self.currency,self.customer)
34  self.invoice.SetDateOpened(self.today)
35  entry = Entry(self.book)
36  entry.SetDate(self.today)
37  entry.SetDescription("Some income")
38  entry.SetQuantity(GncNumeric(1))
39  entry.SetInvAccount(self.income)
40  entry.SetInvPrice(GncNumeric(100))
41  self.invoice.AddEntry(entry)
42 
43  self.invoice.PostToAccount(self.receivable,
44  self.today, self.today, "", True, False)
45 
47  def test_equal(self):
48  self.assertTrue( self.vendor.Equal( self.vendor.GetVendor() ) )
49  self.assertTrue( self.customer.Equal( self.job.GetOwner() ) )
50  self.assertTrue( self.customer.Equal( self.invoice.GetOwner() ) )
51 
52  def test_employee_name(self):
53  NAME = 'John Doe'
54  self.assertEqual( '', self.employee.GetUsername() )
55  self.employee.SetUsername(NAME)
56  self.assertEqual( NAME, self.employee.GetUsername() )
57 
58  def test_post(self):
59  self.assertTrue( self.invoice.IsPosted() )
60 
61  def test_owner(self):
62  OWNER = self.invoice.GetOwner()
63  self.assertTrue( self.customer.Equal( OWNER ) )
64 
65  def test_commodities(self):
66  self.assertTrue( self.currency.equal( self.customer.GetCommoditiesList()[0] ) )
67 
68 if __name__ == '__main__':
69  main()
struct account_s Account
Account in Gnucash. This is the typename for an account. The actual structure is defined in the priva...
Definition: gnc-engine.h:132