private Account FindOrAddAccount(AccountTypeEnum accountType, AccountClassificationEnum classification) { Account typeOfAccount = null; List <Account> listOfAccount = FindAll <Account>(new Account(), 1, 500); if (listOfAccount.Count > 0) { foreach (Account acc in listOfAccount) { if (acc.AccountType == accountType && acc.Classification == classification && acc.status != EntityStatusEnum.SyncError) { typeOfAccount = acc; break; } } } if (typeOfAccount == null) { Account account; account = CreateAccount(accountType, classification); account.Classification = classification; account.AccountType = accountType; Account createdAccount = dataService.Add <Account>(account); typeOfAccount = createdAccount; } return(typeOfAccount); }
private Account CreateAccount(AccountTypeEnum accountType, AccountClassificationEnum classification) { //Note: Have not removed comments because it will help in understanding the parameters. // Account account = new Account(); String guid = Guid.NewGuid().ToString("N"); account.Name = "Name_" + guid; //account.SubAccount = true; //account.SubAccountSpecified = true; //account.ParentRef = new ReferenceType() //{ //name = //type = //Value = //}; //account.Description = "Description"; account.FullyQualifiedName = account.Name; //account.Active = true; //account.ActiveSpecified = true; account.Classification = classification; account.ClassificationSpecified = true; account.AccountType = accountType; account.AccountTypeSpecified = true; //account.AccountSubType = "AccountSubType"; //account.AcctNum = "AcctNum"; //account.BankNum = "BankNum"; if (accountType != AccountTypeEnum.Expense && accountType != AccountTypeEnum.AccountsPayable && accountType != AccountTypeEnum.AccountsReceivable) { //TestComment: Opening Balances not working for QBO Item tests //account.OpeningBalance = new Decimal(100.00); //account.OpeningBalanceSpecified = true; //account.OpeningBalanceDate = DateTime.UtcNow.Date; //account.OpeningBalanceDateSpecified = true; } //account.CurrentBalance = new Decimal(100.00); //account.CurrentBalanceSpecified = true; //account.CurrentBalanceWithSubAccounts = new Decimal(100.00); //account.CurrentBalanceWithSubAccountsSpecified = true; account.CurrencyRef = new ReferenceType() { name = "United States Dollar", Value = "USD" }; //account.TaxAccount = true; //account.TaxAccountSpecified = true; //account.TaxCodeRef = new ReferenceType() //{ //name = //type = //Value = //}; //account.AccountEx = return(account); }
internal static Account AccountCreate(DataService dataService, AccountTypeEnum accountType, AccountClassificationEnum classification, AccountSubTypeEnum subType) { var random = new Random(); var account = new Account { Name = "Account_" + random.NextDouble(), AccountType = accountType, AccountTypeSpecified = true, Classification = classification, ClassificationSpecified = true, AccountSubType = subType.ToString(), SubAccountSpecified = true }; var apiResponse = dataService.Add(account); return(apiResponse); }
internal static Account FindOrAddAccount(ServiceContext context, AccountTypeEnum accountType, AccountClassificationEnum classification) { Account typeOfAccount = null; List <Account> listOfAccount = FindAll <Account>(context, new Account(), 1, 500); if (listOfAccount.Count > 0) { foreach (Account acc in listOfAccount) { if (acc.AccountType == accountType && acc.Classification == classification && acc.status != EntityStatusEnum.SyncError) { typeOfAccount = acc; break; } } } if (typeOfAccount == null) { DataService service = new DataService(context); Account account; account = QBOHelper.CreateAccount(context, accountType, classification); account.Classification = classification; account.AccountType = accountType; Account createdAccount = service.Add <Account>(account); typeOfAccount = createdAccount; } return(typeOfAccount); }
internal static Account AccountCreate(ServiceContext context, AccountTypeEnum accountType, AccountClassificationEnum classification, AccountSubTypeEnum subType) { Account account = new Account { Name = "Account_" + Helper.GetGuid(), AccountType = accountType, AccountTypeSpecified = true, Classification = classification, ClassificationSpecified = true, AccountSubType = subType.ToString(), SubAccountSpecified = true }; Account apiResponse = Helper.AddToQBO(context, account); return(apiResponse); }
internal static Account QueryOrAddAccount(ServiceContext context, String query, AccountTypeEnum accountType, AccountClassificationEnum classification, AccountSubTypeEnum subType) { DataService service = new DataService(context); QueryService <Account> entityQuery = new QueryService <Account>(context); List <Account> queryResponse = entityQuery.ExecuteIdsQuery(query).ToList <Account>(); if (queryResponse.Count == 0) { Account account = AccountCreate(context, accountType, classification, subType); return(account); } return(queryResponse[0]); }
internal static Account QueryOrAddAccount(DataService dataService, QueryService <Account> queryService, string query, AccountTypeEnum accountType, AccountClassificationEnum classification, AccountSubTypeEnum subType) { var queryResponse = queryService.ExecuteIdsQuery(query).ToList(); if (queryResponse.Count == 0) { var account = AccountCreate(dataService, accountType, classification, subType); return(account); } return(queryResponse[0]); }
internal static Account FindOrAddAccount(ServiceContext context, AccountTypeEnum accountType, AccountClassificationEnum classification) { Account typeOfAccount = null; List <Account> listOfAccount = FindAll <Account>(context, new Account(), 1, 500); if (listOfAccount.Count > 0) { foreach (Account acc in listOfAccount) { if (acc.AccountType == accountType && acc.Classification == classification && acc.status != EntityStatusEnum.SyncError) { typeOfAccount = acc; break; } } } return(typeOfAccount); }
internal static Account AccountCreate(DataService dataService, AccountTypeEnum accountType, AccountClassificationEnum classification, AccountSubTypeEnum subType) { Account account = new Account { Name = "Account_" + GetGuid(), AccountType = accountType, AccountTypeSpecified = true, Classification = classification, ClassificationSpecified = true, AccountSubType = subType.ToString(), SubAccountSpecified = true }; Account apiResponse = dataService.Add(account); return(apiResponse); }