def test_create(self):
        vendor = Vendor()

        vendor.TaxIdentifier = '99-9999999'
        vendor.AcctNum = self.account_number
        vendor.Title = 'Ms.'
        vendor.GivenName = 'First'
        vendor.FamilyName = 'Last'
        vendor.Suffix = 'Sr.'
        vendor.CompanyName = self.name
        vendor.DisplayName = self.name
        vendor.PrintOnCheckName = self.name

        vendor.BillAddr = Address()
        vendor.BillAddr.Line1 = "123 Main"
        vendor.BillAddr.Line2 = "Apartment 1"
        vendor.BillAddr.City = "City"
        vendor.BillAddr.Country = "U.S.A"
        vendor.BillAddr.CountrySubDivisionCode = "CA"
        vendor.BillAddr.PostalCode = "94030"

        vendor.PrimaryPhone = PhoneNumber()
        vendor.PrimaryPhone.FreeFormNumber = '555-555-5555'

        vendor.PrimaryEmailAddr = EmailAddress()
        vendor.PrimaryEmailAddr.Address = '*****@*****.**'

        vendor.WebAddr = WebAddress()
        vendor.WebAddr.URI = 'http://testurl.com'

        vendor.save(qb=self.qb_client)

        query_vendor = Vendor.get(vendor.Id, qb=self.qb_client)

        self.assertEquals(query_vendor.Id, vendor.Id)

        self.assertEquals(query_vendor.AcctNum, self.account_number)
        self.assertEquals(query_vendor.Title, 'Ms.')
        self.assertEquals(query_vendor.GivenName, 'First')
        self.assertEquals(query_vendor.FamilyName, 'Last')
        self.assertEquals(query_vendor.Suffix, 'Sr.')
        self.assertEquals(query_vendor.CompanyName, self.name)
        self.assertEquals(query_vendor.DisplayName, self.name)
        self.assertEquals(query_vendor.PrintOnCheckName, self.name)

        self.assertEquals(query_vendor.BillAddr.Line1, "123 Main")
        self.assertEquals(query_vendor.BillAddr.Line2, "Apartment 1")
        self.assertEquals(query_vendor.BillAddr.City, "City")
        self.assertEquals(query_vendor.BillAddr.Country, "U.S.A")
        self.assertEquals(query_vendor.BillAddr.CountrySubDivisionCode, "CA")
        self.assertEquals(query_vendor.BillAddr.PostalCode, "94030")
        self.assertEquals(query_vendor.PrimaryPhone.FreeFormNumber,
                          '555-555-5555')
        self.assertEquals(query_vendor.PrimaryEmailAddr.Address,
                          '*****@*****.**')
        self.assertEquals(query_vendor.WebAddr.URI, 'http://testurl.com')
    def test_to_ref(self):
        vendor = Vendor()
        vendor.DisplayName = "test"
        vendor.Id = 100

        ref = vendor.to_ref()

        self.assertEquals(ref.name, "test")
        self.assertEquals(ref.type, "Vendor")
        self.assertEquals(ref.value, 100)
    def test_create(self):
        vendor = Vendor()

        vendor.TaxIdentifier = '99-9999999'
        vendor.AcctNum = self.account_number
        vendor.Title = 'Ms.'
        vendor.GivenName = 'First'
        vendor.FamilyName = 'Last'
        vendor.Suffix = 'Sr.'
        vendor.CompanyName = self.name
        vendor.DisplayName = self.name
        vendor.PrintOnCheckName = self.name

        vendor.BillAddr = Address()
        vendor.BillAddr.Line1 = "123 Main"
        vendor.BillAddr.Line2 = "Apartment 1"
        vendor.BillAddr.City = "City"
        vendor.BillAddr.Country = "U.S.A"
        vendor.BillAddr.CountrySubDivisionCode = "CA"
        vendor.BillAddr.PostalCode = "94030"

        vendor.PrimaryPhone = PhoneNumber()
        vendor.PrimaryPhone.FreeFormNumber = '555-555-5555'

        vendor.PrimaryEmailAddr = EmailAddress()
        vendor.PrimaryEmailAddr.Address = '*****@*****.**'

        vendor.WebAddr = WebAddress()
        vendor.WebAddr.URI = 'http://testurl.com'

        vendor.save(qb=self.qb_client)

        query_vendor = Vendor.get(vendor.Id, qb=self.qb_client)

        self.assertEquals(query_vendor.Id, vendor.Id)

        self.assertEquals(query_vendor.AcctNum, self.account_number)
        self.assertEquals(query_vendor.Title, 'Ms.')
        self.assertEquals(query_vendor.GivenName, 'First')
        self.assertEquals(query_vendor.FamilyName, 'Last')
        self.assertEquals(query_vendor.Suffix, 'Sr.')
        self.assertEquals(query_vendor.CompanyName, self.name)
        self.assertEquals(query_vendor.DisplayName, self.name)
        self.assertEquals(query_vendor.PrintOnCheckName, self.name)

        self.assertEquals(query_vendor.BillAddr.Line1, "123 Main")
        self.assertEquals(query_vendor.BillAddr.Line2, "Apartment 1")
        self.assertEquals(query_vendor.BillAddr.City, "City")
        self.assertEquals(query_vendor.BillAddr.Country, "U.S.A")
        self.assertEquals(query_vendor.BillAddr.CountrySubDivisionCode, "CA")
        self.assertEquals(query_vendor.BillAddr.PostalCode, "94030")
        self.assertEquals(query_vendor.PrimaryPhone.FreeFormNumber, '555-555-5555')
        self.assertEquals(query_vendor.PrimaryEmailAddr.Address, '*****@*****.**')
        self.assertEquals(query_vendor.WebAddr.URI, 'http://testurl.com')
Exemple #4
0
def create_vendor(user, company, vendorName):
    client = get_qbo_client(user, company)
    vendors = Vendor.filter(Active=True, DisplayName=vendorName, qb=client)
    if len(vendors) > 0:
        return vendors[0]
    #
    # Check for inactive vendors with the same name and rename
    #  them since we cant delete them
    logger.debug("Check for inactive vendor")
    query = "Active = False AND DisplayName LIKE '{}%'".format(vendorName)
    vendors = Vendor.where(query, qb=client)
    for vendor in vendors:
        #logger.debug("Renaming inactive vendor")
        #vendor.DisplayName = vendorName + 'deleted' + str(time.time())
        logger.debug("Reactivate vendor")
        vendor.Active = True
        vendor.DisplayName = vendorName
        return vendor.save(qb=client)

    vendor = Vendor()
    vendor.DisplayName = vendorName
    return vendor.save(qb=client)
    def test_unicode(self):
        vendor = Vendor()
        vendor.DisplayName = "test"

        self.assertEquals(str(vendor), "test")