Skip to content

Commit f972fd4

Browse files
committed
Merge pull request ej2#10 from amacneil/trackingclass
Add Class object
2 parents 71b9ab6 + 51521c1 commit f972fd4

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

quickbooks/objects/trackingclass.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from six import python_2_unicode_compatible
2+
from .base import QuickbooksManagedObject, QuickbooksTransactionEntity, Ref
3+
4+
5+
@python_2_unicode_compatible
6+
class TrackingClass(QuickbooksManagedObject, QuickbooksTransactionEntity):
7+
"""
8+
QBO definition: Classes provide a way to track different segments of the business so they're
9+
not tied to a particular client or project. For example, you can define classes to break down
10+
the income and expenses for each business segment. Classes are applied to individual detail
11+
lines of a transaction. This is in contrast to Department objects, which are applied to the
12+
entire transaction.
13+
"""
14+
15+
class_dict = {
16+
"ParentRef": Ref
17+
}
18+
19+
qbo_object_name = "Class"
20+
21+
def __init__(self):
22+
super(TrackingClass, self).__init__()
23+
self.Name = ""
24+
self.SubClass = False
25+
self.FullyQualifiedName = ""
26+
self.Active = True
27+
28+
def __str__(self):
29+
return self.Name
30+
31+
def to_ref(self):
32+
ref = Ref()
33+
34+
ref.name = self.Name
35+
ref.type = self.qbo_object_name
36+
ref.value = self.Id
37+
38+
return ref
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import unittest
2+
3+
from quickbooks.objects.trackingclass import TrackingClass
4+
5+
6+
class TrackingClassTests(unittest.TestCase):
7+
def test_unicode(self):
8+
cls = TrackingClass()
9+
cls.Name = "test"
10+
11+
self.assertEquals(str(cls), "test")
12+
13+
def test_to_ref(self):
14+
cls = TrackingClass()
15+
cls.Name = "test"
16+
cls.Id = 100
17+
18+
dept_ref = cls.to_ref()
19+
20+
self.assertEquals(dept_ref.name, "test")
21+
self.assertEquals(dept_ref.type, "Class")
22+
self.assertEquals(dept_ref.value, 100)

0 commit comments

Comments
 (0)