def test_to_LinkedTxn(self): bill = Bill() bill.Id = 10 linked_txn = bill.to_linked_txn() self.assertEquals(linked_txn.TxnId, bill.Id) self.assertEquals(linked_txn.TxnType, "Bill") self.assertEquals(linked_txn.TxnLineId, 1)
def test_to_ref(self): bill = Bill() bill.DocNumber = "test" bill.Id = 100 ref = bill.to_ref() self.assertEquals(ref.name, "test") self.assertEquals(ref.type, "Bill") self.assertEquals(ref.value, 100)
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): bill = Bill() bill.Balance = 1000 self.assertEquals(str(bill), "1000")
def test_valid_object_name(self): obj = Bill() client = QuickBooks() result = client.isvalid_object_name(obj.qbo_object_name) self.assertTrue(result)