Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions quickbooks/objects/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,12 @@ def email_sent(self):
return True

return False

def to_ref(self):
ref = Ref()

ref.name = self.DocNumber
ref.type = self.qbo_object_name
ref.value = self.Id

return ref
11 changes: 11 additions & 0 deletions tests/unit/objects/test_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ def test_valid_object_name(self):

self.assertTrue(result)

def test_to_ref(self):
invoice = Invoice()
invoice.DocNumber = 1
invoice.Id = 2

ref = invoice.to_ref()
self.assertIsInstance(ref, Ref)
self.assertEquals(ref.type, "Invoice")
self.assertEquals(ref.name, 1) # should be DocNumber
self.assertEquals(ref.value, 2) # should be Id


class DeliveryInfoTests(unittest.TestCase):
def test_init(self):
Expand Down