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): 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_unicode(self): purchase_order = PurchaseOrder() purchase_order.TotalAmt = 1000 self.assertEquals(str(purchase_order), '1000')
def test_valid_object_name(self): obj = PurchaseOrder() client = QuickBooks() result = client.isvalid_object_name(obj.qbo_object_name) self.assertTrue(result)