public static Company CreateCompany(AccountSvc _accountSvc, int accountId, bool isSST = false)
        {
            var companyContact = new CompanyContact
            {
                CompanyContactCode = "001",
                FirstName          = "testfirstname",
                LastName           = "testlastname",
                Line1        = "700 Pike St",
                City         = "Seattle",
                Region       = "WA",
                PostalCode   = "98101",
                Phone        = "1-877-780-4848",
                Email        = "*****@*****.**",
                CreatedDate  = DateTime.UtcNow,
                ModifiedDate = DateTime.UtcNow
            };

            var company = new Company
            {
                AccountId            = accountId,
                CompanyCode          = Guid.NewGuid().ToString("N").Substring(0, 25),
                CompanyName          = "TEST::" + Guid.NewGuid().ToString("N"),
                CompanyId            = 0,
                IsActive             = true,
                HasProfile           = true,
                IsReportingEntity    = true,
                CreatedDate          = DateTime.UtcNow,
                ModifiedDate         = DateTime.UtcNow,
                RoundingLevelId      = RoundingLevelId.Document,
                DefaultCountry       = "US",
                IsTest               = false,
                TaxDependencyLevelId = TaxDependencyLevelId.Document,
                IsDefault            = false,
                TIN = "123457777"
            };

            if (isSST)
            {
                company.SSTEffDate = DateTime.UtcNow.AddYears(-10);
                company.SSTPID     = "Test";
            }
            company.Contacts.Add(companyContact);

            CompanySaveResult result = _accountSvc.CompanySave(company);

            if (result.ResultCode != SeverityLevel.Success)
            {
                foreach (Message message in result.Messages)
                {
                    Console.WriteLine(message.Summary);
                }

                return(null);
            }

            company.CompanyId = result.CompanyId;
            return(company);
        }
        //Creates a new company in the target account with hardcoded company detail.
        private static int CreateNewCompany(AccountSvc svc, int accountId)
        {
            //check credentials by pulling current account data
            FetchRequest req = new FetchRequest();
            req.Filters = "AccountId=" + accountId;
            CompanyFetchResult fetchres = svc.CompanyFetch(req);
            Console.WriteLine("Companies fetched: "+ fetchres.RecordCount);

            Company company = new Company();
            company.AccountId = accountId;
            company.CompanyCode = "XYZ"+DateTime.Now; //This will need to be unique on the account - it should be whatever unique system value you assign to the merchant.
            company.CompanyName = "Test Company XYZ"; //Does not need to be strictly unique - should be the legal name of the merchant.

            CompanyContact company_contact = new CompanyContact(); //This should be the contact info for your primary contact at the merchant company.
            company_contact.CompanyContactCode = "001";
            company_contact.FirstName = "Anya";
            company_contact.LastName = "Stettler";
            company_contact.Line1 = "100 Ravine Lane";
            company_contact.City = "Bainbridge Island";
            company_contact.Region = "WA";
            company_contact.PostalCode = "98110";
            company_contact.Phone = "1-877-780-4848";
            company_contact.Email = "*****@*****.**";
            CompanyContact[] arr = new CompanyContact[1];
            arr[0] = company_contact;
            company.Contacts = arr;

            company.IsActive = true; // Allow us to skip activiation later.
            company.HasProfile = true; //Tells us that you will be creating a tax profile for this company instead of inheriting an existing one.
            company.IsReportingEntity = true; //Separates reported transctions from other companies.

            CompanySaveResult res = new CompanySaveResult();
            try
            {
                res = svc.CompanySave(company); //Save the company
                if (res.ResultCode.Equals(SeverityLevel.Success))
                {
                    Console.WriteLine("Company saved successfully. CompanyId: " + res.CompanyId);
                }
                else
                {
                    Console.WriteLine("Error when saving company. Error: " + res.Messages[0].Summary);

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in CompanySave: " + ex);
            }

            return res.CompanyId; //Return the newly-created companyId
        }