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.DisplayName = "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_to_ref(self): bill = Bill() bill.DocNumber = "test" bill.Id = 100 ref = bill.to_ref() self.assertEqual(ref.name, "test") self.assertEqual(ref.type, "Bill") self.assertEqual(ref.value, 100)
def to_json(request): client = get_qbo_client(get_callback_url(request)) bill_id = request.GET.get('bill_id') bill = Bill.get(int(bill_id), qb=client) bill = json.loads(bill.to_json()) attach_prices(bill, client) return JsonResponse(bill)
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 create_bill(vendor, account, amount, client): bill = Bill() bill = bill.from_json({ "Line": [{ "DetailType": "AccountBasedExpenseLineDetail", "Id": 1, "Amount": float(amount), "AccountBasedExpenseLineDetail": { "AccountRef": { "value": account.Id } } }], "VendorRef": { "value": vendor.Id } }) logger.debug("BILL: " + json.dumps(bill.to_json())) return bill.save(qb=client)
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)
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)
outgoing_invoices.InsertInvoice(con, cur, title, invoice_id, created_date, expiration_date, fullfillement_date, total_amount, total_vat, currency, products, status) else: outgoing_invoices.update(con, cur, invoice_id, invoices[x].Balance) except: print("problem when getting invoice from quickbook") # ---------------------- incoming_Invoices---------------------- try: LocalInvoicesIDs = incoming_invoices.GetAllIncomingInvoices(con, cur) invoices = Bill.all(qb=client) for x in range(len(invoices)): invoice_id = int(invoices[x].Id) if (invoice_id not in LocalInvoicesIDs): title = invoices[x].VendorRef.name created_date = invoices[x].TxnDate expiration_date = invoices[x].DueDate fullfillement_date = None total_amount = invoices[x].TotalAmt total_vat = None currency = invoices[x].CurrencyRef.value products_list = [] list_products = (invoices[x].Line) for y in range(len(list_products)): try: Description = list_products[y].Description