示例#1
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]);
        }
        private Account CreateAccount(DataService dataService, AccountTypeEnum type, AccountSubTypeEnum subType)
        {
            // We are creating new Account by type and subtype which we will use for new inventory
            // The Account name should be unique
            // Following lines are just object creation, to create this account in QBO it should follow by the service call
            Random  random     = new Random();
            Account newAccount = new Account
            {
                Name                 = "My " + type.ToString() + random.Next(), // Dont forget to change the name before running the code
                AccountType          = type,
                AccountSubType       = subType.ToString(),
                AccountTypeSpecified = true,
                SubAccountSpecified  = true
            };

            // Following line will create incomeAccount in quickbooks with Name= My Income Account
            return(dataService.Add <Account>(newAccount));
        }
示例#3
0
        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);
        }
示例#4
0
        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]);
        }
示例#5
0
        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 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);
        }