forked from routablehq/python-quickbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_bill.py
More file actions
39 lines (29 loc) · 1.32 KB
/
test_bill.py
File metadata and controls
39 lines (29 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from datetime import datetime
from quickbooks.objects.base import Ref
from quickbooks.objects.bill import Bill
from quickbooks.objects.detailline import AccountBasedExpenseLine, AccountBasedExpenseLineDetail
from quickbooks.objects.vendor import Vendor
from tests.integration.test_base import QuickbooksTestCase
class BillTest(QuickbooksTestCase):
def setUp(self):
super(BillTest, self).setUp()
self.account_number = datetime.now().strftime('%d%H%M')
self.name = "Test Account {0}".format(self.account_number)
def test_create(self):
bill = Bill()
line = AccountBasedExpenseLine()
line.Amount = 200
line.DetailType = "AccountBasedExpenseLineDetail"
account_ref = Ref()
account_ref.type = "Account"
account_ref.value = 1
line.AccountBasedExpenseLineDetail = AccountBasedExpenseLineDetail()
line.AccountBasedExpenseLineDetail.AccountRef = account_ref
bill.Line.append(line)
vendor = Vendor.all(max_results=1, qb=self.qb_client)[0]
bill.VendorRef = vendor.to_ref()
bill.save(qb=self.qb_client)
query_bill = Bill.get(bill.Id, qb=self.qb_client)
self.assertEquals(query_bill.Id, bill.Id)
self.assertEquals(len(query_bill.Line), 1)
self.assertEquals(query_bill.Line[0].Amount, 200.0)