Skip to content

Commit b022f4c

Browse files
committed
Updated Department.
1 parent 7efa8ab commit b022f4c

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

quickbooks/objects/department.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
from base import QuickbooksManagedObject, QuickbooksTransactionEntity
1+
from base import QuickbooksManagedObject, QuickbooksTransactionEntity, Ref
22

33

44
class Department(QuickbooksManagedObject, QuickbooksTransactionEntity):
55
"""
6-
QBO definition: The Department entity provides a way to track different segments of the business, divisions, or physical locations
7-
such as stores, and allows another way of categorizing the entire transaction. This is in contrast to Class objects,
8-
which are applied to individual transaction line details. Delete is achieved by setting the Active attribute to
9-
false in an entity update request; thus, making it inactive. In this type of delete, the record is not permanently
10-
deleted, but is hidden for display purposes. References to inactive objects are left intact.
6+
QBO definition: The Department entity provides a way to track different segments of the business, divisions, or
7+
physical locations such as stores, and allows another way of categorizing the entire transaction.
8+
This is in contrast to Class objects, which are applied to individual transaction line details.
9+
Delete is achieved by setting the Active attribute to false in an entity update request; thus,
10+
making it inactive. In this type of delete, the record is not permanently deleted, but is hidden
11+
for display purposes. References to inactive objects are left intact.
1112
"""
1213

13-
class_dict = {}
14+
class_dict = {
15+
"ParentRef": Ref
16+
}
17+
1418
qbo_object_name = "Department"
1519

1620
def __init__(self):
@@ -21,4 +25,13 @@ def __init__(self):
2125
self.Active = True
2226

2327
def __unicode__(self):
24-
return self.FullyQualifiedName
28+
return self.Name
29+
30+
def to_ref(self):
31+
ref = Ref()
32+
33+
ref.name = self.Name
34+
ref.type = self.qbo_object_name
35+
ref.value = self.Id
36+
37+
return ref

tests/unit/objects/test_department.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
class DepartmentTests(unittest.TestCase):
77
def test_unicode(self):
88
department = Department()
9-
department.FullyQualifiedName = "test"
9+
department.Name = "test"
1010

1111
self.assertEquals(unicode(department), "test")
12+
13+
def test_to_ref(self):
14+
department = Department()
15+
department.Name = "test"
16+
department.Id = 100
17+
18+
dept_ref = department.to_ref()
19+
20+
self.assertEquals(dept_ref.name, "test")
21+
self.assertEquals(dept_ref.type, "Department")
22+
self.assertEquals(dept_ref.value, 100)

0 commit comments

Comments
 (0)