Пример #1
0
    def test_update(self):
        term = Term.all(max_results=1, qb=self.qb_client)[0]
        term.DueDays = 60
        term.save(qb=self.qb_client)

        query_term = Term.get(term.Id, qb=self.qb_client)

        self.assertEquals(query_term.Id, term.Id)
        self.assertEquals(query_term.DueDays, 60)
Пример #2
0
    def test_update(self):
        term = Term.all(max_results=1, qb=self.qb_client)[0]
        term.DueDays = 60
        term.save(qb=self.qb_client)

        query_term = Term.get(term.Id, qb=self.qb_client)

        self.assertEquals(query_term.Id, term.Id)
        self.assertEquals(query_term.DueDays, 60)
Пример #3
0
    def test_to_ref(self):
        term = Term()
        term.Name = "test"
        term.Id = 100

        ref = term.to_ref()

        self.assertEquals(ref.name, "test")
        self.assertEquals(ref.type, "Term")
        self.assertEquals(ref.value, 100)
Пример #4
0
    def _get_sales_term(self, id):
        """
        Get information about Sales Terms

        Name
        DayOfMonthDue
        DueDays
        """
        return Term.get(id, qb=self.client)
Пример #5
0
    def test_create(self):
        term = Term()
        term.Name = self.name
        term.DueDays = 10
        term.save(qb=self.qb_client)

        query_term = Term.get(term.Id, qb=self.qb_client)

        self.assertEquals(query_term.Id, term.Id)
        self.assertEquals(query_term.Name, self.name)
        self.assertEquals(query_term.DueDays, 10)
Пример #6
0
    def test_create(self):
        term = Term()
        term.Name = self.name
        term.DueDays = 10
        term.save(qb=self.qb_client)

        query_term = Term.get(term.Id, qb=self.qb_client)

        self.assertEquals(query_term.Id, term.Id)
        self.assertEquals(query_term.Name, self.name)
        self.assertEquals(query_term.DueDays, 10)
Пример #7
0
def invoice_search(invoice_number, customer, client=None):
    """
    invoice_number
        if == 1 then will force create a new one
        999999999 will search for any existing
        specific # will search for that invoice #
    """
    if client is None:
        client = get_quickbooks_client()
    invoice = None
    if invoice_number == "999999999":
        # search for any NeedToSend invoices for chapter
        #   however, can not filter on EmailStatus directly
        invoices = Invoice.query(
            select=
            f"select * from Invoice where balance > '0' AND CustomerRef = '{customer.Id}'",
            qb=client,
        )
        for invoice_test in invoices:
            if invoice_test.EmailStatus == "NeedToSend":
                invoice = invoice_test
                break
    elif invoice_number != "1" and invoice_number != "":
        # search for specific invoice number
        invoices = Invoice.query(
            select=
            f"select * from Invoice where DocNumber = '{invoice_number}' AND CustomerRef = '{customer.Id}'",
            qb=client,
        )
        if invoices:
            invoice = invoices[0]
    if invoice is None:
        invoice = Invoice()
        term = Term.filter(name="Two Weeks", qb=client)[0]
        linenumber_count = 1
        invoice.CustomerRef = customer.to_ref()
        invoice.AllowOnlineACHPayment = True
        invoice.BillEmail = customer.PrimaryEmailAddr
        invoice.EmailStatus = "NeedToSend"
        invoice.SalesTermRef = term.to_ref()
        invoice.CustomerMemo = CustomerMemo()
    else:
        linenumber_count = len(invoice.Line)
    return invoice, linenumber_count
Пример #8
0
 def _get_customer_terms(self, customer):
     """Get Customer terms of payment"""
     if customer.SalesTermRef.value is not None:
         return Term.get(customer.SalesTermRef.value, qb=self.client)
     return None
Пример #9
0
    def test_unicode(self):
        term = Term()
        term.Name = "test"

        self.assertEquals(str(term), "test")
Пример #10
0
    def test_valid_object_name(self):
        obj = Term()
        client = QuickBooks()
        result = client.isvalid_object_name(obj.qbo_object_name)

        self.assertTrue(result)