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)[0] bill_payment.VendorRef = vendor.to_ref() bill_payment.CheckPayment = CheckPayment() account = Account.where("AccountSubType = 'Checking'")[0] bill_payment.CheckPayment.BankAccountRef = account.to_ref() ap_account = Account.where("AccountSubType = 'AccountsPayable'")[0] bill_payment.APAccountRef = ap_account.to_ref() bill = Bill.all(max_results=1)[0] line = BillPaymentLine() line.LinkedTxn.append(bill.to_linked_txn()) line.Amount = 200 bill_payment.Line.append(line) bill_payment.save() query_bill_payment = BillPayment.get(bill_payment.Id) 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_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 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(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.assertEqual(query_purchaseorder.VendorRef.value, vendor.Id) self.assertEqual(query_purchaseorder.APAccountRef.value, account.Id) self.assertEqual(query_purchaseorder.TotalAmt, 100) query_detail_line = query_purchaseorder.Line[0] self.assertEqual(query_detail_line.Amount, 100) self.assertEqual( query_detail_line.ItemBasedExpenseLineDetail.UnitPrice, 100) self.assertEqual(query_detail_line.ItemBasedExpenseLineDetail.Qty, 1) self.assertEqual( query_detail_line.ItemBasedExpenseLineDetail.CustomerRef.value, customer.Id) self.assertEqual( query_detail_line.ItemBasedExpenseLineDetail.TaxCodeRef.value, taxcode.Name) self.assertEqual( query_detail_line.ItemBasedExpenseLineDetail.ItemRef.value, item.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_file(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.FileName = 'TestFileName' attachable._FilePath = __file__ attachable.ContentType = 'application/txt' 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_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(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 = 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_create(self): bill = Bill() line = BillLine() 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)