def test_to_ref(self): vendor = Vendor() vendor.DisplayName = "test" vendor.Id = 100 ref = vendor.to_ref() self.assertEquals(ref.name, "test") self.assertEquals(ref.type, "Vendor") self.assertEquals(ref.value, 100)
def update_vendor(self): vendor = Vendor.all(max_results=1, qb=self.qb_client)[0] vendor.GivenName = 'Updated Name' vendor.FamilyName = 'Updated Lastname' vendor.save(qb=self.qb_client) query_vendor = Vendor.get(vendor.Id, qb=self.qb_client) self.assertEquals(query_vendor.GivenName, 'Updated Name') self.assertEquals(query_vendor.FamilyName, 'Updated Lastname')
def test_create_file(self): attachable = Attachable() test_file = tempfile.NamedTemporaryFile(suffix=".txt") vendor = Vendor.all(max_results=1, qb=self.qb_client)[0] attachable_ref = AttachableRef() attachable_ref.EntityRef = vendor.to_ref() attachable.AttachableRef.append(attachable_ref) attachable.FileName = os.path.basename(test_file.name) attachable._FilePath = test_file.name attachable.ContentType = 'text/plain' attachable.save(qb=self.qb_client) query_attachable = Attachable.get(attachable.Id, qb=self.qb_client) self.assertEquals(query_attachable.AttachableRef[0].EntityRef.value, vendor.Id)
def test_create_note(self): attachable = Attachable() vendor = Vendor.all(max_results=1, qb=self.qb_client)[0] attachable_ref = AttachableRef() attachable_ref.EntityRef = vendor.to_ref() attachable.AttachableRef.append(attachable_ref) attachable.Note = "Test note added on {}".format( self.time.strftime("%Y-%m-%d %H:%M:%S")) attachable.save(qb=self.qb_client) query_attachable = Attachable.get(attachable.Id, qb=self.qb_client) self.assertEquals(query_attachable.AttachableRef[0].EntityRef.value, vendor.Id) self.assertEquals( query_attachable.Note, "Test note added on {}".format( self.time.strftime("%Y-%m-%d %H:%M:%S")))
def test_create(self): customer = Customer.all(max_results=1, qb=self.qb_client)[0] taxcode = TaxCode.all(max_results=1, qb=self.qb_client)[0] item = Item.filter(Type='Inventory', max_results=1, qb=self.qb_client)[0] vendor = Vendor.all(max_results=1, qb=self.qb_client)[0] account = Account.all(max_results=1, qb=self.qb_client)[0] purchaseorder = PurchaseOrder() detail_line = ItemBasedExpenseLine() detail_line.Amount = 100 detail_line.ItemBasedExpenseLineDetail = ItemBasedExpenseLineDetail() detail_line.ItemBasedExpenseLineDetail.BillableStatus = "NotBillable" detail_line.ItemBasedExpenseLineDetail.UnitPrice = 100 detail_line.ItemBasedExpenseLineDetail.Qty = 1 detail_line.ItemBasedExpenseLineDetail.CustomerRef = customer.to_ref() detail_line.ItemBasedExpenseLineDetail.TaxCodeRef = taxcode.to_ref() detail_line.ItemBasedExpenseLineDetail.ItemRef = item.to_ref() purchaseorder.Line.append(detail_line) purchaseorder.VendorRef = vendor.to_ref() purchaseorder.APAccountRef = account.to_ref() purchaseorder.TotalAmt = 100 #print purchaseorder.to_json() purchaseorder.save(qb=self.qb_client) query_purchaseorder = PurchaseOrder.get(purchaseorder.Id, qb=self.qb_client) self.assertEquals(query_purchaseorder.VendorRef.value, vendor.Id) self.assertEquals(query_purchaseorder.APAccountRef.value, account.Id) self.assertEquals(query_purchaseorder.TotalAmt, 100) query_detail_line = query_purchaseorder.Line[0] self.assertEquals(query_detail_line.Amount, 100) self.assertEquals(query_detail_line.ItemBasedExpenseLineDetail.UnitPrice, 100) self.assertEquals(query_detail_line.ItemBasedExpenseLineDetail.Qty, 1) self.assertEquals(query_detail_line.ItemBasedExpenseLineDetail.CustomerRef.value, customer.Id) self.assertEquals(query_detail_line.ItemBasedExpenseLineDetail.TaxCodeRef.value, taxcode.Name) self.assertEquals(query_detail_line.ItemBasedExpenseLineDetail.ItemRef.value, item.Id)
def test_create(self): bill_payment = BillPayment() bill_payment.PayType = "Check" bill_payment.TotalAmt = 200 bill_payment.PrivateNote = "Private Note" vendor = Vendor.all(max_results=1, qb=self.qb_client)[0] bill_payment.VendorRef = vendor.to_ref() bill_payment.CheckPayment = CheckPayment() account = Account.where("AccountSubType = 'Checking'", qb=self.qb_client)[0] bill_payment.CheckPayment.BankAccountRef = account.to_ref() ap_account = Account.where("AccountSubType = 'AccountsPayable'", qb=self.qb_client)[0] bill_payment.APAccountRef = ap_account.to_ref() bill = Bill.all(max_results=1, qb=self.qb_client)[0] line = BillPaymentLine() line.LinkedTxn.append(bill.to_linked_txn()) line.Amount = 200 bill_payment.Line.append(line) bill_payment.save(qb=self.qb_client) query_bill_payment = BillPayment.get(bill_payment.Id, qb=self.qb_client) self.assertEquals(query_bill_payment.PayType, "Check") self.assertEquals(query_bill_payment.TotalAmt, 200.0) self.assertEquals(query_bill_payment.PrivateNote, "Private Note") self.assertEquals(len(query_bill_payment.Line), 1) self.assertEquals(query_bill_payment.Line[0].Amount, 200.0)
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)
def test_unicode(self): vendor = Vendor() vendor.DisplayName = "test" self.assertEquals(str(vendor), "test")
def test_valid_object_name(self): obj = Vendor() client = QuickBooks() result = client.isvalid_object_name(obj.qbo_object_name) self.assertTrue(result)
def test_create(self): vendor = Vendor() vendor.TaxIdentifier = '99-9999999' vendor.AcctNum = self.account_number vendor.Title = 'Ms.' vendor.GivenName = 'First' vendor.FamilyName = 'Last' vendor.Suffix = 'Sr.' vendor.CompanyName = self.name vendor.DisplayName = self.name vendor.PrintOnCheckName = self.name vendor.BillAddr = Address() vendor.BillAddr.Line1 = "123 Main" vendor.BillAddr.Line2 = "Apartment 1" vendor.BillAddr.City = "City" vendor.BillAddr.Country = "U.S.A" vendor.BillAddr.CountrySubDivisionCode = "CA" vendor.BillAddr.PostalCode = "94030" vendor.PrimaryPhone = PhoneNumber() vendor.PrimaryPhone.FreeFormNumber = '555-555-5555' vendor.PrimaryEmailAddr = EmailAddress() vendor.PrimaryEmailAddr.Address = '*****@*****.**' vendor.WebAddr = WebAddress() vendor.WebAddr.URI = 'http://testurl.com' vendor.save(qb=self.qb_client) query_vendor = Vendor.get(vendor.Id, qb=self.qb_client) self.assertEquals(query_vendor.Id, vendor.Id) self.assertEquals(query_vendor.AcctNum, self.account_number) self.assertEquals(query_vendor.Title, 'Ms.') self.assertEquals(query_vendor.GivenName, 'First') self.assertEquals(query_vendor.FamilyName, 'Last') self.assertEquals(query_vendor.Suffix, 'Sr.') self.assertEquals(query_vendor.CompanyName, self.name) self.assertEquals(query_vendor.DisplayName, self.name) self.assertEquals(query_vendor.PrintOnCheckName, self.name) self.assertEquals(query_vendor.BillAddr.Line1, "123 Main") self.assertEquals(query_vendor.BillAddr.Line2, "Apartment 1") self.assertEquals(query_vendor.BillAddr.City, "City") self.assertEquals(query_vendor.BillAddr.Country, "U.S.A") self.assertEquals(query_vendor.BillAddr.CountrySubDivisionCode, "CA") self.assertEquals(query_vendor.BillAddr.PostalCode, "94030") self.assertEquals(query_vendor.PrimaryPhone.FreeFormNumber, '555-555-5555') self.assertEquals(query_vendor.PrimaryEmailAddr.Address, '*****@*****.**') self.assertEquals(query_vendor.WebAddr.URI, 'http://testurl.com')